Skip to content

Commit 0b2f194

Browse files
committed
Auto merge of rust-lang#125541 - matthiaskrgr:rollup-4gwt4xp, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#125271 (use posix_memalign on almost all Unix targets) - rust-lang#125451 (Fail relating constants of different types) - rust-lang#125478 (Bump bootstrap compiler to the latest beta compiler) - rust-lang#125498 (Stop using the avx512er and avx512pf x86 target features) - rust-lang#125510 (remove proof tree formatting, make em shallow) - rust-lang#125513 (Don't eagerly monomorphize drop for types that are impossible to instantiate) - rust-lang#125514 (Structurally resolve before `builtin_index` in EUV) - rust-lang#125527 (Add manual Sync impl for ReentrantLockGuard) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 77d4115 + 1d54ba8 commit 0b2f194

File tree

54 files changed

+797
-1134
lines changed

Some content is hidden

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

54 files changed

+797
-1134
lines changed

compiler/rustc_hir_typeck/src/expr_use_visitor.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1741,7 +1741,11 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
17411741
}
17421742

17431743
PatKind::Slice(before, ref slice, after) => {
1744-
let Some(element_ty) = place_with_id.place.ty().builtin_index() else {
1744+
let Some(element_ty) = self
1745+
.cx
1746+
.try_structurally_resolve_type(pat.span, place_with_id.place.ty())
1747+
.builtin_index()
1748+
else {
17451749
debug!("explicit index of non-indexable type {:?}", place_with_id);
17461750
return Err(self
17471751
.cx

compiler/rustc_infer/src/infer/relate/combine.rs

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ use super::glb::Glb;
2222
use super::lub::Lub;
2323
use super::type_relating::TypeRelating;
2424
use super::StructurallyRelateAliases;
25-
use crate::infer::{DefineOpaqueTypes, InferCtxt, TypeTrace};
25+
use crate::infer::{DefineOpaqueTypes, InferCtxt, InferOk, TypeTrace};
2626
use crate::traits::{Obligation, PredicateObligations};
2727
use rustc_middle::bug;
28-
use rustc_middle::infer::canonical::OriginalQueryValues;
2928
use rustc_middle::infer::unify_key::EffectVarValue;
29+
use rustc_middle::traits::ObligationCause;
3030
use rustc_middle::ty::error::{ExpectedFound, TypeError};
3131
use rustc_middle::ty::relate::{RelateResult, TypeRelation};
3232
use rustc_middle::ty::{self, InferConst, Ty, TyCtxt, TypeVisitableExt, Upcast};
@@ -159,36 +159,11 @@ impl<'tcx> InferCtxt<'tcx> {
159159
let a = self.shallow_resolve_const(a);
160160
let b = self.shallow_resolve_const(b);
161161

162-
// We should never have to relate the `ty` field on `Const` as it is checked elsewhere that consts have the
163-
// correct type for the generic param they are an argument for. However there have been a number of cases
164-
// historically where asserting that the types are equal has found bugs in the compiler so this is valuable
165-
// to check even if it is a bit nasty impl wise :(
166-
//
167-
// This probe is probably not strictly necessary but it seems better to be safe and not accidentally find
168-
// ourselves with a check to find bugs being required for code to compile because it made inference progress.
169-
self.probe(|_| {
170-
if a.ty() == b.ty() {
171-
return;
172-
}
173-
174-
// We don't have access to trait solving machinery in `rustc_infer` so the logic for determining if the
175-
// two const param's types are able to be equal has to go through a canonical query with the actual logic
176-
// in `rustc_trait_selection`.
177-
let canonical = self.canonicalize_query(
178-
relation.param_env().and((a.ty(), b.ty())),
179-
&mut OriginalQueryValues::default(),
180-
);
181-
self.tcx.check_tys_might_be_eq(canonical).unwrap_or_else(|_| {
182-
// The error will only be reported later. If we emit an ErrorGuaranteed
183-
// here, then we will never get to the code that actually emits the error.
184-
self.tcx.dcx().delayed_bug(format!(
185-
"cannot relate consts of different types (a={a:?}, b={b:?})",
186-
));
187-
// We treat these constants as if they were of the same type, so that any
188-
// such constants being used in impls make these impls match barring other mismatches.
189-
// This helps with diagnostics down the road.
190-
});
191-
});
162+
// It is always an error if the types of two constants that are related are not equal.
163+
let InferOk { value: (), obligations } = self
164+
.at(&ObligationCause::dummy_with_span(relation.span()), relation.param_env())
165+
.eq(DefineOpaqueTypes::No, a.ty(), b.ty())?;
166+
relation.register_obligations(obligations);
192167

193168
match (a.kind(), b.kind()) {
194169
(

compiler/rustc_interface/src/tests.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -799,10 +799,7 @@ fn test_unstable_options_tracking_hash() {
799799
tracked!(mir_opt_level, Some(4));
800800
tracked!(move_size_limit, Some(4096));
801801
tracked!(mutable_noalias, false);
802-
tracked!(
803-
next_solver,
804-
Some(NextSolverConfig { coherence: true, globally: false, dump_tree: Default::default() })
805-
);
802+
tracked!(next_solver, Some(NextSolverConfig { coherence: true, globally: false }));
806803
tracked!(no_generate_arange_section, true);
807804
tracked!(no_jump_tables, true);
808805
tracked!(no_link, true);

compiler/rustc_middle/src/arena.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ macro_rules! arena_types {
6161
[] dtorck_constraint: rustc_middle::traits::query::DropckConstraint<'tcx>,
6262
[] candidate_step: rustc_middle::traits::query::CandidateStep<'tcx>,
6363
[] autoderef_bad_ty: rustc_middle::traits::query::MethodAutoderefBadTy<'tcx>,
64-
[] canonical_goal_evaluation: rustc_next_trait_solver::solve::inspect::GoalEvaluationStep<rustc_middle::ty::TyCtxt<'tcx>>,
64+
[] canonical_goal_evaluation:
65+
rustc_next_trait_solver::solve::inspect::CanonicalGoalEvaluationStep<
66+
rustc_middle::ty::TyCtxt<'tcx>
67+
>,
6568
[] query_region_constraints: rustc_middle::infer::canonical::QueryRegionConstraints<'tcx>,
6669
[] type_op_subtype:
6770
rustc_middle::infer::canonical::Canonical<'tcx,

compiler/rustc_middle/src/query/mod.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,15 +2218,6 @@ rustc_queries! {
22182218
separate_provide_extern
22192219
}
22202220

2221-
/// Used in `super_combine_consts` to ICE if the type of the two consts are definitely not going to end up being
2222-
/// equal to eachother. This might return `Ok` even if the types are not equal, but will never return `Err` if
2223-
/// the types might be equal.
2224-
query check_tys_might_be_eq(
2225-
arg: Canonical<'tcx, ty::ParamEnvAnd<'tcx, (Ty<'tcx>, Ty<'tcx>)>>
2226-
) -> Result<(), NoSolution> {
2227-
desc { "check whether two const param are definitely not equal to eachother"}
2228-
}
2229-
22302221
/// Get all item paths that were stripped by a `#[cfg]` in a particular crate.
22312222
/// Should not be called for the local crate before the resolver outputs are created, as it
22322223
/// is only fed there.

compiler/rustc_middle/src/traits/solve/cache.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct EvaluationCache<'tcx> {
1717
#[derive(Debug, PartialEq, Eq)]
1818
pub struct CacheData<'tcx> {
1919
pub result: QueryResult<'tcx>,
20-
pub proof_tree: Option<&'tcx [inspect::GoalEvaluationStep<TyCtxt<'tcx>>]>,
20+
pub proof_tree: Option<&'tcx inspect::CanonicalGoalEvaluationStep<TyCtxt<'tcx>>>,
2121
pub additional_depth: usize,
2222
pub encountered_overflow: bool,
2323
}
@@ -28,7 +28,7 @@ impl<'tcx> EvaluationCache<'tcx> {
2828
&self,
2929
tcx: TyCtxt<'tcx>,
3030
key: CanonicalInput<'tcx>,
31-
proof_tree: Option<&'tcx [inspect::GoalEvaluationStep<TyCtxt<'tcx>>]>,
31+
proof_tree: Option<&'tcx inspect::CanonicalGoalEvaluationStep<TyCtxt<'tcx>>>,
3232
additional_depth: usize,
3333
encountered_overflow: bool,
3434
cycle_participants: FxHashSet<CanonicalInput<'tcx>>,
@@ -107,7 +107,7 @@ struct Success<'tcx> {
107107
#[derive(Clone, Copy)]
108108
pub struct QueryData<'tcx> {
109109
pub result: QueryResult<'tcx>,
110-
pub proof_tree: Option<&'tcx [inspect::GoalEvaluationStep<TyCtxt<'tcx>>]>,
110+
pub proof_tree: Option<&'tcx inspect::CanonicalGoalEvaluationStep<TyCtxt<'tcx>>>,
111111
}
112112

113113
/// The cache entry for a goal `CanonicalInput`.

compiler/rustc_middle/src/ty/context.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
103103
type PredefinedOpaques = solve::PredefinedOpaques<'tcx>;
104104
type DefiningOpaqueTypes = &'tcx ty::List<LocalDefId>;
105105
type ExternalConstraints = ExternalConstraints<'tcx>;
106-
type GoalEvaluationSteps = &'tcx [solve::inspect::GoalEvaluationStep<TyCtxt<'tcx>>];
106+
type CanonicalGoalEvaluationStepRef =
107+
&'tcx solve::inspect::CanonicalGoalEvaluationStep<TyCtxt<'tcx>>;
107108

108109
type Ty = Ty<'tcx>;
109110
type Tys = &'tcx List<Ty<'tcx>>;

compiler/rustc_mir_build/src/build/expr/as_place.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::build::expr::category::Category;
44
use crate::build::ForGuard::{OutsideGuard, RefWithinGuard};
55
use crate::build::{BlockAnd, BlockAndExtension, Builder, Capture, CaptureMap};
66
use rustc_hir::def_id::LocalDefId;
7-
use rustc_middle::bug;
87
use rustc_middle::hir::place::Projection as HirProjection;
98
use rustc_middle::hir::place::ProjectionKind as HirProjectionKind;
109
use rustc_middle::middle::region;
@@ -13,6 +12,7 @@ use rustc_middle::mir::*;
1312
use rustc_middle::thir::*;
1413
use rustc_middle::ty::AdtDef;
1514
use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty, Variance};
15+
use rustc_middle::{bug, span_bug};
1616
use rustc_span::Span;
1717
use rustc_target::abi::{FieldIdx, VariantIdx, FIRST_VARIANT};
1818
use tracing::{debug, instrument, trace};
@@ -252,7 +252,18 @@ fn strip_prefix<'a, 'tcx>(
252252

253253
impl<'tcx> PlaceBuilder<'tcx> {
254254
pub(in crate::build) fn to_place(&self, cx: &Builder<'_, 'tcx>) -> Place<'tcx> {
255-
self.try_to_place(cx).unwrap()
255+
self.try_to_place(cx).unwrap_or_else(|| match self.base {
256+
PlaceBase::Local(local) => span_bug!(
257+
cx.local_decls[local].source_info.span,
258+
"could not resolve local: {local:#?} + {:?}",
259+
self.projection
260+
),
261+
PlaceBase::Upvar { var_hir_id, closure_def_id: _ } => span_bug!(
262+
cx.tcx.hir().span(var_hir_id.0),
263+
"could not resolve upvar: {var_hir_id:?} + {:?}",
264+
self.projection
265+
),
266+
})
256267
}
257268

258269
/// Creates a `Place` or returns `None` if an upvar cannot be resolved

compiler/rustc_monomorphize/src/collector.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,15 @@ impl<'v> RootCollector<'_, 'v> {
14341434
{
14351435
debug!("RootCollector: ADT drop-glue for `{id:?}`",);
14361436

1437+
// This type is impossible to instantiate, so we should not try to
1438+
// generate a `drop_in_place` instance for it.
1439+
if self.tcx.instantiate_and_check_impossible_predicates((
1440+
id.owner_id.to_def_id(),
1441+
ty::List::empty(),
1442+
)) {
1443+
return;
1444+
}
1445+
14371446
let ty = self.tcx.type_of(id.owner_id.to_def_id()).no_bound_vars().unwrap();
14381447
visit_drop_use(self.tcx, ty, true, DUMMY_SP, self.output);
14391448
}

compiler/rustc_session/src/config.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -796,16 +796,6 @@ pub struct NextSolverConfig {
796796
/// Whether the new trait solver should be enabled everywhere.
797797
/// This is only `true` if `coherence` is also enabled.
798798
pub globally: bool,
799-
/// Whether to dump proof trees after computing a proof tree.
800-
pub dump_tree: DumpSolverProofTree,
801-
}
802-
803-
#[derive(Default, Debug, Copy, Clone, Hash, PartialEq, Eq)]
804-
pub enum DumpSolverProofTree {
805-
Always,
806-
OnError,
807-
#[default]
808-
Never,
809799
}
810800

811801
#[derive(Clone)]

0 commit comments

Comments
 (0)