Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 2010bba

Browse files
committed
Auto merge of rust-lang#137927 - matthiaskrgr:rollup-yj463ns, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#132388 (Implement `#[cfg]` in `where` clauses) - rust-lang#134900 (Fix parsing of ranges after unary operators) - rust-lang#136938 (Remove `:` from `stack-protector-heuristics-effect.rs` Filecheck Pattern) - rust-lang#137054 (Make phantom variance markers transparent) - rust-lang#137525 (Simplify parallelization in test-float-parse) - rust-lang#137618 (Skip `tidy` in pre-push hook if the user is deleting a remote branch) - rust-lang#137741 (Stop using `hash_raw_entry` in `CodegenCx::const_str`) - rust-lang#137849 (Revert "Remove Win SDK 10.0.26100.0 from CI") - rust-lang#137862 (ensure we always print all --print options in help) r? `@ghost` `@rustbot` modify labels: rollup
2 parents e16a049 + 1998cf7 commit 2010bba

File tree

59 files changed

+3606
-410
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+3606
-410
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,6 @@ jobs:
182182
- name: show the current environment
183183
run: src/ci/scripts/dump-environment.sh
184184

185-
# Temporary fix to unblock CI
186-
# Remove the latest Windows SDK for 32-bit Windows MSVC builds.
187-
# See issue https://github.com/rust-lang/rust/issues/137733 for more details.
188-
- name: Remove Windows SDK 10.0.26100.0
189-
shell: powershell
190-
if: ${{ matrix.name == 'i686-msvc-1' || matrix.name == 'i686-msvc-2' || matrix.name == 'dist-i686-msvc' }}
191-
run: |
192-
$kits = (Get-ItemProperty -path 'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots').KitsRoot10
193-
$sdk_version = "10.0.26100.0"
194-
195-
foreach ($kind in 'Bin', 'Lib', 'Include') {
196-
Remove-Item -Force -Recurse $kits\$kind\$sdk_version -ErrorAction Continue
197-
}
198-
199185
- name: run the build
200186
# Redirect stderr to stdout to avoid reordering the two streams in the GHA logs.
201187
run: src/ci/scripts/run-build-from-ci.sh 2>&1

