-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: parsing of ?
opt-out trait bounds
#12444
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
Conversation
} else if p.at(T![for]) { | ||
// test question_for_type_trait_bound | ||
// fn f<T>() where T: ?for<> Sized {} | ||
types::for_type(p, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this also allows fn f<T>() where T: ~const for<> Sized {}
.
One question: does our parser need to be 100% equivalent to rustc's? Or do we just need to make sure that those that can be parsed by rustc can be parsed by ra. For those syntaxes that can be parsed by ra but not by rustc, flycheck
should be able to help us diagnose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to be as independent from flycheck
as possible so we should reject this ideally yes, given that ~const
is unstable atm I don't think this would be too bad, but I also don't think doing it proper here should be too difficult
@Veykril Now I think the side effects have been eliminated but some duplicate code was introduced, if there is a better way to do this, please let me know. |
T![?] => { | ||
p.bump_any(); | ||
if p.at(T![for]) { | ||
// test question_for_type_trait_bound | ||
// fn f<T>() where T: ?for<> Sized {} | ||
types::for_type(p, false) | ||
} else if paths::is_use_path_start(p) { | ||
types::path_type_(p, false); | ||
} else { | ||
m.abandon(p); | ||
return false; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do the following here
T![?] => { | |
p.bump_any(); | |
if p.at(T![for]) { | |
// test question_for_type_trait_bound | |
// fn f<T>() where T: ?for<> Sized {} | |
types::for_type(p, false) | |
} else if paths::is_use_path_start(p) { | |
types::path_type_(p, false); | |
} else { | |
m.abandon(p); | |
return false; | |
} | |
} | |
// test question_for_type_trait_bound | |
// fn f<T>() where T: ?for<> Sized {} | |
T![?] if p.nth_at(1, T![for]) => { | |
p.bump_any(); | |
types::for_type(p, false) | |
} |
and keep the T![?]
match arm on line 138 as is I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better, thanks!
thanks to Veykril
Thanks! |
📌 Commit df67bbd has been approved by |
☀️ Test successful - checks-actions |
fixes #12442