about summary refs log tree commit diff
path: root/src/librustdoc/clean
AgeCommit message (Collapse)AuthorLines
2024-02-06Add CoroutineClosure to TyKind, AggregateKind, UpvarArgsMichael Goulet-0/+1
2024-02-04Prevent running some code if it is already in the mapGuillaume Gomez-0/+8
2024-02-01Fix handling of `doc_auto_cfg` feature for `cfg` attributes on glob reexportGuillaume Gomez-1/+1
2024-01-31Rollup merge of #120501 - GuillaumeGomez:glob-reexport-attr-merge-bugfix, ↵Nadrieril-1/+19
r=notriddle rustdoc: Correctly handle attribute merge if this is a glob reexport Fixes #120487. The regression was introduced in https://github.com/rust-lang/rust/pull/113091. Only non-glob reexports should have been impacted. cc `````@Nemo157````` r? `````@notriddle`````
2024-01-30rustdoc: Correctly handle attribute merge if this is a glob reexportGuillaume Gomez-1/+19
2024-01-29Rollup merge of #120428 - petrochenkov:somehir2, r=compiler-errorsDylan DPC-1/+1
hir: Two preparatory changes for #120206 cc https://github.com/rust-lang/rust/pull/120206 r? ```@compiler-errors```
2024-01-29Stop using `String` for error codes.Nicholas Nethercote-2/+3
Error codes are integers, but `String` is used everywhere to represent them. Gross! This commit introduces `ErrCode`, an integral newtype for error codes, replacing `String`. It also introduces a constant for every error code, e.g. `E0123`, and removes the `error_code!` macro. The constants are imported wherever used with `use rustc_errors::codes::*`. With the old code, we have three different ways to specify an error code at a use point: ``` error_code!(E0123) // macro call struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call \#[diag(name, code = "E0123")] // string struct Diag; ``` With the new code, they all use the `E0123` constant. ``` E0123 // constant struct_span_code_err!(dcx, span, E0123, "msg"); // constant \#[diag(name, code = E0123)] // constant struct Diag; ``` The commit also changes the structure of the error code definitions: - `rustc_error_codes` now just defines a higher-order macro listing the used error codes and nothing else. - Because that's now the only thing in the `rustc_error_codes` crate, I moved it into the `lib.rs` file and removed the `error_codes.rs` file. - `rustc_errors` uses that macro to define everything, e.g. the error code constants and the `DIAGNOSTIC_TABLES`. This is in its new `codes.rs` file.
2024-01-28hir: Use `InferArg` in `ArrayLen::Infer`Vadim Petrochenkov-1/+1
2024-01-19Pack the u128 in LitKind::IntJosh Stone-1/+1
2024-01-18Rollup merge of #119869 - oli-obk:track_errors2, r=matthewjasperMatthias Krüger-4/+4
replace `track_errors` usages with bubbling up `ErrorGuaranteed` more of the same as https://github.com/rust-lang/rust/pull/117449 (removing `track_errors`)
2024-01-17Make crate_inherent_impls fallible and stop using `track_errors` for itOli Scherer-4/+4
2024-01-17Add `PatKind::Err`Lieselotte-1/+3
2024-01-13Rollup merge of #119898 - compiler-errors:error-reporting, r=oli-obkMatthias Krüger-1/+0
Remove unused `ErrorReporting` variant from overflow handling r? oli-obk
2024-01-12Remove unused ErrorReporting variant from overflow handlingMichael Goulet-1/+0
2024-01-12Delegation implementation: step 1Bryanskiy-1/+1
2024-01-11Stop using `DiagnosticBuilder::buffer` in the parser.Nicholas Nethercote-2/+2
One consequence is that errors returned by `maybe_new_parser_from_source_str` now must be consumed, so a bunch of places that previously ignored those errors now cancel them. (Most of them explicitly dropped the errors before. I guess that was to indicate "we are explicitly ignoring these", though I'm not 100% sure.)
2024-01-10Auto merge of #119751 - nnethercote:error-api-fixes, r=oli-obkbors-2/+2
Diagnostic API fixes Some improvements to diagnostic APIs: improve some naming, use shortcuts in more places, and add a couple of missing methods. r? `@compiler-errors`
2024-01-10Rollup merge of #119769 - fmease:rustdoc-off-by-one-dyn-trait-def-gen-args, ↵Matthias Krüger-91/+99
r=GuillaumeGomez rustdoc: offset generic args of cross-crate trait object types when cleaning Fixes #119529. This PR contains several refactorings apart from the bug fix. Best reviewed commit by commit. r? GuillaumeGomez
2024-01-10Rename consuming chaining methods on `DiagnosticBuilder`.Nicholas Nethercote-1/+1
In #119606 I added them and used a `_mv` suffix, but that wasn't great. A `with_` prefix has three different existing uses. - Constructors, e.g. `Vec::with_capacity`. - Wrappers that provide an environment to execute some code, e.g. `with_session_globals`. - Consuming chaining methods, e.g. `Span::with_{lo,hi,ctxt}`. The third case is exactly what we want, so this commit changes `DiagnosticBuilder::foo_mv` to `DiagnosticBuilder::with_foo`. Thanks to @compiler-errors for the suggestion.
2024-01-10Rename `struct_span_err!` as `struct_span_code_err!`.Nicholas Nethercote-1/+1
Because it takes an error code after the span. This avoids the confusing overlap with the `DiagCtxt::struct_span_err` method, which doesn't take an error code.
2024-01-09Move variables closer to their usage sitesLeón Orell Valerian Liehr-6/+4
2024-01-09Simplify elision of default generic argumentsLeón Orell Valerian Liehr-48/+42
2024-01-09Don't arena-allocate extended generic argsLeón Orell Valerian Liehr-28/+31
2024-01-09Offset args of trait object types when cleaningLeón Orell Valerian Liehr-16/+29
2024-01-09Rename rustc_middle path cleaning functionsLeón Orell Valerian Liehr-37/+37
The new names are consistent with the other rustc_middle cleaning functions. Regarding the local variable `ty_args`, it's used throughout the function and personally speaking its name isn't very legible, I trip up on it.
2024-01-08Make `DiagnosticBuilder::emit` consuming.Nicholas Nethercote-1/+1
This works for most of its call sites. This is nice, because `emit` very much makes sense as a consuming operation -- indeed, `DiagnosticBuilderState` exists to ensure no diagnostic is emitted twice, but it uses runtime checks. For the small number of call sites where a consuming emit doesn't work, the commit adds `DiagnosticBuilder::emit_without_consuming`. (This will be removed in subsequent commits.) Likewise, `emit_unless` becomes consuming. And `delay_as_bug` becomes consuming, while `delay_as_bug_without_consuming` is added (which will also be removed in subsequent commits.) All this requires significant changes to `DiagnosticBuilder`'s chaining methods. Currently `DiagnosticBuilder` method chaining uses a non-consuming `&mut self -> &mut Self` style, which allows chaining to be used when the chain ends in `emit()`, like so: ``` struct_err(msg).span(span).emit(); ``` But it doesn't work when producing a `DiagnosticBuilder` value, requiring this: ``` let mut err = self.struct_err(msg); err.span(span); err ``` This style of chaining won't work with consuming `emit` though. For that, we need to use to a `self -> Self` style. That also would allow `DiagnosticBuilder` production to be chained, e.g.: ``` self.struct_err(msg).span(span) ``` However, removing the `&mut self -> &mut Self` style would require that individual modifications of a `DiagnosticBuilder` go from this: ``` err.span(span); ``` to this: ``` err = err.span(span); ``` There are *many* such places. I have a high tolerance for tedious refactorings, but even I gave up after a long time trying to convert them all. Instead, this commit has it both ways: the existing `&mut self -> Self` chaining methods are kept, and new `self -> Self` chaining methods are added, all of which have a `_mv` suffix (short for "move"). Changes to the existing `forward!` macro lets this happen with very little additional boilerplate code. I chose to add the suffix to the new chaining methods rather than the existing ones, because the number of changes required is much smaller that way. This doubled chainging is a bit clumsy, but I think it is worthwhile because it allows a *lot* of good things to subsequently happen. In this commit, there are many `mut` qualifiers removed in places where diagnostics are emitted without being modified. In subsequent commits: - chaining can be used more, making the code more concise; - more use of chaining also permits the removal of redundant diagnostic APIs like `struct_err_with_code`, which can be replaced easily with `struct_err` + `code_mv`; - `emit_without_diagnostic` can be removed, which simplifies a lot of machinery, removing the need for `DiagnosticBuilderState`.
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-2/+2
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-22Auto merge of #118824 - aliemjay:perf-region-cons, r=compiler-errorsbors-1/+1
use Vec for region constraints instead of BTreeMap ~1% perf gain Diagnostic regressions need more investigation. r? `@ghost`
2023-12-20Give `VariantData::Struct` named fields, to clairfy `recovered`.Alona Enraght-Moony-2/+2
2023-12-17use Vec for region constraintsAli MJ Al-Nasrawy-1/+1
2023-12-15Rollup merge of #119004 - matthiaskrgr:conv, r=compiler-errorsJubilee-1/+1
NFC don't convert types to identical types
2023-12-15NFC don't convert types to identical typesMatthias Krüger-1/+1
2023-12-15Appease the tools: clippy, rustdocMichael Goulet-16/+0
2023-12-15Rollup merge of #113091 - GuillaumeGomez:prevent-cfg-merge-reexport, r=rustdocGuillaume Gomez-34/+42
Don't merge cfg and doc(cfg) attributes for re-exports Fixes #112881. ## Explanations When re-exporting things with different `cfg`s there are two things that can happen: * The re-export uses a subset of `cfg`s, this subset is sufficient so that the item will appear exactly with the subset * The re-export uses a non-subset of `cfg`s (e.g. like the example I posted just above where the re-export is ungated), if the non-subset `cfg`s are active (e.g. compiling that example on windows) then this will be a compile error as the item doesn't exist to re-export, if the subset `cfg`s are active it behaves like 1. ### Glob re-exports? **This only applies to non-glob inlined re-exports.** For glob re-exports the item may or may not exist to be re-exported (potentially the `cfg`s on the path up until the glob can be removed, and only `cfg`s on the globbed item itself matter), for non-inlined re-exports see https://github.com/rust-lang/rust/issues/85043. cc `@Nemo157` r? `@notriddle`
2023-12-14Auto merge of #117749 - aliemjay:perf-canon-cache, r=lcnrbors-3/+2
cache param env canonicalization Canonicalize ParamEnv only once and store it. Then whenever we try to canonicalize `ParamEnvAnd<'tcx, T>` we only have to canonicalize `T` and then merge the results. Prelimiary results show ~3-4% savings in diesel and serde benchmarks. Best to review commits individually. Some commits have a short description. Initial implementation had a soundness bug (https://github.com/rust-lang/rust/pull/117749#issuecomment-1840453387) due to cache invalidation: - When canonicalizing `Ty<'?0>` we first try to resolve region variables in the current InferCtxt which may have a constraint `?0 == 'static`. This means that we register `Ty<'?0> => Canonical<Ty<'static>>` in the cache, which is obviously incorrect in another inference context. - This is fixed by not doing region resolution when canonicalizing the query *input* (vs. response), which is the only place where ParamEnv is used, and then in a later commit we *statically* guard against any form of inference variable resolution of the cached canonical ParamEnv's. r? `@ghost`
2023-12-14rustdoc: avoid ParamEnv with infer varsAli MJ Al-Nasrawy-3/+2
ParamEnv's with inference variabels are invalid.
2023-12-13Auto merge of #118500 - ZetaNumbers:tcx_hir_refactor, r=petrochenkovbors-5/+4
Move some methods from `tcx.hir()` to `tcx` https://github.com/rust-lang/rust/pull/118256#issuecomment-1826442834 Renamed: - find -> opt_hir_node - get -> hir_node - find_by_def_id -> opt_hir_node_by_def_id - get_by_def_id -> hir_node_by_def_id
2023-12-12more clippy::complexity fixesMatthias Krüger-4/+4
redundant_guards redundant_slicing filter_next needless_borrowed_reference useless_format
2023-12-12Move some methods from `tcx.hir()` to `tcx`zetanumbers-5/+4
Renamings: - find -> opt_hir_node - get -> hir_node - find_by_def_id -> opt_hir_node_by_def_id - get_by_def_id -> hir_node_by_def_id Fix rebase changes using removed methods Use `tcx.hir_node_by_def_id()` whenever possible in compiler Fix clippy errors Fix compiler Apply suggestions from code review Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com> Add FIXME for `tcx.hir()` returned type about its removal Simplify with with `tcx.hir_node_by_def_id`
2023-12-11Add spacing information to delimiters.Nicholas Nethercote-3/+3
This is an extension of the previous commit. It means the output of something like this: ``` stringify!(let a: Vec<u32> = vec![];) ``` goes from this: ``` let a: Vec<u32> = vec![] ; ``` With this PR, it now produces this string: ``` let a: Vec<u32> = vec![]; ```
2023-12-10remove redundant importssurechen-9/+6
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-12-05Remove `#[rustc_host]`, use internal desugaringDeadbeef-6/+7
2023-11-29Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errorsMatthias Krüger-1/+2
Add `never_patterns` feature gate This PR adds the feature gate and most basic parsing for the experimental `never_patterns` feature. See the tracking issue (https://github.com/rust-lang/rust/issues/118155) for details on the experiment. `@scottmcm` has agreed to be my lang-team liaison for this experiment.
2023-11-29Always display stability version even if it's the same as the containing itemGuillaume Gomez-7/+0
2023-11-29Add `never_patterns` feature gateNadrieril-1/+2
2023-11-27Address unused tuple struct fields in rustdocJake Goulding-6/+3
2023-11-26rustc: `hir().local_def_id_to_hir_id()` -> `tcx.local_def_id_to_hir_id()` ↵Vadim Petrochenkov-2/+2
cleanup
2023-11-25is_{some,ok}_and for rustdocMichael Goulet-5/+4
2023-11-22Add documentation on `filter_doc_attr`Guillaume Gomez-0/+2
2023-11-22Don't merge cfg and doc(cfg) attributes for re-exportsGuillaume Gomez-34/+40