Skip to content

Commit 42a4673

Browse files
committed
Auto merge of #82153 - jonas-schievink:rollup-ls5r943, r=jonas-schievink
Rollup of 19 pull requests Successful merges: - #81503 (Suggest to create a new `const` item if the `fn` in the array is a `const fn`) - #81897 (Add match pattern diagnostics regression test) - #81975 (Seal the CommandExt, OsStrExt and OsStringExt traits) - #82009 (const_generics: Dont evaluate array length const when handling errors) - #82060 (Fix typos in BTreeSet::{first, last} docs) - #82061 (CTFE validation: catch ReadPointerAsBytes and better error) - #82063 (Fixed minor typo in catch_unwind docs) - #82067 (const_generics: Fix incorrect ty::ParamEnv::empty() usage) - #82077 (Edit `rustc_arena::DropArena` docs) - #82096 (Fix a typo) - #82106 (Remove unnecessary `Option` in `default_doc`) - #82107 (expand: Some cleanup) - #82118 (Add missing env!-decl variant) - #82119 (Fix typo in link to CreateSymbolicLinkW documentation.) - #82120 (Stabilize Arguments::as_str) - #82129 (Remove redundant bool_to_option feature gate) - #82133 (Update link for extern prelude.) - #82141 (32-bit ARM: Emit `lr` instead of `r14` when specified as an `asm!` output register.) - #82147 (:arrow_up: rust-analyzer) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents d1206f9 + a105280 commit 42a4673

File tree

50 files changed

+350
-135
lines changed

Some content is hidden

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

50 files changed

+350
-135
lines changed

compiler/rustc_arena/src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,13 @@ impl Drop for DropType {
568568
}
569569

