about summary refs log tree commit diff
path: root/src/librustdoc/lib.rs
AgeCommit message (Collapse)AuthorLines
2023-12-18Rename many `DiagCtxt` and `EarlyDiagCtxt` locals.Nicholas Nethercote-6/+6
2023-12-18Rename many `EarlyDiagCtxt` arguments.Nicholas Nethercote-9/+9
2023-12-18Rename many `DiagCtxt` arguments.Nicholas Nethercote-3/+3
2023-12-18Rename `new_handler` as `new_dcx`.Nicholas Nethercote-6/+2
2023-12-18Rename `Session::span_diagnostic` as `Session::dcx`.Nicholas Nethercote-1/+1
2023-12-18Rename `EarlyErrorHandler` as `EarlyDiagCtxt`.Nicholas Nethercote-5/+5
2023-12-18Rename `Handler` as `DiagCtxt`.Nicholas Nethercote-2/+2
2023-11-22Make `Compiler::{sess,codegen_backend}` public.Nicholas Nethercote-1/+1
And remove the relevant getters on `Compiler` and `Queries`.
2023-11-17Move `lint_store` from `GlobalCtxt` to `Session`.Nicholas Nethercote-8/+1
This was made possible by the removal of plugin support, which simplified lint store creation. This simplifies the places in rustc and rustdoc that call `describe_lints`, which are early on. The lint store is now built before those places, so they don't have to create their own lint store for temporary use, they can just use the main one.
2023-11-11rustc_log: provide a way to init logging based on the values, not names, of ↵Ralf Jung-1/+2
the env vars
2023-10-30Delay parsing of `--cfg` and `--check-cfg` options.Nicholas Nethercote-3/+2
By storing the unparsed values in `Config` and then parsing them within `run_compiler`, the parsing functions can use the main symbol interner, and not create their own short-lived interners. This change also eliminates the need for one `EarlyErrorHandler` in rustdoc, because parsing errors can be reported by another, slightly later `EarlyErrorHandler`.
2023-10-25Stop telling people to submit bugs for internal feature ICEsNilstrieb-5/+11
This keeps track of usage of internal features, and changes the message to instead tell them that using internal features is not supported. See MCP 620.
2023-10-12hide `host` param from generic parameter list of `~const` boundsOli Scherer-0/+1
2023-09-20Delete obsolete --disable-per-crate-search rustdoc flagDavid Tolnay-7/+0
2023-09-15rustdoc: merge theme css into rustdoc.cssMichael Howell-2/+2
Based on https://github.com/rust-lang/rust/pull/115812#issuecomment-1717960119 Having them in separate files used to make more sense, before the migration to CSS variables made the theme files as small as they are nowadays. This is already how docs.rs and mdBook do it.
2023-08-23Add unstable `--no-html-source` rustdoc flagGuillaume Gomez-0/+3
2023-08-16Improve code readability by moving fmt args directly into the stringGuillaume Gomez-7/+5
2023-07-11Don't require each rustc_interface tool to opt-in to parallel_rustc supportjyn-3/+0
Previously, forgetting to call `interface::set_thread_safe_mode` would cause the following ICE: ``` thread 'rustc' panicked at 'uninitialized dyn_thread_safe mode!', /rustc/dfe0683138de0959b6ab6a039b54d9347f6a6355/compiler/rustc_data_structures/src/sync.rs:74:18 ``` This calls `set_thread_safe_mode` in `interface::run_compiler` to avoid requiring it in the caller. Fixes `tests/run-make-fulldeps/issue-19371` when parallel-compiler is enabled.
2023-06-27Provide more context for `rustc +nightly -Zunstable-options` on stable许杰友 Jieyou Xu (Joe)-29/+25
2023-06-14s/drain_filter/extract_if/ for Vec, Btree{Map,Set} and LinkedListThe 8472-1/+0
2023-05-27Rollup merge of #109084 - dekrain:fix-panic-arg0-expansion, r=petrochenkovMatthias Krüger-1/+11
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-1/+11
2023-05-16Avoid `&format("...")` calls in error message code.Nicholas Nethercote-4/+4
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-06Rollup merge of #110989 - jyn514:bug-report-url, r=WaffleLapkinMatthias Krüger-4/+8
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-1/+6
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-3/+3
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-05-01Make the BUG_REPORT_URL configurable by toolsjyn-1/+5
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-30Rollup merge of #110983 - GuillaumeGomez:foreign-repr, r=notriddleMatthias Krüger-0/+1
rustdoc: Get `repr` information through `AdtDef` for foreign items As suggested by `@notriddle,` this approach works too. The only downside is that the display of the original attribute isn't kept, but I think it's an acceptable downside. r? `@notriddle`
2023-04-29Get `repr` information through `AdtDef` for foreign itemsGuillaume Gomez-0/+1
2023-04-29drive-by cleanup of rustdoc commentjyn-3/+3
2023-04-29Add `rustdoc::unescaped_backtick` lintLukas Markeffsky-5/+6
2023-04-28handle cfg(bootstrap)Pietro Albini-1/+1
2023-04-14Rollup merge of #110244 - kadiwa4:unnecessary_imports, r=JohnTitorMatthias Krüger-1/+0
Remove some unneeded imports / qualified paths Continuation of #105537.
2023-04-14Rollup merge of #103682 - Swatinem:stable-run-directory, r=GuillaumeGomezYuki Okushi-1/+1
Stabilize rustdoc `--test-run-directory` This should resolve https://github.com/rust-lang/rust/issues/84674
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-12remove some unneeded importsKaDiWa-1/+0
2023-04-12Split out a separate feature gate for impl trait in associated typesOli Scherer-0/+1
2023-04-10Stabilize IsTerminalJosh Triplett-1/+0
closes: https://github.com/rust-lang/rust/issues/98070
2023-04-04write threads info into log only when debuggingSparrowLii-1/+1
2023-03-31Stabilize rustdoc `--test-run-directory`Arpad Borsos-1/+1
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-02-21Use `ThinVec` in various AST types.Nicholas Nethercote-0/+1
This commit changes the sequence parsers to produce `ThinVec`, which triggers numerous conversions.
2023-02-13rustdoc: Eliminate remaining uses of resolverVadim Petrochenkov-19/+2
2023-02-11Auto merge of #94857 - petrochenkov:doclink2, r=oli-obkbors-15/+6
Resolve documentation links in rustc and store the results in metadata This PR implements MCP https://github.com/rust-lang/compiler-team/issues/584. Doc links are now resolved in rustc and stored into metadata, so rustdoc simply retrieves them through a query (local or extern), Code that is no longer used is removed, and some code that no longer needs to be public is privatized. The removed code includes resolver cloning, so this PR fixes https://github.com/rust-lang/rust/issues/83761.
2023-02-10Skip doc link resolution for some crate types and non-exported itemsVadim Petrochenkov-2/+2
2023-02-10Resolve documentation links in rustc and store the results in metadataVadim Petrochenkov-13/+4
This commit implements MCP https://github.com/rust-lang/compiler-team/issues/584 It also removes code that is no longer used, and that includes code cloning resolver, so issue #83761 is fixed.
2023-02-09Remove `QueryContext`.Nicholas Nethercote-2/+2
There is a type `QueryCtxt`, which impls the trait `QueryContext`. Confusingly, there is another type `QueryContext`. The latter is (like `TyCtxt`) just a pointer to a `GlobalContext`. It's not used much, e.g. its `impl` block has a single method. This commit removes `QueryContext`, replacing its use with direct `GlobalCtxt` use.