summary refs log tree commit diff
path: root/compiler/rustc_driver_impl/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2023-05-27Rollup merge of #109084 - dekrain:fix-panic-arg0-expansion, r=petrochenkovMatthias Krüger-3/+10
rustc driver: Remove argument 0 before at-expansion to prevent ICE Under Unix-based operating systems, when I execute rustc by setting argv0 to ``@/dev/null`,` it will expand command-line arguments from this file, leading to an empty arglist, which then triggers an ICE by trying to remove first argument. The panic message is this: ``` thread 'main' panicked at 'range start index 1 out of range for slice of length 0', compiler/rustc_driver/src/lib.rs:972:17 ``` My fix is to remove the first argument before expanding arguments. <details> <summary>Full backtrace</summary> ```sh % (exec -a `@/dev/null` `rustup which rustc`) thread 'main' panicked at 'range start index 1 out of range for slice of length 0', compiler/rustc_driver/src/lib.rs:972:17 stack backtrace: 0: 0x7fcec776659a - std::backtrace_rs::backtrace::libunwind::trace::h595f06c70adcc478 at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5 1: 0x7fcec776659a - std::backtrace_rs::backtrace::trace_unsynchronized::h177a0149c76cdde9 at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7fcec776659a - std::sys_common::backtrace::_print_fmt::hc0701fd2c3530c58 at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:65:5 3: 0x7fcec776659a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd4cd115d8750fd6c at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7fcec77c839e - core::fmt::write::h93e2f5923c7eca08 at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/fmt/mod.rs:1213:17 5: 0x7fcec7756be5 - std::io::Write::write_fmt::h8162dbb45f0b9e62 at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/io/mod.rs:1682:15 6: 0x7fcec7766365 - std::sys_common::backtrace::_print::h1835ef8a8f9066da at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:47:5 7: 0x7fcec7766365 - std::sys_common::backtrace::print::hcb5e6388b9235f41 at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:34:9 8: 0x7fcec776912f - std::panicking::default_hook::{{closure}}::h9c084969ccf9a722 at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:267:22 9: 0x7fcec7768e6b - std::panicking::default_hook::h68fa2ba3c3c6c12f at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:286:9 10: 0x7fcecaab56e4 - <rustc_driver[f4ad927b3c57833d]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[d16e85342ea223d9]::ops::function::FnOnce<(&core[d16e85342ea223d9]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0} 11: 0x7fcec776996a - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h4e6ced11e07d8b24 at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/alloc/src/boxed.rs:2002:9 12: 0x7fcec776996a - std::panicking::rust_panic_with_hook::h8d5c434518ef298c at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:692:13 13: 0x7fcec77696e9 - std::panicking::begin_panic_handler::{{closure}}::hf33414f5dabf6faf at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:579:13 14: 0x7fcec7766a4c - std::sys_common::backtrace::__rust_end_short_backtrace::hc50389427413bb75 at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:137:18 15: 0x7fcec77693f2 - rust_begin_unwind at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:575:5 16: 0x7fcec77c4d43 - core::panicking::panic_fmt::h2de7a7938f816de8 at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/panicking.rs:64:14 17: 0x7fcec77cb492 - core::slice::index::slice_start_index_len_fail_rt::h0c87d85ce11d10f6 at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/slice/index.rs:53:5 18: 0x7fcec77cb416 - core::slice::index::slice_start_index_len_fail::h504609f2a6b168d1 at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/slice/index.rs:41:9 19: 0x7fceca0eca1f - rustc_driver[f4ad927b3c57833d]::handle_options 20: 0x7fceca0e037f - <rustc_driver[f4ad927b3c57833d]::RunCompiler>::run 21: 0x7fceca0dfd0d - <core[d16e85342ea223d9]::panic::unwind_safe::AssertUnwindSafe<rustc_driver[f4ad927b3c57833d]::main::{closure#0}> as core[d16e85342ea223d9]::ops::function::FnOnce<()>>::call_once 22: 0x7fceca17ce89 - rustc_driver[f4ad927b3c57833d]::main 23: 0x564f5f008a87 - rustc_main[f164605d1302e295]::main 24: 0x564f5f008973 - std[3da461b304582a2c]::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()> 25: 0x564f5f008969 - <std[3da461b304582a2c]::rt::lang_start<()>::{closure#0} as core[d16e85342ea223d9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 26: 0x7fcec774795c - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h699977d052768608 at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/ops/function.rs:287:13 27: 0x7fcec774795c - std::panicking::try::do_call::h4e121e623c70f903 at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:483:40 28: 0x7fcec774795c - std::panicking::try::hf9d919e062bc178a at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:447:19 29: 0x7fcec774795c - std::panic::catch_unwind::h7a7b12272684cb97 at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panic.rs:140:14 30: 0x7fcec774795c - std::rt::lang_start_internal::{{closure}}::hd96b0eb4844b8762 at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/rt.rs:148:48 31: 0x7fcec774795c - std::panicking::try::do_call::h1af1f88f4f92a22c at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:483:40 32: 0x7fcec774795c - std::panicking::try::hf20d7abea7f0f097 at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:447:19 33: 0x7fcec774795c - std::panic::catch_unwind::hb0e084c3a9c042e4 at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panic.rs:140:14 34: 0x7fcec774795c - std::rt::lang_start_internal::hca9d5c7277f5b67c at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/rt.rs:148:20 35: 0x564f5f008ab7 - main 36: 0x7fcec74a1790 - <unknown> 37: 0x7fcec74a184a - __libc_start_main 38: 0x564f5f00899e - <unknown> 39: 0x0 - <unknown> error: internal compiler error: unexpected panic note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md note: rustc 1.68.0 (2c8cc3432 2023-03-06) running on x86_64-unknown-linux-gnu query stack during panic: end of query stack ``` </details> I also checked if I can trigger a similar problem by passing empty argument list to `execve`, but at least under Linux, it seems to always insert an empty first argument if there are none.
2023-05-27Fix ICE caused by at-expanding argument 0 instead of removing it earlydekrain-3/+10
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-1/+1
2023-05-20Rollup merge of #111606 - jyn514:nightly-diagnostics, r=lcnrDylan DPC-1/+2
very minor cleanups - add `must_use` to `early_error_no_abort` this was already being used at its only callsite, but this ensures that new code remembers to use it if it's called in the future. found this while investigating https://github.com/rust-lang/rust/issues/110090. - remove outdated and incorrect comment in `builder.rs`. `doc_rust_lang_org_channel` doesn't exist in rustdoc, it gets it from an env var instead: https://github.com/rust-lang/rust/blob/b275d2c30b6e88cc48747f349f7137076d450658/src/librustdoc/clean/utils.rs#L569-L573
2023-05-18Auto merge of #111345 - jyn514:cfg-release-caching, r=cjgillot,est31bors-3/+3
Only depend on CFG_VERSION in rustc_interface This avoids having to rebuild the whole compiler on each commit when `omit-git-hash = false`. cc https://github.com/rust-lang/rust/issues/76720 - this won't fix it, and I'm not suggesting we turn this on by default, but it will make it less painful for people who do have `omit-git-hash` on as a workaround.
2023-05-18very minor cleanupsjyn-1/+2
- add `must_use` to `early_error_no_abort` this was already being used at its only callsite, but this ensures that new code remembers to use it if it's called in the future. - remove outdated and incorrect comment in `builder.rs`. `doc_rust_lang_org_channel` doesn't exist in rustdoc, it gets it from an env var instead.
2023-05-17Only depend on CFG_VERSION in rustc_interfacejyn-3/+3
this avoids having to rebuild the whole compiler on each commit when `omit-git-hash = false`.
2023-05-16Avoid `&format("...")` calls in error message code.Nicholas Nethercote-6/+6
Error message all end up passing into a function as an `impl Into<{D,Subd}iagnosticMessage>`. If an error message is creatd as `&format("...")` that means we allocate a string (in the `format!` call), then take a reference, and then clone (allocating again) the reference to produce the `{D,Subd}iagnosticMessage`, which is silly. This commit removes the leading `&` from a lot of these cases. This means the original `String` is moved into the `{D,Subd}iagnosticMessage`, avoiding the double allocations. This requires changing some function argument types from `&str` to `String` (when all arguments are `String`) or `impl Into<{D,Subd}iagnosticMessage>` (when some arguments are `String` and some are `&str`).
2023-05-13Auto merge of #107586 - SparrowLii:parallel-query, r=cjgillotbors-0/+3
Introduce `DynSend` and `DynSync` auto trait for parallel compiler part of parallel-rustc #101566 This PR introduces `DynSend / DynSync` trait and `FromDyn / IntoDyn` structure in rustc_data_structure::marker. `FromDyn` can dynamically check data structures for thread safety when switching to parallel environments (such as calling `par_for_each_in`). This happens only when `-Z threads > 1` so it doesn't affect single-threaded mode's compile efficiency. r? `@cjgillot`
2023-05-08Rollup merge of #111004 - clubby789:migrate-mir-transform, r=oli-obkMichael Goulet-0/+1
Migrate `mir_transform` to translatable diagnostics cc #100717
2023-05-08Rollup merge of #105354 - BlackHoleFox:apple-deployment-printer, r=oli-obkYuki Okushi-0/+16
Add deployment-target --print flag for Apple targets This is very useful for crates that need to know what the Apple OS deployment target is for their build scripts or inside of a build environment. Right now, the defaults just get copy/pasted around the ecosystem since they've been stable for so long. But with #104385 in progress, that won't be true anymore and everything will need to move. Ideally whenever it happens again, this could be less painful as everything can ask the compiler what its default is instead. To show examples of the copy/paste proliferation, here's some crates and/or apps that do: - [cc](https://github.com/rust-lang/cc-rs/pull/708/files), Soon - [mac-notification-sys](https://github.com/h4llow3En/mac-notification-sys/pull/46/files#diff-d0d98998092552a1d3259338c2c71e118a5b8343dd4703c0c7f552ada7f9cb42R10-R12) - [PyO3](https://github.com/PyO3/maturin/blob/ccb02d1aa1cc41e82a3572a3c8b35cace15f3e78/src/target.rs#L755-L758) - [Anki](https://github.com/ankitects/anki/blob/613b5c1034cc9943f3f68d818ae22b2e0acec877/build/runner/src/bundle/artifacts.rs#L49-L54) - [jsc-rs](https://github.com/Brooooooklyn/jsc-rs/blob/37767267568fb2de62fc441473e7d158dd980520/xtask/src/build.rs#L402-L405) ... and probably more that a simple GitHub codesearch didn't see
2023-05-06Rollup merge of #110989 - jyn514:bug-report-url, r=WaffleLapkinMatthias Krüger-46/+57
Make the BUG_REPORT_URL configurable by tools This greatly simplifies how hard it is to set a custom bug report url; previously tools had to copy the entire hook implementation. I haven't changed clippy in case they want to make the change upstream instead of the subtree, but I'm happy to do so here if the maintainers want - cc ````@rust-lang/clippy```` Fixes https://github.com/rust-lang/rust/issues/109486.
2023-05-06correct literals for dyn thread safeSparrowLii-2/+2
2023-05-06introduce `DynSend` and `DynSync` auto traitSparrowLii-0/+3
2023-05-05Mark `ErrorGuaranteed` constructor as deprecated so people don't use itMichael Goulet-0/+1
2023-05-05Add deployment-target --print flag for Apple targetsBlackHoleFox-0/+16
2023-05-02Migrate `mir_transform` to translatable diagnosticsclubby789-0/+1
2023-05-01Make the BUG_REPORT_URL configurable by toolsjyn-46/+57
This greatly simplifies how hard it is to set a custom bug report url; previously tools had to copy the entire hook implementation. - Switch clippy to the new hook This also adds a `extra_info` callback so clippy can include its own version number, which differs from rustc's. - Call `install_ice_hook` in rustfmt
2023-04-25Fix ICE on --print=... i/o errorsDavid Tolnay-40/+48
2023-04-18Add `rustc_fluent_macro` to decouple fluent from `rustc_macros`Nilstrieb-1/+1
Fluent, with all the icu4x it brings in, takes quite some time to compile. `fluent_messages!` is only needed in further downstream rustc crates, but is blocking more upstream crates like `rustc_index`. By splitting it out, we allow `rustc_macros` to be compiled earlier, which speeds up `x check compiler` by about 5 seconds (and even more after the needless dependency on `serde_json` is removed from `rustc_data_structures`).
2023-04-13Rollup merge of #110072 - joshtriplett:stabilize-is-terminal, r=Mark-SimulacrumMatthias Krüger-1/+0
Stabilize IsTerminal FCP completed in https://github.com/rust-lang/rust/issues/98070 . closes: https://github.com/rust-lang/rust/issues/98070
2023-04-12Make rustdoc and rustc's help match exactlyJynn Nelson-33/+43
Before, rustdoc was missing `-C passes=list` and the "Available options" header. Making these match allows testing that they match exactly.
2023-04-10Stabilize IsTerminalJosh Triplett-1/+0
closes: https://github.com/rust-lang/rust/issues/98070
2023-04-03implement --print=all-target-specs-jsonPietro Albini-0/+11
2023-03-29Stabilize a portion of 'once_cell'Trevor Gross-1/+1
Move items not part of this stabilization to 'lazy_cell' or 'once_cell_try'
2023-03-23Rollup merge of #107718 - Zoxc:z-time, r=nnethercoteMatthias Krüger-5/+8
Add `-Z time-passes-format` to allow specifying a JSON output for `-Z time-passes` This adds back the `-Z time` option as that is useful for [my rustc benchmark tool](https://github.com/Zoxc/rcb), reverting https://github.com/rust-lang/rust/pull/102725. It now uses nanoseconds and bytes as the units so it is renamed to `time-precise`.
2023-03-23rustc_interface: Add a new query `pre_configure`Vadim Petrochenkov-1/+1
It partially expands crate attributes before the main expansion pass (without modifying the crate), and the produced preliminary crate attribute list is used for querying a few attributes that are required very early. Crate-level cfg attributes are then expanded normally during the main expansion pass, like attributes on any other nodes.
2023-03-21Remove `unique` and move `VerboseTimingGuard` fields into a new structJohn Kåre Alsaker-1/+1
2023-03-21Add `-Z time-passes-format` to allow specifying a JSON output for `-Z ↵John Kåre Alsaker-5/+8
time-passes`
2023-03-20migrate compiler, bootstrap, and compiletest to windows-rsAndy Russell-5/+3
2023-03-11Simplify message pathsest31-1/+1
This makes it easier to open the messages file while developing on features. The commit was the result of automatted changes: for p in compiler/rustc_*; do mv $p/locales/en-US.ftl $p/messages.ftl; rmdir $p/locales; done for p in compiler/rustc_*; do sed -i "s#\.\./locales/en-US.ftl#../messages.ftl#" $p/src/lib.rs; done
2023-03-06Querify early_lint_checks.Camille GILLOT-0/+1
2023-02-26refactor: statically guarantee that current error codes are documentedEzra Shaw-4/+1
2023-02-22various: translation resources from cg backendDavid Wood-2/+2
Extend `CodegenBackend` trait with a function returning the translation resources from the codegen backend, which can be added to the complete list of resources provided to the emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-22errors: generate typed identifiers in each crateDavid Wood-3/+45
Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-20Move the resolver into a queryOli Scherer-1/+1
2023-02-16Remove save-analysis.Nicholas Nethercote-19/+1
Most tests involving save-analysis were removed, but I kept a few where the `-Zsave-analysis` was an add-on to the main thing being tested, rather than the main thing being tested. For `x.py install`, the `rust-analysis` target has been removed. For `x.py dist`, the `rust-analysis` target has been kept in a degenerate form: it just produces a single file `reduced.json` indicating that save-analysis has been removed. This is necessary for rustup to keep working. Closes #43606.
2023-02-13Rollup merge of #107838 - estebank:terminal_hyperlinks, r=nagisaMatthias Krüger-1/+2
Introduce `-Zterminal-urls` to use OSC8 for error codes Terminals supporting the OSC8 Hyperlink Extension can support inline anchors where the text is user defineable but clicking on it opens a browser to a specified URLs, just like `<a href="URL">` does in HTML. https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
2023-02-10Rollup merge of #107836 - chenyukang:yukang/fix-107822, r=oli-obkMatthias Krüger-1/+4
Handle properly when there is no crate attrs Fixes #107822 r? `@oli-obk`
2023-02-10add test for no input fileyukang-1/+4
2023-02-09Introduce `-Zterminal-urls` to use OSC8 for error codesEsteban Küber-1/+2
Terminals supporting the OSC8 Hyperlink Extension can support inline anchors where the text is user defineable but clicking on it opens a browser to a specified URLs, just like `<a href="URL">` does in HTML. https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
2023-02-09fix #107822, handle properly when there is no crate attrsyukang-1/+1
2023-02-08Rollup merge of #107761 - oli-obk:miri_🪵, r=TaKO8KiMichael Goulet-14/+2
Replace a command line flag with an env var to allow tools to initialize the tracing loggers at their own discretion fixes https://github.com/rust-lang/miri/issues/2778 this was introduced in https://github.com/rust-lang/rust/pull/104645, so this PR reverts the flag-part and uses an env var instead.
2023-02-08Rollup merge of #107771 - estebank:ice-msg, r=compiler-errorsMatthias Krüger-3/+1
Tweak ICE message Modify main message to be more conversational and emit one fewer note.
2023-02-07Tweak ICE messageEsteban Küber-3/+1
Modify main message to be more conversational and emit one fewer note.
2023-02-07Replace a command line flag with an env var to allow tools to initialize the ↵Oli Scherer-14/+2
tracing loggers at their own discretion
2023-02-06Avoid locking the global context across the `after_expansion` callbackOli Scherer-5/+5
2023-02-02Rename rustc_driver to rustc_driver_implJohn Kåre Alsaker-0/+1353