Add missing visit_pat_field in early lint visitor.
This ensures that lint attributes on pattern fields can control early lints.
This commit is contained in:
parent
7b36047239
commit
c655f17bce
3 changed files with 33 additions and 6 deletions
|
@ -101,6 +101,12 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
|
||||||
run_early_pass!(self, check_pat_post, p);
|
run_early_pass!(self, check_pat_post, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn visit_pat_field(&mut self, field: &'a ast::PatField) {
|
||||||
|
self.with_lint_attrs(field.id, &field.attrs, |cx| {
|
||||||
|
ast_visit::walk_pat_field(cx, field);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
fn visit_anon_const(&mut self, c: &'a ast::AnonConst) {
|
fn visit_anon_const(&mut self, c: &'a ast::AnonConst) {
|
||||||
self.check_id(c.id);
|
self.check_id(c.id);
|
||||||
ast_visit::walk_anon_const(self, c);
|
ast_visit::walk_anon_const(self, c);
|
||||||
|
|
|
@ -159,11 +159,18 @@ fn expressions() {
|
||||||
|
|
||||||
// ################## Patterns
|
// ################## Patterns
|
||||||
fn patterns() {
|
fn patterns() {
|
||||||
// There aren't any early lints that I can find that apply to pattern fields.
|
struct PatField{f1: i32, f2: i32};
|
||||||
//
|
let f = PatField{f1: 1, f2: 2};
|
||||||
// struct PatField{f1: i32, f2: i32};
|
match f {
|
||||||
// let f = PatField{f1: 1, f2: 2};
|
PatField {
|
||||||
// let PatField{#[deny()]f1, #[deny()]..} = f;
|
#[deny(ellipsis_inclusive_range_patterns)]
|
||||||
|
f1: 0...100,
|
||||||
|
//~^ ERROR range patterns are deprecated
|
||||||
|
//~| WARNING this is accepted in the current edition
|
||||||
|
..
|
||||||
|
} => {}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -468,5 +468,19 @@ note: the lint level is defined here
|
||||||
LL | TupleStruct(#[deny(unsafe_code)] unsafe {123});
|
LL | TupleStruct(#[deny(unsafe_code)] unsafe {123});
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 35 previous errors
|
error: `...` range patterns are deprecated
|
||||||
|
--> $DIR/lint-attr-everywhere-early.rs:167:18
|
||||||
|
|
|
||||||
|
LL | f1: 0...100,
|
||||||
|
| ^^^ help: use `..=` for an inclusive range
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/lint-attr-everywhere-early.rs:166:20
|
||||||
|
|
|
||||||
|
LL | #[deny(ellipsis_inclusive_range_patterns)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= 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>
|
||||||
|
|
||||||
|
error: aborting due to 36 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue