Skip to content

Conversation

@saethlin
Copy link
Member

Currently, we get diagnostics that look like this:

error: Undefined Behavior: no item granting read access to tag <untagged> at alloc994 found in borrow stack.
 --> src/main.rs:5:23
  |
5 |     unsafe { let _z = *y; }
  |                       ^^ no item granting read access to tag <untagged> at alloc994 found in borrow stack.
  |
  = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental
  = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
          
  = note: inside `main` at src/main.rs:5:23

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to previous error

This line:

  = note: inside `main` at src/main.rs:5:23

is the trimmed backtrace. But when there's only one frame, we don't need it at all. This PR removes it, along with its extra newline.

We could also always skip the first element of the stacktrace (because we always print a span for it). Should we?

@RalfJung
Copy link
Member

There's nothing fundamentally different about 1-frame stack traces so I don't think we should special-case them.

However, it is true that our backtrace is a bit odd... the reason we print the first frame at all is that it contains one bit of information that is not otherwise present: the name of the function the error occurred in. It didn't seem right to name all functions except for the one with the error, so that's why I made it print that span again.

@saethlin
Copy link
Member Author

Ah. So what I want here is to fold the function name of the topmost frame into the --> src/main.rs:5:23, but I don't think that is possible with the current API. grumble grumble

@RalfJung
Copy link
Member

Yeah that would indeed be best.

Any other ideas? :D

@bors
Copy link
Contributor

bors commented Mar 17, 2022

☔ The latest upstream changes (presumably #1971) made this pull request unmergeable. Please resolve the merge conflicts.

@RalfJung RalfJung added the S-waiting-on-author Status: Waiting for the PR author to address review comments label Mar 17, 2022
@saethlin
Copy link
Member Author

I asked the diagnostics people about this on Zulip and Esteban said the only real option here is to mash the file name into the diagnostic text. Gah. I'll just quietly be bothered by this. Perhaps when Span starts to know about the function it is in there will be some helpful changes on the rustc side.

@saethlin saethlin closed this Mar 26, 2022
@saethlin saethlin deleted the ignore-redundant-stack-frame branch May 15, 2022 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: Waiting for the PR author to address review comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants