aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryvt <i@yvt.jp>2022-10-14 00:56:38 +0900
committeryvt <i@yvt.jp>2022-10-16 19:19:13 +0900
commit687ac6c77ff6390d479711dd2c7ff89e427ca469 (patch)
tree495844b9a0da6c4172f13a46d2186dae631c1e97
parent3cd4837e635ad8a053e8be331c55a1efd0477b57 (diff)
downloadservo-687ac6c77ff6390d479711dd2c7ff89e427ca469.tar.gz
servo-687ac6c77ff6390d479711dd2c7ff89e427ca469.zip
fix(script_plugins): adapt to the new rustc lint API
<https://github.com/rust-lang/rust/pull/101986>
-rw-r--r--components/script_plugins/lib.rs60
1 files changed, 27 insertions, 33 deletions
diff --git a/components/script_plugins/lib.rs b/components/script_plugins/lib.rs
index 895bf94de8e..396a63dca8a 100644
--- a/components/script_plugins/lib.rs
+++ b/components/script_plugins/lib.rs
@@ -217,14 +217,12 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
for ref field in def.fields() {
let def_id = cx.tcx.hir().local_def_id(field.hir_id);
if is_unrooted_ty(&self.symbols, cx, cx.tcx.type_of(def_id), false) {
- cx.lint(UNROOTED_MUST_ROOT, |lint| {
- lint.build(
- "Type must be rooted, use #[unrooted_must_root_lint::must_root] \
- on the struct definition to propagate",
- )
- .set_span(field.span)
- .emit()
- })
+ cx.lint(
+ UNROOTED_MUST_ROOT,
+ "Type must be rooted, use #[unrooted_must_root_lint::must_root] \
+ on the struct definition to propagate",
+ |lint| lint.set_span(field.span),
+ )
}
}
}
@@ -242,15 +240,13 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
for field in fields {
let def_id = cx.tcx.hir().local_def_id(field.hir_id);
if is_unrooted_ty(&self.symbols, cx, cx.tcx.type_of(def_id), false) {
- cx.lint(UNROOTED_MUST_ROOT, |lint| {
- lint.build(
- "Type must be rooted, \
- use #[unrooted_must_root_lint::must_root] \
- on the enum definition to propagate",
- )
- .set_span(field.ty.span)
- .emit()
- })
+ cx.lint(
+ UNROOTED_MUST_ROOT,
+ "Type must be rooted, \
+ use #[unrooted_must_root_lint::must_root] \
+ on the enum definition to propagate",
+ |lint| lint.set_span(field.ty.span),
+ )
}
}
},
@@ -281,8 +277,8 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
for (arg, ty) in decl.inputs.iter().zip(sig.inputs().skip_binder().iter()) {
if is_unrooted_ty(&self.symbols, cx, *ty, false) {
- cx.lint(UNROOTED_MUST_ROOT, |lint| {
- lint.build("Type must be rooted").set_span(arg.span).emit()
+ cx.lint(UNROOTED_MUST_ROOT, "Type must be rooted", |lint| {
+ lint.set_span(arg.span)
})
}
}
@@ -290,10 +286,8 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
if !in_new_function &&
is_unrooted_ty(&self.symbols, cx, sig.output().skip_binder(), false)
{
- cx.lint(UNROOTED_MUST_ROOT, |lint| {
- lint.build("Type must be rooted")
- .set_span(decl.output.span())
- .emit()
+ cx.lint(UNROOTED_MUST_ROOT, "Type must be rooted", |lint| {
+ lint.set_span(decl.output.span())
})
}
}
@@ -322,11 +316,11 @@ impl<'a, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'tcx> {
let require_rooted = |cx: &LateContext, in_new_function: bool, subexpr: &hir::Expr| {
let ty = cx.typeck_results().expr_ty(&subexpr);
if is_unrooted_ty(&self.symbols, cx, ty, in_new_function) {
- cx.lint(UNROOTED_MUST_ROOT, |lint| {
- lint.build(&format!("Expression of type {:?} must be rooted", ty))
- .set_span(subexpr.span)
- .emit()
- })
+ cx.lint(
+ UNROOTED_MUST_ROOT,
+ format!("Expression of type {:?} must be rooted", ty),
+ |lint| lint.set_span(subexpr.span),
+ )
}
};
@@ -364,11 +358,11 @@ impl<'a, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'tcx> {
hir::PatKind::Binding(hir::BindingAnnotation::MUT, ..) => {
let ty = cx.typeck_results().pat_ty(pat);
if is_unrooted_ty(self.symbols, cx, ty, self.in_new_function) {
- cx.lint(UNROOTED_MUST_ROOT, |lint| {
- lint.build(&format!("Expression of type {:?} must be rooted", ty))
- .set_span(pat.span)
- .emit()
- })
+ cx.lint(
+ UNROOTED_MUST_ROOT,
+ format!("Expression of type {:?} must be rooted", ty),
+ |lint| lint.set_span(pat.span),
+ )
}
},
_ => {},