about summary refs log tree commit diff
path: root/compiler/rustc_errors
AgeCommit message (Collapse)AuthorLines
2023-08-24Add comment to the push_trailing functionallaboutevemirolive-2/+16
2023-08-23Bump cfg(bootstrap)Mark Rousskov-1/+1
2023-08-18fixKyle Lin-1/+1
2023-08-18lint linksKyle Lin-3/+3
2023-08-04Auto merge of #114104 - oli-obk:syn2, r=compiler-errorsbors-192/+105
Lots of tiny incremental simplifications of `EmitterWriter` internals ignore the first commit, it's https://github.com/rust-lang/rust/pull/114088 squashed and rebased, but it's needed to use to use `derive_setters`, as they need a newer `syn` version. Then this PR starts out with removing many arguments that are almost always defaulted to `None` or `false` and replace them with builder methods that can set these fields in the few cases that want to set them. After that it's one commit after the other that removes or merges things until everything becomes some very simple trait objects
2023-08-03Add `internal_features` lintNilstrieb-0/+1
It lints against features that are inteded to be internal to the compiler and standard library. Implements MCP #596. We allow `internal_features` in the standard library and compiler as those use many features and this _is_ the standard library from the "internal to the compiler and standard library" after all. Marking some features as internal wasn't exactly the most scientific approach, I just marked some mostly obvious features. While there is a categorization in the macro, it's not very well upheld (should probably be fixed in another PR). We always pass `-Ainternal_features` in the testsuite About 400 UI tests and several other tests use internal features. Instead of throwing the attribute on each one, just always allow them. There's nothing wrong with testing internal features^^
2023-07-31Sanity check that we actually flush all buffersOli Scherer-0/+9
2023-07-31Get rid of the thin wrapper type that is `Destination` and just write to the ↵Oli Scherer-32/+19
`Writer` trait object directly
2023-07-31Turn a single-variant enum into a structOli Scherer-14/+6
2023-07-31Merge all `Destination` variantsOli Scherer-4/+1
2023-07-31Remove a now-redundant single-variant enumOli Scherer-43/+5
2023-07-31Move `WritableDst` method onto `Style` directlyOli Scherer-5/+8
2023-07-31Merge buffered destination into raw destinationOli Scherer-17/+37
2023-07-31Remove an enum variant that can be covered by anotherOli Scherer-6/+1
2023-07-31Remove a `bool` for color in favor of the `WriteColor` trait wrapping ↵Oli Scherer-18/+27
colored and uncolored printing
2023-07-31Use builder pattern instead of lots of arguments for `EmitterWriter::new`Oli Scherer-52/+13
2023-07-31Replace the many arguments of `EmitterWriter::stderr` with builder methodsOli Scherer-37/+15
2023-07-30Rollup merge of #114068 - matthiaskrgr:fmt_args_rustc_1, r=WaffleLapkinMatthias Krüger-16/+14
inline format!() args up to and including rustc_middle (2) r? `@WaffleLapkin`
2023-07-30Rollup merge of #114018 - Enselic:multi-annotation, r=b-naberMatthias Krüger-7/+13
Make `--error-format human-annotate-rs` handle multiple files Closes #64205 which is E-help-wanted
2023-07-30inline format!() args up to and including rustc_middleMatthias Krüger-16/+14
2023-07-29Auto merge of #113099 - bvanjoi:fix-112713-2, r=petrochenkovbors-0/+16
fix(resolve): update the ambiguity glob binding as warning recursively Fixes #47525 Fixes #56593, but `issue-56593-2.rs` is not fixed to ensure backward compatibility. Fixes #98467 Fixes #105235 Fixes #112713 This PR had added a field called `warn_ambiguous` in `NameBinding` which is only for back compatibly reason and used for lint. More details: https://github.com/rust-lang/rust/pull/112743 r? `@petrochenkov`
2023-07-28Rollup merge of #114128 - estebank:delayed-span-bug-dump, r=davidtwcoMatthias Krüger-2/+2
When flushing delayed span bugs, write to the ICE dump file even if it doesn't exist Fix #113881.
2023-07-29fix(resolve): update the ambiguity glob binding as warning recursivelybohan-0/+16
2023-07-27Auto merge of #113298 - tgross35:update-bless-envs, r=oli-obkbors-1/+1
Unite bless environment variables under `RUST_BLESS` Currently, Clippy and Miri both use an environment variable to indicate that output should be blessed, but they use different variable names. In order to improve consistency, this patch applies the following changes: - Rename the variable `MIRI_BLESS` (as used in the Miri subtree) to `RUST_BLESS` - Rename the variable `BLESS` (as used in the Clippy subtree) to `RUST_BLESS` - Move emitting `RUST_BLESS` into `prepare_cargo_test` so it is always available (I need this for a WIP PR) --- I prefer something like `RUST_BLESS` to `BLESS` just for a lower chance of conflict (not super common but other tools [do use `BLESS`](https://grep.app/search?q=%22BLESS%22&case=true&words=true&filter[lang][0]=Text&filter[lang][1]=Rust&filter[lang][2]=Python&filter[lang][3]=C%2B%2B&filter[lang][4]=Markdown&filter[lang][5]=C&filter[lang][6]=JSON)), but I can change it to whatever is preferred. Original discussion: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/BLESS.20env.20var.3A.20rename.20to.20CLIPPY_BLESS r? `@oli-obk` cc `@flip1995`
2023-07-27When flushing delayed span bugs, write to the ICE dump file even if it ↵Esteban Küber-2/+2
doesn't exist Fix #113881.
2023-07-27Auto merge of #113281 - dayo05:master, r=davidtwcobors-14/+111
Implement diagnostic translation for rustc-errors This is my first PR to rustc yeah~ I'm going to implement diagnostic translation on rustc-errors crate. This PR is WIP, the reason of opening this as draft, I want to show my code to prevent the issue caused by misunderstanding and also I have few questions. Some error messages are processed by `pluralize!` macro which determines to use plural word or not. From now, I make two kinds of keys and combine with enum but I'm not sure is this best method to do it. Is there any prefered method to do this? => This resolved on conversation on PR. I'll remain to perform force-push until my first implementation looks good to me
2023-07-26Unite bless environment variables under `RUSTC_BLESS`Trevor Gross-1/+1
Currently, Clippy, Miri, Rustfmt, and rustc all use an environment variable to indicate that output should be blessed, but they use different variable names. In order to improve consistency, this patch applies the following changes: - Emit `RUSTC_BLESS` within `prepare_cargo_test` so it is always available - Change usage of `MIRI_BLESS` in the Miri subtree to use `RUSTC_BLESS` - Change usage of `BLESS` in the Clippy subtree to `RUSTC_BLESS` - Change usage of `BLESS` in the Rustfmt subtree to `RUSTC_BLESS` - Adjust the blessable test in `rustc_errors` to use this same convention - Update documentation where applicable Any tools that uses `RUSTC_BLESS` should check that it is set to any value other than `"0"`.
2023-07-26Auto merge of #114054 - oli-obk:cleanups, r=estebankbors-51/+30
Split some functions with many arguments into builder pattern functions r? `@estebank` This doesn't resolve all of the ones in rustc, mostly because I need to do other cleanups in order to be able to use some builder derives from crates.io Works around https://github.com/rust-lang/rust/issues/90672 by making `x test rustfmt --bless` format itself instead of testing that it is formatted
2023-07-25Rollup merge of #114014 - davidtwco:issue-114010-env-rawstr, r=cjgillotMatthias Krüger-0/+6
builtin_macros: expect raw strings too Fixes #114010. `expr_to_string` allows raw strings through so this code should be expected to handle those.
2023-07-25Use a builder instead of boolean/option argumentsOli Scherer-25/+24
2023-07-25Remove a redundant fieldOli Scherer-4/+4
2023-07-25Inline a function that is only used onceOli Scherer-20/+4
2023-07-25Remove some arguments that are always the sameOli Scherer-8/+4
2023-07-25builtin_macros: raw str in diagnostic outputDavid Wood-0/+6
If a raw string was used in the `env!` invocation, then it should also be shown in the diagnostic messages as a raw string. Signed-off-by: David Wood <david@davidtw.co>
2023-07-24Make `--error-format human-annotate-rs` handle multiple filesMartin Nordholts-7/+13
2023-07-24Optimize format usageYuri Astrakhan-9/+9
Per #112156, using `&` in `format!` may cause a small perf delay, so I tried to clean up one module at a time format usage. This PR includes a few removals of the ref in format (they do compile locally without the ref), as well as a few format inlining for consistency.
2023-07-20Don't translate compiler-internal bug messagesOli Scherer-7/+7
2023-07-20Rollup merge of #113871 - clubby789:derive-sugg-span, r=compiler-errorsMatthias Krüger-1/+1
Use the correct span for displaying the line following a derive sugge… `span` here is the main span of the diagnostic. In the linked issue's case, this belongs to `main.rs`. However, the line numbers (and line we are trying to display) are in `name.rs`, so using `span_to_lines` gives us the wrong `FileLines`. Use `parts[0].span` (the span of the suggestion) here like the rest of the code does to get the right file. Not sure if this needs a dedicated test because this fixes an existing error in the UI suite Fixes #113844
2023-07-19Use the correct span for displaying the line following a derive suggestionclubby789-1/+1
2023-07-19On nightly, dump ICE backtraces to diskEsteban Küber-4/+29
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-17Simplify implement diagnostic of errors_indicate_anonymous_lifetimeDayo-17/+5
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-2/+2
2023-07-07Implement diagnostic translation for expected lifetime parameter messageDayo-16/+125
2023-07-03Add a simple markdown parser for formatting `rustc --explain`Trevor Gross-2/+1343
Currently, the output of `rustc --explain foo` displays the raw markdown in a pager. This is acceptable, but using actual formatting makes it easier to understand. This patch consists of three major components: 1. A markdown parser. This is an extremely simple non-backtracking recursive implementation that requires normalization of the final token stream 2. A utility to write the token stream to an output buffer 3. Configuration within rustc_driver_impl to invoke this combination for `--explain`. Like the current implementation, it first attempts to print to a pager with a fallback colorized terminal, and standard print as a last resort. If color is disabled, or if the output does not support it, or if printing with color fails, it will write the raw markdown (which matches current behavior). Pagers known to support color are: `less` (with `-r`), `bat` (aka `catbat`), and `delta`. The markdown parser does not support the entire markdown specification, but should support the following with reasonable accuracy: - Headings, including formatting - Comments - Code, inline and fenced block (no indented block) - Strong, emphasis, and strikethrough formatted text - Links, anchor, inline, and reference-style - Horizontal rules - Unordered and ordered list items, including formatting This parser and writer should be reusable by other systems if ever needed.
2023-06-14s/drain_filter/extract_if/ for Vec, Btree{Map,Set} and LinkedListThe 8472-2/+2
2023-06-06Respect `RUST_BACKTRACE` for delayed bugsNilstrieb-4/+14
Sometimes, especially with MIR validation, the backtraces from delayed bugs are noise and make it harder to look at them. Respect the environment variable and don't print it when the user doesn't want it.
2023-06-02Auto merge of #112198 - compiler-errors:rollup-o2xe4of, r=compiler-errorsbors-26/+9
Rollup of 7 pull requests Successful merges: - #111670 (Require that const param tys implement `ConstParamTy`) - #111914 (CFI: Fix cfi with async: transform_ty: unexpected GeneratorWitness(Bi…) - #112030 (Migrate `item_trait_alias` to Askama) - #112150 (Support 128-bit atomics on all x86_64 Apple targets) - #112174 (Fix broken link) - #112190 (Improve comments on `TyCtxt` and `GlobalCtxt`.) - #112193 (Check tuple elements are `Sized` in `offset_of`) Failed merges: - #112071 (Group rfcs tests) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-01Remove adt_const_params usage from compilerMichael Goulet-26/+9
2023-06-01Use translatable diagnostics in `rustc_const_eval`Deadbeef-9/+24
2023-05-29Use `Cow` in `{D,Subd}iagnosticMessage`.Nicholas Nethercote-26/+22
Each of `{D,Subd}iagnosticMessage::{Str,Eager}` has a comment: ``` // FIXME(davidtwco): can a `Cow<'static, str>` be used here? ``` This commit answers that question in the affirmative. It's not the most compelling change ever, but it might be worth merging. This requires changing the `impl<'a> From<&'a str>` impls to `impl From<&'static str>`, which involves a bunch of knock-on changes that require/result in call sites being a little more precise about exactly what kind of string they use to create errors, and not just `&str`. This will result in fewer unnecessary allocations, though this will not have any notable perf effects given that these are error paths. Note that I was lazy within Clippy, using `to_string` in a few places to preserve the existing string imprecision. I could have used `impl Into<{D,Subd}iagnosticMessage>` in various places as is done in the compiler, but that would have required changes to *many* call sites (mostly changing `&format("...")` to `format!("...")`) which didn't seem worthwhile.