-
Notifications
You must be signed in to change notification settings - Fork 48
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
Discuss the possibility of denying bare_trait_objects
in 2021 edition
#65
Comments
The link to "lang-team design meeting proposal" points to a 404, I assume that is not intended? |
The link in the template is broken. I've changed it to what seems most appropriate. |
@varkor I don't know if this is a good idea or not, but it's worth noting that we could make |
@joshtriplett: we could, but as the only issue is a diagnostics issue, I think it's still work stabilising on older editions. The usefulness outweighs the occasional diagnostic confusion, I feel. |
Tangentially related, it would be nice to have the option for specific traits and/or specific generic parameters "slots", not to require that
|
To me, at least, those don't seem persuasive enough to dissuade from making
|
I just ran into another place where it would be helpful for trait Foo : Bar {}
trait Bar {
fn from_integer(x: i32) -> Self;
}
fn make_it<T: Foo>() -> T {
Foo::from_integer(123)
} It currently gives a book:
It feels rather unlikely that someone wanted the trait type there, and it would be nice for name resolution to be able to find the supertrait function, like it does for methods. (And would fit well with rust-lang/rfcs#2845.) |
This looks similar to rust-lang/rust#65371 which is a hole in the implementation of |
Closing in favor of rust-lang/rust#83213, as discussed in today's planning meeting. That PR has the outcome of various discussions (and is currently in FCP). |
Summary
Bare trait objects do not interact well with const generics, as if a user does not surround a const expression with
{}
, it can be parsed as a trait object (e.g.foo + bar
is interpreted asdyn foo + bar
), which leads to confusing errors. See, for instance: rust-lang/rust#77502 (comment). If we denybare_trait_objects
in the 2021 edition, which is a permitted edition change, we can emit better errors for const generics, a feature we hope to stabilise in the form ofmin_const_generics
in the near future.bare_trait_objects
would continue to work pre-2021 edition. Thus, the better error messages will only be available in the 2021 edition.About this issue
This issue corresponds to a lang-team design meeting proposal. It corresponds
to a possible topic of discussion that may be scheduled for deeper discussion
during one of our design meetings.
The text was updated successfully, but these errors were encountered: