Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bounds parsing refactoring 2 #39158

Merged
merged 5 commits into from
Jan 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/librustc_passes/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
TyKind::TraitObject(ref bounds) => {
self.no_questions_in_bounds(bounds, "trait object types", false);
}
TyKind::ImplTrait(ref bounds) => {
if !bounds.iter()
.any(|b| if let TraitTyParamBound(..) = *b { true } else { false }) {
self.err_handler().span_err(ty.span, "at least one trait must be specified");
}
}
_ => {}
}

Expand Down Expand Up @@ -284,6 +290,26 @@ impl<'a> Visitor<'a> for AstValidator<'a> {

visit::walk_vis(self, vis)
}

fn visit_generics(&mut self, g: &'a Generics) {
let mut seen_default = None;
for ty_param in &g.ty_params {
if ty_param.default.is_some() {
seen_default = Some(ty_param.span);
} else if let Some(span) = seen_default {
self.err_handler()
.span_err(span, "type parameters with a default must be trailing");
break
}
}
for predicate in &g.where_clause.predicates {
if let WherePredicate::EqPredicate(ref predicate) = *predicate {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh, we should really remove this variant from the compiler (and parser)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be clear, not as part of this PR =)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no plans to implement this?
Then #20041 should be officially closed or something before removing WherePredicate::EqPredicate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, eventually perhaps, but at the moment there are some theoretical limitations that I do not yet know how to overcome. I would say "we may implement it eventually, but in that case we can add that stuff back in to the compiler".

self.err_handler().span_err(predicate.span, "equality constraints are not yet \
supported in where clauses (#20041)");
}
}
visit::walk_generics(self, g)
}
}

pub fn check_crate(session: &Session, krate: &Crate) {
Expand Down
5 changes: 1 addition & 4 deletions src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1833,11 +1833,8 @@ fn ty_generic_predicates<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
}
}

&hir::WherePredicate::EqPredicate(ref eq_pred) => {
&hir::WherePredicate::EqPredicate(..) => {
// FIXME(#20041)
span_bug!(eq_pred.span,
"Equality constraints are not yet \
implemented (#20041)")
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,11 @@ impl Clean<WherePredicate> for hir::WherePredicate {
}
}

hir::WherePredicate::EqPredicate(_) => {
unimplemented!() // FIXME(#20041)
hir::WherePredicate::EqPredicate(ref wrp) => {
WherePredicate::EqPredicate {
lhs: wrp.lhs_ty.clean(cx),
rhs: wrp.rhs_ty.clean(cx)
}
}
}
}
Expand Down
Loading