aboutsummaryrefslogtreecommitdiffstats
path: root/support/crown
diff options
context:
space:
mode:
Diffstat (limited to 'support/crown')
-rw-r--r--support/crown/src/common.rs46
-rw-r--r--support/crown/src/main.rs7
-rw-r--r--support/crown/src/trace_in_no_trace.rs6
-rw-r--r--support/crown/src/unrooted_must_root.rs8
-rw-r--r--support/crown/tests/compile-fail/trace_in_no_trace_composable_works.rs2
-rw-r--r--support/crown/tests/compile-fail/trace_in_no_trace_works.rs1
-rw-r--r--support/crown/tests/compile-fail/unrooted_must_root_parameter.rs1
-rw-r--r--support/crown/tests/compile-fail/unrooted_must_root_return_type.rs1
-rw-r--r--support/crown/tests/compile-fail/unrooted_must_root_struct_field.rs1
-rw-r--r--support/crown/tests/run-pass/trace_in_no_trace_composable.rs1
-rw-r--r--support/crown/tests/run-pass/trace_in_no_trace_ok.rs1
-rw-r--r--support/crown/tests/run-pass/unrooted_must_root_ok.rs2
-rw-r--r--support/crown/tests/ui/trace_in_no_trace_primitive.rs1
-rw-r--r--support/crown/tests/ui/trace_in_no_trace_primitive.stderr4
14 files changed, 48 insertions, 34 deletions
diff --git a/support/crown/src/common.rs b/support/crown/src/common.rs
index d360b05069e..c955564d61e 100644
--- a/support/crown/src/common.rs
+++ b/support/crown/src/common.rs
@@ -70,32 +70,32 @@ Stuff copied from clippy:
*/
fn find_primitive_impls<'tcx>(tcx: TyCtxt<'tcx>, name: &str) -> impl Iterator<Item = DefId> + 'tcx {
- use rustc_middle::ty::fast_reject::SimplifiedType::*;
+ use rustc_middle::ty::fast_reject::SimplifiedType;
let ty = match name {
- "bool" => BoolSimplifiedType,
- "char" => CharSimplifiedType,
- "str" => StrSimplifiedType,
- "array" => ArraySimplifiedType,
- "slice" => SliceSimplifiedType,
+ "bool" => SimplifiedType::Bool,
+ "char" => SimplifiedType::Char,
+ "str" => SimplifiedType::Str,
+ "array" => SimplifiedType::Array,
+ "slice" => SimplifiedType::Slice,
// FIXME: rustdoc documents these two using just `pointer`.
//
// Maybe this is something we should do here too.
- "const_ptr" => PtrSimplifiedType(Mutability::Not),
- "mut_ptr" => PtrSimplifiedType(Mutability::Mut),
- "isize" => IntSimplifiedType(IntTy::Isize),
- "i8" => IntSimplifiedType(IntTy::I8),
- "i16" => IntSimplifiedType(IntTy::I16),
- "i32" => IntSimplifiedType(IntTy::I32),
- "i64" => IntSimplifiedType(IntTy::I64),
- "i128" => IntSimplifiedType(IntTy::I128),
- "usize" => UintSimplifiedType(UintTy::Usize),
- "u8" => UintSimplifiedType(UintTy::U8),
- "u16" => UintSimplifiedType(UintTy::U16),
- "u32" => UintSimplifiedType(UintTy::U32),
- "u64" => UintSimplifiedType(UintTy::U64),
- "u128" => UintSimplifiedType(UintTy::U128),
- "f32" => FloatSimplifiedType(FloatTy::F32),
- "f64" => FloatSimplifiedType(FloatTy::F64),
+ "const_ptr" => SimplifiedType::Ptr(Mutability::Not),
+ "mut_ptr" => SimplifiedType::Ptr(Mutability::Mut),
+ "isize" => SimplifiedType::Int(IntTy::Isize),
+ "i8" => SimplifiedType::Int(IntTy::I8),
+ "i16" => SimplifiedType::Int(IntTy::I16),
+ "i32" => SimplifiedType::Int(IntTy::I32),
+ "i64" => SimplifiedType::Int(IntTy::I64),
+ "i128" => SimplifiedType::Int(IntTy::I128),
+ "usize" => SimplifiedType::Uint(UintTy::Usize),
+ "u8" => SimplifiedType::Uint(UintTy::U8),
+ "u16" => SimplifiedType::Uint(UintTy::U16),
+ "u32" => SimplifiedType::Uint(UintTy::U32),
+ "u64" => SimplifiedType::Uint(UintTy::U64),
+ "u128" => SimplifiedType::Uint(UintTy::U128),
+ "f32" => SimplifiedType::Float(FloatTy::F32),
+ "f64" => SimplifiedType::Float(FloatTy::F64),
_ => return [].iter().copied(),
};
@@ -329,7 +329,7 @@ pub fn implements_trait_with_env<'tcx>(
kind: TypeVariableOriginKind::MiscVariable,
span: DUMMY_SP,
};
- let ty_params = tcx.mk_substs_from_iter(
+ let ty_params = tcx.mk_args_from_iter(
ty_params
.into_iter()
.map(|arg| arg.unwrap_or_else(|| infcx.next_ty_var(orig).into())),
diff --git a/support/crown/src/main.rs b/support/crown/src/main.rs
index fa2a16868b1..d9a7fd0f757 100644
--- a/support/crown/src/main.rs
+++ b/support/crown/src/main.rs
@@ -42,7 +42,8 @@ impl Callbacks for MyCallbacks {
config.register_lints = Some(Box::new(move |sess, lint_store| {
// Skip checks for proc-macro crates.
if sess
- .crate_types()
+ .opts
+ .crate_types
.contains(&rustc_session::config::CrateType::ProcMacro)
{
return;
@@ -58,7 +59,9 @@ impl Callbacks for MyCallbacks {
}
fn main() -> ExitCode {
- rustc_driver::init_env_logger("CROWN_LOG");
+ let handler =
+ rustc_session::EarlyErrorHandler::new(rustc_session::config::ErrorOutputType::default());
+ rustc_driver::init_env_logger(&handler, "CROWN_LOG");
let args: Vec<_> = std::env::args().collect();
match rustc_driver::RunCompiler::new(&args, &mut MyCallbacks).run() {
diff --git a/support/crown/src/trace_in_no_trace.rs b/support/crown/src/trace_in_no_trace.rs
index 0e685c242a0..917a2c7459b 100644
--- a/support/crown/src/trace_in_no_trace.rs
+++ b/support/crown/src/trace_in_no_trace.rs
@@ -118,7 +118,7 @@ fn incorrect_no_trace<'tcx, I: Into<MultiSpan> + Copy>(
let mut walker = ty.walk();
while let Some(generic_arg) = walker.next() {
let t = match generic_arg.unpack() {
- rustc_middle::ty::subst::GenericArgKind::Type(t) => t,
+ rustc_middle::ty::GenericArgKind::Type(t) => t,
_ => {
walker.skip_current_subtree();
continue;
@@ -171,7 +171,7 @@ impl<'tcx> LateLintPass<'tcx> for NotracePass {
if let hir::ItemKind::Struct(def, ..) = &item.kind {
for ref field in def.fields() {
let field_type = cx.tcx.type_of(field.def_id);
- incorrect_no_trace(&self.symbols, cx, field_type.0, field.span);
+ incorrect_no_trace(&self.symbols, cx, field_type.skip_binder(), field.span);
}
}
}
@@ -181,7 +181,7 @@ impl<'tcx> LateLintPass<'tcx> for NotracePass {
hir::VariantData::Tuple(fields, ..) => {
for field in fields {
let field_type = cx.tcx.type_of(field.def_id);
- incorrect_no_trace(&self.symbols, cx, field_type.0, field.ty.span);
+ incorrect_no_trace(&self.symbols, cx, field_type.skip_binder(), field.ty.span);
}
},
_ => (), // Struct variants already caught by check_struct_def
diff --git a/support/crown/src/unrooted_must_root.rs b/support/crown/src/unrooted_must_root.rs
index 36c22c3170b..d01ede4c0bb 100644
--- a/support/crown/src/unrooted_must_root.rs
+++ b/support/crown/src/unrooted_must_root.rs
@@ -77,7 +77,7 @@ fn is_unrooted_ty<'tcx>(
let mut walker = ty.walk();
while let Some(generic_arg) = walker.next() {
let t = match generic_arg.unpack() {
- rustc_middle::ty::subst::GenericArgKind::Type(t) => t,
+ rustc_middle::ty::GenericArgKind::Type(t) => t,
_ => {
walker.skip_current_subtree();
continue;
@@ -191,7 +191,7 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
if let hir::ItemKind::Struct(def, ..) = &item.kind {
for ref field in def.fields() {
let field_type = cx.tcx.type_of(field.def_id);
- if is_unrooted_ty(&self.symbols, cx, field_type.0, false) {
+ if is_unrooted_ty(&self.symbols, cx, field_type.skip_binder(), false) {
cx.lint(
UNROOTED_MUST_ROOT,
"Type must be rooted, use #[crown::unrooted_must_root_lint::must_root] \
@@ -214,7 +214,7 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
hir::VariantData::Tuple(fields, ..) => {
for field in fields {
let field_type = cx.tcx.type_of(field.def_id);
- if is_unrooted_ty(&self.symbols, cx, field_type.0, false) {
+ if is_unrooted_ty(&self.symbols, cx, field_type.skip_binder(), false) {
cx.lint(
UNROOTED_MUST_ROOT,
"Type must be rooted, \
@@ -247,7 +247,7 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
};
if !in_derive_expn(span) {
- let sig = cx.tcx.type_of(def_id).0.fn_sig(cx.tcx);
+ let sig = cx.tcx.type_of(def_id).skip_binder().fn_sig(cx.tcx);
for (arg, ty) in decl.inputs.iter().zip(sig.inputs().skip_binder().iter()) {
if is_unrooted_ty(&self.symbols, cx, *ty, false) {
diff --git a/support/crown/tests/compile-fail/trace_in_no_trace_composable_works.rs b/support/crown/tests/compile-fail/trace_in_no_trace_composable_works.rs
index 8b8ed813052..345f02e7dd4 100644
--- a/support/crown/tests/compile-fail/trace_in_no_trace_composable_works.rs
+++ b/support/crown/tests/compile-fail/trace_in_no_trace_composable_works.rs
@@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// compile-flags: --error-format=human
+//@rustc-env:RUSTC_BOOTSTRAP=1
+
/// Mock `JSTraceable`
pub trait JSTraceable {}
diff --git a/support/crown/tests/compile-fail/trace_in_no_trace_works.rs b/support/crown/tests/compile-fail/trace_in_no_trace_works.rs
index e45964e56f1..8f2341067d3 100644
--- a/support/crown/tests/compile-fail/trace_in_no_trace_works.rs
+++ b/support/crown/tests/compile-fail/trace_in_no_trace_works.rs
@@ -1,6 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+//@rustc-env:RUSTC_BOOTSTRAP=1
/// Mock `JSTraceable`
pub trait JSTraceable {}
diff --git a/support/crown/tests/compile-fail/unrooted_must_root_parameter.rs b/support/crown/tests/compile-fail/unrooted_must_root_parameter.rs
index 626832cd567..5e9000f8bd9 100644
--- a/support/crown/tests/compile-fail/unrooted_must_root_parameter.rs
+++ b/support/crown/tests/compile-fail/unrooted_must_root_parameter.rs
@@ -1,6 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+//@rustc-env:RUSTC_BOOTSTRAP=1
#[crown::unrooted_must_root_lint::must_root]
struct Foo(i32);
diff --git a/support/crown/tests/compile-fail/unrooted_must_root_return_type.rs b/support/crown/tests/compile-fail/unrooted_must_root_return_type.rs
index 768e56b258c..fa334522a68 100644
--- a/support/crown/tests/compile-fail/unrooted_must_root_return_type.rs
+++ b/support/crown/tests/compile-fail/unrooted_must_root_return_type.rs
@@ -1,6 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+//@rustc-env:RUSTC_BOOTSTRAP=1
#[crown::unrooted_must_root_lint::must_root]
struct Foo(i32);
diff --git a/support/crown/tests/compile-fail/unrooted_must_root_struct_field.rs b/support/crown/tests/compile-fail/unrooted_must_root_struct_field.rs
index 5c132577c32..4f4bf95e8cf 100644
--- a/support/crown/tests/compile-fail/unrooted_must_root_struct_field.rs
+++ b/support/crown/tests/compile-fail/unrooted_must_root_struct_field.rs
@@ -1,6 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+//@rustc-env:RUSTC_BOOTSTRAP=1
#[crown::unrooted_must_root_lint::must_root]
struct Foo(i32);
diff --git a/support/crown/tests/run-pass/trace_in_no_trace_composable.rs b/support/crown/tests/run-pass/trace_in_no_trace_composable.rs
index 1d642ad85e1..64fa9045f2b 100644
--- a/support/crown/tests/run-pass/trace_in_no_trace_composable.rs
+++ b/support/crown/tests/run-pass/trace_in_no_trace_composable.rs
@@ -1,6 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+//@rustc-env:RUSTC_BOOTSTRAP=1
/// Mock `JSTraceable`
pub trait JSTraceable {}
diff --git a/support/crown/tests/run-pass/trace_in_no_trace_ok.rs b/support/crown/tests/run-pass/trace_in_no_trace_ok.rs
index 6c573c2f105..14f467f4335 100644
--- a/support/crown/tests/run-pass/trace_in_no_trace_ok.rs
+++ b/support/crown/tests/run-pass/trace_in_no_trace_ok.rs
@@ -1,6 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+//@rustc-env:RUSTC_BOOTSTRAP=1
/// Mock `JSTraceable`
pub trait JSTraceable {}
diff --git a/support/crown/tests/run-pass/unrooted_must_root_ok.rs b/support/crown/tests/run-pass/unrooted_must_root_ok.rs
index e556143d8a2..ef03e6881bb 100644
--- a/support/crown/tests/run-pass/unrooted_must_root_ok.rs
+++ b/support/crown/tests/run-pass/unrooted_must_root_ok.rs
@@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// compile-flags: --error-format=human
+//@rustc-env:RUSTC_BOOTSTRAP=1
+
#[crown::unrooted_must_root_lint::must_root]
struct Foo(i32);
#[crown::unrooted_must_root_lint::must_root]
diff --git a/support/crown/tests/ui/trace_in_no_trace_primitive.rs b/support/crown/tests/ui/trace_in_no_trace_primitive.rs
index d1f765a3afd..8c940a37ad6 100644
--- a/support/crown/tests/ui/trace_in_no_trace_primitive.rs
+++ b/support/crown/tests/ui/trace_in_no_trace_primitive.rs
@@ -1,6 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+//@rustc-env:RUSTC_BOOTSTRAP=1
/// Mock `JSTraceable`
pub trait JSTraceable {}
diff --git a/support/crown/tests/ui/trace_in_no_trace_primitive.stderr b/support/crown/tests/ui/trace_in_no_trace_primitive.stderr
index b3e8178289a..a62c91acc4e 100644
--- a/support/crown/tests/ui/trace_in_no_trace_primitive.stderr
+++ b/support/crown/tests/ui/trace_in_no_trace_primitive.stderr
@@ -1,7 +1,7 @@
warning: must_not_have_traceable marked wrapper is not needed for types that implements empty Traceable (like primitive types). Consider removing the wrapper.
- --> $DIR/trace_in_no_trace_primitive.rs:15:12
+ --> $DIR/trace_in_no_trace_primitive.rs:16:12
|
-15 | struct Foo(NoTrace<i32>);
+16 | struct Foo(NoTrace<i32>);
| ^^^^^^^^^^^^
|
= note: `#[warn(crown::empty_trace_in_no_trace)]` on by default