Implment #[cfg]
and #[cfg_attr]
in where
clauses
This commit is contained in:
parent
30508faeb3
commit
42f51d4fd4
38 changed files with 3296 additions and 88 deletions
|
@ -300,13 +300,16 @@ pub(crate) fn expand_deriving_coerce_pointee(
|
|||
to_ty: &s_ty,
|
||||
rewritten: false,
|
||||
};
|
||||
let mut predicate = ast::WherePredicate {
|
||||
kind: ast::WherePredicateKind::BoundPredicate(bound.clone()),
|
||||
span: predicate.span,
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
};
|
||||
substitution.visit_where_predicate(&mut predicate);
|
||||
let mut kind = ast::WherePredicateKind::BoundPredicate(bound.clone());
|
||||
substitution.visit_where_predicate_kind(&mut kind);
|
||||
if substitution.rewritten {
|
||||
let predicate = ast::WherePredicate {
|
||||
attrs: predicate.attrs.clone(),
|
||||
kind,
|
||||
span: predicate.span,
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
is_placeholder: false,
|
||||
};
|
||||
impl_generics.where_clause.predicates.push(predicate);
|
||||
}
|
||||
}
|
||||
|
@ -388,8 +391,8 @@ impl<'a> ast::mut_visit::MutVisitor for TypeSubstitution<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn visit_where_predicate(&mut self, where_predicate: &mut ast::WherePredicate) {
|
||||
match &mut where_predicate.kind {
|
||||
fn visit_where_predicate_kind(&mut self, kind: &mut ast::WherePredicateKind) {
|
||||
match kind {
|
||||
rustc_ast::WherePredicateKind::BoundPredicate(bound) => {
|
||||
bound
|
||||
.bound_generic_params
|
||||
|
|
|
@ -687,9 +687,11 @@ impl<'a> TraitDef<'a> {
|
|||
// and similarly for where clauses
|
||||
where_clause.predicates.extend(generics.where_clause.predicates.iter().map(|clause| {
|
||||
ast::WherePredicate {
|
||||
attrs: clause.attrs.clone(),
|
||||
kind: clause.kind.clone(),
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
span: clause.span.with_ctxt(ctxt),
|
||||
is_placeholder: false,
|
||||
}
|
||||
}));
|
||||
|
||||
|
@ -744,8 +746,13 @@ impl<'a> TraitDef<'a> {
|
|||
};
|
||||
|
||||
let kind = ast::WherePredicateKind::BoundPredicate(predicate);
|
||||
let predicate =
|
||||
ast::WherePredicate { kind, id: ast::DUMMY_NODE_ID, span: self.span };
|
||||
let predicate = ast::WherePredicate {
|
||||
attrs: ThinVec::new(),
|
||||
kind,
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
span: self.span,
|
||||
is_placeholder: false,
|
||||
};
|
||||
where_clause.predicates.push(predicate);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue