Auto merge of #150231 - JonathanBrouwer:rollup-btei0hm, r=JonathanBrouwer

Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#149512 (Fix d32 usage in Arm target specs )
 - rust-lang/rust#150210 (tests/debuginfo/function-arg-initialization.rs: Stop disabling SingleUseConsts MIR pass)
 - rust-lang/rust#150221 (rustdoc: handle macro expansions in types)
 - rust-lang/rust#150223 (GVN: Adds the `insert_unique` method)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-12-21 22:49:21 +00:00
commit f41f40408d
18 changed files with 74 additions and 40 deletions

View file

@ -33,6 +33,9 @@ pub fn where_bound_predicate_to_string(where_bound_predicate: &ast::WhereBoundPr
State::new().where_bound_predicate_to_string(where_bound_predicate)
}
/// # Panics
///
/// Panics if `pat.kind` is `PatKind::Missing`.
pub fn pat_to_string(pat: &ast::Pat) -> String {
State::new().pat_to_string(pat)
}

View file

@ -420,6 +420,19 @@ impl<'body, 'a, 'tcx> VnState<'body, 'a, 'tcx> {
self.ecx.typing_env()
}
fn insert_unique(
&mut self,
ty: Ty<'tcx>,
value: impl FnOnce(VnOpaque) -> Value<'a, 'tcx>,
) -> VnIndex {
let index = self.values.insert_unique(ty, value);
let _index = self.evaluated.push(None);
debug_assert_eq!(index, _index);
let _index = self.rev_locals.push(SmallVec::new());
debug_assert_eq!(index, _index);
index
}
#[instrument(level = "trace", skip(self), ret)]
fn insert(&mut self, ty: Ty<'tcx>, value: Value<'a, 'tcx>) -> VnIndex {
let (index, new) = self.values.insert(ty, value);
@ -437,11 +450,8 @@ impl<'body, 'a, 'tcx> VnState<'body, 'a, 'tcx> {
/// from all the others.
#[instrument(level = "trace", skip(self), ret)]
fn new_opaque(&mut self, ty: Ty<'tcx>) -> VnIndex {
let index = self.values.insert_unique(ty, Value::Opaque);
let _index = self.evaluated.push(Some(None));
debug_assert_eq!(index, _index);
let _index = self.rev_locals.push(SmallVec::new());
debug_assert_eq!(index, _index);
let index = self.insert_unique(ty, Value::Opaque);
self.evaluated[index] = Some(None);
index
}
@ -470,42 +480,29 @@ impl<'body, 'a, 'tcx> VnState<'body, 'a, 'tcx> {
projection.map(|proj| proj.try_map(|index| self.locals[index], |ty| ty).ok_or(()));
let projection = self.arena.try_alloc_from_iter(projection).ok()?;
let index = self.values.insert_unique(ty, |provenance| Value::Address {
let index = self.insert_unique(ty, |provenance| Value::Address {
base,
projection,
kind,
provenance,
});
let _index = self.evaluated.push(None);
debug_assert_eq!(index, _index);
let _index = self.rev_locals.push(SmallVec::new());
debug_assert_eq!(index, _index);
Some(index)
}
#[instrument(level = "trace", skip(self), ret)]
fn insert_constant(&mut self, value: Const<'tcx>) -> VnIndex {
let (index, new) = if value.is_deterministic() {
if value.is_deterministic() {
// The constant is deterministic, no need to disambiguate.
let constant = Value::Constant { value, disambiguator: None };
self.values.insert(value.ty(), constant)
self.insert(value.ty(), constant)
} else {
// Multiple mentions of this constant will yield different values,
// so assign a different `disambiguator` to ensure they do not get the same `VnIndex`.
let index = self.values.insert_unique(value.ty(), |disambiguator| Value::Constant {
self.insert_unique(value.ty(), |disambiguator| Value::Constant {
value,
disambiguator: Some(disambiguator),
});
(index, true)
};
if new {
let _index = self.evaluated.push(None);
debug_assert_eq!(index, _index);
let _index = self.rev_locals.push(SmallVec::new());
debug_assert_eq!(index, _index);
})
}
index
}
#[inline]

View file

@ -15,7 +15,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
abi: Abi::EabiHf,
llvm_floatabi: Some(FloatAbi::Hard),
features: "+strict-align,+v6,+vfp2,-d32".into(),
features: "+strict-align,+v6,+vfp2".into(),
max_atomic_width: Some(64),
mcount: "\u{1}__gnu_mcount_nc".into(),
llvm_mcount_intrinsic: Some("llvm.arm.gnu.eabi.mcount".into()),

View file

@ -17,7 +17,7 @@ pub(crate) fn target() -> Target {
llvm_floatabi: Some(FloatAbi::Hard),
// Most of these settings are copied from the arm_unknown_linux_gnueabihf
// target.
features: "+strict-align,+v6,+vfp2,-d32".into(),
features: "+strict-align,+v6,+vfp2".into(),
max_atomic_width: Some(64),
mcount: "\u{1}mcount".into(),
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.

View file

@ -15,7 +15,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
abi: Abi::EabiHf,
llvm_floatabi: Some(FloatAbi::Hard),
features: "+v6,+vfp2,-d32".into(),
features: "+v6,+vfp2".into(),
max_atomic_width: Some(64),
mcount: "\u{1}__gnu_mcount_nc".into(),
llvm_mcount_intrinsic: Some("llvm.arm.gnu.eabi.mcount".into()),

View file

@ -15,7 +15,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
abi: Abi::EabiHf,
llvm_floatabi: Some(FloatAbi::Hard),
features: "+v6,+vfp2,-d32".into(),
features: "+v6,+vfp2".into(),
max_atomic_width: Some(64),
mcount: "__mcount".into(),
..base::netbsd::opts()

View file

@ -28,7 +28,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
abi: Abi::Eabi,
llvm_floatabi: Some(FloatAbi::Soft),
features: "+v7,+thumb-mode,+thumb2,+vfp3,-d32,-neon".into(),
features: "+v7,+thumb-mode,+thumb2,+vfp3d16,-neon".into(),
supported_sanitizers: SanitizerSet::ADDRESS,
max_atomic_width: Some(64),
..base

View file

@ -15,7 +15,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
abi: Abi::EabiHf,
llvm_floatabi: Some(FloatAbi::Hard),
features: "+v7,+vfp3,-d32,+thumb2,-neon".into(),
features: "+v7,+vfp3d16,+thumb2,-neon".into(),
max_atomic_width: Some(64),
mcount: "\u{1}__gnu_mcount_nc".into(),
..base::freebsd::opts()

View file

@ -19,7 +19,7 @@ pub(crate) fn target() -> Target {
abi: Abi::EabiHf,
llvm_floatabi: Some(FloatAbi::Hard),
// Info about features at https://wiki.debian.org/ArmHardFloatPort
features: "+v7,+vfp3,-d32,+thumb2,-neon".into(),
features: "+v7,+vfp3d16,+thumb2,-neon".into(),
max_atomic_width: Some(64),
mcount: "\u{1}__gnu_mcount_nc".into(),
llvm_mcount_intrinsic: Some("llvm.arm.gnu.eabi.mcount".into()),

View file

@ -20,7 +20,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
abi: Abi::EabiHf,
llvm_floatabi: Some(FloatAbi::Hard),
features: "+v7,+vfp3,-d32,+thumb2,-neon".into(),
features: "+v7,+vfp3d16,+thumb2,-neon".into(),
max_atomic_width: Some(64),
mcount: "\u{1}mcount".into(),
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.

View file

@ -19,7 +19,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
// Info about features at https://wiki.debian.org/ArmHardFloatPort
features: "+v7,+vfp3,-d32,+thumb2,-neon".into(),
features: "+v7,+vfp3d16,+thumb2,-neon".into(),
cpu: "generic".into(),
max_atomic_width: Some(64),
mcount: "_mcount".into(),

View file

@ -15,7 +15,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
abi: Abi::EabiHf,
llvm_floatabi: Some(FloatAbi::Hard),
features: "+v7,+vfp3,-d32,+thumb2,-neon".into(),
features: "+v7,+vfp3d16,+thumb2,-neon".into(),
max_atomic_width: Some(64),
mcount: "__mcount".into(),
..base::netbsd::opts()

View file

@ -16,7 +16,7 @@ pub(crate) fn target() -> Target {
abi: Abi::EabiHf,
llvm_floatabi: Some(FloatAbi::Hard),
// Info about features at https://wiki.debian.org/ArmHardFloatPort
features: "+v7,+vfp3,-d32,+thumb2,-neon".into(),
features: "+v7,+vfp3d16,+thumb2,-neon".into(),
max_atomic_width: Some(64),
..base::vxworks::opts()
},

View file

@ -17,7 +17,7 @@ pub(crate) fn target() -> Target {
abi: Abi::EabiHf,
llvm_floatabi: Some(FloatAbi::Hard),
linker: Some("arm-kmc-eabi-gcc".into()),
features: "+v7,+vfp3,-d32,+thumb2,-neon".into(),
features: "+v7,+vfp3d16,+thumb2,-neon".into(),
relocation_model: RelocModel::Static,
disable_redzone: true,
max_atomic_width: Some(64),

View file

@ -16,7 +16,7 @@ pub(crate) fn target() -> Target {
llvm_floatabi: Some(FloatAbi::Hard),
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
features: "+v7,+vfp3,-d32,+thumb2,-neon,+strict-align".into(),
features: "+v7,+vfp3d16,+thumb2,-neon,+strict-align".into(),
relocation_model: RelocModel::Static,
disable_redzone: true,
max_atomic_width: Some(64),

View file

@ -1,5 +1,5 @@
use rustc_ast::visit::{Visitor, walk_crate, walk_expr, walk_item, walk_pat, walk_stmt};
use rustc_ast::{Crate, Expr, Item, Pat, Stmt};
use rustc_ast::visit::{Visitor, walk_crate, walk_expr, walk_item, walk_pat, walk_stmt, walk_ty};
use rustc_ast::{Crate, Expr, Item, Pat, Stmt, Ty};
use rustc_data_structures::fx::FxHashMap;
use rustc_span::source_map::SourceMap;
use rustc_span::{BytePos, Span};
@ -153,4 +153,12 @@ impl<'ast> Visitor<'ast> for ExpandedCodeVisitor<'ast> {
walk_pat(self, pat);
}
}
fn visit_ty(&mut self, ty: &'ast Ty) {
if ty.span.from_expansion() {
self.handle_new_span(ty.span, || rustc_ast_pretty::pprust::ty_to_string(ty));
} else {
walk_ty(self, ty);
}
}
}

View file

@ -6,8 +6,7 @@
// function name.
//@ min-lldb-version: 1800
//@ compile-flags:-g -Zmir-enable-passes=-SingleUseConsts
// SingleUseConsts shouldn't need to be disabled, see #128945
//@ compile-flags:-g
//@ disable-gdb-pretty-printers
//@ ignore-backends: gcc

View file

@ -0,0 +1,27 @@
// Ensure macro invocations at type position are expanded correctly
//@ compile-flags: -Zunstable-options --generate-macro-expansion
#![crate_name = "foo"]
//@ has 'src/foo/type-macro-expansion.rs.html'
macro_rules! foo {
() => {
fn(())
};
($_arg:expr) => {
[(); 1]
};
}
fn bar() {
//@ has - '//*[@class="expansion"]/*[@class="original"]/*[@class="macro"]' 'foo!'
//@ has - '//*[@class="expansion"]/*[@class="original"]' 'foo!()'
//@ has - '//*[@class="expansion"]/*[@class="expanded"]' 'fn(())'
let _: foo!();
//@ has - '//*[@class="expansion"]/*[@class="original"]/*[@class="macro"]' 'foo!'
//@ has - '//*[@class="expansion"]/*[@class="original"]' 'foo!(42)'
//@ has - '//*[@class="expansion"]/*[@class="expanded"]' '[(); 1]'
let _: foo!(42);
}