Skip to content

Commit a15cce2

Browse files
committed
Auto merge of rust-lang#139979 - matthiaskrgr:rollup-7wu5169, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#139774 (Fix replacing supertrait aliases in `ReplaceProjectionWith`) - rust-lang#139850 (Hide unstable print kinds within emit_unknown_print_request_help in stable channel) - rust-lang#139870 (add retries to remove and create dir all) - rust-lang#139902 (do not emit `OpaqueCast` projections with `-Znext-solver`) - rust-lang#139931 (bootstrap: enable zlib for LLVM for Windows GNU) - rust-lang#139935 (Upgrade to `rustc-rayon-core` 0.5.1) - rust-lang#139943 (rustdoc: Support inlined cross-crate re-exported trait aliases) - rust-lang#139961 (Two `rustc_const_eval` cleanups) - rust-lang#139962 (opt-dist: add a flag for running tests) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 883f9f7 + 6922524 commit a15cce2

File tree

45 files changed

+597
-236
lines changed

Some content is hidden

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

45 files changed

+597
-236
lines changed

Cargo.lock

+2-4
Original file line numberDiff line numberDiff line change
@@ -3199,14 +3199,12 @@ dependencies = [
31993199

32003200
[[package]]
32013201
name = "rustc-rayon-core"
3202-
version = "0.5.0"
3202+
version = "0.5.1"
32033203
source = "registry+https://github.com/rust-lang/crates.io-index"
3204-
checksum = "67668daaf00e359c126f6dcb40d652d89b458a008c8afa727a42a2d20fca0b7f"
3204+
checksum = "2f42932dcd3bcbe484b38a3ccf79b7906fac41c02d408b5b1bac26da3416efdb"
32053205
dependencies = [
3206-
"crossbeam-channel",
32073206
"crossbeam-deque",
32083207
"crossbeam-utils",
3209-
"num_cpus",
32103208
]
32113209

32123210
[[package]]

compiler/rustc_const_eval/src/check_consts/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::check_consts::is_fn_or_trait_safe_to_expose_on_stable;
3434
use crate::errors;
3535

3636
type QualifResults<'mir, 'tcx, Q> =
37-
rustc_mir_dataflow::ResultsCursor<'mir, 'tcx, FlowSensitiveAnalysis<'mir, 'mir, 'tcx, Q>>;
37+
rustc_mir_dataflow::ResultsCursor<'mir, 'tcx, FlowSensitiveAnalysis<'mir, 'tcx, Q>>;
3838

3939
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
4040
enum ConstConditionsHold {

compiler/rustc_const_eval/src/check_consts/resolver.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ use super::{ConstCx, Qualif, qualifs};
2222
/// qualified immediately after it is borrowed or its address escapes. The borrow must allow for
2323
/// mutation, which includes shared borrows of places with interior mutability. The type of
2424
/// borrowed place must contain the qualif.
25-
struct TransferFunction<'a, 'mir, 'tcx, Q> {
26-
ccx: &'a ConstCx<'mir, 'tcx>,
27-
state: &'a mut State,
25+
struct TransferFunction<'mir, 'tcx, Q> {
26+
ccx: &'mir ConstCx<'mir, 'tcx>,
27+
state: &'mir mut State,
2828
_qualif: PhantomData<Q>,
2929
}
3030

31-
impl<'a, 'mir, 'tcx, Q> TransferFunction<'a, 'mir, 'tcx, Q>
31+
impl<'mir, 'tcx, Q> TransferFunction<'mir, 'tcx, Q>
3232
where
3333
Q: Qualif,
3434
{
35-
fn new(ccx: &'a ConstCx<'mir, 'tcx>, state: &'a mut State) -> Self {
35+
fn new(ccx: &'mir ConstCx<'mir, 'tcx>, state: &'mir mut State) -> Self {
3636
TransferFunction { ccx, state, _qualif: PhantomData }
3737
}
3838

@@ -124,7 +124,7 @@ where
124124
}
125125
}
126126

127-
impl<'tcx, Q> Visitor<'tcx> for TransferFunction<'_, '_, 'tcx, Q>
127+
impl<'tcx, Q> Visitor<'tcx> for TransferFunction<'_, 'tcx, Q>
128128
where
129129
Q: Qualif,
130130
{
@@ -228,20 +228,20 @@ where
228228
}
229229

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

236-
impl<'a, 'mir, 'tcx, Q> FlowSensitiveAnalysis<'a, 'mir, 'tcx, Q>
236+
impl<'mir, 'tcx, Q> FlowSensitiveAnalysis<'mir, 'tcx, Q>
237237
where
238238
Q: Qualif,
239239
{
240-
pub(super) fn new(_: Q, ccx: &'a ConstCx<'mir, 'tcx>) -> Self {
240+
pub(super) fn new(_: Q, ccx: &'mir ConstCx<'mir, 'tcx>) -> Self {
241241
FlowSensitiveAnalysis { ccx, _qualif: PhantomData }
242242
}
243243

244-
fn transfer_function(&self, state: &'a mut State) -> TransferFunction<'a, 'mir, 'tcx, Q> {
244+
fn transfer_function(&self, state: &'mir mut State) -> TransferFunction<'mir, 'tcx, Q> {
245245
TransferFunction::<Q>::new(self.ccx, state)
246246
}
247247
}
@@ -313,7 +313,7 @@ impl JoinSemiLattice for State {
313313
}
314314
}
315315

316-
impl<'tcx, Q> Analysis<'tcx> for FlowSensitiveAnalysis<'_, '_, 'tcx, Q>
316+
impl<'tcx, Q> Analysis<'tcx> for FlowSensitiveAnalysis<'_, 'tcx, Q>
317317
where
318318
Q: Qualif,
319319
{

compiler/rustc_const_eval/src/interpret/intern.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use super::{
3030
AllocId, Allocation, InterpCx, MPlaceTy, Machine, MemoryKind, PlaceTy, err_ub, interp_ok,
3131
};
3232
use crate::const_eval;
33+
use crate::const_eval::DummyMachine;
3334
use crate::errors::NestedStaticInThreadLocal;
3435

3536
pub trait CompileTimeMachine<'tcx, T> = Machine<
@@ -323,14 +324,17 @@ pub fn intern_const_alloc_for_constprop<'tcx, T, M: CompileTimeMachine<'tcx, T>>
323324
interp_ok(())
324325
}
325326

326-
impl<'tcx, M: super::intern::CompileTimeMachine<'tcx, !>> InterpCx<'tcx, M> {
327+
impl<'tcx> InterpCx<'tcx, DummyMachine> {
327328
/// A helper function that allocates memory for the layout given and gives you access to mutate
328329
/// it. Once your own mutation code is done, the backing `Allocation` is removed from the
329330
/// current `Memory` and interned as read-only into the global memory.
330331
pub fn intern_with_temp_alloc(
331332
&mut self,
332333
layout: TyAndLayout<'tcx>,
333-
f: impl FnOnce(&mut InterpCx<'tcx, M>, &PlaceTy<'tcx, M::Provenance>) -> InterpResult<'tcx, ()>,
334+
f: impl FnOnce(
335+
&mut InterpCx<'tcx, DummyMachine>,
336+
&PlaceTy<'tcx, CtfeProvenance>,
337+
) -> InterpResult<'tcx, ()>,
334338
) -> InterpResult<'tcx, AllocId> {
335339
// `allocate` picks a fresh AllocId that we will associate with its data below.
336340
let dest = self.allocate(layout, MemoryKind::Stack)?;

compiler/rustc_hir_typeck/src/expr_use_visitor.rs

+15-10
Original file line numberDiff line numberDiff line change
@@ -1502,16 +1502,21 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
15021502
let mut projections = base_place.place.projections;
15031503

15041504
let node_ty = self.cx.typeck_results().node_type(node);
1505-
// Opaque types can't have field projections, but we can instead convert
1506-
// the current place in-place (heh) to the hidden type, and then apply all
1507-
// follow up projections on that.
1508-
if node_ty != place_ty
1509-
&& self
1510-
.cx
1511-
.try_structurally_resolve_type(self.cx.tcx().hir_span(base_place.hir_id), place_ty)
1512-
.is_impl_trait()
1513-
{
1514-
projections.push(Projection { kind: ProjectionKind::OpaqueCast, ty: node_ty });
1505+
if !self.cx.tcx().next_trait_solver_globally() {
1506+
// Opaque types can't have field projections, but we can instead convert
1507+
// the current place in-place (heh) to the hidden type, and then apply all
1508+
// follow up projections on that.
1509+
if node_ty != place_ty
1510+
&& self
1511+
.cx
1512+
.try_structurally_resolve_type(
1513+
self.cx.tcx().hir_span(base_place.hir_id),
1514+
place_ty,
1515+
)
1516+
.is_impl_trait()
1517+
{
1518+
projections.push(Projection { kind: ProjectionKind::OpaqueCast, ty: node_ty });
1519+
}
15151520
}
15161521
projections.push(Projection { kind, ty });
15171522
PlaceWithHirId::new(node, base_place.place.base_ty, base_place.place.base, projections)

compiler/rustc_middle/src/hir/place.rs

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ pub enum ProjectionKind {
4040

4141
/// A conversion from an opaque type to its hidden type so we can
4242
/// do further projections on it.
43+
///
44+
/// This is unused if `-Znext-solver` is enabled.
4345
OpaqueCast,
4446
}
4547

compiler/rustc_middle/src/mir/syntax.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,8 @@ pub enum ProjectionElem<V, T> {
12421242

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

12471249
/// A transmute from an unsafe binder to the type that it wraps. This is a projection

compiler/rustc_mir_build/src/builder/matches/match_pair.rs

+14-11
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,21 @@ impl<'tcx> MatchPairTree<'tcx> {
101101
place_builder = resolved;
102102
}
103103

104-
// Only add the OpaqueCast projection if the given place is an opaque type and the
105-
// expected type from the pattern is not.
106-
let may_need_cast = match place_builder.base() {
107-
PlaceBase::Local(local) => {
108-
let ty =
109-
Place::ty_from(local, place_builder.projection(), &cx.local_decls, cx.tcx).ty;
110-
ty != pattern.ty && ty.has_opaque_types()
104+
if !cx.tcx.next_trait_solver_globally() {
105+
// Only add the OpaqueCast projection if the given place is an opaque type and the
106+
// expected type from the pattern is not.
107+
let may_need_cast = match place_builder.base() {
108+
PlaceBase::Local(local) => {
109+
let ty =
110+
Place::ty_from(local, place_builder.projection(), &cx.local_decls, cx.tcx)
111+
.ty;
112+
ty != pattern.ty && ty.has_opaque_types()
113+
}
114+
_ => true,
115+
};
116+
if may_need_cast {
117+
place_builder = place_builder.project(ProjectionElem::OpaqueCast(pattern.ty));
111118
}
112-
_ => true,
113-
};
114-
if may_need_cast {
115-
place_builder = place_builder.project(ProjectionElem::OpaqueCast(pattern.ty));
116119
}
117120

118121
let place = place_builder.try_to_place(cx);

compiler/rustc_mir_transform/src/post_analysis_normalize.rs

+15-13
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,22 @@ impl<'tcx> MutVisitor<'tcx> for PostAnalysisNormalizeVisitor<'tcx> {
3939
_context: PlaceContext,
4040
_location: Location,
4141
) {
42-
// Performance optimization: don't reintern if there is no `OpaqueCast` to remove.
43-
if place.projection.iter().all(|elem| !matches!(elem, ProjectionElem::OpaqueCast(_))) {
44-
return;
42+
if !self.tcx.next_trait_solver_globally() {
43+
// `OpaqueCast` projections are only needed if there are opaque types on which projections
44+
// are performed. After the `PostAnalysisNormalize` pass, all opaque types are replaced with their
45+
// hidden types, so we don't need these projections anymore.
46+
//
47+
// Performance optimization: don't reintern if there is no `OpaqueCast` to remove.
48+
if place.projection.iter().any(|elem| matches!(elem, ProjectionElem::OpaqueCast(_))) {
49+
place.projection = self.tcx.mk_place_elems(
50+
&place
51+
.projection
52+
.into_iter()
53+
.filter(|elem| !matches!(elem, ProjectionElem::OpaqueCast(_)))
54+
.collect::<Vec<_>>(),
55+
);
56+
};
4557
}
46-
// `OpaqueCast` projections are only needed if there are opaque types on which projections
47-
// are performed. After the `PostAnalysisNormalize` pass, all opaque types are replaced with their
48-
// hidden types, so we don't need these projections anymore.
49-
place.projection = self.tcx.mk_place_elems(
50-
&place
51-
.projection
52-
.into_iter()
53-
.filter(|elem| !matches!(elem, ProjectionElem::OpaqueCast(_)))
54-
.collect::<Vec<_>>(),
55-
);
5658
self.super_place(place, _context, _location);
5759
}
5860

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

+14-10
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,20 @@ where
9292
let ty::Dynamic(bounds, _, _) = goal.predicate.self_ty().kind() else {
9393
panic!("expected object type in `probe_and_consider_object_bound_candidate`");
9494
};
95-
ecx.add_goals(
96-
GoalSource::ImplWhereBound,
97-
structural_traits::predicates_for_object_candidate(
98-
ecx,
99-
goal.param_env,
100-
goal.predicate.trait_ref(cx),
101-
bounds,
102-
),
103-
);
104-
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
95+
match structural_traits::predicates_for_object_candidate(
96+
ecx,
97+
goal.param_env,
98+
goal.predicate.trait_ref(cx),
99+
bounds,
100+
) {
101+
Ok(requirements) => {
102+
ecx.add_goals(GoalSource::ImplWhereBound, requirements);
103+
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
104+
}
105+
Err(_) => {
106+
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
107+
}
108+
}
105109
})
106110
}
107111

0 commit comments

Comments
 (0)