Skip to content

Commit 4cedbfc

Browse files
committed
fix mispositioned span
1 parent 73ac5d6 commit 4cedbfc

File tree

2 files changed

+2
-67
lines changed

2 files changed

+2
-67
lines changed

src/librustc_errors/emitter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ impl EmitterWriter {
11871187
let sub_len = parts[0].snippet.trim().chars().fold(0, |acc, ch| {
11881188
acc + unicode_width::UnicodeWidthChar::width(ch).unwrap_or(0)
11891189
});
1190-
let underline_start = span_start_pos.col.0 + start;
1190+
let underline_start = span_start_pos.col_display + start;
11911191
let underline_end = span_start_pos.col.0 + start + sub_len;
11921192
for p in underline_start..underline_end {
11931193
buffer.putc(row_num,

src/test/ui/lint/use_suggestion_json.stderr

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,72 +2,7 @@
22
"message": "cannot find type `Iter` in this scope",
33
"code": {
44
"code": "E0412",
5-
"explanation": "
6-
The type name used is not in scope.
7-
8-
Erroneous code examples:
9-
10-
```compile_fail,E0412
11-
impl Something {} // error: type name `Something` is not in scope
12-
13-
// or:
14-
15-
trait Foo {
16-
fn bar(N); // error: type name `N` is not in scope
17-
}
18-
19-
// or:
20-
21-
fn foo(x: T) {} // type name `T` is not in scope
22-
```
23-
24-
To fix this error, please verify you didn't misspell the type name, you did
25-
declare it or imported it into the scope. Examples:
26-
27-
```
28-
struct Something;
29-
30-
impl Something {} // ok!
31-
32-
// or:
33-
34-
trait Foo {
35-
type N;
36-
37-
fn bar(_: Self::N); // ok!
38-
}
39-
40-
// or:
41-
42-
fn foo<T>(x: T) {} // ok!
43-
```
44-
45-
Another case that causes this error is when a type is imported into a parent
46-
module. To fix this, you can follow the suggestion and use File directly or
47-
`use super::File;` which will import the types from the parent namespace. An
48-
example that causes this error is below:
49-
50-
```compile_fail,E0412
51-
use std::fs::File;
52-
53-
mod foo {
54-
fn some_function(f: File) {}
55-
}
56-
```
57-
58-
```
59-
use std::fs::File;
60-
61-
mod foo {
62-
// either
63-
use super::File;
64-
// or
65-
// use std::fs::File;
66-
fn foo(f: File) {}
67-
}
68-
# fn main() {} // don't insert it for us; that'll break imports
69-
```
70-
"
5+
"explanation": null
716
},
727
"level": "error",
738
"spans": [

0 commit comments

Comments
 (0)