diff options
| author | Michael Goulet <michael@errs.io> | 2024-07-10 17:49:50 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-07-10 17:49:50 -0400 |
| commit | 898ed2ffa6c485530af1fbe6117c0deb4290715f (patch) | |
| tree | 4813396f722c85139d412395a3a9a9c05858de40 /compiler/rustc_parse/src/parser | |
| parent | 32c8bfdb11e519c6608ead730b6dfafc6cafb9c5 (diff) | |
| download | rust-898ed2ffa6c485530af1fbe6117c0deb4290715f.tar.gz rust-898ed2ffa6c485530af1fbe6117c0deb4290715f.zip | |
Enforce that ? and for<...> are not combined
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/ty.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index 306029ca94c..6de778fa9f2 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -994,6 +994,19 @@ impl<'a> Parser<'a> { let modifiers = self.parse_trait_bound_modifiers()?; let modifiers_span = modifiers_lo.to(self.prev_token.span); + if let Some(binder_span) = binder_span { + match modifiers.polarity { + BoundPolarity::Negative(polarity_span) | BoundPolarity::Maybe(polarity_span) => { + self.dcx().emit_err(errors::BinderAndPolarity { + binder_span, + polarity_span, + polarity: modifiers.polarity.as_str(), + }); + } + BoundPolarity::Positive => {} + } + } + // Recover erroneous lifetime bound with modifiers or binder. // e.g. `T: for<'a> 'a` or `T: ~const 'a`. if self.token.is_lifetime() { |
