Skip to content

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

-14
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

+2
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

+13-2
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

+13-5
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

+2-1
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

+1
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

+1
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

+2-1
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

+11-8
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

+9-2
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
}

compiler/rustc_codegen_gcc/src/common.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,12 @@ impl<'gcc, 'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
146146
}
147147

148148
fn const_str(&self, s: &str) -> (RValue<'gcc>, RValue<'gcc>) {
149-
let str_global = *self
150-
.const_str_cache
151-
.borrow_mut()
152-
.raw_entry_mut()
153-
.from_key(s)
154-
.or_insert_with(|| (s.to_owned(), self.global_string(s)))
155-
.1;
149+
let mut const_str_cache = self.const_str_cache.borrow_mut();
150+
let str_global = const_str_cache.get(s).copied().unwrap_or_else(|| {
151+
let g = self.global_string(s);
152+
const_str_cache.insert(s.to_owned(), g);
153+
g
154+
});
156155
let len = s.len();
157156
let cs = self.const_ptrcast(
158157
str_global.get_address(None),

compiler/rustc_codegen_gcc/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#![allow(internal_features)]
1717
#![doc(rust_logo)]
1818
#![feature(rustdoc_internals)]
19-
#![feature(rustc_private, decl_macro, never_type, trusted_len, hash_raw_entry, let_chains)]
19+
#![feature(rustc_private, decl_macro, never_type, trusted_len, let_chains)]
2020
#![allow(broken_intra_doc_links)]
2121
#![recursion_limit = "256"]
2222
#![warn(rust_2018_idioms)]

compiler/rustc_codegen_llvm/src/common.rs

+18-22
Original file line numberDiff line numberDiff line change
@@ -209,28 +209,24 @@ impl<'ll, 'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
209209
}
210210

211211
fn const_str(&self, s: &str) -> (&'ll Value, &'ll Value) {
212-
let str_global = *self
213-
.const_str_cache
214-
.borrow_mut()
215-
.raw_entry_mut()
216-
.from_key(s)
217-
.or_insert_with(|| {
218-
let sc = self.const_bytes(s.as_bytes());
219-
let sym = self.generate_local_symbol_name("str");
220-
let g = self.define_global(&sym, self.val_ty(sc)).unwrap_or_else(|| {
221-
bug!("symbol `{}` is already defined", sym);
222-
});
223-
llvm::set_initializer(g, sc);
224-
unsafe {
225-
llvm::LLVMSetGlobalConstant(g, True);
226-
llvm::LLVMSetUnnamedAddress(g, llvm::UnnamedAddr::Global);
227-
}
228-
llvm::set_linkage(g, llvm::Linkage::InternalLinkage);
229-
// Cast to default address space if globals are in a different addrspace
230-
let g = self.const_pointercast(g, self.type_ptr());
231-
(s.to_owned(), g)
232-
})
233-
.1;
212+
let mut const_str_cache = self.const_str_cache.borrow_mut();
213+
let str_global = const_str_cache.get(s).copied().unwrap_or_else(|| {
214+
let sc = self.const_bytes(s.as_bytes());
215+
let sym = self.generate_local_symbol_name("str");
216+
let g = self.define_global(&sym, self.val_ty(sc)).unwrap_or_else(|| {
217+
bug!("symbol `{}` is already defined", sym);
218+
});
219+
llvm::set_initializer(g, sc);
220+
unsafe {
221+
llvm::LLVMSetGlobalConstant(g, True);
222+
llvm::LLVMSetUnnamedAddress(g, llvm::UnnamedAddr::Global);
223+
}
224+
llvm::set_linkage(g, llvm::Linkage::InternalLinkage);
225+
// Cast to default address space if globals are in a different addrspace
226+
let g = self.const_pointercast(g, self.type_ptr());
227+
const_str_cache.insert(s.to_owned(), g);
228+
g
229+
});
234230
let len = s.len();
235231
(str_global, self.const_usize(len as u64))
236232
}

compiler/rustc_codegen_llvm/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#![feature(exact_size_is_empty)]
1313
#![feature(extern_types)]
1414
#![feature(file_buffered)]
15-
#![feature(hash_raw_entry)]
1615
#![feature(if_let_guard)]
1716
#![feature(impl_trait_in_assoc_type)]
1817
#![feature(iter_intersperse)]

compiler/rustc_expand/src/base.rs

+16
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub enum Annotatable {
5353
Param(ast::Param),
5454
FieldDef(ast::FieldDef),
5555
Variant(ast::Variant),
56+
WherePredicate(ast::WherePredicate),
5657
Crate(ast::Crate),
5758
}
5859

@@ -71,6 +72,7 @@ impl Annotatable {
7172
Annotatable::Param(p) => p.span,
7273
Annotatable::FieldDef(sf) => sf.span,
7374
Annotatable::Variant(v) => v.span,
75+
Annotatable::WherePredicate(wp) => wp.span,
7476
Annotatable::Crate(c) => c.spans.inner_span,
7577
}
7678
}
@@ -89,6 +91,7 @@ impl Annotatable {
8991
Annotatable::Param(p) => p.visit_attrs(f),
9092
Annotatable::FieldDef(sf) => sf.visit_attrs(f),
9193
Annotatable::Variant(v) => v.visit_attrs(f),
94+
Annotatable::WherePredicate(wp) => wp.visit_attrs(f),
9295
Annotatable::Crate(c) => c.visit_attrs(f),
9396
}
9497
}
@@ -107,6 +110,7 @@ impl Annotatable {
107110
Annotatable::Param(p) => visitor.visit_param(p),
108111
Annotatable::FieldDef(sf) => visitor.visit_field_def(sf),
109112
Annotatable::Variant(v) => visitor.visit_variant(v),
113+
Annotatable::WherePredicate(wp) => visitor.visit_where_predicate(wp),
110114
Annotatable::Crate(c) => visitor.visit_crate(c),
111115
}
112116
}
@@ -128,6 +132,7 @@ impl Annotatable {
128132
| Annotatable::Param(..)
129133
| Annotatable::FieldDef(..)
130134
| Annotatable::Variant(..)
135+
| Annotatable::WherePredicate(..)
131136
| Annotatable::Crate(..) => panic!("unexpected annotatable"),
132137
}
133138
}
@@ -223,6 +228,13 @@ impl Annotatable {
223228
}
224229
}
225230

231+
pub fn expect_where_predicate(self) -> ast::WherePredicate {
232+
match self {
233+
Annotatable::WherePredicate(wp) => wp,
234+
_ => panic!("expected where predicate"),
235+
}
236+
}
237+
226238
pub fn expect_crate(self) -> ast::Crate {
227239
match self {
228240
Annotatable::Crate(krate) => krate,
@@ -446,6 +458,10 @@ pub trait MacResult {
446458
None
447459
}
448460

461+
fn make_where_predicates(self: Box<Self>) -> Option<SmallVec<[ast::WherePredicate; 1]>> {
462+
None
463+
}
464+
449465
fn make_crate(self: Box<Self>) -> Option<ast::Crate> {
450466
// Fn-like macros cannot produce a crate.
451467
unreachable!()

0 commit comments

Comments
 (0)