File tree Expand file tree Collapse file tree 4 files changed +35
-8
lines changed Expand file tree Collapse file tree 4 files changed +35
-8
lines changed Original file line number Diff line number Diff line change @@ -6055,7 +6055,13 @@ impl<'a> Parser<'a> {
6055
6055
Some ( ty_second) => {
6056
6056
// impl Trait for Type
6057
6057
if !has_for {
6058
- self . span_err ( missing_for_span, "missing `for` in a trait impl" ) ;
6058
+ self . struct_span_err ( missing_for_span, "missing `for` in a trait impl" )
6059
+ . span_suggestion_short_with_applicability (
6060
+ missing_for_span,
6061
+ "add `for` here" ,
6062
+ " for " . to_string ( ) ,
6063
+ Applicability :: MachineApplicable ,
6064
+ ) . emit ( ) ;
6059
6065
}
6060
6066
6061
6067
let ty_first = ty_first. into_inner ( ) ;
Original file line number Diff line number Diff line change @@ -2,13 +2,13 @@ error: missing `for` in a trait impl
2
2
--> $DIR/impl-parsing.rs:6:11
3
3
|
4
4
LL | impl Trait Type {} //~ ERROR missing `for` in a trait impl
5
- | ^
5
+ | ^ help: add `for` here
6
6
7
7
error: missing `for` in a trait impl
8
8
--> $DIR/impl-parsing.rs:7:11
9
9
|
10
10
LL | impl Trait .. {} //~ ERROR missing `for` in a trait impl
11
- | ^
11
+ | ^ help: add `for` here
12
12
13
13
error: expected a trait, found type
14
14
--> $DIR/impl-parsing.rs:8:6
Original file line number Diff line number Diff line change 1
- impl A .. { } //~ ERROR
1
+ trait A { }
2
+
3
+ impl A .. { }
4
+ //~^ ERROR missing `for` in a trait impl
5
+ //~| ERROR `impl Trait for .. {}` is an obsolete syntax
6
+
7
+ impl A usize { }
8
+ //~^ ERROR missing `for` in a trait impl
2
9
3
10
fn main ( ) { }
Original file line number Diff line number Diff line change 1
1
error: missing `for` in a trait impl
2
- --> $DIR/issue-27255.rs:1 :7
2
+ --> $DIR/issue-27255.rs:3 :7
3
3
|
4
- LL | impl A .. {} //~ ERROR
5
- | ^
4
+ LL | impl A .. {}
5
+ | ^ help: add `for` here
6
6
7
- error: aborting due to previous error
7
+ error: missing `for` in a trait impl
8
+ --> $DIR/issue-27255.rs:7:7
9
+ |
10
+ LL | impl A usize {}
11
+ | ^^^^^^ help: add `for` here
12
+
13
+ error: `impl Trait for .. {}` is an obsolete syntax
14
+ --> $DIR/issue-27255.rs:3:1
15
+ |
16
+ LL | impl A .. {}
17
+ | ^^^^^^^^^^^^
18
+ |
19
+ = help: use `auto trait Trait {}` instead
20
+
21
+ error: aborting due to 3 previous errors
8
22
You can’t perform that action at this time.
0 commit comments