Skip to content

Commit a57969b

Browse files
committed
Added tests for correct highlighting of strings with shared prefix
1 parent b21f96f commit a57969b

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

compiler/rustc_errors/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ fn as_substr<'a>(original: &'a str, suggestion: &'a str) -> Option<(usize, &'a s
318318
{
319319
return Some((0, prefix, original.len()));
320320
}
321-
321+
322322
let common_prefix = original
323323
.chars()
324324
.zip(suggestion.chars())
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// https://github.com/rust-lang/rust/issues/148070
2+
#![no_main]
3+
use stat; //~ ERROR unresolved import `stat`
4+
use str; //~ ERROR unresolved import `str`
5+
use sync; //~ ERROR unresolved import `sync`
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
error[E0432]: unresolved import `stat`
2+
--> $DIR/same-prefix-unresolved-import-148070.rs:3:5
3+
|
4+
LL | use stat;
5+
| ^^^^ no `stat` in the root
6+
|
7+
help: consider importing this struct instead
8+
|
9+
LL | use std::os::linux::raw::stat;
10+
| +++++++++++++++++++++
11+
12+
error[E0432]: unresolved import `str`
13+
--> $DIR/same-prefix-unresolved-import-148070.rs:4:5
14+
|
15+
LL | use str;
16+
| ^^^ no `str` in the root
17+
|
18+
help: a similar name exists in the module
19+
|
20+
LL - use str;
21+
LL + use std;
22+
|
23+
help: consider importing one of these items instead
24+
|
25+
LL | use std::primitive::str;
26+
| ++++++++++++++++
27+
LL | use std::str;
28+
| +++++
29+
30+
error[E0432]: unresolved import `sync`
31+
--> $DIR/same-prefix-unresolved-import-148070.rs:5:5
32+
|
33+
LL | use sync;
34+
| ^^^^ no `sync` in the root
35+
|
36+
help: consider importing this module instead
37+
|
38+
LL | use std::sync;
39+
| +++++
40+
41+
error: aborting due to 3 previous errors
42+
43+
For more information about this error, try `rustc --explain E0432`.

0 commit comments

Comments
 (0)