Commit Graph

109 Commits

Author SHA1 Message Date
Esteban Küber 6fd175185e Properly colorize multi-part suggestions in the same line
Fix #108547.
2023-03-04 00:29:52 +00:00
Esteban Küber f02d8ec15e More accurate spans for arg removal suggestion 2023-02-14 20:22:09 +00:00
Matthias Krüger 780beae7bd Rollup merge of #107838 - estebank:terminal_hyperlinks, r=nagisa
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-13 11:34:57 +01:00
Esteban Küber a576514e13 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-09 14:52:54 +00:00
bohan 7615045ebd test: snapshot for derive suggestion in diff files 2023-02-09 22:28:53 +08:00
CastilloDel 3dd004470d Clean up and comment EmitterWriter.draw_code_line 2023-02-05 19:01:28 +01:00
CastilloDel cf0279991d Fix suggestions rendering when the span is multiline 2023-02-04 19:04:04 +01:00
Maybe Waffle fd649a3cc5 Replace enum ==s with matches where it makes sense 2023-01-30 12:26:26 +00:00
Maybe Waffle 6a28fb42a8 Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
mejrs 262ff86138 Make translate_message return result and add tests 2023-01-08 23:35:43 +01:00
Esteban Küber af74ca0666 Account for multiple multiline spans with empty padding
Instead of

```
LL |    fn oom(
   |  __^
   | | _|
   | ||
LL | || ) {
   | ||_-
LL | |  }
   | |__^
```

emit

```
LL | // fn oom(
LL | || ) {
   | ||_-
LL | |  }
   | |__^
   ```
