ui-fulldeps
: adopt to the new rustc lint API
This commit is contained in:
parent
b3071153c2
commit
d028db9dbd
@ -917,7 +917,7 @@ fn emit_lint(&self, lint: &'static Lint, decorator: impl for<'a> DecorateLint<'a
|
||||
fn lint(
|
||||
&self,
|
||||
lint: &'static Lint,
|
||||
msg: DiagnosticMessage,
|
||||
msg: impl Into<DiagnosticMessage>,
|
||||
decorate: impl for<'a, 'b> FnOnce(
|
||||
&'b mut DiagnosticBuilder<'a, ()>,
|
||||
) -> &'b mut DiagnosticBuilder<'a, ()>,
|
||||
|
@ -49,9 +49,11 @@ fn check_fn(
|
||||
|
||||
let allowed = |attr| pprust::attribute_to_string(attr).contains("allowed_attr");
|
||||
if !cx.tcx.hir().attrs(item.hir_id()).iter().any(allowed) {
|
||||
cx.lint(MISSING_ALLOWED_ATTR, |lint| {
|
||||
lint.build("Missing 'allowed_attr' attribute").set_span(span).emit();
|
||||
});
|
||||
cx.lint(
|
||||
MISSING_ALLOWED_ATTR,
|
||||
"Missing 'allowed_attr' attribute",
|
||||
|lint| lint.set_span(span)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,9 +29,11 @@ fn check_crate(&mut self, cx: &LateContext) {
|
||||
let attrs = cx.tcx.hir().attrs(rustc_hir::CRATE_HIR_ID);
|
||||
let span = cx.tcx.def_span(CRATE_DEF_ID);
|
||||
if !cx.sess().contains_name(attrs, Symbol::intern("crate_okay")) {
|
||||
cx.lint(CRATE_NOT_OKAY, |lint| {
|
||||
lint.build("crate is not marked with #![crate_okay]").set_span(span).emit();
|
||||
});
|
||||
cx.lint(
|
||||
CRATE_NOT_OKAY,
|
||||
"crate is not marked with #![crate_okay]",
|
||||
|lint| lint.set_span(span)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,12 +22,10 @@
|
||||
impl<'tcx> LateLintPass<'tcx> for Pass {
|
||||
fn check_item(&mut self, cx: &LateContext, it: &rustc_hir::Item) {
|
||||
match it.ident.as_str() {
|
||||
"lintme" => cx.lint(TEST_LINT, |lint| {
|
||||
lint.build("item is named 'lintme'").set_span(it.span).emit();
|
||||
}),
|
||||
"pleaselintme" => cx.lint(PLEASE_LINT, |lint| {
|
||||
lint.build("item is named 'pleaselintme'").set_span(it.span).emit();
|
||||
}),
|
||||
"lintme" => cx.lint(TEST_LINT, "item is named 'lintme'", |lint| lint.set_span(it.span)),
|
||||
"pleaselintme" => {
|
||||
cx.lint(PLEASE_LINT, "item is named 'pleaselintme'", |lint| lint.set_span(it.span))
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -21,9 +21,7 @@
|
||||
impl EarlyLintPass for Pass {
|
||||
fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
|
||||
if it.ident.name.as_str() == "lintme" {
|
||||
cx.lint(TEST_LINT, |lint| {
|
||||
lint.build("item is named 'lintme'").set_span(it.span).emit();
|
||||
});
|
||||
cx.lint(TEST_LINT, "item is named 'lintme'", |lint| lint.set_span(it.span));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,14 +31,10 @@
|
||||
impl EarlyLintPass for Pass {
|
||||
fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
|
||||
if it.ident.name.as_str() == "lintme" {
|
||||
cx.lint(TEST_LINT, |lint| {
|
||||
lint.build("item is named 'lintme'").set_span(it.span).emit();
|
||||
});
|
||||
cx.lint(TEST_LINT, "item is named 'lintme'", |lint| lint.set_span(it.span));
|
||||
}
|
||||
if it.ident.name.as_str() == "lintmetoo" {
|
||||
cx.lint(TEST_GROUP, |lint| {
|
||||
lint.build("item is named 'lintmetoo'").set_span(it.span).emit();
|
||||
});
|
||||
cx.lint(TEST_GROUP, "item is named 'lintmetoo'", |lint| lint.set_span(it.span));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,12 @@ error: prefer `FxHashMap` over `HashMap`, it has better performance
|
||||
LL | let _map: HashMap<String, String> = HashMap::default();
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: a `use rustc_data_structures::fx::FxHashMap` may be necessary
|
||||
note: the lint level is defined here
|
||||
--> $DIR/default_hash_types.rs:4:9
|
||||
|
|
||||
LL | #![deny(rustc::default_hash_types)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: a `use rustc_data_structures::fx::FxHashMap` may be necessary
|
||||
|
||||
error: prefer `FxHashMap` over `HashMap`, it has better performance
|
||||
--> $DIR/default_hash_types.rs:16:15
|
||||
|
@ -4,12 +4,12 @@ error: found non-existing keyword `tadam` used in `#[doc(keyword = \"...\")]`
|
||||
LL | #[doc(keyword = "tadam")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: only existing keywords are allowed in core/std
|
||||
note: the lint level is defined here
|
||||
--> $DIR/existing_doc_keyword.rs:8:9
|
||||
|
|
||||
LL | #![deny(rustc::existing_doc_keyword)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= help: only existing keywords are allowed in core/std
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -4,12 +4,12 @@ error: implementing `LintPass` by hand
|
||||
LL | impl LintPass for Foo {
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= help: try using `declare_lint_pass!` or `impl_lint_pass!` instead
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint_pass_impl_without_macro.rs:4:9
|
||||
|
|
||||
LL | #![deny(rustc::lint_pass_impl_without_macro)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= help: try using `declare_lint_pass!` or `impl_lint_pass!` instead
|
||||
|
||||
error: implementing `LintPass` by hand
|
||||
--> $DIR/lint_pass_impl_without_macro.rs:30:14
|
||||
|
@ -4,12 +4,12 @@ error: using `drain` can result in unstable query results
|
||||
LL | for _ in x.drain() {}
|
||||
| ^^^^^
|
||||
|
|
||||
= note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale
|
||||
note: the lint level is defined here
|
||||
--> $DIR/query_stability.rs:4:9
|
||||
|
|
||||
LL | #![deny(rustc::potential_query_instability)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale
|
||||
|
||||
error: using `iter` can result in unstable query results
|
||||
--> $DIR/query_stability.rs:16:16
|
||||
|
@ -585,6 +585,7 @@ struct LintAttributeOnSessionDiag {}
|
||||
#[derive(LintDiagnostic)]
|
||||
#[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
||||
//~^ ERROR `#[lint(...)]` is not a valid attribute
|
||||
//~| ERROR `#[lint(...)]` is not a valid attribute
|
||||
//~| ERROR diagnostic slug not specified
|
||||
//~| ERROR cannot find attribute `lint` in this scope
|
||||
struct LintAttributeOnLintDiag {}
|
||||
|
@ -440,6 +440,12 @@ error: `#[lint(...)]` is not a valid attribute
|
||||
LL | #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `#[lint(...)]` is not a valid attribute
|
||||
--> $DIR/diagnostic-derive.rs:586:1
|
||||
|
|
||||
LL | #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: diagnostic slug not specified
|
||||
--> $DIR/diagnostic-derive.rs:586:1
|
||||
|
|
||||
@ -447,25 +453,26 @@ LL | / #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | struct LintAttributeOnLintDiag {}
|
||||
| |_________________________________^
|
||||
|
|
||||
= help: specify the slug as the first argument to the attribute, such as `#[diag(typeck::example_error)]`
|
||||
|
||||
error: specified multiple times
|
||||
--> $DIR/diagnostic-derive.rs:595:52
|
||||
--> $DIR/diagnostic-derive.rs:596:52
|
||||
|
|
||||
LL | #[suggestion(typeck::suggestion, code = "...", code = ",,,")]
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
note: previously specified here
|
||||
--> $DIR/diagnostic-derive.rs:595:38
|
||||
--> $DIR/diagnostic-derive.rs:596:38
|
||||
|
|
||||
LL | #[suggestion(typeck::suggestion, code = "...", code = ",,,")]
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: wrong types for suggestion
|
||||
--> $DIR/diagnostic-derive.rs:604:24
|
||||
--> $DIR/diagnostic-derive.rs:605:24
|
||||
|
|
||||
LL | suggestion: (Span, usize),
|
||||
| ^^^^^
|
||||
@ -473,7 +480,7 @@ LL | suggestion: (Span, usize),
|
||||
= help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`
|
||||
|
||||
error: wrong types for suggestion
|
||||
--> $DIR/diagnostic-derive.rs:612:17
|
||||
--> $DIR/diagnostic-derive.rs:613:17
|
||||
|
|
||||
LL | suggestion: (Span,),
|
||||
| ^^^^^^^
|
||||
@ -481,13 +488,13 @@ LL | suggestion: (Span,),
|
||||
= help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`
|
||||
|
||||
error: suggestion without `code = "..."`
|
||||
--> $DIR/diagnostic-derive.rs:619:5
|
||||
--> $DIR/diagnostic-derive.rs:620:5
|
||||
|
|
||||
LL | #[suggestion(typeck::suggestion)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `#[multipart_suggestion(...)]` is not a valid attribute
|
||||
--> $DIR/diagnostic-derive.rs:626:1
|
||||
--> $DIR/diagnostic-derive.rs:627:1
|
||||
|
|
||||
LL | #[multipart_suggestion(typeck::suggestion)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -495,7 +502,7 @@ LL | #[multipart_suggestion(typeck::suggestion)]
|
||||
= help: consider creating a `Subdiagnostic` instead
|
||||
|
||||
error: `#[multipart_suggestion(...)]` is not a valid attribute
|
||||
--> $DIR/diagnostic-derive.rs:629:1
|
||||
--> $DIR/diagnostic-derive.rs:630:1
|
||||
|
|
||||
LL | #[multipart_suggestion()]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -503,7 +510,7 @@ LL | #[multipart_suggestion()]
|
||||
= help: consider creating a `Subdiagnostic` instead
|
||||
|
||||
error: `#[multipart_suggestion(...)]` is not a valid attribute
|
||||
--> $DIR/diagnostic-derive.rs:633:5
|
||||
--> $DIR/diagnostic-derive.rs:634:5
|
||||
|
|
||||
LL | #[multipart_suggestion(typeck::suggestion)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -511,7 +518,7 @@ LL | #[multipart_suggestion(typeck::suggestion)]
|
||||
= help: consider creating a `Subdiagnostic` instead
|
||||
|
||||
error: `#[suggestion(...)]` is not a valid attribute
|
||||
--> $DIR/diagnostic-derive.rs:641:1
|
||||
--> $DIR/diagnostic-derive.rs:642:1
|
||||
|
|
||||
LL | #[suggestion(typeck::suggestion, code = "...")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -519,7 +526,7 @@ LL | #[suggestion(typeck::suggestion, code = "...")]
|
||||
= help: `#[label]` and `#[suggestion]` can only be applied to fields
|
||||
|
||||
error: `#[label]` is not a valid attribute
|
||||
--> $DIR/diagnostic-derive.rs:650:1
|
||||
--> $DIR/diagnostic-derive.rs:651:1
|
||||
|
|
||||
LL | #[label]
|
||||
| ^^^^^^^^
|
||||
@ -563,19 +570,19 @@ LL | #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
||||
| ^^^^ help: a built-in attribute with a similar name exists: `link`
|
||||
|
||||
error: cannot find attribute `multipart_suggestion` in this scope
|
||||
--> $DIR/diagnostic-derive.rs:626:3
|
||||
--> $DIR/diagnostic-derive.rs:627:3
|
||||
|
|
||||
LL | #[multipart_suggestion(typeck::suggestion)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: cannot find attribute `multipart_suggestion` in this scope
|
||||
--> $DIR/diagnostic-derive.rs:629:3
|
||||
--> $DIR/diagnostic-derive.rs:630:3
|
||||
|
|
||||
LL | #[multipart_suggestion()]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: cannot find attribute `multipart_suggestion` in this scope
|
||||
--> $DIR/diagnostic-derive.rs:633:7
|
||||
--> $DIR/diagnostic-derive.rs:634:7
|
||||
|
|
||||
LL | #[multipart_suggestion(typeck::suggestion)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
@ -600,7 +607,7 @@ LL | arg: impl IntoDiagnosticArg,
|
||||
| ^^^^^^^^^^^^^^^^^ required by this bound in `DiagnosticBuilder::<'a, G>::set_arg`
|
||||
= note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 74 previous errors
|
||||
error: aborting due to 75 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0425.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
|
Loading…
Reference in New Issue
Block a user