Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions compiler/rustc_passes/src/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1691,7 +1691,10 @@ impl<'tcx> Liveness<'_, 'tcx> {
if ln == self.exit_ln { false } else { self.assigned_on_exit(ln, var) };

let mut typo = None;
for (hir_id, _, span) in &hir_ids_and_spans {
let filtered_hir_ids_and_spans = hir_ids_and_spans.iter().filter(|(hir_id, ..)| {
!matches!(self.ir.tcx.parent_hir_node(*hir_id), hir::Node::Param(_))
});
for (hir_id, _, span) in filtered_hir_ids_and_spans.clone() {
let ty = self.typeck_results.node_type(*hir_id);
if let ty::Adt(adt, _) = ty.peel_refs().kind() {
let name = Symbol::intern(&name);
Expand All @@ -1717,7 +1720,7 @@ impl<'tcx> Liveness<'_, 'tcx> {
}
}
if typo.is_none() {
for (hir_id, _, span) in &hir_ids_and_spans {
for (hir_id, _, span) in filtered_hir_ids_and_spans {
let ty = self.typeck_results.node_type(*hir_id);
// Look for consts of the same type with similar names as well, not just unit
// structs and variants.
Expand Down
13 changes: 13 additions & 0 deletions tests/ui/fn/invalid-sugg-for-unused-fn-arg-147303.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Regression test for <https://github.com/rust-lang/rust/issues/147303>.

#![deny(unused_assignments, unused_variables)]

mod m1 {
const _MAX_FMTVER_X1X_EVENTNUM: i32 = 0;
}

mod m2 {
fn fun(rough: i32) {} //~ERROR unused variable
}

fn main() {}
14 changes: 14 additions & 0 deletions tests/ui/fn/invalid-sugg-for-unused-fn-arg-147303.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error: unused variable: `rough`
--> $DIR/invalid-sugg-for-unused-fn-arg-147303.rs:10:12
|
LL | fn fun(rough: i32) {}
| ^^^^^ help: if this is intentional, prefix it with an underscore: `_rough`
|
note: the lint level is defined here
--> $DIR/invalid-sugg-for-unused-fn-arg-147303.rs:3:29
|
LL | #![deny(unused_assignments, unused_variables)]
| ^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

11 changes: 1 addition & 10 deletions tests/ui/lint/non-snake-case/lint-uppercase-variables.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,7 @@ warning: unused variable: `Foo`
--> $DIR/lint-uppercase-variables.rs:33:17
|
LL | fn in_param(Foo: foo::Foo) {}
| ^^^
|
help: if this is intentional, prefix it with an underscore
|
LL | fn in_param(_Foo: foo::Foo) {}
| +
help: you might have meant to pattern match on the similarly named variant `Foo`
|
LL | fn in_param(foo::Foo::Foo: foo::Foo) {}
| ++++++++++
| ^^^ help: if this is intentional, prefix it with an underscore: `_Foo`

error: structure field `X` should have a snake case name
--> $DIR/lint-uppercase-variables.rs:10:5
Expand Down
Loading