Address review.
This commit is contained in:
parent
4e3953bbdd
commit
8b4d852f32
6 changed files with 16 additions and 75 deletions
|
@ -248,15 +248,15 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
// Auto traits cannot have generics, super traits nor contain items.
|
||||
if generics.is_parameterized() {
|
||||
struct_span_err!(self.session, item.span, E0567,
|
||||
"Auto traits cannot have generic parameters").emit();
|
||||
"auto traits cannot have generic parameters").emit();
|
||||
}
|
||||
if !bounds.is_empty() {
|
||||
struct_span_err!(self.session, item.span, E0568,
|
||||
"Auto traits cannot have predicates").emit();
|
||||
"auto traits cannot have super traits").emit();
|
||||
}
|
||||
if !trait_items.is_empty() {
|
||||
struct_span_err!(self.session, item.span, E0380,
|
||||
"Auto traits cannot have methods or associated items").emit();
|
||||
"auto traits cannot have methods or associated items").emit();
|
||||
}
|
||||
}
|
||||
self.no_questions_in_bounds(bounds, "supertraits", true);
|
||||
|
|
|
@ -271,7 +271,7 @@ register_diagnostics! {
|
|||
E0226, // only a single explicit lifetime bound is permitted
|
||||
E0472, // asm! is unsupported on this target
|
||||
E0561, // patterns aren't allowed in function pointer types
|
||||
E0567, // auto traits can not have type parameters
|
||||
E0568, // auto traits can not have predicates
|
||||
E0567, // auto traits can not have generic parameters
|
||||
E0568, // auto traits can not have super traits
|
||||
E0642, // patterns aren't allowed in methods without bodies
|
||||
}
|
||||
|
|
|
@ -714,7 +714,7 @@ fn trait_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
|
||||
let (is_auto, unsafety) = match item.node {
|
||||
hir::ItemTrait(is_auto, unsafety, ..) => (is_auto == hir::IsAuto::Yes, unsafety),
|
||||
hir::ItemTraitAlias(..) => (hir::IsAuto::No, hir::Unsafety::Normal),
|
||||
hir::ItemTraitAlias(..) => (false, hir::Unsafety::Normal),
|
||||
_ => span_bug!(item.span, "trait_def_of_item invoked on non-trait"),
|
||||
};
|
||||
|
||||
|
@ -1714,54 +1714,3 @@ fn is_foreign_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
_ => bug!("is_foreign_item applied to non-local def-id {:?}", def_id)
|
||||
}
|
||||
}
|
||||
|
||||
struct ImplTraitUniversalInfo<'hir> {
|
||||
id: ast::NodeId,
|
||||
def_id: DefId,
|
||||
span: Span,
|
||||
bounds: &'hir [hir::TyParamBound],
|
||||
}
|
||||
|
||||
/// Take some possible list of arguments and return the DefIds of the ImplTraitUniversal
|
||||
/// arguments
|
||||
fn extract_universal_impl_trait_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
opt_inputs: Option<&'tcx [P<hir::Ty>]>)
|
||||
-> Vec<ImplTraitUniversalInfo<'tcx>>
|
||||
{
|
||||
// A visitor for simply collecting Universally quantified impl Trait arguments
|
||||
struct ImplTraitUniversalVisitor<'tcx> {
|
||||
items: Vec<&'tcx hir::Ty>
|
||||
}
|
||||
|
||||
impl<'tcx> Visitor<'tcx> for ImplTraitUniversalVisitor<'tcx> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
|
||||
if let hir::TyImplTraitUniversal(..) = ty.node {
|
||||
self.items.push(ty);
|
||||
}
|
||||
intravisit::walk_ty(self, ty);
|
||||
}
|
||||
}
|
||||
|
||||
let mut visitor = ImplTraitUniversalVisitor { items: Vec::new() };
|
||||
|
||||
if let Some(inputs) = opt_inputs {
|
||||
for t in inputs.iter() {
|
||||
visitor.visit_ty(t);
|
||||
}
|
||||
}
|
||||
|
||||
visitor.items.into_iter().map(|ty| if let hir::TyImplTraitUniversal(_, ref bounds) = ty.node {
|
||||
ImplTraitUniversalInfo {
|
||||
id: ty.id,
|
||||
def_id: tcx.hir.local_def_id(ty.id),
|
||||
span: ty.span,
|
||||
bounds: bounds
|
||||
}
|
||||
} else {
|
||||
span_bug!(ty.span, "this type should be a universally quantified impl trait. this is a bug")
|
||||
}).collect()
|
||||
}
|
||||
|
|
|
@ -6370,8 +6370,8 @@ impl<'a> Parser<'a> {
|
|||
let is_auto = if self.eat_keyword(keywords::Trait) {
|
||||
IsAuto::No
|
||||
} else {
|
||||
self.eat_keyword(keywords::Auto);
|
||||
self.eat_keyword(keywords::Trait);
|
||||
self.expect_keyword(keywords::Auto)?;
|
||||
self.expect_keyword(keywords::Trait)?;
|
||||
IsAuto::Yes
|
||||
};
|
||||
let (ident, item_, extra_attrs) =
|
||||
|
@ -6485,8 +6485,8 @@ impl<'a> Parser<'a> {
|
|||
let is_auto = if self.eat_keyword(keywords::Trait) {
|
||||
IsAuto::No
|
||||
} else {
|
||||
self.eat_keyword(keywords::Auto);
|
||||
self.eat_keyword(keywords::Trait);
|
||||
self.expect_keyword(keywords::Auto)?;
|
||||
self.expect_keyword(keywords::Trait)?;
|
||||
IsAuto::Yes
|
||||
};
|
||||
// TRAIT ITEM
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
#![feature(optin_builtin_traits)]
|
||||
|
||||
auto trait Generic<T> {}
|
||||
//~^ Auto traits cannot have type parameters [E0567]
|
||||
//~^ auto traits cannot have generic parameters [E0567]
|
||||
auto trait Bound : Copy {}
|
||||
//~^ Auto traits cannot have predicates [E0568]
|
||||
//~^ auto traits cannot have super traits [E0568]
|
||||
auto trait MyTrait { fn foo() {} }
|
||||
//~^ Auto traits cannot have methods or associated items [E0380]
|
||||
//~^ auto traits cannot have methods or associated items [E0380]
|
||||
fn main() {}
|
||||
|
|
|
@ -6,21 +6,13 @@ error: auto traits are experimental and possibly buggy (see issue #13231)
|
|||
|
|
||||
= help: add #![feature(optin_builtin_traits)] to the crate attributes to enable
|
||||
|
||||
error: auto trait implementations are experimental and possibly buggy (see issue #13231)
|
||||
--> $DIR/feature-gate-optin-builtin-traits.rs:24:1
|
||||
|
|
||||
24 | impl DummyTrait for .. {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(optin_builtin_traits)] to the crate attributes to enable
|
||||
|
||||
error: negative trait bounds are not yet fully implemented; use marker types for now (see issue #13231)
|
||||
--> $DIR/feature-gate-optin-builtin-traits.rs:27:1
|
||||
--> $DIR/feature-gate-optin-builtin-traits.rs:23:1
|
||||
|
|
||||
27 | impl !DummyTrait for DummyStruct {}
|
||||
23 | impl !DummyTrait for DummyStruct {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(optin_builtin_traits)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue