Auto merge of #127197 - matthiaskrgr:rollup-aqpvn5q, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #126923 (test: dont optimize to invalid bitcasts) - #127090 (Reduce merge conflicts from rustfmt's wrapping) - #127105 (Only update `Eq` operands in GVN if it can update both sides) - #127150 (Fix x86_64 code being produced for bare-metal LoongArch targets' `compiler_builtins`) - #127181 (Introduce a `rustc_` attribute to dump all the `DefId` parents of a `DefId`) - #127182 (Fix error in documentation for IpAddr::to_canonical and Ipv6Addr::to_canonical) - #127191 (Ensure `out_of_scope_macro_calls` lint is registered) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
c3774be741
20 changed files with 436 additions and 18 deletions
|
@ -1117,6 +1117,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
TEST, rustc_dump_predicates, Normal, template!(Word),
|
||||
WarnFollowing, EncodeCrossCrate::No
|
||||
),
|
||||
rustc_attr!(
|
||||
TEST, rustc_dump_def_parents, Normal, template!(Word),
|
||||
WarnFollowing, EncodeCrossCrate::No
|
||||
),
|
||||
rustc_attr!(
|
||||
TEST, rustc_object_lifetime_default, Normal, template!(Word),
|
||||
WarnFollowing, EncodeCrossCrate::No
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::CRATE_DEF_ID;
|
||||
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
|
||||
use rustc_hir::intravisit;
|
||||
use rustc_middle::hir::nested_filter::OnlyBodies;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_span::sym;
|
||||
|
||||
|
@ -41,3 +43,49 @@ pub(crate) fn predicates_and_item_bounds(tcx: TyCtxt<'_>) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn def_parents(tcx: TyCtxt<'_>) {
|
||||
for did in tcx.hir().body_owners() {
|
||||
if tcx.has_attr(did, sym::rustc_dump_def_parents) {
|
||||
struct AnonConstFinder<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
anon_consts: Vec<LocalDefId>,
|
||||
}
|
||||
|
||||
impl<'tcx> intravisit::Visitor<'tcx> for AnonConstFinder<'tcx> {
|
||||
type NestedFilter = OnlyBodies;
|
||||
|
||||
fn nested_visit_map(&mut self) -> Self::Map {
|
||||
self.tcx.hir()
|
||||
}
|
||||
|
||||
fn visit_anon_const(&mut self, c: &'tcx rustc_hir::AnonConst) {
|
||||
self.anon_consts.push(c.def_id);
|
||||
intravisit::walk_anon_const(self, c)
|
||||
}
|
||||
}
|
||||
|
||||
// Look for any anon consts inside of this body owner as there is no way to apply
|
||||
// the `rustc_dump_def_parents` attribute to the anon const so it would not be possible
|
||||
// to see what its def parent is.
|
||||
let mut anon_ct_finder = AnonConstFinder { tcx, anon_consts: vec![] };
|
||||
intravisit::walk_expr(&mut anon_ct_finder, tcx.hir().body_owned_by(did).value);
|
||||
|
||||
for did in [did].into_iter().chain(anon_ct_finder.anon_consts) {
|
||||
let span = tcx.def_span(did);
|
||||
|
||||
let mut diag = tcx.dcx().struct_span_err(
|
||||
span,
|
||||
format!("{}: {did:?}", sym::rustc_dump_def_parents.as_str()),
|
||||
);
|
||||
|
||||
let mut current_did = did.to_def_id();
|
||||
while let Some(parent_did) = tcx.opt_parent(current_did) {
|
||||
current_did = parent_did;
|
||||
diag.span_note(tcx.def_span(parent_did), format!("{parent_did:?}"));
|
||||
}
|
||||
diag.emit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -175,6 +175,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
|
|||
tcx.sess.time("variance_dumping", || variance::dump::variances(tcx));
|
||||
collect::dump::opaque_hidden_types(tcx);
|
||||
collect::dump::predicates_and_item_bounds(tcx);
|
||||
collect::dump::def_parents(tcx);
|
||||
}
|
||||
|
||||
// Make sure we evaluate all static and (non-associated) const items, even if unused.
|
||||
|
|
|
@ -2,14 +2,22 @@
|
|||
use crate::interface::{initialize_checked_jobserver, parse_cfg};
|
||||
use rustc_data_structures::profiling::TimePassesFormat;
|
||||
use rustc_errors::{emitter::HumanReadableErrorType, registry, ColorConfig};
|
||||
use rustc_session::config::{build_configuration, build_session_options, rustc_optgroups};
|
||||
use rustc_session::config::{
|
||||
build_configuration, build_session_options, rustc_optgroups, BranchProtection, CFGuard, Cfg,
|
||||
CollapseMacroDebuginfo, CoverageLevel, CoverageOptions, DebugInfo, DumpMonoStatsFormat,
|
||||
ErrorOutputType, ExternEntry, ExternLocation, Externs, FunctionReturn, InliningThreshold,
|
||||
Input, InstrumentCoverage, InstrumentXRay, LinkSelfContained, LinkerPluginLto, LocationDetail,
|
||||
LtoCli, NextSolverConfig, OomStrategy, Options, OutFileName, OutputType, OutputTypes, PAuthKey,
|
||||
PacRet, Passes, PatchableFunctionEntry, Polonius, ProcMacroExecutionStrategy, Strip,
|
||||
SwitchWithOptPath, SymbolManglingVersion, WasiExecModel,
|
||||
BranchProtection, CFGuard, Cfg, CollapseMacroDebuginfo, CoverageLevel, CoverageOptions,
|
||||
DebugInfo, DumpMonoStatsFormat, ErrorOutputType,
|
||||
};
|
||||
use rustc_session::config::{
|
||||
ExternEntry, ExternLocation, Externs, FunctionReturn, InliningThreshold, Input,
|
||||
InstrumentCoverage, InstrumentXRay, LinkSelfContained, LinkerPluginLto,
|
||||
};
|
||||
use rustc_session::config::{
|
||||
LocationDetail, LtoCli, NextSolverConfig, OomStrategy, Options, OutFileName, OutputType,
|
||||
OutputTypes, PAuthKey, PacRet, Passes, PatchableFunctionEntry,
|
||||
};
|
||||
use rustc_session::config::{
|
||||
Polonius, ProcMacroExecutionStrategy, Strip, SwitchWithOptPath, SymbolManglingVersion,
|
||||
WasiExecModel,
|
||||
};
|
||||
use rustc_session::lint::Level;
|
||||
use rustc_session::search_paths::SearchPath;
|
||||
|
|
|
@ -74,6 +74,7 @@ declare_lint_pass! {
|
|||
NON_CONTIGUOUS_RANGE_ENDPOINTS,
|
||||
NON_EXHAUSTIVE_OMITTED_PATTERNS,
|
||||
ORDER_DEPENDENT_TRAIT_OBJECTS,
|
||||
OUT_OF_SCOPE_MACRO_CALLS,
|
||||
OVERLAPPING_RANGE_ENDPOINTS,
|
||||
PATTERNS_IN_FNS_WITHOUT_BODY,
|
||||
PRIVATE_BOUNDS,
|
||||
|
|
|
@ -1074,11 +1074,11 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
|
|||
{
|
||||
lhs = *lhs_value;
|
||||
rhs = *rhs_value;
|
||||
if let Some(op) = self.try_as_operand(lhs, location) {
|
||||
*lhs_operand = op;
|
||||
}
|
||||
if let Some(op) = self.try_as_operand(rhs, location) {
|
||||
*rhs_operand = op;
|
||||
if let Some(lhs_op) = self.try_as_operand(lhs, location)
|
||||
&& let Some(rhs_op) = self.try_as_operand(rhs, location)
|
||||
{
|
||||
*lhs_operand = lhs_op;
|
||||
*rhs_operand = rhs_op;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1614,6 +1614,7 @@ symbols! {
|
|||
rustc_do_not_const_check,
|
||||
rustc_doc_primitive,
|
||||
rustc_dummy,
|
||||
rustc_dump_def_parents,
|
||||
rustc_dump_item_bounds,
|
||||
rustc_dump_predicates,
|
||||
rustc_dump_user_args,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue