mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
fix(script_plugins): adapt to the new rustc lint API
<https://github.com/rust-lang/rust/pull/101986>
This commit is contained in:
parent
3cd4837e63
commit
687ac6c77f
1 changed files with 27 additions and 33 deletions
|
@ -217,14 +217,12 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
|
||||||
for ref field in def.fields() {
|
for ref field in def.fields() {
|
||||||
let def_id = cx.tcx.hir().local_def_id(field.hir_id);
|
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) {
|
if is_unrooted_ty(&self.symbols, cx, cx.tcx.type_of(def_id), false) {
|
||||||
cx.lint(UNROOTED_MUST_ROOT, |lint| {
|
cx.lint(
|
||||||
lint.build(
|
UNROOTED_MUST_ROOT,
|
||||||
"Type must be rooted, use #[unrooted_must_root_lint::must_root] \
|
"Type must be rooted, use #[unrooted_must_root_lint::must_root] \
|
||||||
on the struct definition to propagate",
|
on the struct definition to propagate",
|
||||||
|
|lint| lint.set_span(field.span),
|
||||||
)
|
)
|
||||||
.set_span(field.span)
|
|
||||||
.emit()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,15 +240,13 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
|
||||||
for field in fields {
|
for field in fields {
|
||||||
let def_id = cx.tcx.hir().local_def_id(field.hir_id);
|
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) {
|
if is_unrooted_ty(&self.symbols, cx, cx.tcx.type_of(def_id), false) {
|
||||||
cx.lint(UNROOTED_MUST_ROOT, |lint| {
|
cx.lint(
|
||||||
lint.build(
|
UNROOTED_MUST_ROOT,
|
||||||
"Type must be rooted, \
|
"Type must be rooted, \
|
||||||
use #[unrooted_must_root_lint::must_root] \
|
use #[unrooted_must_root_lint::must_root] \
|
||||||
on the enum definition to propagate",
|
on the enum definition to propagate",
|
||||||
|
|lint| lint.set_span(field.ty.span),
|
||||||
)
|
)
|
||||||
.set_span(field.ty.span)
|
|
||||||
.emit()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -281,8 +277,8 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
|
||||||
|
|
||||||
for (arg, ty) in decl.inputs.iter().zip(sig.inputs().skip_binder().iter()) {
|
for (arg, ty) in decl.inputs.iter().zip(sig.inputs().skip_binder().iter()) {
|
||||||
if is_unrooted_ty(&self.symbols, cx, *ty, false) {
|
if is_unrooted_ty(&self.symbols, cx, *ty, false) {
|
||||||
cx.lint(UNROOTED_MUST_ROOT, |lint| {
|
cx.lint(UNROOTED_MUST_ROOT, "Type must be rooted", |lint| {
|
||||||
lint.build("Type must be rooted").set_span(arg.span).emit()
|
lint.set_span(arg.span)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,10 +286,8 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
|
||||||
if !in_new_function &&
|
if !in_new_function &&
|
||||||
is_unrooted_ty(&self.symbols, cx, sig.output().skip_binder(), false)
|
is_unrooted_ty(&self.symbols, cx, sig.output().skip_binder(), false)
|
||||||
{
|
{
|
||||||
cx.lint(UNROOTED_MUST_ROOT, |lint| {
|
cx.lint(UNROOTED_MUST_ROOT, "Type must be rooted", |lint| {
|
||||||
lint.build("Type must be rooted")
|
lint.set_span(decl.output.span())
|
||||||
.set_span(decl.output.span())
|
|
||||||
.emit()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 require_rooted = |cx: &LateContext, in_new_function: bool, subexpr: &hir::Expr| {
|
||||||
let ty = cx.typeck_results().expr_ty(&subexpr);
|
let ty = cx.typeck_results().expr_ty(&subexpr);
|
||||||
if is_unrooted_ty(&self.symbols, cx, ty, in_new_function) {
|
if is_unrooted_ty(&self.symbols, cx, ty, in_new_function) {
|
||||||
cx.lint(UNROOTED_MUST_ROOT, |lint| {
|
cx.lint(
|
||||||
lint.build(&format!("Expression of type {:?} must be rooted", ty))
|
UNROOTED_MUST_ROOT,
|
||||||
.set_span(subexpr.span)
|
format!("Expression of type {:?} must be rooted", ty),
|
||||||
.emit()
|
|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, ..) => {
|
hir::PatKind::Binding(hir::BindingAnnotation::MUT, ..) => {
|
||||||
let ty = cx.typeck_results().pat_ty(pat);
|
let ty = cx.typeck_results().pat_ty(pat);
|
||||||
if is_unrooted_ty(self.symbols, cx, ty, self.in_new_function) {
|
if is_unrooted_ty(self.symbols, cx, ty, self.in_new_function) {
|
||||||
cx.lint(UNROOTED_MUST_ROOT, |lint| {
|
cx.lint(
|
||||||
lint.build(&format!("Expression of type {:?} must be rooted", ty))
|
UNROOTED_MUST_ROOT,
|
||||||
.set_span(pat.span)
|
format!("Expression of type {:?} must be rooted", ty),
|
||||||
.emit()
|
|lint| lint.set_span(pat.span),
|
||||||
})
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue