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

Unhelpful errors for unintended use of box (...) ... syntax #14085

Closed
huonw opened this issue May 10, 2014 · 3 comments
Closed

Unhelpful errors for unintended use of box (...) ... syntax #14085

huonw opened this issue May 10, 2014 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@huonw
Copy link
Member

huonw commented May 10, 2014

fn main() {
    box (1 + 2) * 3;

    // box (1.0 + 2.0).sqrt()
}

with just the first:

boxerror.rs:2:17: 2:20 error: type `<generic integer #2>` cannot be dereferenced
boxerror.rs:2     box (1 + 2) * 3;
                              ^~~
boxerror.rs:2:5: 2:20 error: only the managed heap and exchange heap are currently supported
boxerror.rs:2     box (1 + 2) * 3;
                  ^~~~~~~~~~~~~~~

with the second uncommented it's a parse error:

boxerror.rs:4:20: 4:21 error: unexpected token: `.`
boxerror.rs:4     box (1.0 + 2.0).sqrt()
                                 ^

The (...) is interpreted as the allocator/placement part of the box expression, rather than just part of the value to be boxed. It would be nice to suggest something like "if you wish to use the default box write box () ...;".

(Also, "amusingly", the code as written above hits #14084)

@frewsxcv
Copy link
Member

frewsxcv commented Feb 3, 2015

visiting for triage

I don't know what the end-game plan is for the box keyword, so this is probably still a valid issue. Even with opting-in to other box syntax, the error is still there:

/t/triage $ cat foo.rs
#![feature(box_syntax)]

fn main() {
    box (1 + 2) * 3;

    //box (1.0 + 2.0).sqrt()
}
/t/triage $ rustc foo.rs
foo.rs:4:17: 4:20 error: type `_` cannot be dereferenced
foo.rs:4     box (1 + 2) * 3;
                         ^~~
foo.rs:4:5: 4:20 error: only the managed heap and exchange heap are currently supported [E0066]
foo.rs:4     box (1 + 2) * 3;
             ^~~~~~~~~~~~~~~
error: aborting due to 2 previous errors
/t/triage $ cat foo.rs
#![feature(box_syntax)]

fn main() {
    //box (1 + 2) * 3;

    box (1.0 + 2.0).sqrt()
}
/t/triage $ rustc foo.rs
foo.rs:6:20: 6:21 error: expected expression, found `.`
foo.rs:6     box (1.0 + 2.0).sqrt()
                            ^
foo.rs:6:5: 6:20 help: perhaps you meant `box() (foo)` instead?
foo.rs:6     box (1.0 + 2.0).sqrt()
             ^~~~~~~~~~~~~~~
error: aborting due to previous error

Error messages are slightly different though

@pnkfelix
Copy link
Member

cc #22181

I think this problem will just go away with migration away from placement-box and towards placement-in.

@huonw
Copy link
Member Author

huonw commented Jan 5, 2016

Box syntax has changed so this is irrelevant, closing.

@huonw huonw closed this as completed Jan 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

3 participants