3 files changed +56
-5
lines changed Original file line number Diff line number Diff line change @@ -211,11 +211,18 @@ fn missing_items_err(
211
211
. collect :: < Vec < _ > > ( )
212
212
. join ( "`, `" ) ;
213
213
214
- // `Span` before impl block closing brace.
215
- let hi = full_impl_span. hi ( ) - BytePos ( 1 ) ;
216
- // Point at the place right before the closing brace of the relevant `impl` to suggest
217
- // adding the associated item at the end of its body.
218
- let sugg_sp = full_impl_span. with_lo ( hi) . with_hi ( hi) ;
214
+ let sugg_sp = if let Ok ( snippet) = tcx. sess . source_map ( ) . span_to_snippet ( full_impl_span)
215
+ && snippet. ends_with ( "}" )
216
+ {
217
+ // `Span` before impl block closing brace.
218
+ let hi = full_impl_span. hi ( ) - BytePos ( 1 ) ;
219
+ // Point at the place right before the closing brace of the relevant `impl` to suggest
220
+ // adding the associated item at the end of its body.
221
+ full_impl_span. with_lo ( hi) . with_hi ( hi)
222
+ } else {
223
+ full_impl_span. shrink_to_hi ( )
224
+ } ;
225
+
219
226
// Obtain the level of indentation ending in `sugg_sp`.
220
227
let padding =
221
228
tcx. sess . source_map ( ) . indentation_before ( sugg_sp) . unwrap_or_else ( || String :: new ( ) ) ;
Original file line number Diff line number Diff line change
1
+ // issue#126764
2
+
3
+ struct S ;
4
+
5
+ trait T {
6
+ fn f ( ) ;
7
+ }
8
+ impl T for S ;
9
+ //~^ ERROR: unknown start of token
10
+ //~| ERROR: expected `{}`
11
+ //~| ERROR: not all trait items implemented, missing: `f`
12
+
13
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error: unknown start of token: \u{ff1b}
2
+ --> $DIR/missing-impl-trait-block-but-not-ascii.rs:8:13
3
+ |
4
+ LL | impl T for S;
5
+ | ^^
6
+ |
7
+ help: Unicode character ';' (Fullwidth Semicolon) looks like ';' (Semicolon), but it is not
8
+ |
9
+ LL | impl T for S;
10
+ | ~
11
+
12
+ error: expected `{}`, found `;`
13
+ --> $DIR/missing-impl-trait-block-but-not-ascii.rs:8:13
14
+ |
15
+ LL | impl T for S;
16
+ | ^^
17
+ |
18
+ = help: try using `{}` instead
19
+
20
+ error[E0046]: not all trait items implemented, missing: `f`
21
+ --> $DIR/missing-impl-trait-block-but-not-ascii.rs:8:1
22
+ |
23
+ LL | fn f();
24
+ | ------- `f` from trait
25
+ LL | }
26
+ LL | impl T for S;
27
+ | ^^^^^^^^^^^^ missing `f` in implementation
28
+
29
+ error: aborting due to 3 previous errors
30
+
31
+ For more information about this error, try `rustc --explain E0046`.
0 commit comments