compiler/rustc_ast/src/ast.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,11 @@ impl WhereClause {
417417
/// A single predicate in a where-clause.
418418
#[derive(Clone, Encodable, Decodable, Debug)]
419419
pub struct WherePredicate {
420+
pub attrs: AttrVec,
420421
pub kind: WherePredicateKind,
421422
pub id: NodeId,
422423
pub span: Span,
424+
pub is_placeholder: bool,
423425
}
424426

425427
/// Predicate kind in where-clause.

compiler/rustc_ast/src/ast_traits.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::tokenstream::LazyAttrTokenStream;
1111
use crate::{
1212
Arm, AssocItem, AttrItem, AttrKind, AttrVec, Attribute, Block, Crate, Expr, ExprField,
1313
FieldDef, ForeignItem, GenericParam, Item, NodeId, Param, Pat, PatField, Path, Stmt, StmtKind,
14-
Ty, Variant, Visibility,
14+
Ty, Variant, Visibility, WherePredicate,
1515
};
1616

1717
/// A utility trait to reduce boilerplate.
@@ -79,6 +79,7 @@ impl_has_node_id!(
7979
Stmt,
8080
Ty,
8181
Variant,
82+
WherePredicate,
8283
);
8384

8485
impl<T: AstDeref<Target: HasNodeId>> HasNodeId for T {
@@ -127,7 +128,16 @@ macro_rules! impl_has_tokens_none {
127128
}
128129

129130
impl_has_tokens!(AssocItem, AttrItem, Block, Expr, ForeignItem, Item, Pat, Path, Ty, Visibility);
130-
impl_has_tokens_none!(Arm, ExprField, FieldDef, GenericParam, Param, PatField, Variant);
131+
impl_has_tokens_none!(
132+
Arm,
133+
ExprField,
134+
FieldDef,
135+
GenericParam,
136+
Param,
137+
PatField,
138+
Variant,
139+
WherePredicate
140+
);
131141

132142
impl<T: AstDeref<Target: HasTokens>> HasTokens for T {
133143
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
@@ -279,6 +289,7 @@ impl_has_attrs!(
279289
Param,
280290
PatField,
281291
Variant,
292+
WherePredicate,
282293
);
283294
impl_has_attrs_none!(Attribute, AttrItem, Block, Pat, Path, Ty, Visibility);
284295

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,11 @@ pub trait MutVisitor: Sized {
338338
walk_where_clause(self, where_clause);
339339
}
340340

341-
fn visit_where_predicate(&mut self, where_predicate: &mut WherePredicate) {
342-
walk_where_predicate(self, where_predicate)
341+
fn flat_map_where_predicate(
342+
&mut self,
343+
where_predicate: WherePredicate,
344+
) -> SmallVec<[WherePredicate; 1]> {
345+
walk_flat_map_where_predicate(self, where_predicate)
343346
}
344347

345348
fn visit_where_predicate_kind(&mut self, kind: &mut WherePredicateKind) {
@@ -1097,15 +1100,20 @@ fn walk_ty_alias_where_clauses<T: MutVisitor>(vis: &mut T, tawcs: &mut TyAliasWh
10971100

10981101
fn walk_where_clause<T: MutVisitor>(vis: &mut T, wc: &mut WhereClause) {
10991102
let WhereClause { has_where_token: _, predicates, span } = wc;
1100-
visit_thin_vec(predicates, |predicate| vis.visit_where_predicate(predicate));
1103+
predicates.flat_map_in_place(|predicate| vis.flat_map_where_predicate(predicate));
11011104
vis.visit_span(span);
11021105
}
11031106

1104-
pub fn walk_where_predicate<T: MutVisitor>(vis: &mut T, pred: &mut WherePredicate) {
1105-
let WherePredicate { kind, id, span } = pred;
1107+
pub fn walk_flat_map_where_predicate<T: MutVisitor>(
1108+
vis: &mut T,
1109+
mut pred: WherePredicate,
1110+
) -> SmallVec<[WherePredicate; 1]> {
1111+
let WherePredicate { attrs, kind, id, span, is_placeholder: _ } = &mut pred;
11061112
vis.visit_id(id);
1113+
visit_attrs(vis, attrs);
11071114
vis.visit_where_predicate_kind(kind);
11081115
vis.visit_span(span);
1116+
smallvec![pred]
11091117
}
11101118

11111119
pub fn walk_where_predicate_kind<T: MutVisitor>(vis: &mut T, kind: &mut WherePredicateKind) {

compiler/rustc_ast/src/visit.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,8 @@ pub fn walk_where_predicate<'a, V: Visitor<'a>>(
833833
visitor: &mut V,
834834
predicate: &'a WherePredicate,
835835
) -> V::Result {
836-
let WherePredicate { kind, id: _, span: _ } = predicate;
836+
let WherePredicate { attrs, kind, id: _, span: _, is_placeholder: _ } = predicate;
837+
walk_list!(visitor, visit_attribute, attrs);
837838
visitor.visit_where_predicate_kind(kind)
838839
}
839840

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,6 +1728,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
17281728
fn lower_where_predicate(&mut self, pred: &WherePredicate) -> hir::WherePredicate<'hir> {
17291729
let hir_id = self.lower_node_id(pred.id);
17301730
let span = self.lower_span(pred.span);
1731+
self.lower_attrs(hir_id, &pred.attrs, span);
17311732
let kind = self.arena.alloc(match &pred.kind {
17321733
WherePredicateKind::BoundPredicate(WhereBoundPredicate {
17331734
bound_generic_params,

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
503503
gate_all!(unsafe_binders, "unsafe binder types are experimental");
504504
gate_all!(contracts, "contracts are incomplete");
505505
gate_all!(contracts_internals, "contract internal machinery is for internal use only");
506+
gate_all!(where_clause_attrs, "attributes in `where` clause are unstable");
506507

507508
if !visitor.features.never_patterns() {
508509
if let Some(spans) = spans.get(&sym::never_patterns) {

compiler/rustc_ast_pretty/src/pprust/state/item.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,8 @@ impl<'a> State<'a> {
735735
}
736736

737737
pub fn print_where_predicate(&mut self, predicate: &ast::WherePredicate) {
738-
let ast::WherePredicate { kind, id: _, span: _ } = predicate;
738+
let ast::WherePredicate { attrs, kind, id: _, span: _, is_placeholder: _ } = predicate;
739+
self.print_outer_attributes(attrs);
739740
match kind {
740741
ast::WherePredicateKind::BoundPredicate(where_bound_predicate) => {
741742
self.print_where_bound_predicate(where_bound_predicate);

compiler/rustc_builtin_macros/src/deriving/coerce_pointee.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,16 @@ pub(crate) fn expand_deriving_coerce_pointee(
300300
to_ty: &s_ty,
301301
rewritten: false,
302302
};
303-
let mut predicate = ast::WherePredicate {
304-
kind: ast::WherePredicateKind::BoundPredicate(bound.clone()),
305-
span: predicate.span,
306-
id: ast::DUMMY_NODE_ID,
307-
};
308-
substitution.visit_where_predicate(&mut predicate);
303+
let mut kind = ast::WherePredicateKind::BoundPredicate(bound.clone());
304+
substitution.visit_where_predicate_kind(&mut kind);
309305
if substitution.rewritten {
306+
let predicate = ast::WherePredicate {
307+
attrs: predicate.attrs.clone(),
308+
kind,
309+
span: predicate.span,
310+
id: ast::DUMMY_NODE_ID,
311+
is_placeholder: false,
312+
};
310313
impl_generics.where_clause.predicates.push(predicate);
311314
}
312315
}
@@ -388,8 +391,8 @@ impl<'a> ast::mut_visit::MutVisitor for TypeSubstitution<'a> {
388391
}
389392
}
390393

391-
fn visit_where_predicate(&mut self, where_predicate: &mut ast::WherePredicate) {
392-
match &mut where_predicate.kind {
394+
fn visit_where_predicate_kind(&mut self, kind: &mut ast::WherePredicateKind) {
395+
match kind {
393396
rustc_ast::WherePredicateKind::BoundPredicate(bound) => {
394397
bound
395398
.bound_generic_params

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,11 @@ impl<'a> TraitDef<'a> {
687687
// and similarly for where clauses
688688
where_clause.predicates.extend(generics.where_clause.predicates.iter().map(|clause| {
689689
ast::WherePredicate {
690+
attrs: clause.attrs.clone(),
690691
kind: clause.kind.clone(),
691692
id: ast::DUMMY_NODE_ID,
692693
span: clause.span.with_ctxt(ctxt),
694+
is_placeholder: false,
693695
}
694696
}));
695697

@@ -744,8 +746,13 @@ impl<'a> TraitDef<'a> {
744746
};
745747

746748
let kind = ast::WherePredicateKind::BoundPredicate(predicate);
747-
let predicate =
748-
ast::WherePredicate { kind, id: ast::DUMMY_NODE_ID, span: self.span };
749+
let predicate = ast::WherePredicate {
750+
attrs: ThinVec::new(),
751+
kind,
752+
id: ast::DUMMY_NODE_ID,
753+
span: self.span,
754+
is_placeholder: false,
755+
};
749756
where_clause.predicates.push(predicate);
750757
}
751758
}

0 commit comments

Comments
 (0)