Skip to content

Commit 1de257b

Browse files
authored
Rollup merge of #111289 - clubby789:fix-111280, r=jyn514
Check arguments length in trivial diagnostic lint Fixes #111280
2 parents ecc0615 + 9027d20 commit 1de257b

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

compiler/rustc_lint/src/internal.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,10 @@ impl EarlyLintPass for Diagnostics {
478478
}
479479
if !segments.iter().all(|(name, args)| {
480480
let arg = match name.as_str() {
481-
"struct_span_err" | "span_note" | "span_label" | "span_help" => &args[1],
482-
"note" | "help" => &args[0],
481+
"struct_span_err" | "span_note" | "span_label" | "span_help" if args.len() == 2 => {
482+
&args[1]
483+
}
484+
"note" | "help" if args.len() == 1 => &args[0],
483485
_ => {
484486
return false;
485487
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// compile-flags: -Zunstable-options
2+
3+
pub fn issue_111280() {
4+
struct_span_err(msg).emit(); //~ ERROR cannot find value `msg`
5+
//~^ ERROR cannot find function `struct_span_err`
6+
}
7+
8+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0425]: cannot find value `msg` in this scope
2+
--> $DIR/trivial-diagnostics.rs:4:21
3+
|
4+
LL | struct_span_err(msg).emit();
5+
| ^^^ not found in this scope
6+
7+
error[E0425]: cannot find function `struct_span_err` in this scope
8+
--> $DIR/trivial-diagnostics.rs:4:5
9+
|
10+
LL | struct_span_err(msg).emit();
11+
| ^^^^^^^^^^^^^^^ not found in this scope
12+
13+
error: aborting due to 2 previous errors
14+
15+
For more information about this error, try `rustc --explain E0425`.

0 commit comments

Comments
 (0)