pre-expansion gate trait_alias.
This commit is contained in:
parent
2e64bb2d37
commit
2d182b82ce
5 changed files with 24 additions and 10 deletions
|
@ -423,15 +423,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
|||
"auto traits are experimental and possibly buggy");
|
||||
}
|
||||
|
||||
ast::ItemKind::TraitAlias(..) => {
|
||||
gate_feature_post!(
|
||||
&self,
|
||||
trait_alias,
|
||||
i.span,
|
||||
"trait aliases are experimental"
|
||||
);
|
||||
}
|
||||
|
||||
ast::ItemKind::MacroDef(ast::MacroDef { legacy: false, .. }) => {
|
||||
let msg = "`macro` is experimental";
|
||||
gate_feature_post!(&self, decl_macro, i.span, msg);
|
||||
|
@ -867,6 +858,7 @@ pub fn check_crate(krate: &ast::Crate,
|
|||
gate_all!(yields, generators, "yield syntax is experimental");
|
||||
gate_all!(or_patterns, "or-patterns syntax is experimental");
|
||||
gate_all!(const_extern_fn, "`const extern fn` definitions are unstable");
|
||||
gate_all!(trait_alias, "trait aliases are experimental");
|
||||
|
||||
visit::walk_crate(&mut visitor, krate);
|
||||
}
|
||||
|
|
|
@ -828,6 +828,8 @@ impl<'a> Parser<'a> {
|
|||
.emit();
|
||||
}
|
||||
|
||||
self.sess.gated_spans.trait_alias.borrow_mut().push(whole_span);
|
||||
|
||||
Ok((ident, ItemKind::TraitAlias(tps, bounds), None))
|
||||
} else {
|
||||
// It's a normal trait.
|
||||
|
|
|
@ -30,6 +30,8 @@ crate struct GatedSpans {
|
|||
crate or_patterns: Lock<Vec<Span>>,
|
||||
/// Spans collected for gating `const_extern_fn`, e.g. `const extern fn foo`.
|
||||
crate const_extern_fn: Lock<Vec<Span>>,
|
||||
/// Spans collected for gating `trait_alias`, e.g. `trait Foo = Ord + Eq;`.
|
||||
pub trait_alias: Lock<Vec<Span>>,
|
||||
}
|
||||
|
||||
/// Info about a parsing session.
|
||||
|
|
|
@ -1,4 +1,13 @@
|
|||
trait Foo = Default;
|
||||
//~^ ERROR trait aliases are experimental
|
||||
|
||||
macro_rules! accept_item {
|
||||
($i:item) => {}
|
||||
}
|
||||
|
||||
accept_item! {
|
||||
trait Foo = Ord + Eq;
|
||||
//~^ ERROR trait aliases are experimental
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -7,6 +7,15 @@ LL | trait Foo = Default;
|
|||
= note: for more information, see https://github.com/rust-lang/rust/issues/41517
|
||||
= help: add `#![feature(trait_alias)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
error[E0658]: trait aliases are experimental
|
||||
--> $DIR/feature-gate-trait-alias.rs:9:5
|
||||
|
|
||||
LL | trait Foo = Ord + Eq;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: for more information, see https://github.com/rust-lang/rust/issues/41517
|
||||
= help: add `#![feature(trait_alias)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue