Skip to content

Commit c3774be

Browse files
committed
Auto merge of rust-lang#127197 - matthiaskrgr:rollup-aqpvn5q, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#126923 (test: dont optimize to invalid bitcasts) - rust-lang#127090 (Reduce merge conflicts from rustfmt's wrapping) - rust-lang#127105 (Only update `Eq` operands in GVN if it can update both sides) - rust-lang#127150 (Fix x86_64 code being produced for bare-metal LoongArch targets' `compiler_builtins`) - rust-lang#127181 (Introduce a `rustc_` attribute to dump all the `DefId` parents of a `DefId`) - rust-lang#127182 (Fix error in documentation for IpAddr::to_canonical and Ipv6Addr::to_canonical) - rust-lang#127191 (Ensure `out_of_scope_macro_calls` lint is registered) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7b21c18 + f5ef1cd commit c3774be

File tree

20 files changed

+436
-18
lines changed

20 files changed

+436
-18
lines changed

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
11171117
TEST, rustc_dump_predicates, Normal, template!(Word),
11181118
WarnFollowing, EncodeCrossCrate::No
11191119
),
1120+
rustc_attr!(
1121+
TEST, rustc_dump_def_parents, Normal, template!(Word),
1122+
WarnFollowing, EncodeCrossCrate::No
1123+
),
11201124
rustc_attr!(
11211125
TEST, rustc_object_lifetime_default, Normal, template!(Word),
11221126
WarnFollowing, EncodeCrossCrate::No

compiler/rustc_hir_analysis/src/collect/dump.rs

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use rustc_hir::def::DefKind;
2-
use rustc_hir::def_id::CRATE_DEF_ID;
2+
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
3+
use rustc_hir::intravisit;
4+
use rustc_middle::hir::nested_filter::OnlyBodies;
35
use rustc_middle::ty::TyCtxt;
46
use rustc_span::sym;
57

@@ -41,3 +43,49 @@ pub(crate) fn predicates_and_item_bounds(tcx: TyCtxt<'_>) {
4143
}
4244
}
4345
}
46+
47+
pub(crate) fn def_parents(tcx: TyCtxt<'_>) {
48+
for did in tcx.hir().body_owners() {
49+
if tcx.has_attr(did, sym::rustc_dump_def_parents) {
50+
struct AnonConstFinder<'tcx> {
51+
tcx: TyCtxt<'tcx>,
52+
anon_consts: Vec<LocalDefId>,
53+
}
54+
55+
impl<'tcx> intravisit::Visitor<'tcx> for AnonConstFinder<'tcx> {
56+
type NestedFilter = OnlyBodies;
57+
58+
fn nested_visit_map(&mut self) -> Self::Map {
59+
self.tcx.hir()
60+
}
61+
62+
fn visit_anon_const(&mut self, c: &'tcx rustc_hir::AnonConst) {
63+
self.anon_consts.push(c.def_id);
64+
intravisit::walk_anon_const(self, c)
65+
}
66+
}
67+
68+
// Look for any anon consts inside of this body owner as there is no way to apply
69+
// the `rustc_dump_def_parents` attribute to the anon const so it would not be possible
70+
// to see what its def parent is.
71+
let mut anon_ct_finder = AnonConstFinder { tcx, anon_consts: vec![] };
72+
intravisit::walk_expr(&mut anon_ct_finder, tcx.hir().body_owned_by(did).value);
73+
74+
for did in [did].into_iter().chain(anon_ct_finder.anon_consts) {
75+
let span = tcx.def_span(did);
76+
77+
let mut diag = tcx.dcx().struct_span_err(
78+
span,
79+
format!("{}: {did:?}", sym::rustc_dump_def_parents.as_str()),
80+
);
81+
82+
let mut current_did = did.to_def_id();
83+
while let Some(parent_did) = tcx.opt_parent(current_did) {
84+
current_did = parent_did;
85+
diag.span_note(tcx.def_span(parent_did), format!("{parent_did:?}"));
86+
}
87+
diag.emit();
88+
}
89+
}
90+
}
91+
}

compiler/rustc_hir_analysis/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
175175
tcx.sess.time("variance_dumping", || variance::dump::variances(tcx));
176176
collect::dump::opaque_hidden_types(tcx);
177177
collect::dump::predicates_and_item_bounds(tcx);
178+
collect::dump::def_parents(tcx);
178179
}
179180

180181
// Make sure we evaluate all static and (non-associated) const items, even if unused.

compiler/rustc_interface/src/tests.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,22 @@
22
use crate::interface::{initialize_checked_jobserver, parse_cfg};
33
use rustc_data_structures::profiling::TimePassesFormat;
44
use rustc_errors::{emitter::HumanReadableErrorType, registry, ColorConfig};
5+
use rustc_session::config::{build_configuration, build_session_options, rustc_optgroups};
56
use rustc_session::config::{
6-
build_configuration, build_session_options, rustc_optgroups, BranchProtection, CFGuard, Cfg,
7-
CollapseMacroDebuginfo, CoverageLevel, CoverageOptions, DebugInfo, DumpMonoStatsFormat,
8-
ErrorOutputType, ExternEntry, ExternLocation, Externs, FunctionReturn, InliningThreshold,
9-
Input, InstrumentCoverage, InstrumentXRay, LinkSelfContained, LinkerPluginLto, LocationDetail,
10-
LtoCli, NextSolverConfig, OomStrategy, Options, OutFileName, OutputType, OutputTypes, PAuthKey,
11-
PacRet, Passes, PatchableFunctionEntry, Polonius, ProcMacroExecutionStrategy, Strip,
12-
SwitchWithOptPath, SymbolManglingVersion, WasiExecModel,
7+
BranchProtection, CFGuard, Cfg, CollapseMacroDebuginfo, CoverageLevel, CoverageOptions,
8+
DebugInfo, DumpMonoStatsFormat, ErrorOutputType,
9+
};
10+
use rustc_session::config::{
11+
ExternEntry, ExternLocation, Externs, FunctionReturn, InliningThreshold, Input,
12+
InstrumentCoverage, InstrumentXRay, LinkSelfContained, LinkerPluginLto,
13+
};
14+
use rustc_session::config::{
15+
LocationDetail, LtoCli, NextSolverConfig, OomStrategy, Options, OutFileName, OutputType,
16+
OutputTypes, PAuthKey, PacRet, Passes, PatchableFunctionEntry,
17+
};
18+
use rustc_session::config::{
19+
Polonius, ProcMacroExecutionStrategy, Strip, SwitchWithOptPath, SymbolManglingVersion,
20+
WasiExecModel,
1321
};
1422
use rustc_session::lint::Level;
1523
use rustc_session::search_paths::SearchPath;

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ declare_lint_pass! {
7474
NON_CONTIGUOUS_RANGE_ENDPOINTS,
7575
NON_EXHAUSTIVE_OMITTED_PATTERNS,
7676
ORDER_DEPENDENT_TRAIT_OBJECTS,
77+
OUT_OF_SCOPE_MACRO_CALLS,
7778
OVERLAPPING_RANGE_ENDPOINTS,
7879
PATTERNS_IN_FNS_WITHOUT_BODY,
7980
PRIVATE_BOUNDS,

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,11 +1074,11 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
10741074
{
10751075
lhs = *lhs_value;
10761076
rhs = *rhs_value;
1077-
if let Some(op) = self.try_as_operand(lhs, location) {
1078-
*lhs_operand = op;
1079-
}
1080-
if let Some(op) = self.try_as_operand(rhs, location) {
1081-
*rhs_operand = op;
1077+
if let Some(lhs_op) = self.try_as_operand(lhs, location)
1078+
&& let Some(rhs_op) = self.try_as_operand(rhs, location)
1079+
{
1080+
*lhs_operand = lhs_op;
1081+
*rhs_operand = rhs_op;
10821082
}
10831083
}
10841084

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,7 @@ symbols! {
16141614
rustc_do_not_const_check,
16151615
rustc_doc_primitive,
16161616
rustc_dummy,
1617+
rustc_dump_def_parents,
16171618
rustc_dump_item_bounds,
16181619
rustc_dump_predicates,
16191620
rustc_dump_user_args,

library/core/src/net/ip_addr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ impl IpAddr {
406406
matches!(self, IpAddr::V6(_))
407407
}
408408

409-
/// Converts this address to an `IpAddr::V4` if it is an IPv4-mapped IPv6 addresses, otherwise it
409+
/// Converts this address to an `IpAddr::V4` if it is an IPv4-mapped IPv6 address, otherwise it
410410
/// returns `self` as-is.
411411
///
412412
/// # Examples
@@ -1879,7 +1879,7 @@ impl Ipv6Addr {
18791879
}
18801880
}
18811881

1882-
/// Converts this address to an `IpAddr::V4` if it is an IPv4-mapped addresses, otherwise it
1882+
/// Converts this address to an `IpAddr::V4` if it is an IPv4-mapped address, otherwise it
18831883
/// returns self wrapped in an `IpAddr::V6`.
18841884
///
18851885
/// # Examples

src/ci/docker/host-x86_64/dist-loongarch64-linux/Dockerfile

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,30 @@ ENV CC_loongarch64_unknown_linux_gnu=loongarch64-unknown-linux-gnu-gcc \
2323
AR_loongarch64_unknown_linux_gnu=loongarch64-unknown-linux-gnu-ar \
2424
CXX_loongarch64_unknown_linux_gnu=loongarch64-unknown-linux-gnu-g++
2525

26+
# We re-use the Linux toolchain for bare-metal, because upstream bare-metal
27+
# target support for LoongArch is only available from GCC 14+.
28+
#
29+
# See: https://github.com/gcc-mirror/gcc/commit/976f4f9e4770
30+
ENV CC_loongarch64_unknown_none=loongarch64-unknown-linux-gnu-gcc \
31+
AR_loongarch64_unknown_none=loongarch64-unknown-linux-gnu-ar \
32+
CXX_loongarch64_unknown_none=loongarch64-unknown-linux-gnu-g++ \
33+
CFLAGS_loongarch64_unknown_none="-ffreestanding -mabi=lp64d" \
34+
CXXFLAGS_loongarch64_unknown_none="-ffreestanding -mabi=lp64d" \
35+
CC_loongarch64_unknown_none_softfloat=loongarch64-unknown-linux-gnu-gcc \
36+
AR_loongarch64_unknown_none_softfloat=loongarch64-unknown-linux-gnu-ar \
37+
CXX_loongarch64_unknown_none_softfloat=loongarch64-unknown-linux-gnu-g++ \
38+
CFLAGS_loongarch64_unknown_none_softfloat="-ffreestanding -mabi=lp64s -mfpu=none" \
39+
CXXFLAGS_loongarch64_unknown_none_softfloat="-ffreestanding -mabi=lp64s -mfpu=none"
40+
2641
ENV HOSTS=loongarch64-unknown-linux-gnu
42+
ENV TARGETS=$HOSTS
43+
ENV TARGETS=$TARGETS,loongarch64-unknown-none
44+
ENV TARGETS=$TARGETS,loongarch64-unknown-none-softfloat
2745

2846
ENV RUST_CONFIGURE_ARGS \
2947
--enable-extended \
3048
--enable-full-tools \
3149
--enable-profiler \
3250
--disable-docs
3351

34-
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS
52+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $TARGETS

src/ci/docker/host-x86_64/dist-various-2/Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ ENV TARGETS=$TARGETS,armv7-unknown-linux-gnueabi
121121
ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabi
122122
ENV TARGETS=$TARGETS,i686-unknown-freebsd
123123
ENV TARGETS=$TARGETS,x86_64-unknown-none
124-
ENV TARGETS=$TARGETS,loongarch64-unknown-none
125-
ENV TARGETS=$TARGETS,loongarch64-unknown-none-softfloat
126124
ENV TARGETS=$TARGETS,aarch64-unknown-uefi
127125
ENV TARGETS=$TARGETS,i686-unknown-uefi
128126
ENV TARGETS=$TARGETS,x86_64-unknown-uefi

0 commit comments

Comments
 (0)