Skip to content

Commit 2c97676

Browse files
committed
Migrate sess.opts.tests uses to sess.is_test_crate()
1 parent 28e19f1 commit 2c97676

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

compiler/rustc_builtin_macros/src/test_harness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub fn inject(krate: &mut ast::Crate, sess: &Session, resolver: &mut dyn Resolve
5353
// even in non-test builds
5454
let test_runner = get_test_runner(span_diagnostic, &krate);
5555

56-
if sess.opts.test {
56+
if sess.is_test_crate() {
5757
let panic_strategy = match (panic_strategy, sess.opts.unstable_opts.panic_abort_tests) {
5858
(PanicStrategy::Abort, true) => PanicStrategy::Abort,
5959
(PanicStrategy::Abort, false) => {

compiler/rustc_codegen_ssa/src/back/link.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2301,7 +2301,7 @@ fn add_native_libs_from_crate(
23012301
|| (whole_archive == None
23022302
&& bundle
23032303
&& cnum == LOCAL_CRATE
2304-
&& sess.opts.test);
2304+
&& sess.is_test_crate());
23052305

23062306
if bundle && cnum != LOCAL_CRATE {
23072307
if let Some(filename) = lib.filename {

compiler/rustc_interface/src/passes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ fn configure_and_expand(
230230
features: Some(features),
231231
recursion_limit,
232232
trace_mac: sess.opts.unstable_opts.trace_macros,
233-
should_test: sess.opts.test,
233+
should_test: sess.is_test_crate(),
234234
span_debug: sess.opts.unstable_opts.span_debug,
235235
proc_macro_backtrace: sess.opts.unstable_opts.proc_macro_backtrace,
236236
..rustc_expand::expand::ExpansionConfig::default(crate_name.to_string())
@@ -292,7 +292,7 @@ fn configure_and_expand(
292292
}
293293

294294
sess.time("maybe_create_a_macro_crate", || {
295-
let is_test_crate = sess.opts.test;
295+
let is_test_crate = sess.is_test_crate();
296296
rustc_builtin_macros::proc_macro_harness::inject(
297297
&mut krate,
298298
sess,

compiler/rustc_passes/src/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ struct MissingStabilityAnnotations<'tcx> {
530530
impl<'tcx> MissingStabilityAnnotations<'tcx> {
531531
fn check_missing_stability(&self, def_id: LocalDefId, span: Span) {
532532
let stab = self.tcx.stability().local_stability(def_id);
533-
if !self.tcx.sess.opts.test
533+
if !self.tcx.sess.is_test_crate()
534534
&& stab.is_none()
535535
&& self.effective_visibilities.is_reachable(def_id)
536536
{

compiler/rustc_resolve/src/check_unused.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ impl Resolver<'_, '_> {
393393
// If we are in the `--test` mode, suppress a help that adds the `#[cfg(test)]`
394394
// attribute; however, if not, suggest adding the attribute. There is no way to
395395
// retrieve attributes here because we do not have a `TyCtxt` yet.
396-
let test_module_span = if tcx.sess.opts.test {
396+
let test_module_span = if tcx.sess.is_test_crate() {
397397
None
398398
} else {
399399
let parent_module = visitor.r.get_nearest_non_block_module(

compiler/rustc_session/src/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ pub fn build_configuration(sess: &Session, mut user_cfg: CrateConfig) -> CrateCo
12581258
// some default and generated configuration items.
12591259
let default_cfg = default_configuration(sess);
12601260
// If the user wants a test runner, then add the test cfg.
1261-
if sess.opts.test {
1261+
if sess.is_test_crate() {
12621262
user_cfg.insert((sym::test, None));
12631263
}
12641264
user_cfg.extend(default_cfg.iter().cloned());

0 commit comments

Comments
 (0)