Skip to content

Commit 291d958

Browse files
committed
Auto merge of #53624 - Zoxc:ice-fix, r=oli-obk
Move with_globals setup from run_compiler to run An alternative to #53526 Note this breaks some miri stuff and clippy since they call `run_compiler` directly, and they now need to also call `with_globals ` cc @rust-lang/dev-tools r? @oli-obk
2 parents 7625c03 + 0972658 commit 291d958

File tree

4 files changed

+34
-45
lines changed

4 files changed

+34
-45
lines changed

src/Cargo.lock

+2-15
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,6 @@ dependencies = [
222222
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
223223
]
224224

225-
[[package]]
226-
name = "cargo_metadata"
227-
version = "0.5.8"
228-
source = "registry+https://github.com/rust-lang/crates.io-index"
229-
dependencies = [
230-
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
231-
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
232-
"serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)",
233-
"serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)",
234-
"serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)",
235-
]
236-
237225
[[package]]
238226
name = "cargo_metadata"
239227
version = "0.6.0"
@@ -307,7 +295,7 @@ name = "clippy"
307295
version = "0.0.212"
308296
dependencies = [
309297
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
310-
"cargo_metadata 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
298+
"cargo_metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
311299
"clippy-mini-macro-test 0.2.0",
312300
"clippy_lints 0.0.212",
313301
"compiletest_rs 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -329,7 +317,7 @@ version = "0.2.0"
329317
name = "clippy_lints"
330318
version = "0.0.212"
331319
dependencies = [
332-
"cargo_metadata 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
320+
"cargo_metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
333321
"if_chain 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
334322
"itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
335323
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3071,7 +3059,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
30713059
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
30723060
"checksum bufstream 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f382711e76b9de6c744cc00d0497baba02fb00a787f088c879f01d09468e32"
30733061
"checksum byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "74c0b906e9446b0a2e4f760cdb3fa4b2c48cdc6db8766a845c54b6ff063fd2e9"
3074-
"checksum cargo_metadata 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1efca0b863ca03ed4c109fb1c55e0bc4bbeb221d3e103d86251046b06a526bd0"
30753062
"checksum cargo_metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d6809b327f87369e6f3651efd2c5a96c49847a3ed2559477ecba79014751ee1"
30763063
"checksum cc 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "4a6007c146fdd28d4512a794b07ffe9d8e89e6bf86e2e0c4ddff2e1fb54a0007"
30773064
"checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3"

src/librustc_driver/lib.rs

+28-28
Original file line numberDiff line numberDiff line change
@@ -185,27 +185,29 @@ pub fn run<F>(run_compiler: F) -> isize
185185
where F: FnOnce() -> (CompileResult, Option<Session>) + Send + 'static
186186
{
187187
let result = monitor(move || {
188-
let (result, session) = run_compiler();
189-
if let Err(CompileIncomplete::Errored(_)) = result {
190-
match session {
191-
Some(sess) => {
192-
sess.abort_if_errors();
193-
panic!("error reported but abort_if_errors didn't abort???");
194-
}
195-
None => {
196-
let emitter =
197-
errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto,
198-
None,
199-
true,
200-
false);
201-
let handler = errors::Handler::with_emitter(true, false, Box::new(emitter));
202-
handler.emit(&MultiSpan::new(),
203-
"aborting due to previous error(s)",
204-
errors::Level::Fatal);
205-
panic::resume_unwind(Box::new(errors::FatalErrorMarker));
188+
syntax::with_globals(|| {
189+
let (result, session) = run_compiler();
190+
if let Err(CompileIncomplete::Errored(_)) = result {
191+
match session {
192+
Some(sess) => {
193+
sess.abort_if_errors();
194+
panic!("error reported but abort_if_errors didn't abort???");
195+
}
196+
None => {
197+
let emitter =
198+
errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto,
199+
None,
200+
true,
201+
false);
202+
let handler = errors::Handler::with_emitter(true, false, Box::new(emitter));
203+
handler.emit(&MultiSpan::new(),
204+
"aborting due to previous error(s)",
205+
errors::Level::Fatal);
206+
panic::resume_unwind(Box::new(errors::FatalErrorMarker));
207+
}
206208
}
207209
}
208-
}
210+
});
209211
});
210212

211213
match result {
@@ -471,17 +473,15 @@ pub fn run_compiler<'a>(args: &[String],
471473
emitter_dest: Option<Box<dyn Write + Send>>)
472474
-> (CompileResult, Option<Session>)
473475
{
474-
syntax::with_globals(|| {
475-
let matches = match handle_options(args) {
476-
Some(matches) => matches,
477-
None => return (Ok(()), None),
478-
};
476+
let matches = match handle_options(args) {
477+
Some(matches) => matches,
478+
None => return (Ok(()), None),
479+
};
479480

480-
let (sopts, cfg) = config::build_session_options_and_crate_config(&matches);
481+
let (sopts, cfg) = config::build_session_options_and_crate_config(&matches);
481482

482-
driver::spawn_thread_pool(sopts, |sopts| {
483-
run_compiler_with_pool(matches, sopts, cfg, callbacks, file_loader, emitter_dest)
484-
})
483+
driver::spawn_thread_pool(sopts, |sopts| {
484+
run_compiler_with_pool(matches, sopts, cfg, callbacks, file_loader, emitter_dest)
485485
})
486486
}
487487

src/test/run-pass-fulldeps/compiler-calls.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ fn main() {
9292
let tc = TestCalls { count: &mut count };
9393
// we should never get use this filename, but lets make sure they are valid args.
9494
let args = vec!["compiler-calls".to_string(), "foo.rs".to_string()];
95-
rustc_driver::run_compiler(&args, Box::new(tc), None, None);
95+
syntax::with_globals(|| {
96+
rustc_driver::run_compiler(&args, Box::new(tc), None, None);
97+
});
9698
}
9799
assert_eq!(count, 30);
98100
}

src/tools/clippy

0 commit comments

Comments
 (0)