hir::LocalSource::AwaitDesugar => ("`await` future binding", None),
};
self.check_irrefutable(&loc.pat, msg, sp);
-
- // Check legality of move bindings and `@` patterns.
self.check_patterns(false, &loc.pat);
}
- fn visit_body(&mut self, body: &'tcx hir::Body<'tcx>) {
- intravisit::walk_body(self, body);
-
- for param in body.params {
- self.check_irrefutable(¶m.pat, "function argument", None);
- self.check_patterns(false, ¶m.pat);
- }
+ fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) {
+ intravisit::walk_param(self, param);
+ self.check_irrefutable(¶m.pat, "function argument", None);
+ self.check_patterns(false, ¶m.pat);
}
}
if !self.tcx.features().bindings_after_at {
check_legality_of_bindings_in_at_patterns(self, pat);
}
+ check_for_bindings_named_same_as_variants(self, pat);
}
fn check_match(
source: hir::MatchSource,
) {
for arm in arms {
- // First, check legality of move bindings.
+ // Check the arm for some things unrelated to exhaustiveness.
self.check_patterns(arm.guard.is_some(), &arm.pat);
-
- // Second, perform some lints.
- check_for_bindings_named_same_as_variants(self, &arm.pat);
}
let module = self.tcx.hir().get_module_parent(scrut.hir_id);
//~^^^ WARN unused variable: `Foo`
}
+ let Foo = foo::Foo::Foo;
+ //~^ ERROR variable `Foo` should have a snake case name
+ //~^^ WARN `Foo` is named the same as one of the variants of the type `foo::Foo`
+ //~^^^ WARN unused variable: `Foo`
+
+ fn in_param(Foo: foo::Foo) {}
+ //~^ ERROR variable `Foo` should have a snake case name
+ //~^^ WARN `Foo` is named the same as one of the variants of the type `foo::Foo`
+ //~^^^ WARN unused variable: `Foo`
+
test(1);
let _ = Something { X: 0 };
|
= note: `#[warn(bindings_with_variant_name)]` on by default
+warning[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo`
+ --> $DIR/lint-uppercase-variables.rs:28:9
+ |
+LL | let Foo = foo::Foo::Foo;
+ | ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo`
+
+warning[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo`
+ --> $DIR/lint-uppercase-variables.rs:33:17
+ |
+LL | fn in_param(Foo: foo::Foo) {}
+ | ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo`
+
warning: unused variable: `Foo`
--> $DIR/lint-uppercase-variables.rs:22:9
|
| ^^^^^^
= note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`
+warning: unused variable: `Foo`
+ --> $DIR/lint-uppercase-variables.rs:28:9
+ |
+LL | let Foo = foo::Foo::Foo;
+ | ^^^ help: consider prefixing with an underscore: `_Foo`
+
+warning: unused variable: `Foo`
+ --> $DIR/lint-uppercase-variables.rs:33:17
+ |
+LL | fn in_param(Foo: foo::Foo) {}
+ | ^^^ help: consider prefixing with an underscore: `_Foo`
+
error: structure field `X` should have a snake case name
--> $DIR/lint-uppercase-variables.rs:10:5
|
LL | Foo => {}
| ^^^ help: convert the identifier to snake case (notice the capitalization): `foo`
-error: aborting due to 4 previous errors
+error: variable `Foo` should have a snake case name
+ --> $DIR/lint-uppercase-variables.rs:28:9
+ |
+LL | let Foo = foo::Foo::Foo;
+ | ^^^ help: convert the identifier to snake case (notice the capitalization): `foo`
+
+error: variable `Foo` should have a snake case name
+ --> $DIR/lint-uppercase-variables.rs:33:17
+ |
+LL | fn in_param(Foo: foo::Foo) {}
+ | ^^^ help: convert the identifier to snake case (notice the capitalization): `foo`
+
+error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0170`.