summary refs log tree commit diff
path: root/compiler/rustc_errors/src/emitter.rs
AgeCommit message (Collapse)AuthorLines
2023-05-25Remove ExpnKind::Inlined.Camille GILLOT-3/+2
2023-05-24Use `is_some_and`/`is_ok_and` in less obvious spotsMaybe Waffle-9/+5
2023-05-19Fix overflow in error emitterBadel2-16/+19
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-21Rollup merge of #110578 - bvanjoi:fix-issue-110547, r=jackh726Matthias Krüger-0/+1
fix(error): normalize whitespace during msg_to_buffer close https://github.com/rust-lang/rust/issues/110547
2023-04-21fix(error): normalize whitespace during msg_to_bufferbohan-0/+1
2023-04-17Spelling - compilerJosh Soref-1/+1
* account * achieved * advising * always * ambiguous * analysis * annotations * appropriate * build * candidates * cascading * category * character * clarification * compound * conceptually * constituent * consts * convenience * corresponds * debruijn * debug * debugable * debuggable * deterministic * discriminant * display * documentation * doesn't * ellipsis * erroneous * evaluability * evaluate * evaluation * explicitly * fallible * fulfill * getting * has * highlighting * illustrative * imported * incompatible * infringing * initialized * into * intrinsic * introduced * javascript * liveness * metadata * monomorphization * nonexistent * nontrivial * obligation * obligations * offset * opaque * opportunities * opt-in * outlive * overlapping * paragraph * parentheses * poisson * precisely * predecessors * predicates * preexisting * propagated * really * reentrant * referent * responsibility * rustonomicon * shortcircuit * simplifiable * simplifications * specify * stabilized * structurally * suggestibility * translatable * transmuting * two * unclosed * uninhabited * visibility * volatile * workaround Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-12Special-case item attributes in the suggestion outputEsteban Küber-1/+10
2023-04-12Tweak output for 'add line' suggestionEsteban Küber-1/+40
2023-04-09Fix some clippy::complexityNilstrieb-5/+5
2023-04-01a couple clippy::complexity fixesMatthias Krüger-1/+1
map_identity filter_next option_as_ref_deref unnecessary_find_map redundant_slicing unnecessary_unwrap bool_comparison derivable_impls manual_flatten needless_borrowed_reference
2023-03-28Create AnnotationColumn struct to fix hard tab column numbers in errorspommicket-21/+30
2023-03-04Properly colorize multi-part suggestions in the same lineEsteban Küber-5/+5
Fix #108547.
2023-02-14More accurate spans for arg removal suggestionEsteban Küber-1/+2
2023-02-13Rollup merge of #107838 - estebank:terminal_hyperlinks, r=nagisaMatthias Krüger-2/+15
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-09Introduce `-Zterminal-urls` to use OSC8 for error codesEsteban Küber-2/+15
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-09test: snapshot for derive suggestion in diff filesbohan-11/+11
2023-02-05Clean up and comment EmitterWriter.draw_code_lineCastilloDel-59/+32
2023-02-04Fix suggestions rendering when the span is multilineCastilloDel-17/+63
2023-01-30Replace enum `==`s with `match`es where it makes senseMaybe Waffle-23/+31
2023-01-17Remove double spaces after dots in commentsMaybe Waffle-3/+3
2023-01-08Make translate_message return result and add testsmejrs-4/+7
2022-12-29Account for multiple multiline spans with empty paddingEsteban Küber-3/+19
Instead of ``` LL | fn oom( | __^ | | _| | || LL | || ) { | ||_- LL | | } | |__^ ``` emit ``` LL | // fn oom( LL | || ) { | ||_- LL | | } | |__^ ```
2022-12-15more clippy::complexity fixesMatthias Krüger-1/+1
2022-12-13Avoid rendering empty annotationsOli Scherer-37/+44
2022-12-13Don't emit empty notesOli Scherer-17/+19
2022-12-12minor code cleanupsMatthias Krüger-2/+2
2022-12-06Properly indent messagesOli Scherer-6/+18
2022-12-06Start emitting labels even if their pointed to file is not available locallyOli Scherer-0/+42
2022-12-06remove an unnecessary `?`Oli Scherer-2/+1
2022-12-06Simplify span fallbackOli Scherer-47/+23
2022-12-06Simplify some nested conditionsOli Scherer-10/+3
2022-12-01Remove useless borrows and derefsMaybe Waffle-13/+13
2022-11-28Tweak outputEsteban Küber-1/+1
2022-11-28Change multiline span ASCII art visual orderEsteban Küber-1/+7
2022-11-24Auto merge of #104507 - WaffleLapkin:asderefsyou, r=wesleywiserbors-1/+1
Use `as_deref` in compiler (but only where it makes sense) This simplifies some code :3 (there are some changes that are not exacly `as_deref`, but more like "clever `Option`/`Result` method use")
2022-11-19Rollup merge of #103117 - joshtriplett:use-is-terminal, r=eholkMatthias Krüger-3/+3
Use `IsTerminal` in place of `atty` In any crate that can use nightly features, use `IsTerminal` rather than `atty`: - Use `IsTerminal` in `rustc_errors` - Use `IsTerminal` in `rustc_driver` - Use `IsTerminal` in `rustc_log` - Use `IsTerminal` in `librustdoc`
2022-11-16Use `as_deref` in compiler (but only where it makes sense)Maybe Waffle-1/+1
2022-11-11Print all labels, even if they have no span. Fall back to main item's span.Oli Scherer-12/+35
2022-11-11Remove some redundant argumentsOli Scherer-8/+5
2022-10-24Address some commentsmejrs-2/+2
2022-10-19Implement -Ztrack-diagnosticsmejrs-5/+31
2022-10-16Use IsTerminal in rustc_errorsJosh Triplett-3/+3
2022-10-10errors: use `HashMap` to store diagnostic argsDavid Wood-2/+2
Eager translation will enable subdiagnostics to be translated multiple times with different arguments - this requires the ability to replace the value of one argument with a new value, which is better suited to a `HashMap` than the previous storage, a `Vec`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-09-13Don't render inline suggestions of only spacesMichael Goulet-4/+1
2022-09-12Don't trim substitution if it's only whitespaceMichael Goulet-9/+19
2022-09-12A SubstitutionPart is not a deletion if it replaces nothing with nothingMichael Goulet-1/+1
2022-09-10rustc_error, rustc_private, rustc_ast: Switch to stable hash containersNiklas Jonsson-2/+2
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-1/+0
by module
2022-08-15errors: move translation logic into moduleDavid Wood-110/+18
Just moving code around so that triagebot can ping relevant parties when translation logic is modified. Signed-off-by: David Wood <david.wood@huawei.com>