Auto merge of #29014 - yvt:patch/bump-rust-toolchain, r=jdm

chore: upgrade the Rust toolchain to `nightly-2022-10-13`

---
- [x] `./mach build -d` does not report any errors (prerequisite: #29009)
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)

---
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because they are not functional changes
This commit is contained in:
bors-servo 2022-10-23 18:54:43 -04:00 committed by GitHub
commit 2926f05f69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 47 deletions

View file

@ -43,7 +43,7 @@ fn registrar(reg: &mut Registry) {
let symbols = Symbols::new(); let symbols = Symbols::new();
reg.lint_store.register_lints(&[&UNROOTED_MUST_ROOT]); reg.lint_store.register_lints(&[&UNROOTED_MUST_ROOT]);
reg.lint_store reg.lint_store
.register_late_pass(move || Box::new(UnrootedPass::new(symbols.clone()))); .register_late_pass(move |_| Box::new(UnrootedPass::new(symbols.clone())));
} }
declare_lint!( declare_lint!(
@ -83,10 +83,10 @@ fn has_lint_attr(sym: &Symbols, attrs: &[Attribute], name: Symbol) -> bool {
attrs.iter().any(|attr| { attrs.iter().any(|attr| {
matches!( matches!(
&attr.kind, &attr.kind,
AttrKind::Normal(attr_item, _) AttrKind::Normal(normal)
if attr_item.path.segments.len() == 2 && if normal.item.path.segments.len() == 2 &&
attr_item.path.segments[0].ident.name == sym.unrooted_must_root_lint && normal.item.path.segments[0].ident.name == sym.unrooted_must_root_lint &&
attr_item.path.segments[1].ident.name == name normal.item.path.segments[1].ident.name == name
) )
}) })
} }
@ -110,7 +110,8 @@ fn is_unrooted_ty<'tcx>(
}; };
let recur_into_subtree = match t.kind() { let recur_into_subtree = match t.kind() {
ty::Adt(did, substs) => { ty::Adt(did, substs) => {
let has_attr = |did, name| has_lint_attr(sym, &cx.tcx.get_attrs(did), name); let has_attr =
|did, name| has_lint_attr(sym, &cx.tcx.get_attrs_unchecked(did), name);
if has_attr(did.did(), sym.must_root) { if has_attr(did.did(), sym.must_root) {
ret = true; ret = true;
false false
@ -216,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()
})
} }
} }
} }
@ -233,7 +232,7 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
/// must be #[unrooted_must_root_lint::must_root] themselves /// must be #[unrooted_must_root_lint::must_root] themselves
fn check_variant(&mut self, cx: &LateContext, var: &hir::Variant) { fn check_variant(&mut self, cx: &LateContext, var: &hir::Variant) {
let ref map = cx.tcx.hir(); let ref map = cx.tcx.hir();
let parent_item = map.expect_item(map.get_parent_item(var.id)); let parent_item = map.expect_item(map.get_parent_item(var.id).def_id);
let attrs = cx.tcx.hir().attrs(parent_item.hir_id()); let attrs = cx.tcx.hir().attrs(parent_item.hir_id());
if !has_lint_attr(&self.symbols, &attrs, self.symbols.must_root) { if !has_lint_attr(&self.symbols, &attrs, self.symbols.must_root) {
match var.data { match var.data {
@ -241,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()
})
} }
} }
}, },
@ -268,7 +265,7 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
id: HirId, id: HirId,
) { ) {
let in_new_function = match kind { let in_new_function = match kind {
visit::FnKind::ItemFn(n, _, _, _) | visit::FnKind::Method(n, _, _) => { visit::FnKind::ItemFn(n, _, _) | visit::FnKind::Method(n, _) => {
&*n.as_str() == "new" || n.as_str().starts_with("new_") &*n.as_str() == "new" || n.as_str().starts_with("new_")
}, },
visit::FnKind::Closure => return, visit::FnKind::Closure => return,
@ -280,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)
}) })
} }
} }
@ -289,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()
}) })
} }
} }
@ -321,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),
}) )
} }
}; };
@ -359,15 +354,15 @@ impl<'a, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'tcx> {
// are implemented, the `Unannotated` case could cause false-positives. // are implemented, the `Unannotated` case could cause false-positives.
// These should be fixable by adding an explicit `ref`. // These should be fixable by adding an explicit `ref`.
match pat.kind { match pat.kind {
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, ..) | hir::PatKind::Binding(hir::BindingAnnotation::NONE, ..) |
hir::PatKind::Binding(hir::BindingAnnotation::Mutable, ..) => { 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),
}) )
} }
}, },
_ => {}, _ => {},

View file

@ -1 +1 @@
nightly-2022-04-11 nightly-2022-10-13

View file

@ -38,14 +38,14 @@ size_of_test!(
40 40
); );
size_of_test!(test_size_of_selector_parse_error, SelectorParseError, 56); size_of_test!(test_size_of_selector_parse_error, SelectorParseError, 48);
size_of_test!( size_of_test!(
test_size_of_style_traits_parse_error, test_size_of_style_traits_parse_error,
::style_traits::ParseError, ::style_traits::ParseError,
72 64
); );
size_of_test!( size_of_test!(
test_size_of_value_parse_error, test_size_of_value_parse_error,
::style_traits::ValueParseError, ::style_traits::ValueParseError,
56 48
); );