about summary refs log tree commit diff
path: root/src/librustc_errors/emitter.rs
AgeCommit message (Collapse)AuthorLines
2018-05-24Underline multiple suggested replacements in the same lineEsteban Küber-18/+47
Follow up to #50943. Fix #50977.
2018-04-07Update based on RangeBounds trait being moved to libcore.Steven Malis-2/+2
2018-03-15Require the code mapper to be thread-safeJohn Kåre Alsaker-7/+5
2018-03-14test for putting back check on jsonGuillaume Gomez-54/+35
2018-03-07rustc: Migrate to `termcolor` crate from `term`Alex Crichton-151/+106
This crate moves the compiler's error reporting to using the `termcolor` crate from crates.io. Previously rustc used a super-old version of the `term` crate in-tree which is basically unmaintained at this point, but Cargo has been using `termcolor` for some time now and tools like `rg` are using `termcolor` as well, so it seems like a good strategy to take! Note that the `term` crate remains in-tree for libtest. Changing libtest will be a bit tricky due to how the build works, but we can always tackle that later. cc #45728
2018-03-02Replace Rc with Lrc for shared dataJohn Kåre Alsaker-7/+7
2018-02-26Fix rebaseVadim Petrochenkov-2/+3
2018-02-26Anonymize remaining line numbers at line startsVadim Petrochenkov-9/+12
2018-02-26Support flag `-Z ui-testing` for tweaking diagnostic output for UI testsVadim Petrochenkov-3/+21
2018-02-25Reduce error codes length when too much are thrownGuillaume Gomez-2/+5
2018-02-25Add rustc --explain backGuillaume Gomez-7/+43
2018-01-31Auto merge of #47900 - kennytm:rollup, r=kennytmbors-0/+4
Rollup of 16 pull requests - Successful merges: #47838, #47840, #47844, #47874, #47875, #47876, #47884, #47886, #47889, #47890, #47891, #47795, #47677, #47893, #47895, #47552 - Failed merges:
2018-02-01Rollup merge of #47677 - etaoins:avoid-underflow-in-rennder-source-line, ↵kennytm-0/+4
r=estebank Avoid underflow in render_source_line While testing rust-lang/rust#47655 I was able to make the compiler panic when it's compiled with debug assertions: ```shell > rustc /dev/null --crate-type proc-macro error: internal compiler error: unexpected panic note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports note: rustc 1.25.0-dev running on x86_64-apple-darwin note: run with `RUST_BACKTRACE=1` for a backtrace thread 'rustc' panicked at 'attempt to subtract with overflow', librustc_errors/emitter.rs:287:49 ``` Without debug assertions the following warning is emitted: ```shell > rustc /dev/null --crate-type proc-macro warning: unused variable: `registrar` --> /dev/null:0:1 | | = note: #[warn(unused_variables)] on by default = note: to avoid this warning, consider using `_registrar` instead ``` The panic is due to the unused variable warning being spanned to `/dev/null:0:1`. When `render_source_line` subtracts 1 from the line number to look up the source line it panics due to underflow. Without debug assertions this would wrap and cause us to return a blank string instead. Fix by explicitly testing for 0 and exiting early. I'm unsure how to automatically test this now that rust-lang/rust#46655 has been approved.
2018-01-31Auto merge of #45752 - estebank:highlight-primary, r=nikomatsakisbors-6/+19
Highlight code on diagnostics when underlined Highlight the label's span with the respective color: <img width="692" alt="" src="https://user-images.githubusercontent.com/1606434/32411026-a1842482-c18d-11e7-9933-6510eefbad19.png"> Fix #42112.
2018-01-30Rollup merge of #47780 - varkor:cross-file-errors-line-col, r=estebankkennytm-1/+14
Add line numbers and columns to error messages spanning multiple files If an error message is emitted that spans several files, only the primary file currently has line and column data attached. This is useful information, even in files other than the one in which the error occurs. We can often work out which line and column the error corresponds to in other files — in this case it is helpful to add them (in the case of ambiguity, the first relevant line/column is picked, which is still helpful than none).
2018-01-29Toggle span highlighting on `-Zteach`Esteban Küber-7/+14
2018-01-28Highlight code on diagnostics when underlinedEsteban Küber-1/+7
2018-01-27Improve formatting of else blockvarkor-1/+3
2018-01-26Don't add "in this macro invocation" label to desugared spansEsteban Küber-0/+1
2018-01-26Add line numbers and columns to error messages spanning multiple filesvarkor-1/+12
If an error message is emitted that spans several files, only the primary file currently has line and column data attached. This is useful information, even in files other than the one in which the error occurs. We can often work out which line and column the error corresponds to in other files — in this case it is helpful to add them (in the case of ambiguity, the first relevant line/column is picked, which is still helpful than none).
2018-01-23Avoid underflow in render_source_lineRyan Cumming-0/+4
While testing rust-lang/rust#47655 I was able to make the compiler panic when it's compiled with debug assertions: ```shell > rustc /dev/null --crate-type proc-macro error: internal compiler error: unexpected panic note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports note: rustc 1.25.0-dev running on x86_64-apple-darwin note: run with `RUST_BACKTRACE=1` for a backtrace thread 'rustc' panicked at 'attempt to subtract with overflow', librustc_errors/emitter.rs:287:49 ``` Without debug assertions the following warning is emitted: ```shell > rustc /dev/null --crate-type proc-macro warning: unused variable: `registrar` --> /dev/null:0:1 | | = note: #[warn(unused_variables)] on by default = note: to avoid this warning, consider using `_registrar` instead ``` The panic is due to the unused variable warning being spanned to `/dev/null:0:1`. When `render_source_line` subtracts 1 from the line number to look up the source line it panics due to underflow. Without debug assertions this would wrap and cause us to return a blank string instead. Fix by explicitly testing for 0 and exiting early. I'm unsure how to automatically test this now that rust-lang/rust#46655 has been approved.
2018-01-18Rollup merge of #47407 - gaurikholkar:master, r=estebankkennytm-2/+2
fix mispositioned span This fixes #47377 The output now looks like this ``` error[E0369]: binary operation `+` cannot be applied to type `&str` --> h.rs:3:11 | 3 | let _a = b + ", World!"; | ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left | 3 | let _a = b.to_owned() + ", World!"; | ^^^^^^^^^ error: aborting due to previous error ``` For the case when emojis are involved, it gives the new output for proper indentation. But for an indentation as follows, ``` fn main() { let b = "hello"; let _a = b + ", World!"; } ``` it still mispositions the span ``` 3 | println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; | ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings | 3 | println!("🦀🦀🦀🦀🦀"); let _a = b.to_owned() + ", World!"; | ^^^^^^^ error: aborting due to previous erro ``` cc @estebank @est31
2018-01-13add ui testGauri-1/+1
2018-01-13fix mispositioned spanGauri-1/+1
2018-01-10Use correct line offsets for doctests (fixes #45868)Manish Goregaokar-2/+2
2017-12-14When attempting to write str with single quote suggest double quotesEsteban Küber-1/+5
2017-12-14Use PathBuf instead of String where applicableOliver Schneider-5/+11
2017-12-14Auto merge of #46605 - estebank:macro-backtrace-spans, r=pnkfelixbors-53/+49
Use spans for -Z external-macro-backtrace ``` % rustc ui/type-check/cannot_infer_local_or_vec.rs -Z external-macro-backtrace error[E0282]: type annotations needed --> <vec macros>:3:1 | 1 | / ( $ elem : expr ; $ n : expr ) => ( 2 | | $ crate :: vec :: from_elem ( $ elem , $ n ) ) ; ( $ ( $ x : expr ) , * ) => ( 3 | | < [ _ ] > :: into_vec ( box [ $ ( $ x ) , * ] ) ) ; ( $ ( $ x : expr , ) * ) | | ^^^^^^^^^^^^^^^^^^^^^ | | | | | cannot infer type for `T` 4 | | => ( vec ! [ $ ( $ x ) , * ] ) | |______________________________- in this expansion of `vec!` | ::: ui/type-check/cannot_infer_local_or_vec.rs | 12 | let x = vec![]; | - ------ in this macro invocation | | | consider giving `x` a type error: aborting due to previous error ```
2017-12-09Resolve type on return type suggestionEsteban Küber-1/+1
2017-12-09Use spans for -Z external-macro-backtraceEsteban Küber-53/+49
``` % rustc ui/type-check/cannot_infer_local_or_vec.rs -Z external-macro-backtrace error[E0282]: type annotations needed --> <vec macros>:3:1 | 1 | / ( $ elem : expr ; $ n : expr ) => ( 2 | | $ crate :: vec :: from_elem ( $ elem , $ n ) ) ; ( $ ( $ x : expr ) , * ) => ( 3 | | < [ _ ] > :: into_vec ( box [ $ ( $ x ) , * ] ) ) ; ( $ ( $ x : expr , ) * ) | | ^^^^^^^^^^^^^^^^^^^^^ | | | | | cannot infer type for `T` 4 | | => ( vec ! [ $ ( $ x ) , * ] ) | |______________________________- in this expansion of `vec!` | ::: ui/type-check/cannot_infer_local_or_vec.rs | 12 | let x = vec![]; | - ------ in this macro invocation | | | consider giving `x` a type error: aborting due to previous error ```
2017-12-01Auto merge of #45997 - estebank:pub-ident, r=nikomatsakisbors-1/+1
Account for missing keyword in fn/struct definition Fix #38911.
2017-11-26mention nightly in -Z external-macro-backtrace noteAlex Burka-1/+2
2017-11-24Fix underline in suggestionsEsteban Küber-1/+1
2017-11-20address review commentsAlex Burka-8/+8
2017-11-19use -Z flag instead of env varAlex Burka-21/+30
2017-11-19add UI testAlex Burka-3/+6
2017-11-19show macro backtrace with env varAlex Burka-13/+46
2017-11-16Remove left over dead code from suggestion diagnostic refactoringOliver Schneider-42/+23
2017-11-09Auto merge of #45741 - oli-obk:refactor_suggestions, r=estebankbors-31/+36
Refactor internal suggestion API ~~The only functional change is that whitespace, which is suggested to be added, also gets `^^^^` under it. An example is shown in the tests (the only test that changed).~~ Continuation of #41876 r? @nagisa the changes are probably best viewed [without whitespace](https://github.com/rust-lang/rust/pull/45741/files?w=1)
2017-11-06Do not highlight surrounding whitespaceOliver Schneider-6/+7
2017-11-04Auto merge of #45711 - tirr-c:unicode-span, r=estebankbors-7/+7
Display spans correctly when there are zero-width or wide characters Hopefully... * fixes #45211 * fixes #8706 --- Before: ``` error: invalid width `7` for integer literal --> unicode_2.rs:12:25 | 12 | let _ = ("a̐éö̲", 0u7); | ^^^ | = help: valid widths are 8, 16, 32, 64 and 128 error: invalid width `42` for integer literal --> unicode_2.rs:13:20 | 13 | let _ = ("아あ", 1i42); | ^^^^ | = help: valid widths are 8, 16, 32, 64 and 128 error: aborting due to 2 previous errors ``` After: ``` error: invalid width `7` for integer literal --> unicode_2.rs:12:25 | 12 | let _ = ("a̐éö̲", 0u7); | ^^^ | = help: valid widths are 8, 16, 32, 64 and 128 error: invalid width `42` for integer literal --> unicode_2.rs:13:20 | 13 | let _ = ("아あ", 1i42); | ^^^^ | = help: valid widths are 8, 16, 32, 64 and 128 error: aborting due to 2 previous errors ``` Spans might display incorrectly on the browser. r? @estebank
2017-11-03Refactor internal suggestion APIOliver Schneider-35/+39
2017-11-03Display spans correctly when there are non-half-width charactersWonwoo Choi-7/+7
2017-11-02Make the difference between lint codes and error codes explicitOliver Schneider-11/+8
2017-11-02Report lint names in json diagnosticsOliver Schneider-1/+2
2017-10-20Add short message-formatGuillaume Gomez-130/+164
2017-09-29fix comment typo, `CodeSuggestion` path in doc commentZack M. Davis-1/+1
`CodeSuggestion` doesn't live in the `diagnostic` module.
2017-08-30Make fields of `Span` privateVadim Petrochenkov-6/+6
2017-08-25Fix a byte/char confusion issue in the error emitterest31-1/+3
Fixes #44078. Fixes #44023. The start_col member is given in chars, while the code previously assumed it was given in bytes. The more basic issue #44080 doesn't get fixed.
2017-08-17Rollup merge of #43891 - Fourchaux:master, r=steveklabnikCorey Farwell-1/+1
Fix typos & us spellings Fixing some typos and non en-US spellings. (Update of PR https://github.com/rust-lang/rust/pull/42812 )