Skip to content

Commit 6dfeab5

Browse files
committed
Auto merge of rust-lang#137001 - workingjubilee:rollup-u3dn4gc, r=workingjubilee
Rollup of 11 pull requests Successful merges: - rust-lang#136863 (rework rigid alias handling ) - rust-lang#136869 (Fix diagnostic when using = instead of : in let binding) - rust-lang#136895 (debuginfo: Set bitwidth appropriately in enum variant tags) - rust-lang#136928 (eagerly prove WF when resolving fully qualified paths) - rust-lang#136941 (Move `llvm.ccache` to `build.ccache`) - rust-lang#136950 (rustdoc: use better, consistent SVG icons for scraped examples) - rust-lang#136957 (coverage: Eliminate more counters by giving them to unreachable nodes) - rust-lang#136960 (Compiletest should not inherit all host RUSTFLAGS) - rust-lang#136962 (unify LLVM version finding logic) - rust-lang#136970 (ci: move `x86_64-gnu-debug` job to the free runner) - rust-lang#136973 (Fix `x test --stage 1 ui-fulldeps` on macOS (until the next beta bump)) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a567209 + 6eb3929 commit 6dfeab5

File tree

74 files changed

+1159
-681
lines changed

Some content is hidden

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

74 files changed

+1159
-681
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,12 @@ fn build_enum_variant_member_di_node<'ll, 'tcx>(
437437
.source_info
438438
.unwrap_or_else(|| (unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER));
439439

440+
let discr = discr_value.opt_single_val().map(|value| {
441+
let tag_base_type = tag_base_type(cx.tcx, enum_type_and_layout);
442+
let size = cx.size_of(tag_base_type);
443+
cx.const_uint_big(cx.type_ix(size.bits()), value)
444+
});
445+
440446
unsafe {
441447
llvm::LLVMRustDIBuilderCreateVariantMemberType(
442448
DIB(cx),
@@ -448,7 +454,7 @@ fn build_enum_variant_member_di_node<'ll, 'tcx>(
448454
enum_type_and_layout.size.bits(),
449455
enum_type_and_layout.align.abi.bits() as u32,
450456
Size::ZERO.bits(),
451-
discr_value.opt_single_val().map(|value| cx.const_u128(value)),
457+
discr,
452458
DIFlags::FlagZero,
453459
variant_member_info.variant_struct_type_di_node,
454460
)

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+8-25
Original file line numberDiff line numberDiff line change
@@ -798,13 +798,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
798798
bug!("`resolve_ty_and_res_fully_qualified_call` called on `LangItem`")
799799
}
800800
};
801+
802+
self.register_wf_obligation(
803+
ty.raw.into(),
804+
qself.span,
805+
ObligationCauseCode::WellFormed(None),
806+
);
807+
self.select_obligations_where_possible(|_| {});
808+
801809
if let Some(&cached_result) = self.typeck_results.borrow().type_dependent_defs().get(hir_id)
802810
{
803-
self.register_wf_obligation(
804-
ty.raw.into(),
805-
qself.span,
806-
ObligationCauseCode::WellFormed(None),
807-
);
808811
// Return directly on cache hit. This is useful to avoid doubly reporting
809812
// errors with default match binding modes. See #44614.
810813
let def = cached_result.map_or(Res::Err, |(kind, def_id)| Res::Def(kind, def_id));
@@ -824,18 +827,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
824827

825828
let trait_missing_method =
826829
matches!(error, method::MethodError::NoMatch(_)) && ty.normalized.is_trait();
827-
// If we have a path like `MyTrait::missing_method`, then don't register
828-
// a WF obligation for `dyn MyTrait` when method lookup fails. Otherwise,
829-
// register a WF obligation so that we can detect any additional
830-
// errors in the self type.
831-
if !trait_missing_method {
832-
self.register_wf_obligation(
833-
ty.raw.into(),
834-
qself.span,
835-
ObligationCauseCode::WellFormed(None),
836-
);
837-
}
838-
839830
if item_name.name != kw::Empty {
840831
self.report_method_error(
841832
hir_id,
@@ -849,14 +840,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
849840
result
850841
});
851842

852-
if result.is_ok() {
853-
self.register_wf_obligation(
854-
ty.raw.into(),
855-
qself.span,
856-
ObligationCauseCode::WellFormed(None),
857-
);
858-
}
859-
860843
// Write back the new resolution.
861844
self.write_resolution(hir_id, result);
862845
(

compiler/rustc_mir_transform/src/coverage/counters.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,8 @@ pub(crate) fn transcribe_counters(
114114
let mut new_counters_for_sites = |sites: Vec<BasicCoverageBlock>| {
115115
sites.into_iter().map(|node| new.ensure_phys_counter(node)).collect::<Vec<_>>()
116116
};
117-
let mut pos = new_counters_for_sites(pos);
118-
let mut neg = new_counters_for_sites(neg);
119-
120-
// These sorts are also not strictly necessary; see above.
121-
pos.sort();
122-
neg.sort();
117+
let pos = new_counters_for_sites(pos);
118+
let neg = new_counters_for_sites(neg);
123119

124120
let pos_counter = new.make_sum(&pos).unwrap_or(CovTerm::Zero);
125121
let new_counter = new.make_subtracted_sum(pos_counter, &neg);

compiler/rustc_mir_transform/src/coverage/query.rs

+14-5
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,20 @@ fn coverage_ids_info<'tcx>(
123123
}
124124
}
125125

126-
// FIXME(Zalathar): It should be possible to sort `priority_list[1..]` by
127-
// `!bcbs_seen.contains(bcb)` to simplify the mappings even further, at the
128-
// expense of some churn in the tests. When doing so, also consider removing
129-
// the sorts in `transcribe_counters`.
130-
let node_counters = make_node_counters(&fn_cov_info.node_flow_data, &fn_cov_info.priority_list);
126+
// Clone the priority list so that we can re-sort it.
127+
let mut priority_list = fn_cov_info.priority_list.clone();
128+
// The first ID in the priority list represents the synthetic "sink" node,
129+
// and must remain first so that it _never_ gets a physical counter.
130+
debug_assert_eq!(priority_list[0], priority_list.iter().copied().max().unwrap());
131+
assert!(!bcbs_seen.contains(priority_list[0]));
132+
// Partition the priority list, so that unreachable nodes (removed by MIR opts)
133+
// are sorted later and therefore are _more_ likely to get a physical counter.
134+
// This is counter-intuitive, but it means that `transcribe_counters` can
135+
// easily skip those unused physical counters and replace them with zero.
136+
// (The original ordering remains in effect within both partitions.)
137+
priority_list[1..].sort_by_key(|&bcb| !bcbs_seen.contains(bcb));
138+
139+
let node_counters = make_node_counters(&fn_cov_info.node_flow_data, &priority_list);
131140
let coverage_counters = transcribe_counters(&node_counters, &bcb_needs_counter, &bcbs_seen);
132141

133142
let CoverageCounters {

compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs

+23-28
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use derive_where::derive_where;
66
use rustc_type_ir::fold::TypeFoldable;
77
use rustc_type_ir::inherent::*;
88
use rustc_type_ir::lang_items::TraitSolverLangItem;
9-
use rustc_type_ir::solve::inspect;
109
use rustc_type_ir::visit::TypeVisitableExt as _;
1110
use rustc_type_ir::{self as ty, Interner, TypingMode, Upcast as _, elaborate};
1211
use tracing::{debug, instrument};
@@ -297,25 +296,6 @@ where
297296
let Ok(normalized_self_ty) =
298297
self.structurally_normalize_ty(goal.param_env, goal.predicate.self_ty())
299298
else {
300-
// FIXME: We register a fake candidate when normalization fails so that
301-
// we can point at the reason for *why*. I'm tempted to say that this
302-
// is the wrong way to do this, though.
303-
let result =
304-
self.probe(|&result| inspect::ProbeKind::RigidAlias { result }).enter(|this| {
305-
let normalized_ty = this.next_ty_infer();
306-
let alias_relate_goal = Goal::new(
307-
this.cx(),
308-
goal.param_env,
309-
ty::PredicateKind::AliasRelate(
310-
goal.predicate.self_ty().into(),
311-
normalized_ty.into(),
312-
ty::AliasRelationDirection::Equate,
313-
),
314-
);
315-
this.add_goal(GoalSource::AliasWellFormed, alias_relate_goal);
316-
this.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
317-
});
318-
assert_eq!(result, Err(NoSolution));
319299
return vec![];
320300
};
321301

@@ -797,11 +777,12 @@ where
797777
/// treat the alias as rigid.
798778
///
799779
/// See trait-system-refactor-initiative#124 for more details.
800-
#[instrument(level = "debug", skip(self), ret)]
780+
#[instrument(level = "debug", skip(self, inject_normalize_to_rigid_candidate), ret)]
801781
pub(super) fn merge_candidates(
802782
&mut self,
803783
proven_via: Option<TraitGoalProvenVia>,
804784
candidates: Vec<Candidate<I>>,
785+
inject_normalize_to_rigid_candidate: impl FnOnce(&mut EvalCtxt<'_, D>) -> QueryResult<I>,
805786
) -> QueryResult<I> {
806787
let Some(proven_via) = proven_via else {
807788
// We don't care about overflow. If proving the trait goal overflowed, then
@@ -818,13 +799,27 @@ where
818799
// FIXME(const_trait_impl): should this behavior also be used by
819800
// constness checking. Doing so is *at least theoretically* breaking,
820801
// see github.com/rust-lang/rust/issues/133044#issuecomment-2500709754
821-
TraitGoalProvenVia::ParamEnv | TraitGoalProvenVia::AliasBound => candidates
822-
.iter()
823-
.filter(|c| {
824-
matches!(c.source, CandidateSource::AliasBound | CandidateSource::ParamEnv(_))
825-
})
826-
.map(|c| c.result)
827-
.collect(),
802+
TraitGoalProvenVia::ParamEnv | TraitGoalProvenVia::AliasBound => {
803+
let mut candidates_from_env: Vec<_> = candidates
804+
.iter()
805+
.filter(|c| {
806+
matches!(
807+
c.source,
808+
CandidateSource::AliasBound | CandidateSource::ParamEnv(_)
809+
)
810+
})
811+
.map(|c| c.result)
812+
.collect();
813+
814+
// If the trait goal has been proven by using the environment, we want to treat
815+
// aliases as rigid if there are no applicable projection bounds in the environment.
816+
if candidates_from_env.is_empty() {
817+
if let Ok(response) = inject_normalize_to_rigid_candidate(self) {
818+
candidates_from_env.push(response);
819+
}
820+
}
821+
candidates_from_env
822+
}
828823
TraitGoalProvenVia::Misc => candidates.iter().map(|c| c.result).collect(),
829824
};
830825

compiler/rustc_next_trait_solver/src/solve/effect_goals.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,6 @@ where
405405
goal.with(ecx.cx(), goal.predicate.trait_ref);
406406
ecx.compute_trait_goal(trait_goal)
407407
})?;
408-
self.merge_candidates(proven_via, candidates)
408+
self.merge_candidates(proven_via, candidates, |_ecx| Err(NoSolution))
409409
}
410410
}

0 commit comments

Comments
 (0)