570570
/// An arena which can be used to allocate any type.
571+
///
572+
/// # Safety
573+
///
571574
/// Allocating in this arena is unsafe since the type system
572575
/// doesn't know which types it contains. In order to
573-
/// allocate safely, you must store a PhantomData<T>
574-
/// alongside this arena for each type T you allocate.
576+
/// allocate safely, you must store a `PhantomData<T>`
577+
/// alongside this arena for each type `T` you allocate.
575578
#[derive(Default)]
576579
pub struct DropArena {
577580
/// A list of destructors to run when the arena drops.
@@ -589,7 +592,7 @@ impl DropArena {
589592
ptr::write(mem, object);
590593
let result = &mut *mem;
591594
// Record the destructor after doing the allocation as that may panic
592-
// and would cause `object`'s destructor to run twice if it was recorded before
595+
// and would cause `object`'s destructor to run twice if it was recorded before.
593596
self.destructors
594597
.borrow_mut()
595598
.push(DropType { drop_fn: drop_for_type::<T>, obj: result as *mut T as *mut u8 });
@@ -607,16 +610,16 @@ impl DropArena {
607610
let start_ptr = self.arena.alloc_raw(Layout::array::<T>(len).unwrap()) as *mut T;
608611

609612
let mut destructors = self.destructors.borrow_mut();
610-
// Reserve space for the destructors so we can't panic while adding them
613+
// Reserve space for the destructors so we can't panic while adding them.
611614
destructors.reserve(len);
612615

613616
// Move the content to the arena by copying it and then forgetting
614-
// the content of the SmallVec
617+
// the content of the SmallVec.
615618
vec.as_ptr().copy_to_nonoverlapping(start_ptr, len);
616619
mem::forget(vec.drain(..));
617620

618621
// Record the destructors after doing the allocation as that may panic
619-
// and would cause `object`'s destructor to run twice if it was recorded before
622+
// and would cause `object`'s destructor to run twice if it was recorded before.
620623
for i in 0..len {
621624
destructors
622625
.push(DropType { drop_fn: drop_for_type::<T>, obj: start_ptr.add(i) as *mut u8 });

compiler/rustc_codegen_llvm/src/asm.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,9 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'tcx>>)
487487
} else if reg == InlineAsmReg::AArch64(AArch64InlineAsmReg::x30) {
488488
// LLVM doesn't recognize x30
489489
"{lr}".to_string()
490+
} else if reg == InlineAsmReg::Arm(ArmInlineAsmReg::r14) {
491+
// LLVM doesn't recognize r14
492+
"{lr}".to_string()
490493
} else {
491494
format!("{{{}}}", reg.name())
492495
}

compiler/rustc_expand/src/expand.rs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,8 +1067,6 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
10671067
fn visit_expr(&mut self, expr: &mut P<ast::Expr>) {
10681068
self.cfg.configure_expr(expr);
10691069
visit_clobber(expr.deref_mut(), |mut expr| {
1070-
self.cfg.configure_expr_kind(&mut expr.kind);
1071-
10721070
if let Some(attr) = self.take_first_attr(&mut expr) {
10731071
// Collect the invoc regardless of whether or not attributes are permitted here
10741072
// expansion will eat the attribute so it won't error later.
@@ -1166,8 +1164,6 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
11661164
fn filter_map_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
11671165
let expr = configure!(self, expr);
11681166
expr.filter_map(|mut expr| {
1169-
self.cfg.configure_expr_kind(&mut expr.kind);
1170-
11711167
if let Some(attr) = self.take_first_attr(&mut expr) {
11721168
self.cfg.maybe_emit_expr_attr_err(&attr.0);
11731169

@@ -1192,7 +1188,6 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
11921188
}
11931189

11941190
fn visit_pat(&mut self, pat: &mut P<ast::Pat>) {
1195-
self.cfg.configure_pat(pat);
11961191
match pat.kind {
11971192
PatKind::MacCall(_) => {}
11981193
_ => return noop_visit_pat(pat, self),
@@ -1406,15 +1401,12 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
14061401
});
14071402
}
14081403

1409-
fn visit_foreign_mod(&mut self, foreign_mod: &mut ast::ForeignMod) {
1410-
self.cfg.configure_foreign_mod(foreign_mod);
1411-
noop_visit_foreign_mod(foreign_mod, self);
1412-
}
1413-
14141404
fn flat_map_foreign_item(
14151405
&mut self,
1416-
mut foreign_item: P<ast::ForeignItem>,
1406+
foreign_item: P<ast::ForeignItem>,
14171407
) -> SmallVec<[P<ast::ForeignItem>; 1]> {
1408+
let mut foreign_item = configure!(self, foreign_item);
1409+
14181410
if let Some(attr) = self.take_first_attr(&mut foreign_item) {
14191411
return self
14201412
.collect_attr(
@@ -1439,11 +1431,6 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
14391431
}
14401432
}
14411433

1442-
fn visit_item_kind(&mut self, item: &mut ast::ItemKind) {
1443-
self.cfg.configure_item_kind(item);
1444-
noop_visit_item_kind(item, self);
1445-
}
1446-
14471434
fn flat_map_generic_param(
14481435
&mut self,
14491436
param: ast::GenericParam,
@@ -1602,21 +1589,15 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
16021589
*id = self.cx.resolver.next_node_id()
16031590
}
16041591
}
1605-
1606-
fn visit_fn_decl(&mut self, mut fn_decl: &mut P<ast::FnDecl>) {
1607-
self.cfg.configure_fn_decl(&mut fn_decl);
1608-
noop_visit_fn_decl(fn_decl, self);
1609-
}
16101592
}
16111593

16121594
pub struct ExpansionConfig<'feat> {
16131595
pub crate_name: String,
16141596
pub features: Option<&'feat Features>,
16151597
pub recursion_limit: Limit,
16161598
pub trace_mac: bool,
1617-
pub should_test: bool, // If false, strip `#[test]` nodes
1618-
pub keep_macs: bool,
1619-
pub span_debug: bool, // If true, use verbose debugging for `proc_macro::Span`
1599+
pub should_test: bool, // If false, strip `#[test]` nodes
1600+
pub span_debug: bool, // If true, use verbose debugging for `proc_macro::Span`
16201601
pub proc_macro_backtrace: bool, // If true, show backtraces for proc-macro panics
16211602
}
16221603

@@ -1628,7 +1609,6 @@ impl<'feat> ExpansionConfig<'feat> {
16281609
recursion_limit: Limit::new(1024),
16291610
trace_mac: false,
16301611
should_test: false,
1631-
keep_macs: false,
16321612
span_debug: false,
16331613
proc_macro_backtrace: false,
16341614
}

compiler/rustc_expand/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(bool_to_option)]
21
#![feature(crate_visibility_modifier)]
32
#![feature(decl_macro)]
43
#![feature(or_patterns)]

compiler/rustc_expand/src/placeholders.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,4 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> {
371371
}
372372
}
373373
}
374-
375-
fn visit_mod(&mut self, module: &mut ast::Mod) {
376-
noop_visit_mod(module, self);
377-
// remove macro definitions
378-
module.items.retain(
379-
|item| !matches!(item.kind, ast::ItemKind::MacCall(_) if !self.cx.ecfg.keep_macs),
380-
);
381-
}
382374
}

compiler/rustc_infer/src/infer/canonical/query_response.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,10 @@ struct QueryTypeRelatingDelegate<'a, 'tcx> {
639639
}
640640

641641
impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
642+
fn param_env(&self) -> ty::ParamEnv<'tcx> {
643+
self.param_env
644+
}
645+
642646
fn create_next_universe(&mut self) -> ty::UniverseIndex {
643647
self.infcx.create_next_universe()
644648
}

compiler/rustc_infer/src/infer/combine.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
221221
/// As `3 + 4` contains `N` in its substs, this must not succeed.
222222
///
223223
/// See `src/test/ui/const-generics/occurs-check/` for more examples where this is relevant.
224+
#[instrument(level = "debug", skip(self))]
224225
fn unify_const_variable(
225226
&self,
226227
param_env: ty::ParamEnv<'tcx>,

compiler/rustc_infer/src/infer/nll_relate/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ where
7272
}
7373

7474
pub trait TypeRelatingDelegate<'tcx> {
75+
fn param_env(&self) -> ty::ParamEnv<'tcx>;
76+
7577
/// Push a constraint `sup: sub` -- this constraint must be
7678
/// satisfied for the two types to be related. `sub` and `sup` may
7779
/// be regions from the type or new variables created through the
@@ -473,9 +475,8 @@ where
473475
self.infcx.tcx
474476
}
475477

