Skip to content
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

Feature Requestion: Improved visualization of missing permission errors #35

Open
xldenis opened this issue Feb 19, 2023 · 2 comments
Open

Comments

@xldenis
Copy link

xldenis commented Feb 19, 2023

First, thanks for working on and releasing Aquascope, I think it's going to have a massive impact on Rust pedagogy.

I was trying it out to see if it could help my students understand one of their most common errors where they attempt to return a mutable reference from an immutable one, and while the information is technically displayed it's not necessarily easy to understand it.

Here's the test program I used:

fn omg<T>(x : & T) -> &mut T {
  &mut x
}

fn main() {
  omg(&mut 5);
}

Aquascope shows (also has a trace which is uninformative here):

image

The permissions show that *x only has +R, but there's no display showing we want a &mut T (and thus need +R +W +O).
Perhaps one of those permissions boxes could be shown for the result when there's a borrow check error?

@gavinleroy
Copy link
Collaborator

Thank you for trying out the tool, we hope your students find it useful!

If I understand your request correctly, it can be summed up as: "in the function omg we can see that *x gains read permission, but there isn't something that directly says we need write permission".

I would argue that this feature is available. In the following screenshot, I've hovered over those two colored dots on line 2 to the left of x.

feature-request-omg-reply

This represents a permission expectation, saying that in order to take a unique reference, we need both read and write permissions. However, the blue W is hollow showing that this permission is missing. Thus symbolizing a permission violation, in this case, promoting a shared reference to a unique reference.

If you're demonstrating this with the online playground, at the moment you'd have to hover the cursor over the dots to expand them to the appropriate characters (they are also color-coded). If you tried your hand at embedding this into mdBook, you can make the characters expanded by default with a `{boundaries}` annotation on line 2. Which combined would look like this:


```aquascope,interpreter+permissions,boundaries,stepper,shouldFail
fn omg(x : & T) -> &mut T {
  &mut x `{boundaries}`
}

fn main() {
  omg(&mut 5);
}```

Note that we don't currently guarantee any stability on the mdBook interface.

Please let us know if this still doesn't capture the feature you're looking for.

@xldenis
Copy link
Author

xldenis commented Feb 19, 2023

Oh I didn't think of doing that, it's not obvious from the interface alone that there is an error, perhaps this info could be highlighted or otherwise identified to show that there's an error?

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

No branches or pull requests

3 participants