Consider lint check attributes on match arms in late lints
Additionally add analogous test for early lints.
This commit is contained in:
parent
19ca5692f6
commit
ddafe23401
@ -240,8 +240,10 @@ fn visit_block(&mut self, b: &'tcx hir::Block<'tcx>) {
|
||||
}
|
||||
|
||||
fn visit_arm(&mut self, a: &'tcx hir::Arm<'tcx>) {
|
||||
lint_callback!(self, check_arm, a);
|
||||
hir_visit::walk_arm(self, a);
|
||||
self.with_lint_attrs(a.hir_id, |cx| {
|
||||
lint_callback!(cx, check_arm, a);
|
||||
hir_visit::walk_arm(cx, a);
|
||||
})
|
||||
}
|
||||
|
||||
fn visit_generic_param(&mut self, p: &'tcx hir::GenericParam<'tcx>) {
|
||||
|
@ -134,6 +134,14 @@ struct Match{f1: i32}
|
||||
}
|
||||
}
|
||||
|
||||
match f {
|
||||
#[deny(ellipsis_inclusive_range_patterns)]
|
||||
Match{f1: 0...100} => {}
|
||||
//~^ ERROR range patterns are deprecated
|
||||
//~| WARNING this is accepted in the current edition
|
||||
_ => {}
|
||||
}
|
||||
|
||||
// Statement Block
|
||||
{
|
||||
#![deny(unsafe_code)]
|
||||
|
@ -384,92 +384,106 @@ note: the lint level is defined here
|
||||
LL | #[deny(while_true)]
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: `...` range patterns are deprecated
|
||||
--> $DIR/lint-attr-everywhere-early.rs:139:20
|
||||
|
|
||||
LL | Match{f1: 0...100} => {}
|
||||
| ^^^ help: use `..=` for an inclusive range
|
||||
|
|
||||
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-attr-everywhere-early.rs:138:16
|
||||
|
|
||||
LL | #[deny(ellipsis_inclusive_range_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: usage of an `unsafe` block
|
||||
--> $DIR/lint-attr-everywhere-early.rs:140:9
|
||||
--> $DIR/lint-attr-everywhere-early.rs:148:9
|
||||
|
|
||||
LL | unsafe {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-attr-everywhere-early.rs:139:17
|
||||
--> $DIR/lint-attr-everywhere-early.rs:147:17
|
||||
|
|
||||
LL | #![deny(unsafe_code)]
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: usage of an `unsafe` block
|
||||
--> $DIR/lint-attr-everywhere-early.rs:144:9
|
||||
--> $DIR/lint-attr-everywhere-early.rs:152:9
|
||||
|
|
||||
LL | unsafe {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-attr-everywhere-early.rs:143:16
|
||||
--> $DIR/lint-attr-everywhere-early.rs:151:16
|
||||
|
|
||||
LL | #[deny(unsafe_code)]
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: usage of an `unsafe` block
|
||||
--> $DIR/lint-attr-everywhere-early.rs:149:5
|
||||
--> $DIR/lint-attr-everywhere-early.rs:157:5
|
||||
|
|
||||
LL | unsafe {};
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-attr-everywhere-early.rs:148:12
|
||||
--> $DIR/lint-attr-everywhere-early.rs:156:12
|
||||
|
|
||||
LL | #[deny(unsafe_code)]
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: usage of an `unsafe` block
|
||||
--> $DIR/lint-attr-everywhere-early.rs:151:27
|
||||
--> $DIR/lint-attr-everywhere-early.rs:159:27
|
||||
|
|
||||
LL | [#[deny(unsafe_code)] unsafe {123}];
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-attr-everywhere-early.rs:151:13
|
||||
--> $DIR/lint-attr-everywhere-early.rs:159:13
|
||||
|
|
||||
LL | [#[deny(unsafe_code)] unsafe {123}];
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: usage of an `unsafe` block
|
||||
--> $DIR/lint-attr-everywhere-early.rs:152:27
|
||||
--> $DIR/lint-attr-everywhere-early.rs:160:27
|
||||
|
|
||||
LL | (#[deny(unsafe_code)] unsafe {123},);
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-attr-everywhere-early.rs:152:13
|
||||
--> $DIR/lint-attr-everywhere-early.rs:160:13
|
||||
|
|
||||
LL | (#[deny(unsafe_code)] unsafe {123},);
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: usage of an `unsafe` block
|
||||
--> $DIR/lint-attr-everywhere-early.rs:154:31
|
||||
--> $DIR/lint-attr-everywhere-early.rs:162:31
|
||||
|
|
||||
LL | call(#[deny(unsafe_code)] unsafe {123});
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-attr-everywhere-early.rs:154:17
|
||||
--> $DIR/lint-attr-everywhere-early.rs:162:17
|
||||
|
|
||||
LL | call(#[deny(unsafe_code)] unsafe {123});
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: usage of an `unsafe` block
|
||||
--> $DIR/lint-attr-everywhere-early.rs:156:38
|
||||
--> $DIR/lint-attr-everywhere-early.rs:164:38
|
||||
|
|
||||
LL | TupleStruct(#[deny(unsafe_code)] unsafe {123});
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-attr-everywhere-early.rs:156:24
|
||||
--> $DIR/lint-attr-everywhere-early.rs:164:24
|
||||
|
|
||||
LL | TupleStruct(#[deny(unsafe_code)] unsafe {123});
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: `...` range patterns are deprecated
|
||||
--> $DIR/lint-attr-everywhere-early.rs:167:18
|
||||
--> $DIR/lint-attr-everywhere-early.rs:175:18
|
||||
|
|
||||
LL | f1: 0...100,
|
||||
| ^^^ help: use `..=` for an inclusive range
|
||||
@ -477,10 +491,10 @@ LL | f1: 0...100,
|
||||
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-attr-everywhere-early.rs:166:20
|
||||
--> $DIR/lint-attr-everywhere-early.rs:174:20
|
||||
|
|
||||
LL | #[deny(ellipsis_inclusive_range_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 36 previous errors
|
||||
error: aborting due to 37 previous errors
|
||||
|
||||
|
@ -162,6 +162,11 @@ struct Match{f1: i32}
|
||||
}
|
||||
}
|
||||
|
||||
match 123 {
|
||||
#[deny(non_snake_case)]
|
||||
ARM_VAR => {} //~ ERROR variable `ARM_VAR` should have a snake case name
|
||||
}
|
||||
|
||||
// Statement Block
|
||||
{
|
||||
#![deny(enum_intrinsics_non_enums)]
|
||||
|
@ -305,124 +305,136 @@ note: the lint level is defined here
|
||||
LL | #[deny(enum_intrinsics_non_enums)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: variable `ARM_VAR` should have a snake case name
|
||||
--> $DIR/lint-attr-everywhere-late.rs:167:9
|
||||
|
|
||||
LL | ARM_VAR => {}
|
||||
| ^^^^^^^ help: convert the identifier to snake case: `arm_var`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-attr-everywhere-late.rs:166:16
|
||||
|
|
||||
LL | #[deny(non_snake_case)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: the return value of `mem::discriminant` is unspecified when called with a non-enum type
|
||||
--> $DIR/lint-attr-everywhere-late.rs:168:9
|
||||
--> $DIR/lint-attr-everywhere-late.rs:173:9
|
||||
|
|
||||
LL | discriminant::<i32>(&123);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum.
|
||||
--> $DIR/lint-attr-everywhere-late.rs:168:29
|
||||
--> $DIR/lint-attr-everywhere-late.rs:173:29
|
||||
|
|
||||
LL | discriminant::<i32>(&123);
|
||||
| ^^^^
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-attr-everywhere-late.rs:167:17
|
||||
--> $DIR/lint-attr-everywhere-late.rs:172:17
|
||||
|
|
||||
LL | #![deny(enum_intrinsics_non_enums)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: the return value of `mem::discriminant` is unspecified when called with a non-enum type
|
||||
--> $DIR/lint-attr-everywhere-late.rs:172:9
|
||||
--> $DIR/lint-attr-everywhere-late.rs:177:9
|
||||
|
|
||||
LL | discriminant::<i32>(&123);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum.
|
||||
--> $DIR/lint-attr-everywhere-late.rs:172:29
|
||||
--> $DIR/lint-attr-everywhere-late.rs:177:29
|
||||
|
|
||||
LL | discriminant::<i32>(&123);
|
||||
| ^^^^
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-attr-everywhere-late.rs:171:16
|
||||
--> $DIR/lint-attr-everywhere-late.rs:176:16
|
||||
|
|
||||
LL | #[deny(enum_intrinsics_non_enums)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: the return value of `mem::discriminant` is unspecified when called with a non-enum type
|
||||
--> $DIR/lint-attr-everywhere-late.rs:177:5
|
||||
--> $DIR/lint-attr-everywhere-late.rs:182:5
|
||||
|
|
||||
LL | discriminant::<i32>(&123);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum.
|
||||
--> $DIR/lint-attr-everywhere-late.rs:177:25
|
||||
--> $DIR/lint-attr-everywhere-late.rs:182:25
|
||||
|
|
||||
LL | discriminant::<i32>(&123);
|
||||
| ^^^^
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-attr-everywhere-late.rs:176:12
|
||||
--> $DIR/lint-attr-everywhere-late.rs:181:12
|
||||
|
|
||||
LL | #[deny(enum_intrinsics_non_enums)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: the return value of `mem::discriminant` is unspecified when called with a non-enum type
|
||||
--> $DIR/lint-attr-everywhere-late.rs:179:41
|
||||
--> $DIR/lint-attr-everywhere-late.rs:184:41
|
||||
|
|
||||
LL | [#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123)];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum.
|
||||
--> $DIR/lint-attr-everywhere-late.rs:179:61
|
||||
--> $DIR/lint-attr-everywhere-late.rs:184:61
|
||||
|
|
||||
LL | [#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123)];
|
||||
| ^^^^
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-attr-everywhere-late.rs:179:13
|
||||
--> $DIR/lint-attr-everywhere-late.rs:184:13
|
||||
|
|
||||
LL | [#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123)];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: the return value of `mem::discriminant` is unspecified when called with a non-enum type
|
||||
--> $DIR/lint-attr-everywhere-late.rs:180:41
|
||||
--> $DIR/lint-attr-everywhere-late.rs:185:41
|
||||
|
|
||||
LL | (#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123),);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum.
|
||||
--> $DIR/lint-attr-everywhere-late.rs:180:61
|
||||
--> $DIR/lint-attr-everywhere-late.rs:185:61
|
||||
|
|
||||
LL | (#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123),);
|
||||
| ^^^^
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-attr-everywhere-late.rs:180:13
|
||||
--> $DIR/lint-attr-everywhere-late.rs:185:13
|
||||
|
|
||||
LL | (#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123),);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: the return value of `mem::discriminant` is unspecified when called with a non-enum type
|
||||
--> $DIR/lint-attr-everywhere-late.rs:182:45
|
||||
--> $DIR/lint-attr-everywhere-late.rs:187:45
|
||||
|
|
||||
LL | call(#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum.
|
||||
--> $DIR/lint-attr-everywhere-late.rs:182:65
|
||||
--> $DIR/lint-attr-everywhere-late.rs:187:65
|
||||
|
|
||||
LL | call(#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123));
|
||||
| ^^^^
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-attr-everywhere-late.rs:182:17
|
||||
--> $DIR/lint-attr-everywhere-late.rs:187:17
|
||||
|
|
||||
LL | call(#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: the return value of `mem::discriminant` is unspecified when called with a non-enum type
|
||||
--> $DIR/lint-attr-everywhere-late.rs:184:52
|
||||
--> $DIR/lint-attr-everywhere-late.rs:189:52
|
||||
|
|
||||
LL | TupleStruct(#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum.
|
||||
--> $DIR/lint-attr-everywhere-late.rs:184:72
|
||||
--> $DIR/lint-attr-everywhere-late.rs:189:72
|
||||
|
|
||||
LL | TupleStruct(#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123));
|
||||
| ^^^^
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-attr-everywhere-late.rs:184:24
|
||||
--> $DIR/lint-attr-everywhere-late.rs:189:24
|
||||
|
|
||||
LL | TupleStruct(#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 31 previous errors
|
||||
error: aborting due to 32 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user