1
Fork 0

Rollup merge of #116393 - compiler-errors:auto-bad, r=WaffleLapkin

Emit feature gate *warning* for `auto` traits pre-expansion

Auto traits were introduced before we were more careful about not stabilizing new syntax pre-expansion.

This is a more conservative step in the general direction we want to go in https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Removal.20of.20.60auto.20trait.60.20syntax.

Fixes #116121
This commit is contained in:
Matthias Krüger 2023-10-04 05:02:07 +02:00 committed by GitHub
commit 4ed2291624
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 1 deletions

View file

@ -813,7 +813,12 @@ impl<'a> Parser<'a> {
fn parse_item_trait(&mut self, attrs: &mut AttrVec, lo: Span) -> PResult<'a, ItemInfo> {
let unsafety = self.parse_unsafety(Case::Sensitive);
// Parse optional `auto` prefix.
let is_auto = if self.eat_keyword(kw::Auto) { IsAuto::Yes } else { IsAuto::No };
let is_auto = if self.eat_keyword(kw::Auto) {
self.sess.gated_spans.gate(sym::auto_traits, self.prev_token.span);
IsAuto::Yes
} else {
IsAuto::No
};
self.expect_keyword(kw::Trait)?;
let ident = self.parse_ident()?;