diff --git a/compiler/rustc_hir_analysis/src/check_unused.rs b/compiler/rustc_hir_analysis/src/check_unused.rs index d10bc5b34ea90..0085342af2619 100644 --- a/compiler/rustc_hir_analysis/src/check_unused.rs +++ b/compiler/rustc_hir_analysis/src/check_unused.rs @@ -10,6 +10,10 @@ pub fn provide(providers: &mut Providers) { } fn check_unused_traits(tcx: TyCtxt<'_>, (): ()) { + if tcx.sess.opts.lint_cap.is_some_and(|cap| cap == rustc_session::lint::Allow) { + return; + } + let mut used_trait_imports = UnordSet::::default(); // FIXME: Use `tcx.hir().par_body_owners()` when we implement creating `DefId`s diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 6b3facd041c28..47b7963cbec2e 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -130,6 +130,10 @@ fn pre_expansion_lint<'a>( check_node: impl EarlyCheckNode<'a>, node_name: Symbol, ) { + if sess.opts.lint_cap.is_some_and(|cap| cap == rustc_session::lint::Allow) { + return; + } + sess.prof.generic_activity_with_arg("pre_AST_expansion_lint_checks", node_name.as_str()).run( || { rustc_lint::check_ast_node( @@ -330,6 +334,10 @@ fn early_lint_checks(tcx: TyCtxt<'_>, (): ()) { rustc_ast_passes::feature_gate::check_crate(&krate, sess); }); + if sess.opts.lint_cap.is_some_and(|cap| cap == rustc_session::lint::Allow) { + return; + } + // Add all buffered lints from the `ParseSess` to the `Session`. sess.parse_sess.buffered_lints.with_lock(|buffered_lints| { info!("{} parse sess buffered_lints", buffered_lints.len()); @@ -841,8 +849,16 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> { tcx.ensure().check_private_in_public(()); }, { - tcx.hir() - .par_for_each_module(|module| tcx.ensure().check_mod_deathness(module)); + if !tcx + .sess + .opts + .lint_cap + .is_some_and(|cap| cap == rustc_session::lint::Allow) + { + tcx.hir().par_for_each_module(|module| { + tcx.ensure().check_mod_deathness(module) + }); + } }, { sess.time("lint_checking", || { diff --git a/compiler/rustc_lint/src/expect.rs b/compiler/rustc_lint/src/expect.rs index b1266b58a61e7..096cfbaa2d6a4 100644 --- a/compiler/rustc_lint/src/expect.rs +++ b/compiler/rustc_lint/src/expect.rs @@ -15,6 +15,10 @@ fn check_expectations(tcx: TyCtxt<'_>, tool_filter: Option) { return; } + if tcx.sess.opts.lint_cap.is_some_and(|cap| cap == rustc_session::lint::Allow) { + return; + } + let lint_expectations = tcx.lint_expectations(()); let fulfilled_expectations = tcx.sess.diagnostic().steal_fulfilled_expectation_ids(); diff --git a/compiler/rustc_lint/src/late.rs b/compiler/rustc_lint/src/late.rs index fb12ded71d682..c73f4cda731f0 100644 --- a/compiler/rustc_lint/src/late.rs +++ b/compiler/rustc_lint/src/late.rs @@ -436,6 +436,10 @@ pub fn check_crate<'tcx, T: LateLintPass<'tcx> + 'tcx>( tcx: TyCtxt<'tcx>, builtin_lints: impl FnOnce() -> T + Send + DynSend, ) { + if tcx.sess.opts.lint_cap.is_some_and(|cap| cap == rustc_session::lint::Allow) { + return; + } + join( || { tcx.sess.time("crate_lints", || { diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 36b5c385ab193..4b4e695088a29 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -1015,7 +1015,7 @@ impl Default for Options { optimize: OptLevel::No, debuginfo: DebugInfo::None, lint_opts: Vec::new(), - lint_cap: None, + lint_cap: Some(lint::Allow), describe_lints: false, output_types: OutputTypes(BTreeMap::new()), search_paths: vec![], @@ -1787,7 +1787,7 @@ pub fn rustc_optgroups() -> Vec { } pub fn get_cmd_lint_options( - handler: &EarlyErrorHandler, + _handler: &EarlyErrorHandler, matches: &getopts::Matches, ) -> (Vec<(String, lint::Level)>, bool, Option) { let mut lint_opts_with_position = vec![]; @@ -1810,10 +1810,7 @@ pub fn get_cmd_lint_options( .map(|(_, lint_name, level)| (lint_name, level)) .collect(); - let lint_cap = matches.opt_str("cap-lints").map(|cap| { - lint::Level::from_str(&cap) - .unwrap_or_else(|| handler.early_error(format!("unknown lint level: `{cap}`"))) - }); + let lint_cap = Some(lint::Allow); (lint_opts, describe_lints, lint_cap) }