Skip to content

Commit 16cd84e

Browse files
committedMay 28, 2018
Auto merge of #50724 - zackmdavis:applicability_rush, r=Manishearth
add suggestion applicabilities to librustc and libsyntax A down payment on #50723. Interested in feedback on whether my `MaybeIncorrect` vs. `MachineApplicable` judgement calls are well-calibrated (and that we have a consensus on what this means). r? @Manishearth cc @killercup @estebank
2 parents 68e0e58 + 98a0429 commit 16cd84e

35 files changed

+447
-117
lines changed
 

‎src/librustc/infer/error_reporting/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ use ty::{self, Region, Ty, TyCtxt, TypeFoldable, TypeVariants};
7070
use ty::error::TypeError;
7171
use syntax::ast::DUMMY_NODE_ID;
7272
use syntax_pos::{Pos, Span};
73-
use errors::{DiagnosticBuilder, DiagnosticStyledString};
73+
use errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString};
7474

7575
use rustc_data_structures::indexed_vec::Idx;
7676

@@ -1097,7 +1097,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
10971097
if let Some((sp, has_lifetimes)) = type_param_span {
10981098
let tail = if has_lifetimes { " + " } else { "" };
10991099
let suggestion = format!("{}: {}{}", bound_kind, sub, tail);
1100-
err.span_suggestion_short(sp, consider, suggestion);
1100+
err.span_suggestion_short_with_applicability(
1101+
sp, consider, suggestion,
1102+
Applicability::MaybeIncorrect // Issue #41966
1103+
);
11011104
} else {
11021105
err.help(consider);
11031106
}

‎src/librustc/lint/levels.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use std::cmp;
1212

13-
use errors::DiagnosticBuilder;
13+
use errors::{Applicability, DiagnosticBuilder};
1414
use hir::HirId;
1515
use ich::StableHashingContext;
1616
use lint::builtin;
@@ -265,10 +265,11 @@ impl<'a> LintLevelsBuilder<'a> {
265265
store.check_lint_name(&name_lower) {
266266
db.emit();
267267
} else {
268-
db.span_suggestion(
268+
db.span_suggestion_with_applicability(
269269
li.span,
270270
"lowercase the lint name",
271-
name_lower
271+
name_lower,
272+
Applicability::MachineApplicable
272273
).emit();
273274
}
274275
} else {

‎src/librustc/middle/liveness.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ use self::VarKind::*;
109109
use hir::def::*;
110110
use ty::{self, TyCtxt};
111111
use lint;
112+
use errors::Applicability;
112113
use util::nodemap::{NodeMap, NodeSet};
113114

114115
use std::collections::VecDeque;
@@ -1535,11 +1536,15 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
15351536
let mut err = self.ir.tcx
15361537
.struct_span_lint_node(lint::builtin::UNUSED_VARIABLES, id, sp, &msg);
15371538
if self.ir.variable_is_shorthand(var) {
1538-
err.span_suggestion(sp, "try ignoring the field",
1539-
format!("{}: _", name));
1539+
err.span_suggestion_with_applicability(sp, "try ignoring the field",
1540+
format!("{}: _", name),
1541+
Applicability::MachineApplicable);
15401542
} else {
1541-
err.span_suggestion_short(sp, &suggest_underscore_msg,
1542-
format!("_{}", name));
1543+
err.span_suggestion_short_with_applicability(
1544+
sp, &suggest_underscore_msg,
1545+
format!("_{}", name),
1546+
Applicability::MachineApplicable,
1547+
);
15431548
}
15441549
err.emit()
15451550
}

‎src/librustc/traits/error_reporting.rs

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use super::{
2727
Overflow,
2828
};
2929

30-
use errors::DiagnosticBuilder;
30+
use errors::{Applicability, DiagnosticBuilder};
3131
use hir;
3232
use hir::def_id::DefId;
3333
use infer::{self, InferCtxt};
@@ -852,9 +852,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
852852
if let Some(ref expr) = local.init {
853853
if let hir::ExprIndex(_, _) = expr.node {
854854
if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(expr.span) {
855-
err.span_suggestion(expr.span,
856-
"consider borrowing here",
857-
format!("&{}", snippet));
855+
err.span_suggestion_with_applicability(
856+
expr.span,
857+
"consider borrowing here",
858+
format!("&{}", snippet),
859+
Applicability::MachineApplicable
860+
);
858861
}
859862
}
860863
}
@@ -897,7 +900,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
897900
let format_str = format!("consider removing {} leading `&`-references",
898901
remove_refs);
899902

900-
err.span_suggestion_short(sp, &format_str, String::from(""));
903+
err.span_suggestion_short_with_applicability(
904+
sp, &format_str, String::from(""), Applicability::MachineApplicable
905+
);
901906
break;
902907
}
903908
} else {
@@ -1042,10 +1047,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
10421047
let sugg = fields.iter()
10431048
.map(|(name, _)| name.to_owned())
10441049
.collect::<Vec<String>>().join(", ");
1045-
err.span_suggestion(found_span,
1046-
"change the closure to take multiple arguments instead of \
1047-
a single tuple",
1048-
format!("|{}|", sugg));
1050+
err.span_suggestion_with_applicability(found_span,
1051+
"change the closure to take multiple \
1052+
arguments instead of a single tuple",
1053+
format!("|{}|", sugg),
1054+
Applicability::MachineApplicable);
10491055
}
10501056
}
10511057
if let &[ArgKind::Tuple(_, ref fields)] = &expected_args[..] {
@@ -1073,10 +1079,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
10731079
"".to_owned()
10741080
},
10751081
);
1076-
err.span_suggestion(found_span,
1077-
"change the closure to accept a tuple instead of \
1078-
individual arguments",
1079-
sugg);
1082+
err.span_suggestion_with_applicability(
1083+
found_span,
1084+
"change the closure to accept a tuple instead of \
1085+
individual arguments",
1086+
sugg,
1087+
Applicability::MachineApplicable
1088+
);
10801089
}
10811090
}
10821091
}