476-
// FIXME(oli-obk): not sure how to get the correct ParamEnv
477478
fn param_env(&self) -> ty::ParamEnv<'tcx> {
478-
ty::ParamEnv::empty()
479+
self.delegate.param_env()
479480
}
480481

481482
fn tag(&self) -> &'static str {
@@ -819,9 +820,8 @@ where
819820
self.infcx.tcx
820821
}
821822

822-
// FIXME(oli-obk): not sure how to get the correct ParamEnv
823823
fn param_env(&self) -> ty::ParamEnv<'tcx> {
824-
ty::ParamEnv::empty()
824+
self.delegate.param_env()
825825
}
826826

827827
fn tag(&self) -> &'static str {

compiler/rustc_middle/src/mir/interpret/queries.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ impl<'tcx> TyCtxt<'tcx> {
3131
/// constant `bar::<T>()` requires a substitution for `T`, if the substitution for `T` is still
3232
/// too generic for the constant to be evaluated then `Err(ErrorHandled::TooGeneric)` is
3333
/// returned.
34+
#[instrument(level = "debug", skip(self))]
3435
pub fn const_eval_resolve(
3536
self,
3637
param_env: ty::ParamEnv<'tcx>,

compiler/rustc_middle/src/traits/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,10 @@ pub enum ObligationCauseCode<'tcx> {
228228
/// Inline asm operand type must be `Sized`.
229229
InlineAsmSized,
230230
/// `[T, ..n]` implies that `T` must be `Copy`.
231-
RepeatVec,
231+
/// If the function in the array repeat expression is a `const fn`,
232+
/// display a help message suggesting to move the function call to a
233+
/// new `const` item while saying that `T` doesn't implement `Copy`.
234+
RepeatVec(bool),
232235

233236
/// Types of fields (other than the last, except for packed structs) in a struct must be sized.
234237
FieldSized {

0 commit comments

Comments
 (0)