Skip to content

Commit d028db9

Browse files
committed
ui-fulldeps: adopt to the new rustc lint API
1 parent b307115 commit d028db9

File tree

12 files changed

+44
-40
lines changed

12 files changed

+44
-40
lines changed

compiler/rustc_lint/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ pub trait LintContext: Sized {
917917
fn lint(
918918
&self,
919919
lint: &'static Lint,
920-
msg: DiagnosticMessage,
920+
msg: impl Into<DiagnosticMessage>,
921921
decorate: impl for<'a, 'b> FnOnce(
922922
&'b mut DiagnosticBuilder<'a, ()>,
923923
) -> &'b mut DiagnosticBuilder<'a, ()>,

src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ impl<'tcx> LateLintPass<'tcx> for MissingAllowedAttrPass {
4949

5050
let allowed = |attr| pprust::attribute_to_string(attr).contains("allowed_attr");
5151
if !cx.tcx.hir().attrs(item.hir_id()).iter().any(allowed) {
52-
cx.lint(MISSING_ALLOWED_ATTR, |lint| {
53-
lint.build("Missing 'allowed_attr' attribute").set_span(span).emit();
54-
});
52+
cx.lint(
53+
MISSING_ALLOWED_ATTR,
54+
"Missing 'allowed_attr' attribute",
55+
|lint| lint.set_span(span)
56+
);
5557
}
5658
}
5759
}

src/test/ui-fulldeps/auxiliary/lint-for-crate.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ impl<'tcx> LateLintPass<'tcx> for Pass {
2929
let attrs = cx.tcx.hir().attrs(rustc_hir::CRATE_HIR_ID);
3030
let span = cx.tcx.def_span(CRATE_DEF_ID);
3131
if !cx.sess().contains_name(attrs, Symbol::intern("crate_okay")) {
32-
cx.lint(CRATE_NOT_OKAY, |lint| {
33-
lint.build("crate is not marked with #![crate_okay]").set_span(span).emit();
34-
});
32+
cx.lint(
33+
CRATE_NOT_OKAY,
34+
"crate is not marked with #![crate_okay]",
35+
|lint| lint.set_span(span)
36+
);
3537
}
3638
}
3739
}

src/test/ui-fulldeps/auxiliary/lint-group-plugin-test.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@ declare_lint_pass!(Pass => [TEST_LINT, PLEASE_LINT]);
2222
impl<'tcx> LateLintPass<'tcx> for Pass {
2323
fn check_item(&mut self, cx: &LateContext, it: &rustc_hir::Item) {
2424
match it.ident.as_str() {
25-
"lintme" => cx.lint(TEST_LINT, |lint| {
26-
lint.build("item is named 'lintme'").set_span(it.span).emit();
27-
}),
28-
"pleaselintme" => cx.lint(PLEASE_LINT, |lint| {
29-
lint.build("item is named 'pleaselintme'").set_span(it.span).emit();
30-
}),
25+
"lintme" => cx.lint(TEST_LINT, "item is named 'lintme'", |lint| lint.set_span(it.span)),
26+
"pleaselintme" => {
27+
cx.lint(PLEASE_LINT, "item is named 'pleaselintme'", |lint| lint.set_span(it.span))
28+
}
3129
_ => {}
3230
}
3331
}

src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ declare_lint_pass!(Pass => [TEST_LINT]);
2121
impl EarlyLintPass for Pass {
2222
fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
2323
if it.ident.name.as_str() == "lintme" {
24-
cx.lint(TEST_LINT, |lint| {
25-
lint.build("item is named 'lintme'").set_span(it.span).emit();
26-
});
24+
cx.lint(TEST_LINT, "item is named 'lintme'", |lint| lint.set_span(it.span));
2725
}
2826
}
2927
}

src/test/ui-fulldeps/auxiliary/lint-tool-test.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,10 @@ declare_lint_pass!(Pass => [TEST_LINT, TEST_GROUP, TEST_RUSTC_TOOL_LINT]);
3131
impl EarlyLintPass for Pass {
3232
fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
3333
if it.ident.name.as_str() == "lintme" {
34-
cx.lint(TEST_LINT, |lint| {
35-
lint.build("item is named 'lintme'").set_span(it.span).emit();
36-
});
34+
cx.lint(TEST_LINT, "item is named 'lintme'", |lint| lint.set_span(it.span));
3735
}
3836
if it.ident.name.as_str() == "lintmetoo" {
39-
cx.lint(TEST_GROUP, |lint| {
40-
lint.build("item is named 'lintmetoo'").set_span(it.span).emit();
41-
});
37+
cx.lint(TEST_GROUP, "item is named 'lintmetoo'", |lint| lint.set_span(it.span));
4238
}
4339
}
4440
}

src/test/ui-fulldeps/internal-lints/default_hash_types.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ error: prefer `FxHashMap` over `HashMap`, it has better performance
44
LL | let _map: HashMap<String, String> = HashMap::default();
55
| ^^^^^^^
66
|
7+
= note: a `use rustc_data_structures::fx::FxHashMap` may be necessary
78
note: the lint level is defined here
89
--> $DIR/default_hash_types.rs:4:9
910
|
1011
LL | #![deny(rustc::default_hash_types)]
1112
| ^^^^^^^^^^^^^^^^^^^^^^^^^
12-
= note: a `use rustc_data_structures::fx::FxHashMap` may be necessary
1313

1414
error: prefer `FxHashMap` over `HashMap`, it has better performance
1515
--> $DIR/default_hash_types.rs:16:15

src/test/ui-fulldeps/internal-lints/existing_doc_keyword.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ error: found non-existing keyword `tadam` used in `#[doc(keyword = \"...\")]`
44
LL | #[doc(keyword = "tadam")]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7+
= help: only existing keywords are allowed in core/std
78
note: the lint level is defined here
89
--> $DIR/existing_doc_keyword.rs:8:9
910
|
1011
LL | #![deny(rustc::existing_doc_keyword)]
1112
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
12-
= help: only existing keywords are allowed in core/std
1313

1414
error: aborting due to previous error
1515

src/test/ui-fulldeps/internal-lints/lint_pass_impl_without_macro.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ error: implementing `LintPass` by hand
44
LL | impl LintPass for Foo {
55
| ^^^^^^^^
66
|
7+
= help: try using `declare_lint_pass!` or `impl_lint_pass!` instead
78
note: the lint level is defined here
89
--> $DIR/lint_pass_impl_without_macro.rs:4:9
910
|
1011
LL | #![deny(rustc::lint_pass_impl_without_macro)]
1112
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12-
= help: try using `declare_lint_pass!` or `impl_lint_pass!` instead
1313

1414
error: implementing `LintPass` by hand
1515
--> $DIR/lint_pass_impl_without_macro.rs:30:14

src/test/ui-fulldeps/internal-lints/query_stability.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ error: using `drain` can result in unstable query results
44
LL | for _ in x.drain() {}
55
| ^^^^^
66
|
7+
= note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale
78
note: the lint level is defined here
89
--> $DIR/query_stability.rs:4:9
910
|
1011
LL | #![deny(rustc::potential_query_instability)]
1112
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12-
= note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale
1313

1414
error: using `iter` can result in unstable query results
1515
--> $DIR/query_stability.rs:16:16

0 commit comments

Comments
 (0)