diff options
| author | Gauri <f2013002@goa.bits-pilani.ac.in> | 2018-01-13 11:59:35 +0530 |
|---|---|---|
| committer | Gauri <f2013002@goa.bits-pilani.ac.in> | 2018-01-13 11:59:35 +0530 |
| commit | 4cedbfc6ee8ef3d35abc22c69903ab3b9573939f (patch) | |
| tree | 28e98bd277dc3bd6b5c68e6c3e108db0246e2799 | |
| parent | 73ac5d6a80f26c692f1e084b72d69637d7de2c8c (diff) | |
| download | rust-4cedbfc6ee8ef3d35abc22c69903ab3b9573939f.tar.gz rust-4cedbfc6ee8ef3d35abc22c69903ab3b9573939f.zip | |
fix mispositioned span
| -rw-r--r-- | src/librustc_errors/emitter.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/lint/use_suggestion_json.stderr | 67 |
2 files changed, 2 insertions, 67 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index af556c576c0..ae0766eeeef 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -1187,7 +1187,7 @@ impl EmitterWriter { let sub_len = parts[0].snippet.trim().chars().fold(0, |acc, ch| { acc + unicode_width::UnicodeWidthChar::width(ch).unwrap_or(0) }); - let underline_start = span_start_pos.col.0 + start; + let underline_start = span_start_pos.col_display + start; let underline_end = span_start_pos.col.0 + start + sub_len; for p in underline_start..underline_end { buffer.putc(row_num, diff --git a/src/test/ui/lint/use_suggestion_json.stderr b/src/test/ui/lint/use_suggestion_json.stderr index 86c2ad4c0e7..abbf3da513a 100644 --- a/src/test/ui/lint/use_suggestion_json.stderr +++ b/src/test/ui/lint/use_suggestion_json.stderr @@ -2,72 +2,7 @@ "message": "cannot find type `Iter` in this scope", "code": { "code": "E0412", - "explanation": " -The type name used is not in scope. - -Erroneous code examples: - -```compile_fail,E0412 -impl Something {} // error: type name `Something` is not in scope - -// or: - -trait Foo { - fn bar(N); // error: type name `N` is not in scope -} - -// or: - -fn foo(x: T) {} // type name `T` is not in scope -``` - -To fix this error, please verify you didn't misspell the type name, you did -declare it or imported it into the scope. Examples: - -``` -struct Something; - -impl Something {} // ok! - -// or: - -trait Foo { - type N; - - fn bar(_: Self::N); // ok! -} - -// or: - -fn foo<T>(x: T) {} // ok! -``` - -Another case that causes this error is when a type is imported into a parent -module. To fix this, you can follow the suggestion and use File directly or -`use super::File;` which will import the types from the parent namespace. An -example that causes this error is below: - -```compile_fail,E0412 -use std::fs::File; - -mod foo { - fn some_function(f: File) {} -} -``` - -``` -use std::fs::File; - -mod foo { - // either - use super::File; - // or - // use std::fs::File; - fn foo(f: File) {} -} -# fn main() {} // don't insert it for us; that'll break imports -``` -" + "explanation": null }, "level": "error", "spans": [ |