‎src/librustc_errors/diagnostic.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,23 @@ impl Diagnostic {
330330
self
331331
}
332332

333+
pub fn span_suggestion_short_with_applicability(
334+
&mut self, sp: Span, msg: &str, suggestion: String, applicability: Applicability
335+
) -> &mut Self {
336+
self.suggestions.push(CodeSuggestion {
337+
substitutions: vec![Substitution {
338+
parts: vec![SubstitutionPart {
339+
snippet: suggestion,
340+
span: sp,
341+
}],
342+
}],
343+
msg: msg.to_owned(),
344+
show_code_when_inline: false,
345+
applicability: applicability,
346+
});
347+
self
348+
}
349+
333350
pub fn set_span<S: Into<MultiSpan>>(&mut self, sp: S) -> &mut Self {
334351
self.span = sp.into();
335352
self

‎src/librustc_errors/diagnostic_builder.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ impl<'a> DiagnosticBuilder<'a> {
205205
suggestions: Vec<String>,
206206
applicability: Applicability)
207207
-> &mut Self);
208+
forward!(pub fn span_suggestion_short_with_applicability(&mut self,
209+
sp: Span,
210+
msg: &str,
211+
suggestion: String,
212+
applicability: Applicability)
213+
-> &mut Self);
208214
forward!(pub fn set_span<S: Into<MultiSpan>>(&mut self, sp: S) -> &mut Self);
209215
forward!(pub fn code(&mut self, s: DiagnosticId) -> &mut Self);
210216

‎src/libsyntax/attr.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use ast::{MetaItem, MetaItemKind, NestedMetaItem, NestedMetaItemKind};
2020
use ast::{Lit, LitKind, Expr, ExprKind, Item, Local, Stmt, StmtKind};
2121
use codemap::{BytePos, Spanned, respan, dummy_spanned};
2222
use syntax_pos::Span;
23-
use errors::Handler;
23+
use errors::{Applicability, Handler};
2424
use feature_gate::{Features, GatedCfg};
2525
use parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration};
2626
use parse::parser::Parser;
@@ -1067,14 +1067,20 @@ pub fn find_repr_attrs(diagnostic: &Handler, attr: &Attribute) -> Vec<ReprAttr>
10671067
"incorrect `repr(align)` attribute format");
10681068
match value.node {
10691069
ast::LitKind::Int(int, ast::LitIntType::Unsuffixed) => {
1070-
err.span_suggestion(item.span,
1071-
"use parentheses instead",
1072-
format!("align({})", int));
1070+
err.span_suggestion_with_applicability(
1071+
item.span,
1072+
"use parentheses instead",
1073+
format!("align({})", int),
1074+
Applicability::MachineApplicable
1075+
);
10731076
}
10741077
ast::LitKind::Str(s, _) => {
1075-
err.span_suggestion(item.span,
1076-
"use parentheses instead",
1077-
format!("align({})", s));
1078+
err.span_suggestion_with_applicability(
1079+
item.span,
1080+
"use parentheses instead",
1081+
format!("align({})", s),
1082+
Applicability::MachineApplicable
1083+
);
10781084
}
10791085
_ => {}
10801086
}