2022-12-29 09:13:40 -08:00
Matthias Krüger de59844c98 more clippy::complexity fixes 2022-12-15 00:09:10 +01:00
Oli Scherer 59554a2b54 Avoid rendering empty annotations 2022-12-13 10:06:08 +00:00
Oli Scherer 2e2a4797a2 Don't emit empty notes 2022-12-13 09:53:36 +00:00
Matthias Krüger 2ea368e53c minor code cleanups 2022-12-12 19:49:53 +01:00
Oli Scherer f89d6236aa Properly indent messages 2022-12-06 18:59:46 +00:00
Oli Scherer 10b75cbbb0 Start emitting labels even if their pointed to file is not available locally 2022-12-06 18:59:46 +00:00
Oli Scherer 19d7dceed3 remove an unnecessary ? 2022-12-06 18:59:45 +00:00
Oli Scherer 9eb9176b08 Simplify span fallback 2022-12-06 18:59:45 +00:00
Oli Scherer b9bf119c4f Simplify some nested conditions 2022-12-06 18:59:45 +00:00
Maybe Waffle f2b97a8bfe Remove useless borrows and derefs 2022-12-01 17:34:43 +00:00
Esteban Küber 6f64432a39 Tweak output 2022-11-28 00:11:12 -08:00
Esteban Küber ab04080b56 Change multiline span ASCII art visual order 2022-11-28 00:11:12 -08:00
bors 872631d0f0 Auto merge of #104507 - WaffleLapkin:asderefsyou, r=wesleywiser
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-24 00:17:35 +00:00
Matthias Krüger 52cc0d5360 Rollup merge of #103117 - joshtriplett:use-is-terminal, r=eholk
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-19 15:35:18 +01:00
Maybe Waffle 94470f4efd Use as_deref in compiler (but only where it makes sense) 2022-11-16 21:58:58 +00:00
Oli Scherer df2adc4760 Print all labels, even if they have no span. Fall back to main item's span. 2022-11-11 14:45:28 +00:00
Oli Scherer 014f7f4092 Remove some redundant arguments 2022-11-11 14:17:27 +00:00
mejrs 854b3166a0 Address some comments 2022-10-24 20:52:51 +02:00
mejrs 406e1dc8eb Implement -Ztrack-diagnostics 2022-10-19 00:08:20 +02:00
Josh Triplett c5ad97da25 Use IsTerminal in rustc_errors 2022-10-16 15:10:40 +01:00
David Wood 508d7e6d26 errors: use HashMap to store diagnostic args
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-10-10 14:20:16 +01:00
Michael Goulet cd962e66cf Don't render inline suggestions of only spaces 2022-09-13 03:52:43 +00:00
Michael Goulet c2cff68d84 Don't trim substitution if it's only whitespace 2022-09-12 22:08:30 +00:00
Michael Goulet 370c816a71 A SubstitutionPart is not a deletion if it replaces nothing with nothing 2022-09-12 22:08:30 +00:00
Niklas Jonsson 8d3c30c004 rustc_error, rustc_private, rustc_ast: Switch to stable hash containers 2022-09-10 11:49:12 +02:00
Oli Scherer ee3c835018 Always import all tracing macros for the entire crate instead of piecemeal by module 2022-09-01 14:54:27 +00:00
David Wood 510ba031dc errors: move translation logic into module
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>
2022-08-15 12:26:35 +01:00
David Wood 2eebd34cd5 errors: don't fail on broken primary translations
If a primary bundle doesn't contain a message then the fallback bundle
is used. However, if the primary bundle's message is broken (e.g. it
refers to a interpolated variable that the compiler isn't providing)
then this would just result in a compiler panic. While there aren't any
primary bundles right now, this is the type of issue that could come up
once translation is further along.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-08-10 11:48:25 +01:00
Michael Goulet 01b2379e49 Mention first and last macro in backtrace 2022-07-19 03:07:54 +00:00
David Wood 44c1fcc04d session: output-width -> diagnostic-width
Rename the `--output-width` flag to `--diagnostic-width` as this appears
to be the preferred name within the compiler team.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-06 17:43:33 +01:00
David Wood cd23af6793 session: terminal-width -> output-width
Rename the `--terminal-width` flag to `--output-width` as the behaviour
doesn't just apply to terminals (and so is slightly less accurate).

Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-06 17:38:18 +01:00
Michael Goulet 98af1bfecc Migrate some rustc_borrowck diagnostics to SessionDiagnostic 2022-06-28 22:41:56 +00:00
Maybe Waffle ffb593bf4d remove MAX_SUGGESTION_HIGHLIGHT_LINES 2022-06-20 00:25:51 +04:00
bors 0cb9899e78 Auto merge of #97892 - klensy:fix-spaces, r=oli-obk
diagnostics: remove trailing spaces

Remove few occurrences of trailing spaces and drive by fix of needless alloc of const string.
2022-06-17 17:30:16 +00:00
Maybe Waffle 3c55672795 Add back MAX_SUGGESTION_HIGHLIGHT_LINES so clippy is happy & buildable 2022-06-16 17:08:26 +04:00
Maybe Waffle cf6f821c33 Try to clean up code...
I'm not sure if I succeeded
2022-06-16 17:08:26 +04:00
Maybe Waffle 87fded1edd Improve suggestions when its parts are far from each other
Previously we only show at most 6 lines of suggestions and, if the
suggestions are more than 6 lines apart, we've just showed ... at the
end. This is probably fine, but quite confusing in my opinion.

This commit is an attempt to show ... in places where there is nothing
to suggest instead, for example:

Before:
```text
help: consider enclosing expression in a block
  |
3 ~     'l: { match () { () => break 'l,
4 |
5 |
6 |
7 |
8 |
...
```

After:
```text
help: consider enclosing expression in a block
  |
3 ~     'l: { match () { () => break 'l,
4 |
...
31|
32~ } };
  |
```
2022-06-16 17:08:26 +04:00
klensy 68ea8ff16f drive by fix needless allocation of const string number 2022-06-16 14:40:30 +03:00
klensy 989d1a732f fix one more case of trailing space 2022-06-16 14:40:29 +03:00