Skip to content

Commit fe40804

Browse files
committed
allow ?Trait bounds in auto traits
1 parent 0531eb5 commit fe40804

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/librustc_passes/ast_validation.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,20 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
235235
"auto traits cannot have generics");
236236
}
237237
if !bounds.is_empty() {
238-
self.err_handler().span_err(item.span,
239-
"auto traits cannot have super traits");
238+
let all_bounds_are_maybe = bounds.iter()
239+
.all(|bound| {
240+
match *bound {
241+
TraitTyParamBound(_, TraitBoundModifier::Maybe) => true,
242+
_ => false
243+
}
244+
});
245+
246+
// allow `?DynSized` bound, since the `DynSized` bound is implicit
247+
// for traits
248+
if !all_bounds_are_maybe {
249+
self.err_handler().span_err(item.span,
250+
"auto traits cannot have super traits");
251+
}
240252
}
241253
if !trait_items.is_empty() {
242254
self.err_handler().span_err(item.span,

0 commit comments

Comments
 (0)