Skip to content

Commit cd5317a

Browse files
authored
Rollup merge of rust-lang#114472 - estebank:issue-76140, r=compiler-errors
Reword `confusable_idents` lint Fix rust-lang#76140.
2 parents 5e42a22 + 553508c commit cd5317a

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

compiler/rustc_lint/messages.ftl

+3-2
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,9 @@ lint_check_name_warning = {$msg}
167167
168168
lint_command_line_source = `forbid` lint level was set on command line
169169
170-
lint_confusable_identifier_pair = identifier pair considered confusable between `{$existing_sym}` and `{$sym}`
171-
.label = this is where the previous identifier occurred
170+
lint_confusable_identifier_pair = found both `{$existing_sym}` and `{$sym}` as identifiers, which look alike
171+
.current_use = this identifier can be confused with `{$existing_sym}`
172+
.other_use = other identifier used here
172173
173174
lint_cstring_ptr = getting the inner pointer of a temporary `CString`
174175
.as_ptr_label = this pointer will be invalid

compiler/rustc_lint/src/lints.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1083,8 +1083,10 @@ pub struct IdentifierUncommonCodepoints;
10831083
pub struct ConfusableIdentifierPair {
10841084
pub existing_sym: Symbol,
10851085
pub sym: Symbol,
1086-
#[label]
1086+
#[label(lint_other_use)]
10871087
pub label: Span,
1088+
#[label(lint_current_use)]
1089+
pub main_label: Span,
10881090
}
10891091

10901092
#[derive(LintDiagnostic)]

compiler/rustc_lint/src/non_ascii_idents.rs

+1
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ impl EarlyLintPass for NonAsciiIdents {
222222
existing_sym: *existing_symbol,
223223
sym: symbol,
224224
label: *existing_span,
225+
main_label: sp,
225226
},
226227
);
227228
}

tests/ui/lint/rfc-2457-non-ascii-idents/lint-confusable-idents.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const s: usize = 42;
55
const s_s: usize = 42;
66

77
fn main() {
8-
let s = "rust"; //~ ERROR identifier pair considered confusable
9-
let s_s = "rust2"; //~ ERROR identifier pair considered confusable
8+
let s = "rust"; //~ ERROR found both
9+
let s_s = "rust2"; //~ ERROR found both
1010
not_affected();
1111
}
1212

Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
error: identifier pair considered confusable between `s` and `s`
1+
error: found both `s` and `s` as identifiers, which look alike
22
--> $DIR/lint-confusable-idents.rs:8:9
33
|
44
LL | const s: usize = 42;
5-
| -- this is where the previous identifier occurred
5+
| -- other identifier used here
66
...
77
LL | let s = "rust";
8-
| ^
8+
| ^ this identifier can be confused with `s`
99
|
1010
note: the lint level is defined here
1111
--> $DIR/lint-confusable-idents.rs:1:9
1212
|
1313
LL | #![deny(confusable_idents)]
1414
| ^^^^^^^^^^^^^^^^^
1515

16-
error: identifier pair considered confusable between `s_s` and `s_s`
16+
error: found both `s_s` and `s_s` as identifiers, which look alike
1717
--> $DIR/lint-confusable-idents.rs:9:9
1818
|
1919
LL | const s_s: usize = 42;
20-
| --- this is where the previous identifier occurred
20+
| --- other identifier used here
2121
...
2222
LL | let s_s = "rust2";
23-
| ^^^^^
23+
| ^^^^^ this identifier can be confused with `s_s`
2424

2525
error: aborting due to 2 previous errors
2626

0 commit comments

Comments
 (0)