about summary refs log tree commit diff
path: root/src/librustdoc/core.rs
AgeCommit message (Collapse)AuthorLines
2023-12-18Rename many `DiagCtxt` and `EarlyDiagCtxt` locals.Nicholas Nethercote-4/+4
2023-12-18Rename many `DiagCtxt` arguments.Nicholas Nethercote-2/+2
2023-12-18Rename `new_handler` as `new_dcx`.Nicholas Nethercote-2/+2
2023-12-18Rename `UnstableOptions::diagnostic_handler_flags` as ↵Nicholas Nethercote-2/+1
`UnstableOptions::dcx_flags`.
2023-12-18Rename `Session::span_diagnostic` as `Session::dcx`.Nicholas Nethercote-2/+2
2023-12-18Rename `Handler` as `DiagCtxt`.Nicholas Nethercote-4/+4
2023-12-15Don't pass lint back out of lint decoratorMichael Goulet-1/+3
2023-11-26rustc: `hir().local_def_id_to_hir_id()` -> `tcx.local_def_id_to_hir_id()` ↵Vadim Petrochenkov-2/+2
cleanup
2023-10-31Accept less invalid Rust in rustdocOli Scherer-1/+5
2023-10-30Delay parsing of `--cfg` and `--check-cfg` options.Nicholas Nethercote-4/+3
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-28Clean up config mess.Nicholas Nethercote-1/+1
`parse_cfgspecs` and `parse_check_cfg` run very early, before the main interner is running. They each use a short-lived interner and convert all interned symbols to strings in their output data structures. Once the main interner starts up, these data structures get converted into new data structures that are identical except with the strings converted to symbols. All is not obvious from the current code, which is a mess, particularly with inconsistent naming that obscures the parallel string/symbol data structures. This commit clean things up a lot. - The existing `CheckCfg` type is generic, allowing both `CheckCfg<String>` and `CheckCfg<Symbol>` forms. This is really useful, but it defaults to `String`. The commit removes the default so we have to use `CheckCfg<String>` and `CheckCfg<Symbol>` explicitly, which makes things clearer. - Introduces `Cfg`, which is generic over `String` and `Symbol`, similar to `CheckCfg`. - Renames some things. - `parse_cfgspecs` -> `parse_cfg` - `CfgSpecs` -> `Cfg<String>`, plus it's used in more places, rather than the underlying `FxHashSet` type. - `CrateConfig` -> `Cfg<Symbol>`. - `CrateCheckConfig` -> `CheckCfg<Symbol>` - Adds some comments explaining the string-to-symbol conversions. - `to_crate_check_config`, which converts `CheckCfg<String>` to `CheckCfg<Symbol>`, is inlined and removed and combined with the overly-general `CheckCfg::map_data` to produce `CheckCfg::<String>::intern`. - `build_configuration` now does the `Cfg<String>`-to-`Cfg<Symbol>` conversion, so callers don't need to, which removes the need for `to_crate_config`. The diff for two of the fields in `Config` is a good example of the improved clarity: ``` - pub crate_cfg: FxHashSet<(String, Option<String>)>, - pub crate_check_cfg: CheckCfg, + pub crate_cfg: Cfg<String>, + pub crate_check_cfg: CheckCfg<String>, ``` Compare that with the diff for the corresponding fields in `ParseSess`, and the relationship to `Config` is much clearer than before: ``` - pub config: CrateConfig, - pub check_config: CrateCheckConfig, + pub config: Cfg<Symbol>, + pub check_config: CheckCfg<Symbol>, ```
2023-10-26Auto merge of #116818 - Nilstrieb:stop-submitting-bug-reports, r=wesleywiserbors-0/+3
Stop telling people to submit bugs for internal feature ICEs This keeps track of usage of internal features, and changes the message to instead tell them that using internal features is not supported. I thought about several ways to do this but now used the explicit threading of an `Arc<AtomicBool>` through `Session`. This is not exactly incremental-safe, but this is fine, as this is set during macro expansion, which is pre-incremental, and also only affects the output of ICEs, at which point incremental correctness doesn't matter much anyways. See [MCP 620.](https://github.com/rust-lang/compiler-team/issues/596) ![image](https://github.com/rust-lang/rust/assets/48135649/be661f05-b78a-40a9-b01d-81ad2dbdb690)
2023-10-25Stop telling people to submit bugs for internal feature ICEsNilstrieb-0/+3
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-14Add `Config::hash_untracked_state` callbackAlex Macleod-0/+1
2023-09-22Merge `ExternProviders` into the general `Providers` structOli Scherer-1/+1
2023-09-22Have a single struct for queries and hookOli Scherer-1/+1
2023-09-22Add a way to decouple the implementation and the declaration of a TyCtxt method.Oli Scherer-1/+1
2023-09-08Add missing Debuginfo to PDB debug file on windows.Florian Schmiderer-0/+2
Set Arg0 and CommandLineArgs in MCTargetoptions so LLVM outputs correct CL and CMD in LF_DEBUGINFO instead of empty/invalid values.
2023-08-30Use conditional synchronization for LockJohn Kåre Alsaker-3/+3
2023-08-16Improve code readability by moving fmt args directly into the stringGuillaume Gomez-5/+4
2023-08-05Auto merge of #113734 - cjgillot:no-crate-lint, r=petrochenkovbors-4/+4
Convert builtin "global" late lints to run per module The compiler currently has 4 non-incremental lints: 1. `clashing_extern_declarations`; 2. `missing_debug_implementations`; 3. ~`unnameable_test_items`;~ changed by https://github.com/rust-lang/rust/pull/114414 4. `missing_docs`. Non-incremental lints get reexecuted for each compilation, which is slow. Moreover, those lints are allow-by-default, so run for nothing most of the time. This PR attempts to make them more incremental-friendly. `clashing_extern_declarations` is moved to a standalone query. `missing_debug_implementation` can use `non_blanket_impls_for_ty` instead of recomputing it. `missing_docs` is harder as it needs to track if there is a `doc(hidden)` module surrounding. I hack around this using the lint level engine. That's easy to implement and allows to re-enable the lint for a re-exported module, while a more proper solution would reuse the same device as `unnameable_test_items`.
2023-08-04Add comment for rustdoc overrides.Camille GILLOT-0/+1
2023-08-04Make MissingDoc a module lint.Camille GILLOT-4/+3
2023-07-31Replace the many arguments of `EmitterWriter::stderr` with builder methodsOli Scherer-13/+7
2023-07-25Use a builder instead of boolean/option argumentsOli Scherer-5/+2
2023-07-19On nightly, dump ICE backtraces to diskEsteban Küber-0/+2
Implement rust-lang/compiler-team#578. When an ICE is encountered on nightly releases, the new rustc panic handler will also write the contents of the backtrace to disk. If any `delay_span_bug`s are encountered, their backtrace is also added to the file. The platform and rustc version will also be collected.
2023-07-18Auto merge of #113574 - GuillaumeGomez:rustdoc-json-strip-hidden-impl, ↵bors-1/+1
r=aDotInTheVoid,notriddle Strip impl if not re-exported and is doc(hidden) Part of #112852. r? `@aDotInTheVoid`
2023-07-14Correctly handle `--document-hidden-items`Guillaume Gomez-1/+1
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-5/+5
2023-06-27Provide more context for `rustc +nightly -Zunstable-options` on stable许杰友 Jieyou Xu (Joe)-3/+4
2023-05-22rustdoc: Cleanup doc string collapsingVadim Petrochenkov-1/+1
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-1/+1
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-04-29rustdoc: catch and don't blow up on impl Trait cyclesMichael Howell-1/+15
An odd feature of Rust is that `Foo` is invalid, but `Bar` is okay: type Foo<'a, 'b> = Box<dyn PartialEq<Foo<'a, 'b>>>; type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>>; To get it right, track every time rustdoc descends into a type alias, so if it shows up twice, it can be write the path instead of infinitely expanding it.
2023-04-21Leave it to the query system to invoke the typeck query instead of invoking ↵Oli Scherer-2/+0
it eagerly. Later queries that are run on all body owners will invoke typeck as they need information from its result to perform their own logic
2023-03-30rustdoc: run more HIR validation to mirror rustcPatrik Kårlin-0/+3
2023-03-23rustdoc: Skip doc link resolution for non-exported itemsVadim Petrochenkov-7/+2
2023-02-22various: translation resources from cg backendDavid Wood-2/+4
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-1/+2
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-14Auto merge of #107765 - petrochenkov:nomoclone, r=oli-obkbors-20/+4
rustc/rustdoc: Perform name resolver cleanups enabled by #94857 Unblocks https://github.com/rust-lang/rust/pull/105462. r? `@oli-obk`
2023-02-13Rollup merge of #107838 - estebank:terminal_hyperlinks, r=nagisaMatthias Krüger-0/+3
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-13rustdoc: Eliminate remaining uses of resolverVadim Petrochenkov-20/+4
2023-02-11rustdoc: Remove cache for preprocessed markdown linksVadim Petrochenkov-2/+0
2023-02-10Skip doc link resolution for some crate types and non-exported itemsVadim Petrochenkov-1/+10
2023-02-10Resolve documentation links in rustc and store the results in metadataVadim Petrochenkov-22/+2
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-09Introduce `-Zterminal-urls` to use OSC8 for error codesEsteban Küber-0/+3
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-01-25rustdoc: Collect rustdoc-reachable items during early doc link resolutionVadim Petrochenkov-0/+5
2023-01-22rustdoc: Use `DefId(Map,Set)` instead of `FxHash(Map,Set)`Vadim Petrochenkov-8/+4
Not all uses are converted, a few cases iterating through maps/sets and requiring nontrivial changes are kept.
2023-01-16Remove redundant `input_path` field from `Config`Oli Scherer-2/+0
2022-12-01rustc_hir: Relax lifetime requirements on `Visitor::visit_path`Vadim Petrochenkov-1/+1
2022-11-01Auto merge of #103217 - mejrs:track, r=eholkbors-0/+2
Track where diagnostics were created. This implements the `-Ztrack-diagnostics` flag, which uses `#[track_caller]` to track where diagnostics are created. It is meant as a debugging tool much like `-Ztreat-err-as-bug`. For example, the following code... ```rust struct A; struct B; fn main(){ let _: A = B; } ``` ...now emits the following error message: ``` error[E0308]: mismatched types --> src\main.rs:5:16 | 5 | let _: A = B; | - ^ expected struct `A`, found struct `B` | | | expected due to this -Ztrack-diagnostics: created at compiler\rustc_infer\src\infer\error_reporting\mod.rs:2275:31 ```