-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Possibly incorrect syntax Enum::<Type, Params>::Variant
allowed since 1.33
#69356
Comments
Not anymore, it was never "correct", it was at best a historical accident. Looks like the |
centril@centrilnas2:~/programming/rust/rust-gamma$ rustc +nightly foo.rs -Z unpretty=hir
#[prelude_import]
use ::std::prelude::v1::*;
#[macro_use]
extern crate std;
pub enum Foo<'a, T> {
Struct {
},
Tuple(),
Unit,
Usage(&'a T),
}
pub fn main() {
let foo = Foo::Unit::<String>;
let foo = Foo::Tuple::<String>();
let foo = Foo::Struct::<, String>{};
} |
Note the So HIR lowering is treating |
Answering my own questions based on the conversations on discord. All of the following should be allowed: pub enum Foo<'a, T> {
Struct {},
Tuple(),
Unit,
Usage(&'a T),
}
pub fn main() {
let foo = Foo::<String>::Unit;
let foo = Foo::<String>::Tuple();
let foo = Foo::<String>::Struct {};
let foo = Foo::Unit::<String>;
let foo = Foo::Tuple::<String>();
let foo = Foo::Struct::<String> {};
} Based on #69363 fixes this ticket. |
[triagebot] The discussion is continued on the PR (#69363), which is currently assigned to me. |
A coworker recently identified the following case:
This used to fail because of the lack of implicit bound
T: 'a
:After fixing that, it complains about the type params:
Starting in 1.33, all but the
Struct
path are accepted:The correct code for this would of course be:
My questions:
Depending on the answer to those questions, the solution to this ticket could be:
let foo = Foo::Struct::<String> {};
casecc @Centril
The text was updated successfully, but these errors were encountered: