1
Fork 0

Rollup merge of #132388 - frank-king:feature/where-cfg, r=petrochenkov

Implement `#[cfg]` in `where` clauses

This PR implements #115590, which supports `#[cfg]` attributes in `where` clauses.

The biggest change is, that it adds `AttrsVec` and  `NodeId` to the `ast::WherePredicate` and `HirId` to the `hir::WherePredicate`.
This commit is contained in:
Matthias Krüger 2025-03-03 10:40:56 +01:00 committed by GitHub
commit 2344a34241
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 3296 additions and 88 deletions

View file

@ -1529,6 +1529,14 @@ impl<'a, 'ra, 'tcx> Visitor<'a> for BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
visit::walk_variant(self, variant);
}
fn visit_where_predicate(&mut self, p: &'a ast::WherePredicate) {
if p.is_placeholder {
self.visit_invoc(p.id);
} else {
visit::walk_where_predicate(self, p);
}
}
fn visit_crate(&mut self, krate: &'a ast::Crate) {
if krate.is_placeholder {
self.visit_invoc_in_module(krate.id);

View file

@ -285,6 +285,14 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> {
});
}
fn visit_where_predicate(&mut self, pred: &'a WherePredicate) {
if pred.is_placeholder {
self.visit_macro_invoc(pred.id)
} else {
visit::walk_where_predicate(self, pred)
}
}
fn visit_variant_data(&mut self, data: &'a VariantData) {
// The assumption here is that non-`cfg` macro expansion cannot change field indices.
// It currently holds because only inert attributes are accepted on fields,