Skip to content

Commit 3cf4663

Browse files
committed
feat: Update to rustc nightly-2025-06-06
1 parent f8b3521 commit 3cf4663

44 files changed

Lines changed: 2057 additions & 1301 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 633 additions & 139 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
resolver = "2"
2+
resolver = "3"
33
members = [
44
"cargo-mutest",
55
"mutest-driver",

cargo-mutest/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mutest-driver-cli = { path = "../mutest-driver-cli" }
1111
mutest-driver = { path = "../mutest-driver" }
1212
mutest-operators = { path = "../mutest-operators" }
1313

14-
cargo_metadata = "0.18"
14+
cargo_metadata = "0.20"
1515
clap = { version = "4", features = ["cargo"] }
1616

1717
[build-dependencies]

mutest-driver/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ clap = { version = "4", features = ["cargo"] }
2020
serde = "1.0"
2121
serde_json = "1.0"
2222

23-
rand = "0.8"
24-
rand_seeder = "0.2"
23+
rand = "0.9"
24+
rand_seeder = "0.4"

mutest-driver/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl MutationBatchingRandomness {
7979

8080
match self.seed {
8181
Some(seed) => StdRng::from_seed(seed),
82-
None => StdRng::from_entropy(),
82+
None => StdRng::from_os_rng(),
8383
}
8484
}
8585
}

mutest-driver/src/main.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::path::{Path, PathBuf};
1313
use std::process::{self, Command};
1414

1515
use mutest_driver::config::{self, Config};
16-
use mutest_emit::analysis::hir::Unsafety;
16+
use mutest_emit::analysis::hir::Safety;
1717
use mutest_emit::codegen::mutation::{Operators, UnsafeTargeting};
1818
use rustc_hash::FxHashSet;
1919
use rustc_interface::Config as CompilerConfig;
@@ -97,7 +97,7 @@ pub fn main() {
9797
args[0] = "rustc".to_string();
9898

9999
process::exit(rustc_driver::catch_with_exit_code(|| {
100-
rustc_driver::RunCompiler::new(&args, &mut DefaultCallbacks).run()
100+
rustc_driver::run_compiler(&args, &mut DefaultCallbacks)
101101
}));
102102
}
103103

@@ -111,7 +111,7 @@ pub fn main() {
111111

112112
if normal_rustc || !primary_package || !test_target {
113113
process::exit(rustc_driver::catch_with_exit_code(|| {
114-
rustc_driver::RunCompiler::new(&args, &mut RustcCallbacks { mutest_args }).run()
114+
rustc_driver::run_compiler(&args, &mut RustcCallbacks { mutest_args })
115115
}));
116116
}
117117

@@ -120,7 +120,7 @@ pub fn main() {
120120
.get_matches_from(mutest_args.as_deref().unwrap_or_default().split(" "));
121121

122122
process::exit(rustc_driver::catch_with_exit_code(|| {
123-
let compiler_config = mutest_driver::passes::parse_compiler_args(&args)?.expect("no compiler configuration was generated");
123+
let compiler_config = mutest_driver::passes::parse_compiler_args(&args).expect("no compiler configuration was generated");
124124

125125
let early_dcx = EarlyDiagCtxt::new(compiler_config.opts.error_format);
126126

@@ -195,8 +195,8 @@ pub fn main() {
195195

196196
let unsafe_targeting = match () {
197197
_ if mutest_arg_matches.get_flag("safe") => UnsafeTargeting::None,
198-
_ if mutest_arg_matches.get_flag("cautious") => UnsafeTargeting::OnlyEnclosing(Unsafety::Unsafe),
199-
_ if mutest_arg_matches.get_flag("risky") => UnsafeTargeting::OnlyEnclosing(Unsafety::Normal),
198+
_ if mutest_arg_matches.get_flag("cautious") => UnsafeTargeting::OnlyEnclosing(Safety::Unsafe),
199+
_ if mutest_arg_matches.get_flag("risky") => UnsafeTargeting::OnlyEnclosing(Safety::Safe),
200200
_ if mutest_arg_matches.get_flag("unsafe") => UnsafeTargeting::All,
201201
_ => UnsafeTargeting::None,
202202
};
@@ -344,7 +344,6 @@ pub fn main() {
344344
},
345345
};
346346

347-
mutest_driver::run(config)?;
348-
Ok(())
347+
mutest_driver::run(config).unwrap();
349348
}));
350349
}

mutest-driver/src/passes/analysis.rs

Lines changed: 332 additions & 333 deletions
Large diffs are not rendered by default.

mutest-driver/src/passes/compilation.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ use std::sync::Arc;
33
use std::time::{Duration, Instant};
44

55
use rustc_feature::UnstableFeatures;
6+
use rustc_interface::{Linker, create_and_enter_global_ctxt, passes, run_compiler};
67
use rustc_interface::interface::Result as CompilerResult;
7-
use rustc_interface::run_compiler;
88
use rustc_lint_defs::Level as LintLevel;
99
use rustc_session::EarlyDiagCtxt;
1010
use rustc_session::config::{ExternEntry, ExternLocation, Externs, Input, OutputFilenames};
11-
use rustc_session::filesearch;
1211
use rustc_session::search_paths::SearchPath;
1312
use rustc_session::utils::CanonicalizedPath;
1413

@@ -37,10 +36,10 @@ pub fn run(config: &Config, analysis_pass: &AnalysisPassResult) -> CompilerResul
3736

3837
// The generated crate code relies on the `mutest_runtime` crate (and its dependencies), which must be loaded.
3938
let early_dcx = EarlyDiagCtxt::new(compiler_config.opts.error_format);
40-
let sysroot = filesearch::materialize_sysroot(compiler_config.opts.maybe_sysroot.clone());
39+
let sysroot = &compiler_config.opts.sysroot;
4140
let triple = &compiler_config.opts.target_triple;
42-
compiler_config.opts.search_paths.push(SearchPath::from_cli_opt(&sysroot, &triple, &early_dcx, &format!("crate={}", config.mutest_search_path.display()), true));
43-
compiler_config.opts.search_paths.push(SearchPath::from_cli_opt(&sysroot, &triple, &early_dcx, &format!("dependency={}", config.mutest_search_path.join("deps").display()), true));
41+
compiler_config.opts.search_paths.push(SearchPath::from_cli_opt(sysroot, &triple, &early_dcx, &format!("crate={}", config.mutest_search_path.display()), true));
42+
compiler_config.opts.search_paths.push(SearchPath::from_cli_opt(sysroot, &triple, &early_dcx, &format!("dependency={}", config.mutest_search_path.join("deps").display()), true));
4443
// The externs (paths to dependencies) of the `mutest_runtime` crate are baked into it at compile time.
4544
// These must be propagated to any crate which depends on it.
4645
let mut externs = BTreeMap::<String, ExternEntry>::new();
@@ -71,7 +70,7 @@ pub fn run(config: &Config, analysis_pass: &AnalysisPassResult) -> CompilerResul
7170
let existing_extern = externs.insert(name.to_owned(), ExternEntry {
7271
location: match path {
7372
Some(path) => ExternLocation::ExactPaths(BTreeSet::from([
74-
CanonicalizedPath::new(&config.mutest_search_path.join(path)),
73+
CanonicalizedPath::new(config.mutest_search_path.join(path)),
7574
])),
7675
None => ExternLocation::FoundInLibrarySearchDirectories,
7776
},
@@ -96,24 +95,24 @@ pub fn run(config: &Config, analysis_pass: &AnalysisPassResult) -> CompilerResul
9695
let sess = &compiler.sess;
9796
let codegen_backend = &*compiler.codegen_backend;
9897

99-
let (linker, outputs) = compiler.enter(|queries| {
100-
queries.parse()?;
98+
let krate = passes::parse(sess);
10199

102-
let outputs = queries.global_ctxt()?.enter(|tcx| {
103-
let _ = tcx.resolver_for_lowering();
100+
let (linker, outputs) = create_and_enter_global_ctxt(compiler, krate, |tcx| {
101+
let _ = tcx.resolver_for_lowering();
104102

105-
let outputs = tcx.output_filenames(());
103+
passes::write_dep_info(tcx);
106104

107-
tcx.analysis(())?;
105+
passes::write_interface(tcx);
108106

109-
Ok(outputs.clone())
110-
})?;
107+
tcx.ensure_ok().analysis(());
111108

112-
let linker = queries.codegen_and_build_linker()?;
113-
Ok((linker, outputs))
114-
})?;
109+
let outputs = tcx.output_filenames(()).clone();
110+
let linker = Linker::codegen_and_build_linker(tcx, &*compiler.codegen_backend);
115111

116-
linker.link(sess, codegen_backend)?;
112+
(linker, outputs)
113+
});
114+
115+
linker.link(sess, codegen_backend);
117116

118117
Ok(CompilationPassResult {
119118
duration: t_start.elapsed(),

mutest-driver/src/passes/mod.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
use std::collections::BTreeMap;
22
use std::convert::Infallible;
33
use std::ops::{ControlFlow, FromResidual, Residual, Try};
4-
use std::sync::Arc;
5-
use std::sync::atomic::{self, AtomicBool};
64

75
use rustc_interface::Config as CompilerConfig;
8-
use rustc_interface::interface::Result as CompilerResult;
96
use rustc_session::config::{ExternEntry, ExternLocation, Externs, Input};
107
use rustc_session::parse::ParseSess;
118
use rustc_span::Symbol;
@@ -84,15 +81,16 @@ pub fn copy_compiler_settings(config: &CompilerConfig) -> CompilerConfig {
8481
output_dir: config.output_dir.clone(),
8582
ice_file: config.ice_file.clone(),
8683
file_loader: Some(Box::new(RealFileLoader)),
87-
locale_resources: config.locale_resources,
84+
locale_resources: config.locale_resources.clone(),
8885
lint_caps: config.lint_caps.clone(),
8986
psess_created: None,
9087
hash_untracked_state: None,
9188
register_lints: None,
9289
override_queries: None,
90+
extra_symbols: config.extra_symbols.clone(),
9391
make_codegen_backend: None,
9492
registry: rustc_driver::diagnostics_registry(),
95-
using_internal_features: Arc::new(AtomicBool::new(config.using_internal_features.load(atomic::Ordering::Relaxed))),
93+
using_internal_features: config.using_internal_features,
9694
expanded_args: config.expanded_args.clone(),
9795
}
9896
}
@@ -106,19 +104,19 @@ impl rustc_driver::Callbacks for RustcConfigCallbacks {
106104
self.config = Some(copy_compiler_settings(config));
107105
}
108106

109-
fn after_crate_root_parsing<'tcx>(
107+
fn after_crate_root_parsing(
110108
&mut self,
111109
_compiler: &rustc_interface::interface::Compiler,
112-
_queries: &'tcx rustc_interface::Queries<'tcx>,
110+
_krate: &mut rustc_ast::Crate,
113111
) -> rustc_driver::Compilation {
114112
rustc_driver::Compilation::Stop
115113
}
116114
}
117115

118-
pub fn parse_compiler_args(args: &[String]) -> CompilerResult<Option<CompilerConfig>> {
116+
pub fn parse_compiler_args(args: &[String]) -> Option<CompilerConfig> {
119117
let mut callbacks = RustcConfigCallbacks { config: None };
120-
rustc_driver::RunCompiler::new(args, &mut callbacks).run()?;
121-
Ok(callbacks.config)
118+
rustc_driver::run_compiler(args, &mut callbacks);
119+
callbacks.config
122120
}
123121

124122
pub fn track_invocation_fingerprint(parse_sess: &mut ParseSess, invocation_fingerprint: &Option<String>) {
@@ -136,6 +134,12 @@ pub fn base_compiler_config(config: &Config) -> CompilerConfig {
136134
track_invocation_fingerprint(parse_sess, &invocation_fingerprint);
137135
}));
138136

137+
// Register #[cfg(test)] as a valid cfg.
138+
// See the rustc change https://github.com/rust-lang/rust/pull/131729, and
139+
// the Cargo change https://github.com/rust-lang/cargo/pull/14963
140+
// for more details.
141+
compiler_config.crate_check_cfg.push("cfg(test)".to_owned());
142+
139143
// Register #[cfg(mutest)] as a valid cfg.
140144
compiler_config.crate_check_cfg.push("cfg(mutest, values(none()))".to_owned());
141145
// Enable #[cfg(mutest)].

mutest-driver/src/print.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ pub fn print_targets<'tcx, 'trg>(tcx: TyCtxt<'tcx>, targets: impl Iterator<Item
4545

4646
// Targets are printed in source span order.
4747
let mut targets_in_print_order = targets
48-
.map(|target| (tcx.hir().span(tcx.local_def_id_to_hir_id(target.def_id)), target))
48+
.map(|target| (tcx.hir_span(tcx.local_def_id_to_hir_id(target.def_id)), target))
4949
.collect::<Vec<_>>();
50-
targets_in_print_order.sort_unstable_by_key(|(target_span, _)| *target_span);
50+
targets_in_print_order.sort_unstable_by(|(target_a_span, _), (target_b_span, _)| span_diagnostic_ord(*target_a_span, *target_b_span));
5151

5252
let targets_count = targets_in_print_order.len();
5353

@@ -127,7 +127,7 @@ pub fn print_call_graph<'tcx, 'trg>(tcx: TyCtxt<'tcx>, tests: &[Test], call_grap
127127
.map(|(_, callee)| (callee.display_str(tcx), tcx.def_span(callee.def_id), callee))
128128
.collect::<Vec<_>>();
129129
callees_in_print_order.sort_unstable_by(|(callee_a_display_str, callee_a_span, _), (callee_b_display_str, callee_b_span, _)| {
130-
Ord::cmp(callee_a_span, callee_b_span).then(Ord::cmp(callee_a_display_str, callee_b_display_str))
130+
span_diagnostic_ord(*callee_a_span, *callee_b_span).then(Ord::cmp(callee_a_display_str, callee_b_display_str))
131131
});
132132

133133
for (callee_display_str, callee_span, callee) in callees_in_print_order {
@@ -150,7 +150,7 @@ pub fn print_call_graph<'tcx, 'trg>(tcx: TyCtxt<'tcx>, tests: &[Test], call_grap
150150
.map(|caller| (caller.display_str(tcx), tcx.def_span(caller.def_id), caller))
151151
.collect::<Vec<_>>();
152152
callers_in_print_order.sort_unstable_by(|(caller_a_display_str, caller_a_span, _), (caller_b_display_str, caller_b_span, _)| {
153-
Ord::cmp(caller_a_span, caller_b_span).then(Ord::cmp(caller_a_display_str, caller_b_display_str))
153+
span_diagnostic_ord(*caller_a_span, *caller_b_span).then(Ord::cmp(caller_a_display_str, caller_b_display_str))
154154
});
155155

156156
for (caller_display_str, caller_span, caller) in callers_in_print_order {
@@ -161,7 +161,7 @@ pub fn print_call_graph<'tcx, 'trg>(tcx: TyCtxt<'tcx>, tests: &[Test], call_grap
161161
.map(|(_, callee)| (callee.display_str(tcx), tcx.def_span(callee.def_id), callee))
162162
.collect::<Vec<_>>();
163163
callees_in_print_order.sort_unstable_by(|(callee_a_display_str, callee_a_span, _), (callee_b_display_str, callee_b_span, _)| {
164-
Ord::cmp(callee_a_span, callee_b_span).then(Ord::cmp(callee_a_display_str, callee_b_display_str))
164+
span_diagnostic_ord(*callee_a_span, *callee_b_span).then(Ord::cmp(callee_a_display_str, callee_b_display_str))
165165
});
166166

167167
for (callee_display_str, callee_span, callee) in callees_in_print_order {

0 commit comments

Comments
 (0)