-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
slightly improve protector-related error messages #2513
Conversation
I'm imagining someone updating their toolchain, looking at this new error and thinking "What does it mean to activate a tag? Is that a new thing in Stacked Borrows?" and I'm coming up empty-handed for where they could look to figure out what "activate" means. I can't find it in the implementation, or in the markdown file that we link in error messages. So I'd prefer that our documentation somewhere be spruced up to at least mention the word in the way that you are using it, or that we word things a bit differently to avoid this sentence construction. Instead of " cannot be activated" perhaps "access through cannot be permitted"? |
Yeah, that's fair, we never explain what 'activate' means... I have changed it to "cannot be used for memory access". Is "derived" an okay term to use? |
I think that "derived" is okay. It's at least mentioned in the markdown documentation that we link to in a sentence that helps explain what it means, and LLVM uses it occasionally. But
I'm not sure what the "derived' is adding here? It seems to beg the question, "derived from what?" |
Derived from the tag that we cannot use for the memory access. I updated the text and the example message in the OP. |
and now I'm even more confused by the "transitively derived from" statement. How can tag 3093 be derived from 3094, if it was created first? |
Ah, I screwed up the direction... |
Ah no wait. The direction is right in the message in the OP. Hm... |
Hm yeah I don't think there is in general a "derived from" relationship between these tags... good catch! |
There is still something odd about the error though, and it comes from somewhere in the diagnostic logic you implemented -- the error says |
I don't understand the |
Protectors get introduced upon function entry, which is a point at which we retag, so there are two important tags in play. The tag for the argument itself inside the function is the tag that we aren't allowed to remove. In some sense it is just how we know there is a problem. For diagnostics, I want to tell the user about which pointer they passed to the function which is being protected, and that's why we store an |
Oh, so there are three tags you want to show here -- tag used for access, protected tag, parent of protected tag. Honestly that seems a bit too confusing for me? Certainly omitting the actually protected tag, as the messages do now, is very confusing. The actually protected tag should usually be derived from the accessing tag, that's why it is further up the stack, but it would also be derived from a sibling of the accessing tag. The parent of the protected tag can have basically arbitrary relationship to the accessing tag.
Yeah, the span for these fn_entry retags should be made to point at the argument they are retagging from. |
Here is how
|
Oh wait you actually went one further in the chain... why that? You printed |
There's even a |
Yeah I wrote that about 4 years ago.^^ But meanwhile, what about this PR? I think it is an improvement, but I don't understand why you were displaying the grandparent of the protected tag. |
Frankly at this stage I don't either (it's possible this was just a mistake or me not understanding protectors), and the adjustment you made to that diagnostic looks like a big improvement to me. |
Also you renamed some but not all of the test which mention |
also rename some tests that still used outdated "barrier" terminology
Good catch, fixed. |
Looking over this again, I think this change is good to go. I think that when rust-lang/rust#101111 becomes available we will be able to replace at least the last span, because the better FnEntry retag spans are a much better way to tell the user which argument was protected. @bors r+ |
☀️ Test successful - checks-actions |
👍 the tests will also need re-blessing then. |
I find the current retag messages confusing, since they sound like the item was protected, when it still actively is protected (and that is, in fact, the issue).
Example error message:
r? @saethlin