diff options
Diffstat (limited to 'support/crown/src')
-rw-r--r-- | support/crown/src/common.rs | 9 | ||||
-rw-r--r-- | support/crown/src/main.rs | 8 | ||||
-rw-r--r-- | support/crown/src/trace_in_no_trace.rs | 26 | ||||
-rw-r--r-- | support/crown/src/unrooted_must_root.rs | 6 |
4 files changed, 26 insertions, 23 deletions
diff --git a/support/crown/src/common.rs b/support/crown/src/common.rs index e36343061b2..958e4b5e4d6 100644 --- a/support/crown/src/common.rs +++ b/support/crown/src/common.rs @@ -9,7 +9,7 @@ use rustc_hir::{ImplItemRef, ItemKind, Node, OwnerId, PrimTy, TraitItemRef}; use rustc_infer::infer::TyCtxtInferExt; use rustc_lint::LateContext; use rustc_middle::ty::fast_reject::SimplifiedType; -use rustc_middle::ty::{self, GenericArg, ParamEnv, Ty, TyCtxt, TypeVisitableExt}; +use rustc_middle::ty::{self, GenericArg, Ty, TyCtxt, TypeVisitableExt, TypingEnv}; use rustc_span::hygiene::{ExpnKind, MacroKind}; use rustc_span::symbol::{Ident, Symbol}; use rustc_span::{Span, DUMMY_SP}; @@ -312,7 +312,7 @@ pub fn implements_trait<'tcx>( ) -> bool { implements_trait_with_env( cx.tcx, - cx.param_env, + cx.typing_env(), ty, trait_id, ty_params.iter().map(|&arg| Some(arg)), @@ -322,7 +322,7 @@ pub fn implements_trait<'tcx>( /// Same as `implements_trait` but allows using a `ParamEnv` different from the lint context. pub fn implements_trait_with_env<'tcx>( tcx: TyCtxt<'tcx>, - param_env: ParamEnv<'tcx>, + typing_env: TypingEnv<'tcx>, ty: ty::Ty<'tcx>, trait_id: DefId, ty_params: impl IntoIterator<Item = Option<GenericArg<'tcx>>>, @@ -331,7 +331,8 @@ pub fn implements_trait_with_env<'tcx>( if ty.has_escaping_bound_vars() { return false; } - let infcx = tcx.infer_ctxt().build(); + + let (infcx, param_env) = tcx.infer_ctxt().build_with_typing_env(typing_env); let ty_params = tcx.mk_args_from_iter( ty_params .into_iter() diff --git a/support/crown/src/main.rs b/support/crown/src/main.rs index cd64ca7331f..7c70f45463b 100644 --- a/support/crown/src/main.rs +++ b/support/crown/src/main.rs @@ -23,7 +23,6 @@ extern crate rustc_trait_selection; extern crate rustc_type_ir; use std::path::Path; -use std::process::ExitCode; use rustc_driver::Callbacks; use rustc_interface::interface::Config; @@ -61,7 +60,7 @@ impl Callbacks for MyCallbacks { } } -fn main() -> ExitCode { +fn main() { let handler = rustc_session::EarlyDiagCtxt::new(rustc_session::config::ErrorOutputType::default()); rustc_driver::init_logger(&handler, rustc_log::LoggerConfig::from_env("CROWN_LOG")); @@ -76,8 +75,5 @@ fn main() -> ExitCode { // Pass cfg(crown) to rustc args.extend(["--cfg".to_owned(), "crown".to_owned()]); - match rustc_driver::RunCompiler::new(&args, &mut MyCallbacks).run() { - Ok(_) => ExitCode::SUCCESS, - Err(_) => ExitCode::FAILURE, - } + 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 059f1cd4894..cb64eb9d55b 100644 --- a/support/crown/src/trace_in_no_trace.rs +++ b/support/crown/src/trace_in_no_trace.rs @@ -2,13 +2,11 @@ * 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/. */ -use rustc_ast::ast::{AttrKind, Attribute}; use rustc_ast::token::TokenKind; use rustc_ast::tokenstream::TokenTree; -use rustc_ast::AttrArgs; use rustc_error_messages::MultiSpan; use rustc_hir::{self as hir}; -use rustc_lint::{LateContext, LateLintPass, LintContext, LintPass, LintStore}; +use rustc_lint::{LateContext, LateLintPass, Lint, LintContext, LintPass, LintStore}; use rustc_middle::ty; use rustc_session::declare_tool_lint; use rustc_span::symbol::Symbol; @@ -59,26 +57,30 @@ impl LintPass for NotracePass { fn name(&self) -> &'static str { "ServoNotracePass" } + + fn get_lints(&self) -> Vec<&'static Lint> { + vec![TRACE_IN_NO_TRACE, EMPTY_TRACE_IN_NO_TRACE] + } } -fn get_must_not_have_traceable(sym: &Symbols, attrs: &[Attribute]) -> Option<usize> { +fn get_must_not_have_traceable(sym: &Symbols, attrs: &[hir::Attribute]) -> Option<usize> { attrs .iter() .find(|attr| { matches!( &attr.kind, - AttrKind::Normal(normal) - if normal.item.path.segments.len() == 3 && - normal.item.path.segments[0].ident.name == sym.crown && - normal.item.path.segments[1].ident.name == sym.trace_in_no_trace_lint && - normal.item.path.segments[2].ident.name == sym.must_not_have_traceable + hir::AttrKind::Normal(normal) + if normal.path.segments.len() == 3 && + normal.path.segments[0].name == sym.crown && + normal.path.segments[1].name == sym.trace_in_no_trace_lint && + normal.path.segments[2].name == sym.must_not_have_traceable ) }) .map(|x| match &x.get_normal_item().args { - AttrArgs::Empty => 0, - AttrArgs::Delimited(a) => match a + hir::AttrArgs::Empty => 0, + hir::AttrArgs::Delimited(a) => match a .tokens - .trees() + .iter() .next() .expect("Arguments not found for must_not_have_traceable") { diff --git a/support/crown/src/unrooted_must_root.rs b/support/crown/src/unrooted_must_root.rs index e0d18cb3b7a..3c1c2f87d9a 100644 --- a/support/crown/src/unrooted_must_root.rs +++ b/support/crown/src/unrooted_must_root.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use rustc_hir::{self as hir, intravisit as visit, ExprKind}; -use rustc_lint::{LateContext, LateLintPass, LintContext, LintPass, LintStore}; +use rustc_lint::{LateContext, LateLintPass, Lint, LintContext, LintPass, LintStore}; use rustc_middle::ty; use rustc_session::declare_tool_lint; use rustc_span::def_id::{DefId, LocalDefId}; @@ -217,6 +217,10 @@ impl LintPass for UnrootedPass { fn name(&self) -> &'static str { "ServoUnrootedPass" } + + fn get_lints(&self) -> Vec<&'static Lint> { + vec![UNROOTED_MUST_ROOT] + } } impl<'tcx> LateLintPass<'tcx> for UnrootedPass { |