Skip to content

Conversation

@veber-alex
Copy link
Contributor

@veber-alex veber-alex commented Dec 27, 2022

fixes #13823 by adding a vscode setting that will keeping the existing diagnostic code and use it as a link to the full compiler error message.
While I was there I also fixed index to fallback to rendered.length to make the previewRustcOutput feature work.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 27, 2022
@veber-alex veber-alex changed the title Fix diagnostic code Use diagnostic code as link to full message Dec 27, 2022
@Veykril
Copy link
Member

Veykril commented Dec 30, 2022

I'd like to have this message be the default for discoverability purposes. Overall this feature is a hack to get around VSCode's terrible diagnostic UX. So if we could make this a VSCode specific setting that would be the best option right now I think.

@veber-alex
Copy link
Contributor Author

I added a setting to control the behavior.

if (preview) {
const index = rendered.match(/^(note|help):/m)?.index || 0;
const index =
rendered.match(/^ = (note|help):/m)?.index || rendered.length;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why exactly was this changed? The regex is meant to stop at the first note:/help: section, there is no = in front of those

Copy link
Contributor Author

@veber-alex veber-alex Jan 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, can you give an example of what are you trying to filter out?
I though it was this lines:

error[E0308]: mismatched types
 --> src/main.rs:3:9
  |
2 |     let x = 1;
  |             - expected due to this value
3 |     x = vec![1];
  |         ^^^^^^^ expected integer, found struct `Vec`
  |
  = note: expected type `{integer}`
           found struct `Vec<{integer}>`
  = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)

which have = in front (and 2 spaces).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error[E0038]: the trait `X` cannot be made into an object
 --> src\main.rs:2:12
  |
2 |     let _: Box<dyn X>;
  |            ^^^^^^^^^^ `X` cannot be made into an object
  |
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
 --> src\main.rs:6:8
  |
5 | trait X {
  |       - this trait cannot be made into an object...
6 |     fn foo() -> Self;
  |        ^^^ ...because associated function `foo` has no `self` parameter
help: consider turning `foo` into a method by giving it a `&self` argument
  |
6 |     fn foo(&self) -> Self;
  |            +++++
help: alternatively, consider constraining `foo` so it does not apply to trait objects
  |
6 |     fn foo() -> Self where Self: Sized;
  |                      +++++++++++++++++


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks,
I changed the regex back.

@Veykril
Copy link
Member

Veykril commented Jan 3, 2023

Thanks!
@bors r+

@bors
Copy link
Contributor

bors commented Jan 3, 2023

📌 Commit ddc0147 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jan 3, 2023

⌛ Testing commit ddc0147 with merge 50801b7...

@bors
Copy link
Contributor

bors commented Jan 3, 2023

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 50801b7 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"click for full compiler diagnostic" sets all errors codes to "rustc(click for full compiler diagnostic)"

4 participants