summary refs log tree commit diff
path: root/compiler/rustc_errors/src
AgeCommit message (Collapse)AuthorLines
2025-02-14Trim suggestion parts to the subset that is purely additiveMichael Goulet-6/+34
2025-02-14Consider add-prefix replacements tooMichael Goulet-3/+4
2025-02-14Use underline suggestions for purely 'additive' replacementsMichael Goulet-1/+13
2025-02-11compiler: replace ExternAbi::name calls with formattersJubilee Young-0/+1
Most of these just format the ABI string, so... just format ExternAbi? This makes it more consistent and less jank when we can do it.
2025-02-11Rollup merge of #136847 - nnethercote:simplify-intra-crate-quals, r=oli-obkMatthias Krüger-2/+2
Simplify intra-crate qualifiers. The following is a weird pattern for a file within `rustc_middle`: ``` use rustc_middle::aaa; use crate::bbb; ``` More sensible and standard would be this: ``` use crate::{aaa, bbb}; ``` I.e. we generally prefer using `crate::` to using a crate's own name. (Exceptions are things like in macros where `crate::` doesn't work because the macro is used in multiple crates.) This commit fixes a bunch of these weird qualifiers. r? `@jieyouxu`
2025-02-11Simplify intra-crate qualifiers.Nicholas Nethercote-2/+2
The following is a weird pattern for a file within `rustc_middle`: ``` use rustc_middle::aaa; use crate::bbb; ``` More sensible and standard would be this: ``` use crate::{aaa, bbb}; ``` I.e. we generally prefer using `crate::` to using a crate's own name. (Exceptions are things like in macros where `crate::` doesn't work because the macro is used in multiple crates.) This commit fixes a bunch of these weird qualifiers.
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-1/+1
``` error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> $DIR/attempted-access-non-fatal.rs:7:15 | LL | let _ = 2.l; | ^ | help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix | LL - let _ = 2.l; LL + let _ = 2.0f64; | ```
2025-02-08Rustfmtbjorn3-64/+96
2025-02-06Rollup merge of #136636 - bjorn3:error_cleanup, r=compiler-errorsMatthias Krüger-2/+2
Couple of minor cleanups to the diagnostic infrastructure
2025-02-06Rollup merge of #136580 - bjorn3:miri_fixes, r=lqdMatthias Krüger-1/+1
Couple of changes to run rustc in miri This is not the full set of patches required to run rustc in miri, but it is the fast majority of the changes to rustc itself. There is also a change to the jobserver crate necessary and on arm64 a change to the memchr crate. Running rustc in miri has already found some UB: https://github.com/rust-lang/rust/pull/136579 cc https://github.com/rust-lang/rust/issues/135870#issuecomment-2612470540
2025-02-06Avoid manually producing FatalError in a couple of placesbjorn3-2/+2
2025-02-05Couple of changes to run rustc in miribjorn3-1/+1
2025-02-03tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc`Askar Safin-24/+26
2025-02-02Rollup merge of #136445 - bjorn3:diag_ctxt_cleanup, r=oli-obkMatthias Krüger-43/+27
Couple of cleanups to DiagCtxt and EarlyDiagCtxt
2025-02-02Rollup merge of #136415 - estebank:highlight-clarification, r=compiler-errorsMatthias Krüger-5/+15
Highlight clarifying information in "expected/found" error When the expected and found types have the same textual representation, we add clarifying in parentheses. We now visually highlight it in the output. Detect a corner case where the clarifying information would be the same for both types and skip it, as it doesn't add anything useful. ![Screenshot of the rustc highlighted output on the terminal](https://github.com/user-attachments/assets/aa4b9433-5332-4941-b2c2-1a43e5cadff7)
2025-02-02Replace ParseSess::set_dcx with DiagCtxt::set_emitterbjorn3-0/+4
Replacing the error emitter doesn't accidentally clear the error count.
2025-02-02Use fallback fluent bundle from inner emitter in SilentEmitterbjorn3-11/+2
2025-02-02Slightly simplify DiagCtxt::make_silentbjorn3-33/+22
2025-02-02Rollup merge of #136368 - estebank:listify, r=fee1-deadMatthias Krüger-13/+1
Make comma separated lists of anything easier to make for errors Provide a new function `listify`, meant to be used in cases similar to `pluralize!`. When you have a slice of arbitrary elements that need to be presented to the user, `listify` allows you to turn that into a list of comma separated strings. This reduces a lot of redundant logic that happens often in diagnostics.
2025-02-02Highlight clarifying information in "expected/found" errorEsteban Küber-5/+15
When the expected and found types have the same textual representation, we add clarifying in parentheses. We now visually highlight it in the output. Detect a corner case where the clarifying information would be the same for both types and skip it, as it doesn't add anything useful.
2025-01-31Rework "long type names" printing logicEsteban Küber-0/+31
Make it so more type-system types can be printed in a shortened version (like `Predicate`s). Centralize printing the information about the "full type name path". Make the "long type path" for the file where long types are written part of `Diag`, so that it becomes easier to keep track of it, and ensure it will always will be printed out last in the diagnostic by making its addition to the output implicit. Tweak the shortening of types in "expected/found" labels. Remove dead file `note.rs`.
2025-01-31Make comma separated lists of anything easier to make for errorsEsteban Küber-13/+1
Provide a new function `listify`, meant to be used in cases similar to `pluralize!`. When you have a slice of arbitrary elements that need to be presented to the user, `listify` allows you to turn that into a list of comma separated strings. This reduces a lot of redundant logic that happens often in diagnostics.
2025-01-20don't ICE when emitting linker errors during `-Z link-only`jyn-18/+31
note that this still ICEs when passed `-Z link-only --error-format json` because i can't be bothered to fix it right now
2025-01-19Manual cleanup of some `is_{or_none|some_and}` usagesYotam Ofek-2/+4
2025-01-19Run `clippy --fix` for `unnecessary_map_or` lintYotam Ofek-3/+3
2025-01-12Auto merge of #135402 - matthiaskrgr:rollup-cz7hs13, r=matthiaskrgrbors-2/+0
Rollup of 6 pull requests Successful merges: - #129259 (Add inherent versions of MaybeUninit methods for slices) - #135374 (Suggest typo fix when trait path expression is typo'ed) - #135377 (Make MIR cleanup for functions with impossible predicates into a real MIR pass) - #135378 (Remove a bunch of diagnostic stashing that doesn't do anything) - #135397 (compiletest: add erroneous variant to `string_enum`s conversions error) - #135398 (add more crash tests) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-11Remove a bunch of diagnostic stashing that doesn't do anythingMichael Goulet-2/+0
2025-01-11fix `it's` -> `its` in doc commentYotam Ofek-1/+1
2024-12-31Convert some Into impls into From implsMichael Goulet-3/+3
2024-12-26Account for removal of multiline span in suggestionEsteban Küber-7/+79
When highlighting the removed parts of a suggestion, properly account for spans that cover more than one line. Fix #134485.
2024-12-20Rollup merge of #134366 - harrisonkaiser:no-break-space, r=davidtwcoDianQK-2/+8
Fix logical error with what text is considered whitespace. There appears to be a logical issue around what counts as leading white-space. There is code which does a subtraction assuming that no errors will be reported inside the leading whitespace. However we compute the length of that whitespace with std::char::is_whitespace and not rustc_lexer::is_whitespace. The former will include a no-break space while later will excluded it. We can only safely make the assumption that no errors will be reported in whitespace if it is all "Rust Standard" whitespace. Indeed an error does occur in unicode whitespace if it contains a no-break space. In that case the subtraction will cause a ICE (for a compiler in debug mode) as described in https://github.com/rust-lang/rust/issues/132918.
2024-12-18chore: fix some typosacceptacross-2/+2
Signed-off-by: acceptacross <csqcqs@gmail.com>
2024-12-18Auto merge of #134243 - nnethercote:re-export-more-rustc_span, r=jieyouxubors-4/+2
Re-export more `rustc_span::symbol` things from `rustc_span`. `rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers to `rustc_span::`. This is a 300+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one. r? `@jieyouxu`
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-4/+2
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-16Fix logical error with what text is considered whitespace.Harrison Kaiser-2/+8
There is a logical issue around what counts as leading white-space. There is code which does a subtraction assuming that no errors will be reported inside the leading whitespace. However we compute the length of that whitespace with std::char::is_whitespace and not rustc_lexer::is_whitespace. The former will include a no-break space while later will excluded it. We can only safely make the assumption that no errors will be reported in whitespace if it is all "Rust Standard" whitespace. Indeed an error does occur in unicode whitespace if it contains a no-break space.
2024-12-16update uses of extract_if in the compilerThe 8472-4/+4
2024-12-14Rollup merge of #134181 - estebank:trim-render, r=oli-obkMatthias Krüger-3/+12
Tweak multispan rendering to reduce output length Consider comments and bare delimiters the same as an "empty line" for purposes of hiding rendered code output of long multispans. This results in more aggressive shortening of rendered output without losing too much context, specially in `*.stderr` tests that have "hidden" comments. We do that check not only on the first 4 lines of the multispan, but now also on the previous to last line as well.
2024-12-13Account for `///` when rendering multiline spansEsteban Küber-8/+9
Don't consider `///` and `//!` docstrings to be empty for the purposes of multiline span rendering.
2024-12-12Filter empty lines, comments and delimiters from previous to last multiline ↵Esteban Küber-1/+5
span rendering
2024-12-12Tweak multispan renderingEsteban Küber-2/+6
Consider comments and bare delimiters the same as an "empty line" for purposes of hiding rendered code output of long multispans. This results in more aggressive shortening of rendered output without losing too much context, specially in `*.stderr` tests that have "hidden" comments.
2024-12-12Rollup merge of #134187 - nnethercote:rm-PErr, r=jieyouxuMatthias Krüger-2/+1
Remove `PErr`. It's just a synonym for `Diag` that adds no value and is only used in a few places. r? ``@spastorino``
2024-12-12Rollup merge of #134154 - dev-ardi:field-expr-generics, r=compiler-errorsMatthias Krüger-0/+4
suppress field expr with generics error message if it's a method Don't emit "field expressions may not have generic arguments" if it's a method call without `()` r? estebank Fixes #67680 Is this the best way to go? It's by far the simplest I could come up with.
2024-12-12Remove `PErr`.Nicholas Nethercote-2/+1
It's just a synonym for `Diag` that adds no value and is only used in a few places.
2024-12-11Don't emit "field expressions may not have generic arguments" if it's a ↵Orion Gonzalez-0/+4
method call without ()
2024-12-11document check_expr_fieldOrion Gonzalez-1/+1
2024-12-06Handle unwinding out of the closure argument of run_compiler with pending ↵bjorn3-3/+7
delayed bugs
2024-12-06Store a single copy of the error registry in DiagCtxtbjorn3-21/+35
And pass this to the individual emitters when necessary.
2024-11-30Eliminate magic numbers from expression precedenceDavid Tolnay-0/+7
2024-11-12Auto merge of #132954 - matthiaskrgr:rollup-x3rww9h, r=matthiaskrgrbors-3/+16
Rollup of 7 pull requests Successful merges: - #131831 (extend the "if-unchanged" logic for compiler builds) - #132541 (Proper support for cross-crate recursive const stability checks) - #132657 (AIX: add run-make support) - #132901 (Warn about invalid `mir-enable-passes` pass names) - #132923 (Triagebot: Consolidate the T-compiler ad hoc assignment groups) - #132938 (Make precise capturing suggestion machine-applicable only if it has no APITs) - #132947 (clarify `must_produce_diag` ICE for debugging) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-12Auto merge of #132282 - Noratrieb:it-is-the-end-of-serial, r=cjgillotbors-5/+0
Delete the `cfg(not(parallel))` serial compiler Since it's inception a long time ago, the parallel compiler and its cfgs have been a maintenance burden. This was a necessary evil the allow iteration while not degrading performance because of synchronization overhead. But this time is over. Thanks to the amazing work by the parallel working group (and the dyn sync crimes), the parallel compiler has now been fast enough to be shipped by default in nightly for quite a while now. Stable and beta have still been on the serial compiler, because they can't use `-Zthreads` anyways. But this is quite suboptimal: - the maintenance burden still sucks - we're not testing the serial compiler in nightly Because of these reasons, it's time to end it. The serial compiler has served us well in the years since it was split from the parallel one, but it's over now. Let the knight slay one head of the two-headed dragon! #113349 Note that the default is still 1 thread, as more than 1 thread is still fairly broken. cc `@onur-ozkan` to see if i did the bootstrap field removal correctly, `@SparrowLii` on the sync parts