unhygienize the generic parameter comparison

include! completely messes up the identifiers' expansion info
This commit is contained in:
Oliver Schneider 2016-07-22 14:09:14 +02:00
parent 1831b471f9
commit f05ba9fdf2
No known key found for this signature in database
GPG Key ID: 56D6EEA0FC67AC46

View File

@ -71,16 +71,16 @@ pub fn with_bound<F>(
struct FindTyParams {
// Set of all generic type parameters on the current struct (A, B, C in
// the example). Initialized up front.
all_ty_params: HashSet<ast::Ident>,
all_ty_params: HashSet<ast::Name>,
// Set of generic type parameters used in fields for which filter
// returns true (A and B in the example). Filled in as the visitor sees
// them.
relevant_ty_params: HashSet<ast::Ident>,
relevant_ty_params: HashSet<ast::Name>,
}
impl visit::Visitor for FindTyParams {
fn visit_path(&mut self, path: &ast::Path, _id: ast::NodeId) {
if !path.global && path.segments.len() == 1 {
let id = path.segments[0].identifier;
let id = path.segments[0].identifier.name;
if self.all_ty_params.contains(&id) {
self.relevant_ty_params.insert(id);
}
@ -90,7 +90,7 @@ pub fn with_bound<F>(
}
let all_ty_params: HashSet<_> = generics.ty_params.iter()
.map(|ty_param| ty_param.ident)
.map(|ty_param| ty_param.ident.name)
.collect();
let relevant_tys = item.body.all_fields()
@ -108,7 +108,7 @@ pub fn with_bound<F>(
builder.from_generics(generics.clone())
.with_predicates(
generics.ty_params.iter()
.map(|ty_param| ty_param.ident)
.map(|ty_param| ty_param.ident.name)
.filter(|id| visitor.relevant_ty_params.contains(id))
.map(|id| builder.where_predicate()
// the type parameter that is being bounded e.g. T