about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
AgeCommit message (Collapse)AuthorLines
2024-06-26Clarify comment on changing to warn future breakage items Urgau-5/+5
https://github.com/rust-lang/rust/pull/120924/files#r1653512240
2024-06-25Prevent ICE from expected future breakagexFrednet-1/+6
2024-06-23Special case when a code line only has multiline span startsEsteban Küber-1/+26
``` 3 | X0 Y0 Z0 | _____^ - - | | _______| | | || _________| 4 | ||| X1 Y1 Z1 5 | ||| X2 Y2 Z2 | |||____^__-__- `Z` label | ||_____|__| | |______| `Y` is a good letter too | `X` is a good letter ```
2024-06-22Rollup merge of #126723 - estebank:dot-dot-dot, r=NadrierilGuillaume Gomez-2/+2
Fix `...` in multline code-skips in suggestions When we have long code skips, we write `...` in the line number gutter. For suggestions, we were "centering" the `...` with the line, but that was inconsistent with what we do in every other case *and* off-center.
2024-06-21Fix another assertion failure for some Expect diagnostics.Nicholas Nethercote-4/+4
Very similar to #126719. So much so that I added a new case to the test from that PR rather than creating a new one.
2024-06-20Rollup merge of #126719 - nnethercote:fix-126521, r=oli-obkMatthias Krüger-9/+19
Fix assertion failure for some `Expect` diagnostics. In #120699 I moved some code dealing with `has_future_breakage` earlier in `emit_diagnostic`. Issue #126521 identified a case where that reordering was invalid (leading to an assertion failure) for some `Expect` diagnostics. This commit partially undoes the change, by moving the handling of unstable `Expect` diagnostics earlier again. This makes `emit_diagnostic` a bit uglier, but is necessary to fix the problem. Fixes #126521. r? ``@oli-obk``
2024-06-20Fix `...` in multline code-skips in suggestionsEsteban Küber-2/+2
When we have long code skips, we write `...` in the line number gutter. For suggestions, we were "centering" the `...` with the line, but that was consistent with what we do in every other case.
2024-06-20Fix assertion failure for some `Expect` diagnostics.Nicholas Nethercote-9/+19
In #120699 I moved some code dealing with `has_future_breakage` earlier in `emit_diagnostic`. Issue #126521 identified a case where that reordering was invalid (leading to an assertion failure) for some `Expect` diagnostics. This commit partially undoes the change, by moving the handling of unstable `Expect` diagnostics earlier again. This makes `emit_diagnostic` a bit uglier, but is necessary to fix the problem. Fixes #126521.
2024-06-20Add blank lines after module-level `//!` comments.Nicholas Nethercote-0/+1
Most modules have such a blank line, but some don't. Inserting the blank line makes it clearer that the `//!` comments are describing the entire module, rather than the `use` declaration(s) that immediately follows.
2024-06-18Remove redundant argument from `subdiagnostic` methodOli Scherer-5/+2
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-74/+86
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-05-27Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercotebors-5/+3
[perf] Delay the construction of early lint diag structs Attacks some of the perf regressions from https://github.com/rust-lang/rust/pull/124417#issuecomment-2123700666. See individual commits for details. The first three commits are not strictly necessary. However, the 2nd one (06bc4fc67145e3a7be9b5a2cf2b5968cef36e587, *Remove `LintDiagnostic::msg`*) makes the main change way nicer to implement. It's also pretty sweet on its own if I may say so myself.
2024-05-23Remove `DelayDm`León Orell Valerian Liehr-3/+3
With the removal of `LintDiagnostic::msg` / the `msg` param from lint diag APIs, primary messages for lint diags are always constructed lazily inside decorator fns rendering this wrapper type unused / useless.
2024-05-23Remove `LintDiagnostic::msg`León Orell Valerian Liehr-2/+0
* instead simply set the primary message inside the lint decorator functions * it used to be this way before [#]101986 which introduced `msg` to prevent good path delayed bugs (which no longer exist) from firing under certain circumstances when lints were suppressed / silenced * this is no longer necessary for various reasons I presume * it shaves off complexity and makes further changes easier to implement
2024-05-22Auto merge of #125335 - compiler-errors:binder, r=lcnrbors-0/+9
Uplift `Binder`, `OutlivesPredicate` into `rustc_type_ir` Almost done with all the types 🙏 r? lcnr
2024-05-21Uplift binderMichael Goulet-0/+9
2024-05-21Implement IntoDiagArg for hir NamespaceXiretza-0/+6
2024-05-16Uplift FnSigMichael Goulet-0/+6
2024-05-15Fix the dedup error because of spans from suggestionyukang-1/+1
2024-05-13Uplift AliasTyMichael Goulet-0/+6
2024-05-11Uplift `NormalizesTo`, `CoercePredicate`, and `SubtypePredicate`Michael Goulet-2/+0
2024-05-11Uplift `ExistentialTraitRef`, `ExistentialProjection`, `ProjectionPredicate`Michael Goulet-0/+8
2024-05-10Lift `TraitRef` into `rustc_type_ir`Michael Goulet-0/+6
2024-05-03Remove some low-value `use` renamings.Nicholas Nethercote-3/+3
There are a few common abbreviations like `use rustc_ast as ast` and `use rust_hir as hir` for names that are used a lot. But there are also some cases where a crate is renamed just once in the whole codebase, and that ends up making things harder to read rather than easier. This commit removes them.
2024-04-30Rollup merge of #124511 - nnethercote:rm-extern-crates, r=fee1-deadMatthias Krüger-6/+8
Remove many `#[macro_use] extern crate foo` items This requires the addition of more `use` items, which often make the code more verbose. But they also make the code easier to read, because `#[macro_use]` obscures where macros are defined. r? `@fee1-dead`
2024-04-30Remove `extern crate tracing` from numerous crates.Nicholas Nethercote-3/+4
2024-04-30Auto merge of #124398 - klensy:trailing-ws, r=compiler-errorsbors-3/+13
tests: remove some trailing ws Cleans one more case of trailing whitespace in tests.
2024-04-29Remove `extern crate rustc_macros` from numerous crates.Nicholas Nethercote-3/+4
2024-04-27Rollup merge of #124370 - ShE3py:substitution-part-offset, r=fee1-deadMatthias Krüger-2/+2
Fix substitution parts having a shifted underline in some cases If two suggestions parts are side by side, the underline's offset: (WIP PR as an example, not yet pushed) ``` error: expected a pattern, found an expression --> ./main.rs:4:9 | 4 | 1 + 2 => 3 | ^^^^^ arbitrary expressions are not allowed in patterns | help: check the value in an arm guard | 4 | n if n == 1 + 2 => 3 | ~ +++++++++++++ ``` The emitter didn't take into account that the string had shrunk/grown if two substitution parts were side-by-side (surprisingly, there was only one case in the ui testsuite.) ``` help: check the value in an arm guard | 4 | n if n == 1 + 2 => 3 | ~ +++++++++++++ ``` ``@rustbot`` label +A-suggestion-diagnostics
2024-04-27tests: remove some trailing wsklensy-3/+13
2024-04-25Format stash message correctlyMichael Goulet-2/+2
2024-04-25Fix substitution parts having a shifted underline in some casesLieselotte-2/+2
2024-04-23Rollup merge of #124218 - Xiretza:subsubdiagnostics, r=davidtwcoLeón Orell Valerian Liehr-50/+55
Allow nesting subdiagnostics in #[derive(Subdiagnostic)]
2024-04-22Stabilize generic `NonZero`.Markus Reiter-1/+0
2024-04-21Move "elided lifetime in path" to subdiagnostic structXiretza-18/+23
This requires nested subdiagnostics.
2024-04-21Fix source ordering of IntoDiagArg implsXiretza-30/+30
2024-04-21Pass translation closure to add_to_diag_with() as referenceXiretza-4/+4
2024-04-20Print note with closure signature on type mismatchDaniel Sedlak-1/+1
2024-04-18Simplify `static_assert_size`s.Nicholas Nethercote-2/+2
We want to run them on all 64-bit platforms.
2024-04-12Rollup merge of #123204 - notriddle:notriddle/include-str-span, r=pnkfelixMatthias Krüger-2/+7
rustdoc: point at span in `include_str!`-ed md file Fixes #118549
2024-04-09Add redundant_lifetime_args lintMichael Goulet-0/+1
2024-04-03Rollup merge of #123401 - Zalathar:assert-size-aarch64, r=fmeaseJacob Pratt-2/+2
Check `x86_64` size assertions on `aarch64`, too (Context: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Checking.20size.20assertions.20on.20aarch64.3F) Currently the compiler has around 30 sets of `static_assert_size!` for various size-critical data structures (e.g. various IR nodes), guarded by `#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]`. (Presumably this cfg avoids having to maintain separate size values for 32-bit targets and unusual 64-bit targets. Apparently it may have been necessary before the i128/u128 alignment changes, too.) This is slightly incovenient for people on aarch64 workstations (e.g. Macs), because the assertions normally aren't checked until we push to a PR. So this PR adds `aarch64` to the `#[cfg(..)]` guarding all of those assertions in the compiler. --- Implemented with a simple find/replace. Verified by manually inspecting each `static_assert_size!` in `compiler/`, and checking that either the replacement succeeded, or adding aarch64 wouldn't have been appropriate.
2024-04-03Rollup merge of #121595 - strottos:issue_116615, r=compiler-errorsMatthias Krüger-0/+33
Better reporting on generic argument mismatchs This allows better reporting as per issue #116615 . If you have a function: ``` fn foo(a: T, b: T) {} ``` and call it like so: ``` foo(1, 2.) ``` it'll give improved error reported similar to the following: ``` error[E0308]: mismatched types --> generic-mismatch-reporting-issue-116615.rs:6:12 | 6 | foo(1, 2.); | --- - ^^ expected integer, found floating-point number | | | | | expected argument `b` to be an integer because that argument needs to match the type of this parameter | arguments to this function are incorrect | note: function defined here --> generic-mismatch-reporting-issue-116615.rs:1:4 | 1 | fn foo<T>(a: T, b: T) {} | ^^^ - ---- ---- | | | | | | | this parameter needs to match the integer type of `a` | | `b` needs to match the type of this parameter | `a` and `b` all reference this parameter T ``` Open question, do we need to worry about error message translation into other languages? Not sure what the status of that is in Rust. NB: Needs some checking over and some tests have altered that need sanity checking, but overall this is starting to get somewhere now. Will take out of draft PR status when this has been done, raising now to allow feedback at this stage, probably 90% ready.
2024-04-03Check `x86_64` size assertions on `aarch64`, tooZalathar-2/+2
This makes it easier for contributors on aarch64 workstations (e.g. Macs) to notice when these assertions have been violated.
2024-03-29diagnostics: fix crash on completely empty included fileMichael Howell-2/+7
2024-03-24Rollup merge of #122737 - ytmimi:conditionally_ignore_fatal_diagnostic, ↵Matthias Krüger-2/+9
r=davidtwco conditionally ignore fatal diagnostic in the SilentEmitter This change is primarily meant to allow rustfmt to ignore all diagnostics when using the `SilentEmitter`. Back in #121301 the `SilentEmitter` was shared between rustc and rustfmt. This changed rustfmt's behavior from ignoring all diagnostic to emitting fatal diagnostics, which lead to https://github.com/rust-lang/rustfmt/issues/6109. These changes allow rustfmt to maintain its previous behaviour when using the `SilentEmitter`, while allowing rustc code to still emit fatal diagnostics.
2024-03-20Auto merge of #122754 - Mark-Simulacrum:bootstrap-bump, r=albertlarsan68bors-1/+0
Bump to 1.78 bootstrap compiler https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-03-20step cfgsMark Rousskov-1/+0
2024-03-19conditionally ignore fatal diagnostic in the SilentEmitterYacin Tmimi-2/+9
This change is primarily meant to allow rustfmt to ignore all diagnostics when using the `SilentEmitter`. Back in PR 121301 the `SilentEmitter` was shared between rustc and rustfmt. This changed rustfmt's behavior from ignoring all diagnostic to emitting fatal diagnostics. These changes allow rustfmt to maintain it's previous behaviour when using the SilentEmitter, while allowing rustc code to still emit fatal diagnostics.
2024-03-18When displaying multispans, ignore empty lines adjacent to `...`Esteban Küber-1/+48
``` error[E0308]: `match` arms have incompatible types --> tests/ui/codemap_tests/huge_multispan_highlight.rs:98:18 | 6 | let _ = match true { | ---------- `match` arms have incompatible types 7 | true => ( | _________________- 8 | | // last line shown in multispan header ... | 96 | | 97 | | ), | |_________- this is found to be of type `()` 98 | false => " | __________________^ ... | 119 | | 120 | | ", | |_________^ expected `()`, found `&str` error[E0308]: `match` arms have incompatible types --> tests/ui/codemap_tests/huge_multispan_highlight.rs:215:18 | 122 | let _ = match true { | ---------- `match` arms have incompatible types 123 | true => ( | _________________- 124 | | 125 | | 1 // last line shown in multispan header ... | 213 | | 214 | | ), | |_________- this is found to be of type `{integer}` 215 | false => " | __________________^ 216 | | 217 | | 218 | | 1 last line shown in multispan ... | 237 | | 238 | | ", | |_________^ expected integer, found `&str` ```