mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-05-01 04:18:02 +00:00
unhygienize the generic parameter comparison
include! completely messes up the identifiers' expansion info
This commit is contained in:
@@ -71,16 +71,16 @@ pub fn with_bound<F>(
|
|||||||
struct FindTyParams {
|
struct FindTyParams {
|
||||||
// Set of all generic type parameters on the current struct (A, B, C in
|
// Set of all generic type parameters on the current struct (A, B, C in
|
||||||
// the example). Initialized up front.
|
// 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
|
// 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
|
// returns true (A and B in the example). Filled in as the visitor sees
|
||||||
// them.
|
// them.
|
||||||
relevant_ty_params: HashSet<ast::Ident>,
|
relevant_ty_params: HashSet<ast::Name>,
|
||||||
}
|
}
|
||||||
impl visit::Visitor for FindTyParams {
|
impl visit::Visitor for FindTyParams {
|
||||||
fn visit_path(&mut self, path: &ast::Path, _id: ast::NodeId) {
|
fn visit_path(&mut self, path: &ast::Path, _id: ast::NodeId) {
|
||||||
if !path.global && path.segments.len() == 1 {
|
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) {
|
if self.all_ty_params.contains(&id) {
|
||||||
self.relevant_ty_params.insert(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()
|
let all_ty_params: HashSet<_> = generics.ty_params.iter()
|
||||||
.map(|ty_param| ty_param.ident)
|
.map(|ty_param| ty_param.ident.name)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let relevant_tys = item.body.all_fields()
|
let relevant_tys = item.body.all_fields()
|
||||||
@@ -108,7 +108,7 @@ pub fn with_bound<F>(
|
|||||||
builder.from_generics(generics.clone())
|
builder.from_generics(generics.clone())
|
||||||
.with_predicates(
|
.with_predicates(
|
||||||
generics.ty_params.iter()
|
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))
|
.filter(|id| visitor.relevant_ty_params.contains(id))
|
||||||
.map(|id| builder.where_predicate()
|
.map(|id| builder.where_predicate()
|
||||||
// the type parameter that is being bounded e.g. T
|
// the type parameter that is being bounded e.g. T
|
||||||
|
|||||||
Reference in New Issue
Block a user