Skip to content

Commit

Permalink
Auto merge of #137001 - workingjubilee:rollup-u3dn4gc, r=workingjubilee
Browse files Browse the repository at this point in the history
Rollup of 11 pull requests

Successful merges:

 - #136863 (rework rigid alias handling )
 - #136869 (Fix diagnostic when using = instead of : in let binding)
 - #136895 (debuginfo: Set bitwidth appropriately in enum variant tags)
 - #136928 (eagerly prove WF when resolving fully qualified paths)
 - #136941 (Move `llvm.ccache` to `build.ccache`)
 - #136950 (rustdoc: use better, consistent SVG icons for scraped examples)
 - #136957 (coverage: Eliminate more counters by giving them to unreachable nodes)
 - #136960 (Compiletest should not inherit all host RUSTFLAGS)
 - #136962 (unify LLVM version finding logic)
 - #136970 (ci: move `x86_64-gnu-debug` job to the free runner)
 - #136973 (Fix `x test --stage 1 ui-fulldeps` on macOS (until the next beta bump))

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Feb 14, 2025
2 parents a567209 + 6eb3929 commit 6dfeab5
Show file tree
Hide file tree
Showing 74 changed files with 1,159 additions and 681 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,12 @@ fn build_enum_variant_member_di_node<'ll, 'tcx>(
.source_info
.unwrap_or_else(|| (unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER));

let discr = discr_value.opt_single_val().map(|value| {
let tag_base_type = tag_base_type(cx.tcx, enum_type_and_layout);
let size = cx.size_of(tag_base_type);
cx.const_uint_big(cx.type_ix(size.bits()), value)
});

unsafe {
llvm::LLVMRustDIBuilderCreateVariantMemberType(
DIB(cx),
Expand All @@ -448,7 +454,7 @@ fn build_enum_variant_member_di_node<'ll, 'tcx>(
enum_type_and_layout.size.bits(),
enum_type_and_layout.align.abi.bits() as u32,
Size::ZERO.bits(),
discr_value.opt_single_val().map(|value| cx.const_u128(value)),
discr,
DIFlags::FlagZero,
variant_member_info.variant_struct_type_di_node,
)
Expand Down
33 changes: 8 additions & 25 deletions compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,13 +798,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
bug!("`resolve_ty_and_res_fully_qualified_call` called on `LangItem`")
}
};

self.register_wf_obligation(
ty.raw.into(),
qself.span,
ObligationCauseCode::WellFormed(None),
);
self.select_obligations_where_possible(|_| {});

if let Some(&cached_result) = self.typeck_results.borrow().type_dependent_defs().get(hir_id)
{
self.register_wf_obligation(
ty.raw.into(),
qself.span,
ObligationCauseCode::WellFormed(None),
);
// Return directly on cache hit. This is useful to avoid doubly reporting
// errors with default match binding modes. See #44614.
let def = cached_result.map_or(Res::Err, |(kind, def_id)| Res::Def(kind, def_id));
Expand All @@ -824,18 +827,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

let trait_missing_method =
matches!(error, method::MethodError::NoMatch(_)) && ty.normalized.is_trait();
// If we have a path like `MyTrait::missing_method`, then don't register
// a WF obligation for `dyn MyTrait` when method lookup fails. Otherwise,
// register a WF obligation so that we can detect any additional
// errors in the self type.
if !trait_missing_method {
self.register_wf_obligation(
ty.raw.into(),
qself.span,
ObligationCauseCode::WellFormed(None),
);
}

if item_name.name != kw::Empty {
self.report_method_error(
hir_id,
Expand All @@ -849,14 +840,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
result
});

if result.is_ok() {
self.register_wf_obligation(
ty.raw.into(),
qself.span,
ObligationCauseCode::WellFormed(None),
);
}

// Write back the new resolution.
self.write_resolution(hir_id, result);
(
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_mir_transform/src/coverage/counters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,8 @@ pub(crate) fn transcribe_counters(
let mut new_counters_for_sites = |sites: Vec<BasicCoverageBlock>| {
sites.into_iter().map(|node| new.ensure_phys_counter(node)).collect::<Vec<_>>()
};
let mut pos = new_counters_for_sites(pos);
let mut neg = new_counters_for_sites(neg);

// These sorts are also not strictly necessary; see above.
pos.sort();
neg.sort();
let pos = new_counters_for_sites(pos);
let neg = new_counters_for_sites(neg);

let pos_counter = new.make_sum(&pos).unwrap_or(CovTerm::Zero);
let new_counter = new.make_subtracted_sum(pos_counter, &neg);
Expand Down
19 changes: 14 additions & 5 deletions compiler/rustc_mir_transform/src/coverage/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,20 @@ fn coverage_ids_info<'tcx>(
}
}

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

let node_counters = make_node_counters(&fn_cov_info.node_flow_data, &priority_list);
let coverage_counters = transcribe_counters(&node_counters, &bcb_needs_counter, &bcbs_seen);

let CoverageCounters {
Expand Down
51 changes: 23 additions & 28 deletions compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use derive_where::derive_where;
use rustc_type_ir::fold::TypeFoldable;
use rustc_type_ir::inherent::*;
use rustc_type_ir::lang_items::TraitSolverLangItem;
use rustc_type_ir::solve::inspect;
use rustc_type_ir::visit::TypeVisitableExt as _;
use rustc_type_ir::{self as ty, Interner, TypingMode, Upcast as _, elaborate};
use tracing::{debug, instrument};
Expand Down Expand Up @@ -297,25 +296,6 @@ where
let Ok(normalized_self_ty) =
self.structurally_normalize_ty(goal.param_env, goal.predicate.self_ty())
else {
// FIXME: We register a fake candidate when normalization fails so that
// we can point at the reason for *why*. I'm tempted to say that this
// is the wrong way to do this, though.
let result =
self.probe(|&result| inspect::ProbeKind::RigidAlias { result }).enter(|this| {
let normalized_ty = this.next_ty_infer();
let alias_relate_goal = Goal::new(
this.cx(),
goal.param_env,
ty::PredicateKind::AliasRelate(
goal.predicate.self_ty().into(),
normalized_ty.into(),
ty::AliasRelationDirection::Equate,
),
);
this.add_goal(GoalSource::AliasWellFormed, alias_relate_goal);
this.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
});
assert_eq!(result, Err(NoSolution));
return vec![];
};

Expand Down Expand Up @@ -797,11 +777,12 @@ where
/// treat the alias as rigid.
///
/// See trait-system-refactor-initiative#124 for more details.
#[instrument(level = "debug", skip(self), ret)]
#[instrument(level = "debug", skip(self, inject_normalize_to_rigid_candidate), ret)]
pub(super) fn merge_candidates(
&mut self,
proven_via: Option<TraitGoalProvenVia>,
candidates: Vec<Candidate<I>>,
inject_normalize_to_rigid_candidate: impl FnOnce(&mut EvalCtxt<'_, D>) -> QueryResult<I>,
) -> QueryResult<I> {
let Some(proven_via) = proven_via else {
// We don't care about overflow. If proving the trait goal overflowed, then
Expand All @@ -818,13 +799,27 @@ where
// FIXME(const_trait_impl): should this behavior also be used by
// constness checking. Doing so is *at least theoretically* breaking,
// see github.com/rust-lang/rust/issues/133044#issuecomment-2500709754
TraitGoalProvenVia::ParamEnv | TraitGoalProvenVia::AliasBound => candidates
.iter()
.filter(|c| {
matches!(c.source, CandidateSource::AliasBound | CandidateSource::ParamEnv(_))
})
.map(|c| c.result)
.collect(),
TraitGoalProvenVia::ParamEnv | TraitGoalProvenVia::AliasBound => {
let mut candidates_from_env: Vec<_> = candidates
.iter()
.filter(|c| {
matches!(
c.source,
CandidateSource::AliasBound | CandidateSource::ParamEnv(_)
)
})
.map(|c| c.result)
.collect();

// If the trait goal has been proven by using the environment, we want to treat
// aliases as rigid if there are no applicable projection bounds in the environment.
if candidates_from_env.is_empty() {
if let Ok(response) = inject_normalize_to_rigid_candidate(self) {
candidates_from_env.push(response);
}
}
candidates_from_env
}
TraitGoalProvenVia::Misc => candidates.iter().map(|c| c.result).collect(),
};

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_next_trait_solver/src/solve/effect_goals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,6 @@ where
goal.with(ecx.cx(), goal.predicate.trait_ref);
ecx.compute_trait_goal(trait_goal)
})?;
self.merge_candidates(proven_via, candidates)
self.merge_candidates(proven_via, candidates, |_ecx| Err(NoSolution))
}
}
Loading

0 comments on commit 6dfeab5

Please sign in to comment.