Skip to content

Rollup of 10 pull requests #139973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
96984c0
add retry support to recursive_remove
Shourya742 Apr 15, 2025
003d633
add remove_and_create_dir_all in build_helper
Shourya742 Apr 15, 2025
d4eab8a
remove old remove_and_create_dir_all and use build_helpers remove_and…
Shourya742 Apr 15, 2025
b4b9cfb
Upgrade to `rustc-rayon-core` 0.5.1
cuviper Apr 16, 2025
3863018
Fix replacing supertrait aliases in ReplaceProjectionWith
compiler-errors Apr 16, 2025
e1936d2
Remove FIXME that is no longer relevant
compiler-errors Apr 14, 2025
9f548e2
Support inlined cross-crate re-exported trait aliases
fmease Apr 17, 2025
675360a
Remove some unnecessary lifetimes.
nnethercote Oct 22, 2024
99a60eb
`intern_with_temp_alloc` is for `DummyMachine` only.
nnethercote Oct 22, 2024
bf26963
bootstrap: enable zlib for LLVM when we compile it for profiling
ognevny Apr 17, 2025
62a104d
opt-dist: add a flag for running tests
ognevny Apr 17, 2025
289a23e
do not emit `OpaqueCast` projections with `-Znext-solver`
lcnr Apr 16, 2025
c85b5fc
check OpaqueCast tests with next-solver
lcnr Apr 17, 2025
857fe8f
Add tests for two untested cases of placeholder relations
amandasystems Apr 17, 2025
8562110
Hide unstable print kinds within emit_unknown_print_request_help in s…
xizheyin Apr 15, 2025
fef2fcb
Rollup merge of #139774 - compiler-errors:supertrait-alias, r=lcnr
matthiaskrgr Apr 17, 2025
bd3c3ba
Rollup merge of #139850 - xizheyin:issue-138698, r=jieyouxu
matthiaskrgr Apr 17, 2025
8f303db
Rollup merge of #139870 - Shourya742:2025-04-15-add-retries-to-remove…
matthiaskrgr Apr 17, 2025
677b31b
Rollup merge of #139902 - lcnr:no-opaque-cast-projection, r=oli-obk
matthiaskrgr Apr 17, 2025
551ca83
Rollup merge of #139931 - ognevny:bootstrap-llvm-zlib, r=Kobzol
matthiaskrgr Apr 17, 2025
b1f0946
Rollup merge of #139935 - cuviper:rustc-rayon-core-0.5.1, r=lqd
matthiaskrgr Apr 17, 2025
0ccdcc4
Rollup merge of #139943 - fmease:rustdoc-ixcre-trait-aliases, r=Guill…
matthiaskrgr Apr 17, 2025
b40e2a3
Rollup merge of #139960 - amandasystems:placeholder-ui-tests, r=lcnr
matthiaskrgr Apr 17, 2025
931f0a8
Rollup merge of #139961 - nnethercote:two-rustc_const_eval-cleanups, …
matthiaskrgr Apr 17, 2025
15a3952
Rollup merge of #139962 - ognevny:opt-dist-tests, r=Kobzol
matthiaskrgr Apr 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3199,14 +3199,12 @@ dependencies = [

[[package]]
name = "rustc-rayon-core"
version = "0.5.0"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67668daaf00e359c126f6dcb40d652d89b458a008c8afa727a42a2d20fca0b7f"
checksum = "2f42932dcd3bcbe484b38a3ccf79b7906fac41c02d408b5b1bac26da3416efdb"
dependencies = [
"crossbeam-channel",
"crossbeam-deque",
"crossbeam-utils",
"num_cpus",
]

[[package]]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/check_consts/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use crate::check_consts::is_fn_or_trait_safe_to_expose_on_stable;
use crate::errors;

type QualifResults<'mir, 'tcx, Q> =
rustc_mir_dataflow::ResultsCursor<'mir, 'tcx, FlowSensitiveAnalysis<'mir, 'mir, 'tcx, Q>>;
rustc_mir_dataflow::ResultsCursor<'mir, 'tcx, FlowSensitiveAnalysis<'mir, 'tcx, Q>>;

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
enum ConstConditionsHold {
Expand Down
24 changes: 12 additions & 12 deletions compiler/rustc_const_eval/src/check_consts/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ use super::{ConstCx, Qualif, qualifs};
/// qualified immediately after it is borrowed or its address escapes. The borrow must allow for
/// mutation, which includes shared borrows of places with interior mutability. The type of
/// borrowed place must contain the qualif.
struct TransferFunction<'a, 'mir, 'tcx, Q> {
ccx: &'a ConstCx<'mir, 'tcx>,
state: &'a mut State,
struct TransferFunction<'mir, 'tcx, Q> {
ccx: &'mir ConstCx<'mir, 'tcx>,
state: &'mir mut State,
_qualif: PhantomData<Q>,
}

impl<'a, 'mir, 'tcx, Q> TransferFunction<'a, 'mir, 'tcx, Q>
impl<'mir, 'tcx, Q> TransferFunction<'mir, 'tcx, Q>
where
Q: Qualif,
{
fn new(ccx: &'a ConstCx<'mir, 'tcx>, state: &'a mut State) -> Self {
fn new(ccx: &'mir ConstCx<'mir, 'tcx>, state: &'mir mut State) -> Self {
TransferFunction { ccx, state, _qualif: PhantomData }
}

Expand Down Expand Up @@ -124,7 +124,7 @@ where
}
}

impl<'tcx, Q> Visitor<'tcx> for TransferFunction<'_, '_, 'tcx, Q>
impl<'tcx, Q> Visitor<'tcx> for TransferFunction<'_, 'tcx, Q>
where
Q: Qualif,
{
Expand Down Expand Up @@ -228,20 +228,20 @@ where
}

/// The dataflow analysis used to propagate qualifs on arbitrary CFGs.
pub(super) struct FlowSensitiveAnalysis<'a, 'mir, 'tcx, Q> {
ccx: &'a ConstCx<'mir, 'tcx>,
pub(super) struct FlowSensitiveAnalysis<'mir, 'tcx, Q> {
ccx: &'mir ConstCx<'mir, 'tcx>,
_qualif: PhantomData<Q>,
}

impl<'a, 'mir, 'tcx, Q> FlowSensitiveAnalysis<'a, 'mir, 'tcx, Q>
impl<'mir, 'tcx, Q> FlowSensitiveAnalysis<'mir, 'tcx, Q>
where
Q: Qualif,
{
pub(super) fn new(_: Q, ccx: &'a ConstCx<'mir, 'tcx>) -> Self {
pub(super) fn new(_: Q, ccx: &'mir ConstCx<'mir, 'tcx>) -> Self {
FlowSensitiveAnalysis { ccx, _qualif: PhantomData }
}

fn transfer_function(&self, state: &'a mut State) -> TransferFunction<'a, 'mir, 'tcx, Q> {
fn transfer_function(&self, state: &'mir mut State) -> TransferFunction<'mir, 'tcx, Q> {
TransferFunction::<Q>::new(self.ccx, state)
}
}
Expand Down Expand Up @@ -313,7 +313,7 @@ impl JoinSemiLattice for State {
}
}

impl<'tcx, Q> Analysis<'tcx> for FlowSensitiveAnalysis<'_, '_, 'tcx, Q>
impl<'tcx, Q> Analysis<'tcx> for FlowSensitiveAnalysis<'_, 'tcx, Q>
where
Q: Qualif,
{
Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_const_eval/src/interpret/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use super::{
AllocId, Allocation, InterpCx, MPlaceTy, Machine, MemoryKind, PlaceTy, err_ub, interp_ok,
};
use crate::const_eval;
use crate::const_eval::DummyMachine;
use crate::errors::NestedStaticInThreadLocal;

pub trait CompileTimeMachine<'tcx, T> = Machine<
Expand Down Expand Up @@ -323,14 +324,17 @@ pub fn intern_const_alloc_for_constprop<'tcx, T, M: CompileTimeMachine<'tcx, T>>
interp_ok(())
}

impl<'tcx, M: super::intern::CompileTimeMachine<'tcx, !>> InterpCx<'tcx, M> {
impl<'tcx> InterpCx<'tcx, DummyMachine> {
/// A helper function that allocates memory for the layout given and gives you access to mutate
/// it. Once your own mutation code is done, the backing `Allocation` is removed from the
/// current `Memory` and interned as read-only into the global memory.
pub fn intern_with_temp_alloc(
&mut self,
layout: TyAndLayout<'tcx>,
f: impl FnOnce(&mut InterpCx<'tcx, M>, &PlaceTy<'tcx, M::Provenance>) -> InterpResult<'tcx, ()>,
f: impl FnOnce(
&mut InterpCx<'tcx, DummyMachine>,
&PlaceTy<'tcx, CtfeProvenance>,
) -> InterpResult<'tcx, ()>,
) -> InterpResult<'tcx, AllocId> {
// `allocate` picks a fresh AllocId that we will associate with its data below.
let dest = self.allocate(layout, MemoryKind::Stack)?;
Expand Down
25 changes: 15 additions & 10 deletions compiler/rustc_hir_typeck/src/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1502,16 +1502,21 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
let mut projections = base_place.place.projections;

let node_ty = self.cx.typeck_results().node_type(node);
// Opaque types can't have field projections, but we can instead convert
// the current place in-place (heh) to the hidden type, and then apply all
// follow up projections on that.
if node_ty != place_ty
&& self
.cx
.try_structurally_resolve_type(self.cx.tcx().hir_span(base_place.hir_id), place_ty)
.is_impl_trait()
{
projections.push(Projection { kind: ProjectionKind::OpaqueCast, ty: node_ty });
if !self.cx.tcx().next_trait_solver_globally() {
// Opaque types can't have field projections, but we can instead convert
// the current place in-place (heh) to the hidden type, and then apply all
// follow up projections on that.
if node_ty != place_ty
&& self
.cx
.try_structurally_resolve_type(
self.cx.tcx().hir_span(base_place.hir_id),
place_ty,
)
.is_impl_trait()
{
projections.push(Projection { kind: ProjectionKind::OpaqueCast, ty: node_ty });
}
}
projections.push(Projection { kind, ty });
PlaceWithHirId::new(node, base_place.place.base_ty, base_place.place.base, projections)
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_middle/src/hir/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub enum ProjectionKind {

/// A conversion from an opaque type to its hidden type so we can
/// do further projections on it.
///
/// This is unused if `-Znext-solver` is enabled.
OpaqueCast,
}

Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_middle/src/mir/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,8 @@ pub enum ProjectionElem<V, T> {

/// Like an explicit cast from an opaque type to a concrete type, but without
/// requiring an intermediate variable.
///
/// This is unused with `-Znext-solver`.
OpaqueCast(T),

/// A transmute from an unsafe binder to the type that it wraps. This is a projection
Expand Down
25 changes: 14 additions & 11 deletions compiler/rustc_mir_build/src/builder/matches/match_pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,21 @@ impl<'tcx> MatchPairTree<'tcx> {
place_builder = resolved;
}

// Only add the OpaqueCast projection if the given place is an opaque type and the
// expected type from the pattern is not.
let may_need_cast = match place_builder.base() {
PlaceBase::Local(local) => {
let ty =
Place::ty_from(local, place_builder.projection(), &cx.local_decls, cx.tcx).ty;
ty != pattern.ty && ty.has_opaque_types()
if !cx.tcx.next_trait_solver_globally() {
// Only add the OpaqueCast projection if the given place is an opaque type and the
// expected type from the pattern is not.
let may_need_cast = match place_builder.base() {
PlaceBase::Local(local) => {
let ty =
Place::ty_from(local, place_builder.projection(), &cx.local_decls, cx.tcx)
.ty;
ty != pattern.ty && ty.has_opaque_types()
}
_ => true,
};
if may_need_cast {
place_builder = place_builder.project(ProjectionElem::OpaqueCast(pattern.ty));
}
_ => true,
};
if may_need_cast {
place_builder = place_builder.project(ProjectionElem::OpaqueCast(pattern.ty));
}

let place = place_builder.try_to_place(cx);
Expand Down
28 changes: 15 additions & 13 deletions compiler/rustc_mir_transform/src/post_analysis_normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,22 @@ impl<'tcx> MutVisitor<'tcx> for PostAnalysisNormalizeVisitor<'tcx> {
_context: PlaceContext,
_location: Location,
) {
// Performance optimization: don't reintern if there is no `OpaqueCast` to remove.
if place.projection.iter().all(|elem| !matches!(elem, ProjectionElem::OpaqueCast(_))) {
return;
if !self.tcx.next_trait_solver_globally() {
// `OpaqueCast` projections are only needed if there are opaque types on which projections
// are performed. After the `PostAnalysisNormalize` pass, all opaque types are replaced with their
// hidden types, so we don't need these projections anymore.
//
// Performance optimization: don't reintern if there is no `OpaqueCast` to remove.
if place.projection.iter().any(|elem| matches!(elem, ProjectionElem::OpaqueCast(_))) {
place.projection = self.tcx.mk_place_elems(
&place
.projection
.into_iter()
.filter(|elem| !matches!(elem, ProjectionElem::OpaqueCast(_)))
.collect::<Vec<_>>(),
);
};
}
// `OpaqueCast` projections are only needed if there are opaque types on which projections
// are performed. After the `PostAnalysisNormalize` pass, all opaque types are replaced with their
// hidden types, so we don't need these projections anymore.
place.projection = self.tcx.mk_place_elems(
&place
.projection
.into_iter()
.filter(|elem| !matches!(elem, ProjectionElem::OpaqueCast(_)))
.collect::<Vec<_>>(),
);
self.super_place(place, _context, _location);
}

Expand Down
24 changes: 14 additions & 10 deletions compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,20 @@ where
let ty::Dynamic(bounds, _, _) = goal.predicate.self_ty().kind() else {
panic!("expected object type in `probe_and_consider_object_bound_candidate`");
};
ecx.add_goals(
GoalSource::ImplWhereBound,
structural_traits::predicates_for_object_candidate(
ecx,
goal.param_env,
goal.predicate.trait_ref(cx),
bounds,
),
);
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
match structural_traits::predicates_for_object_candidate(
ecx,
goal.param_env,
goal.predicate.trait_ref(cx),
bounds,
) {
Ok(requirements) => {
ecx.add_goals(GoalSource::ImplWhereBound, requirements);
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
}
Err(_) => {
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
}
}
})
}

Expand Down
Loading
Loading