‎src/libsyntax/ext/expand.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use ast::{MacStmtStyle, StmtKind, ItemKind};
1313
use attr::{self, HasAttrs};
1414
use codemap::{ExpnInfo, NameAndSpan, MacroBang, MacroAttribute, dummy_spanned, respan};
1515
use config::{is_test_or_bench, StripUnconfigured};
16-
use errors::FatalError;
16+
use errors::{Applicability, FatalError};
1717
use ext::base::*;
1818
use ext::derive::{add_derived_markers, collect_derives};
1919
use ext::hygiene::{self, Mark, SyntaxContext};
@@ -331,7 +331,11 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
331331
let trait_list = traits.iter()
332332
.map(|t| format!("{}", t)).collect::<Vec<_>>();
333333
let suggestion = format!("#[derive({})]", trait_list.join(", "));
334-
err.span_suggestion(span, "try an outer attribute", suggestion);
334+
err.span_suggestion_with_applicability(
335+
span, "try an outer attribute", suggestion,
336+
// We don't 𝑘𝑛𝑜𝑤 that the following item is an ADT
337+
Applicability::MaybeIncorrect
338+
);
335339
}
336340
err.emit();
337341
}

‎src/libsyntax/parse/lexer/mod.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use ast::{self, Ident};
1212
use syntax_pos::{self, BytePos, CharPos, Pos, Span, NO_EXPANSION};
1313
use codemap::{CodeMap, FilePathMapping};
14-
use errors::{FatalError, DiagnosticBuilder};
14+
use errors::{Applicability, FatalError, DiagnosticBuilder};
1515
use parse::{token, ParseSess};
1616
use str::char_at;
1717
use symbol::{Symbol, keywords};
@@ -1379,11 +1379,12 @@ impl<'a> StringReader<'a> {
13791379
self.sess.span_diagnostic
13801380
.struct_span_err(span,
13811381
"character literal may only contain one codepoint")
1382-
.span_suggestion(span,
1383-
"if you meant to write a `str` literal, \
1384-
use double quotes",
1385-
format!("\"{}\"", &self.src[start..end]))
1386-
.emit();
1382+
.span_suggestion_with_applicability(
1383+
span,
1384+
"if you meant to write a `str` literal, use double quotes",
1385+
format!("\"{}\"", &self.src[start..end]),
1386+
Applicability::MachineApplicable
1387+
).emit();
13871388
return Ok(token::Literal(token::Str_(Symbol::intern("??")), None))
13881389
}
13891390
if self.ch_is('\n') || self.is_eof() || self.ch_is('/') {

‎src/libsyntax/parse/parser.rs

Lines changed: 140 additions & 52 deletions
Large diffs are not rendered by default.

‎src/test/ui/extern-const.fixed

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// run-rustfix
12+
// compile-flags: -Z continue-parse-after-error
13+
14+
extern "C" {
15+
static C: u8; //~ ERROR extern items cannot be `const`
16+
}
17+
18+
fn main() {
19+
// We suggest turning the (illegal) extern `const` into an extern `static`,
20+
// but this also requires `unsafe` (a deny-by-default lint at comment time,
21+
// future error; Issue #36247)
22+
unsafe {
23+
let _x = C;
24+
}
25+
}

‎src/test/ui/extern-const.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// run-rustfix
1112
// compile-flags: -Z continue-parse-after-error
1213

1314
extern "C" {
1415
const C: u8; //~ ERROR extern items cannot be `const`
1516
}
1617

1718
fn main() {
18-
let x = C;
19+
// We suggest turning the (illegal) extern `const` into an extern `static`,
20+
// but this also requires `unsafe` (a deny-by-default lint at comment time,
21+
// future error; Issue #36247)
22+
unsafe {
23+
let _x = C;
24+
}
1925
}

‎src/test/ui/extern-const.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: extern items cannot be `const`
2-
--> $DIR/extern-const.rs:14:5
2+
--> $DIR/extern-const.rs:15:5
33
|
44
LL | const C: u8; //~ ERROR extern items cannot be `const`
5-
| ^^^^^ help: instead try using: `static`
5+
| ^^^^^ help: try using a static value: `static`
66

77
error: aborting due to previous error
88

‎src/test/ui/issue-42954.fixed

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// run-rustfix
12+
13+
#![allow(unused_must_use, unused_comparisons)]
14+
15+
macro_rules! is_plainly_printable {
16+
($i: ident) => {
17+
($i as u32) < 0 //~ `<` is interpreted as a start of generic arguments
18+
};
19+
}
20+
21+
fn main() {
22+
let c = 'a';
23+
is_plainly_printable!(c);
24+
}

‎src/test/ui/issue-42954.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// run-rustfix
12+
13+
#![allow(unused_must_use, unused_comparisons)]
14+
1115
macro_rules! is_plainly_printable {
1216
($i: ident) => {
1317
$i as u32 < 0 //~ `<` is interpreted as a start of generic arguments

‎src/test/ui/issue-42954.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `<` is interpreted as a start of generic arguments for `u32`, not a comparison
2-
--> $DIR/issue-42954.rs:13:19
2+
--> $DIR/issue-42954.rs:17:19
33
|
44
LL | $i as u32 < 0 //~ `<` is interpreted as a start of generic arguments
55
| --------- ^ - interpreted as generic arguments

‎src/test/ui/issue-44406.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error: expected type, found keyword `true`
88
--> $DIR/issue-44406.rs:18:10
99
|
1010
LL | bar(baz: $rest)
11-
| - help: did you mean to use `;` here?
11+
| - help: try using a semicolon: `;`
1212
...
1313
LL | foo!(true); //~ ERROR expected type, found keyword
1414
| ^^^^ expecting a type here because of type ascription

‎src/test/ui/issue-48636.fixed

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// run-rustfix
12+
13+
#![allow(dead_code)]
14+
15+
struct S {
16+
x: u8,
17+
/// The id of the parent core
18+
y: u8,
19+
}
20+
//~^^^ ERROR found a documentation comment that doesn't document anything
21+
fn main() {}

‎src/test/ui/issue-48636.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// run-rustfix
12+
13+
#![allow(dead_code)]
14+
1115
struct S {
1216
x: u8
1317
/// The id of the parent core

‎src/test/ui/issue-48636.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0585]: found a documentation comment that doesn't document anything
2-
--> $DIR/issue-48636.rs:13:5
2+
--> $DIR/issue-48636.rs:17:5
33
|
44
LL | x: u8
55
| - help: missing comma here: `,`
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Regression test for #47244: in this specific scenario, when the
12+
// expected type indicated 1 argument but the closure takes two, we
13+
// would (early on) create type variables for the type of `b`. If the
14+
// user then attempts to invoke a method on `b`, we would get an error
15+
// saying that the type of `b` must be known, which was not very
16+
// helpful.
17+
18+
// run-rustfix
19+
20+
use std::collections::HashMap;
21+
22+
fn main() {
23+
let mut m = HashMap::new();
24+
m.insert("foo", "bar");
25+
26+
let _n = m.iter().map(|(_, b)| {
27+
//~^ ERROR closure is expected to take a single 2-tuple
28+
b.to_string()
29+
});
30+
}

‎src/test/ui/mismatched_types/closure-arg-count-expected-type-issue-47244.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
// saying that the type of `b` must be known, which was not very
1616
// helpful.
1717

18+
// run-rustfix
19+
1820
use std::collections::HashMap;
19-
fn main() {
2021

21-
let m = HashMap::new();
22-
m.insert( "foo", "bar" );
22+
fn main() {
23+
let mut m = HashMap::new();
24+
m.insert("foo", "bar");
2325

24-
m.iter().map( |_, b| {
26+
let _n = m.iter().map(|_, b| {
2527
//~^ ERROR closure is expected to take a single 2-tuple
26-
2728
b.to_string()
2829
});
2930
}

‎src/test/ui/mismatched_types/closure-arg-count-expected-type-issue-47244.stderr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments
2-
--> $DIR/closure-arg-count-expected-type-issue-47244.rs:24:14
2+
--> $DIR/closure-arg-count-expected-type-issue-47244.rs:26:23
33
|
4-
LL | m.iter().map( |_, b| {
5-
| ^^^ ------ takes 2 distinct arguments
6-
| |
7-
| expected closure that takes a single 2-tuple as argument
4+
LL | let _n = m.iter().map(|_, b| {
5+
| ^^^ ------ takes 2 distinct arguments
6+
| |
7+
| expected closure that takes a single 2-tuple as argument
88
help: change the closure to accept a tuple instead of individual arguments
99
|
10-
LL | m.iter().map( |(_, b)| {
11-
| ^^^^^^^^
10+
LL | let _n = m.iter().map(|(_, b)| {
11+
| ^^^^^^^^
1212

1313
error: aborting due to previous error
1414

‎src/test/ui/repr-align-assign.fixed

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// run-rustfix
12+
13+
#![allow(dead_code)]
14+
15+
#[repr(align(8))] //~ ERROR incorrect `repr(align)` attribute format
16+
struct A(u64);
17+
18+
#[repr(align(8))] //~ ERROR incorrect `repr(align)` attribute format
19+
struct B(u64);
20+
21+
fn main() {}

‎src/test/ui/repr-align-assign.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// run-rustfix
12+
13+
#![allow(dead_code)]
14+
1115
#[repr(align=8)] //~ ERROR incorrect `repr(align)` attribute format
1216
struct A(u64);
1317

‎src/test/ui/repr-align-assign.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0693]: incorrect `repr(align)` attribute format
2-
--> $DIR/repr-align-assign.rs:11:8
2+
--> $DIR/repr-align-assign.rs:15:8
33
|
44
LL | #[repr(align=8)] //~ ERROR incorrect `repr(align)` attribute format
55
| ^^^^^^^ help: use parentheses instead: `align(8)`
66

77
error[E0693]: incorrect `repr(align)` attribute format
8-
--> $DIR/repr-align-assign.rs:14:8
8+
--> $DIR/repr-align-assign.rs:18:8
99
|
1010
LL | #[repr(align="8")] //~ ERROR incorrect `repr(align)` attribute format
1111
| ^^^^^^^^^ help: use parentheses instead: `align(8)`
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// run-rustfix
12+
13+
#![allow(unused_imports)]
14+
15+
pub mod extension1 {
16+
pub trait ConstructorExtension {}
17+
}
18+
19+
pub mod extension2 {
20+
pub trait ConstructorExtension {}
21+
}
22+
23+
use extension1::ConstructorExtension;
24+
use extension2::ConstructorExtension as OtherConstructorExtension; //~ ERROR is defined multiple times
25+
26+
fn main() {}

‎src/test/ui/suggestions/issue-32354-suggest-import-rename.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// run-rustfix
12+
13+
#![allow(unused_imports)]
14+
1115
pub mod extension1 {
1216
pub trait ConstructorExtension {}
1317
}

‎src/test/ui/suggestions/issue-32354-suggest-import-rename.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0252]: the name `ConstructorExtension` is defined multiple times
2-
--> $DIR/issue-32354-suggest-import-rename.rs:20:5
2+
--> $DIR/issue-32354-suggest-import-rename.rs:24:5
33
|
44
LL | use extension1::ConstructorExtension;
55
| -------------------------------- previous import of the trait `ConstructorExtension` here

‎src/test/ui/suggestions/pub-ident-fn-or-struct-2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: missing `fn` or `struct` for method or struct definition
22
--> $DIR/pub-ident-fn-or-struct-2.rs:11:4
33
|
44
LL | pub S();
5-
| ---^- help: if you meant to call a macro, write instead: `S!`
5+
| ---^- help: if you meant to call a macro, try: `S!`
66

77
error: aborting due to previous error
88

‎src/test/ui/suggestions/pub-ident-fn-or-struct.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: missing `fn` or `struct` for method or struct definition
22
--> $DIR/pub-ident-fn-or-struct.rs:11:4
33
|
44
LL | pub S (foo) bar
5-
| ---^- help: if you meant to call a macro, write instead: `S!`
5+
| ---^- help: if you meant to call a macro, try: `S!`
66

77
error: aborting due to previous error
88

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// run-rustfix
12+
13+
pub fn foo(_s: usize) -> bool { true }
14+
//~^ ERROR missing `fn` for method definition
15+
16+
fn main() {
17+
foo(2);
18+
}

‎src/test/ui/suggestions/pub-ident-fn.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
pub foo(s: usize) -> bool { true }
11+
// run-rustfix
12+
13+
pub foo(_s: usize) -> bool { true }
1214
//~^ ERROR missing `fn` for method definition
1315

1416
fn main() {

‎src/test/ui/suggestions/pub-ident-fn.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: missing `fn` for method definition
2-
--> $DIR/pub-ident-fn.rs:11:4
2+
--> $DIR/pub-ident-fn.rs:13:4
33
|
4-
LL | pub foo(s: usize) -> bool { true }
4+
LL | pub foo(_s: usize) -> bool { true }
55
| ^^^
66
help: add `fn` here to parse `foo` as a public method
77
|
8-
LL | pub fn foo(s: usize) -> bool { true }
8+
LL | pub fn foo(_s: usize) -> bool { true }
99
| ^^
1010

1111
error: aborting due to previous error

‎src/test/ui/suggestions/type-ascription-instead-of-statement-end.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: expected type, found `0`
22
--> $DIR/type-ascription-instead-of-statement-end.rs:15:5
33
|
44
LL | println!("test"):
5-
| - help: did you mean to use `;` here?
5+
| - help: try using a semicolon: `;`
66
LL | 0; //~ ERROR expected type, found `0`
77
| ^ expecting a type here because of type ascription
88

0 commit comments

Comments
 (0)
Please sign in to comment.