Skip to content

Commit 03983fb

Browse files
committed
Auto merge of rust-lang#131827 - matthiaskrgr:rollup-umncb57, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#128391 (Change orphan hint from "only" to "any uncovered type inside...") - rust-lang#131583 (Setting up indirect access to external data for loongarch64-linux-{musl,ohos}) - rust-lang#131595 (rustdoc-JSON: Rename "object safe" to "dyn compatible") - rust-lang#131748 (cleanup canonical queries) - rust-lang#131798 (llvm: Tolerate propagated range metadata) - rust-lang#131815 (compiler: use `is_none_or` where it is clearly better) - rust-lang#131822 (extract `expr_assign_expected_bool_error`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 06d261d + c735655 commit 03983fb

File tree

86 files changed

+602
-565
lines changed

Some content is hidden

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

86 files changed

+602
-565
lines changed

Diff for: compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

+14-15
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ use std::rc::Rc;
33

44
use rustc_errors::Diag;
55
use rustc_hir::def_id::LocalDefId;
6-
use rustc_infer::infer::canonical::Canonical;
6+
use rustc_infer::infer::canonical::CanonicalQueryInput;
77
use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData};
88
use rustc_infer::infer::{
99
InferCtxt, RegionResolutionError, RegionVariableOrigin, SubregionOrigin, TyCtxtInferExt as _,
1010
};
1111
use rustc_infer::traits::ObligationCause;
12+
use rustc_infer::traits::query::{
13+
CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpNormalizeGoal,
14+
CanonicalTypeOpProvePredicateGoal,
15+
};
1216
use rustc_middle::ty::error::TypeError;
1317
use rustc_middle::ty::{
1418
self, RePlaceholder, Region, RegionVid, Ty, TyCtxt, TypeFoldable, UniverseIndex,
@@ -95,9 +99,7 @@ impl<'tcx> ToUniverseInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tc
9599
}
96100
}
97101

98-
impl<'tcx> ToUniverseInfo<'tcx>
99-
for Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::prove_predicate::ProvePredicate<'tcx>>>
100-
{
102+
impl<'tcx> ToUniverseInfo<'tcx> for CanonicalTypeOpProvePredicateGoal<'tcx> {
101103
fn to_universe_info(self, base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> {
102104
UniverseInfo(UniverseInfoInner::TypeOp(Rc::new(PredicateQuery {
103105
canonical_query: self,
@@ -107,7 +109,7 @@ impl<'tcx> ToUniverseInfo<'tcx>
107109
}
108110

109111
impl<'tcx, T: Copy + fmt::Display + TypeFoldable<TyCtxt<'tcx>> + 'tcx> ToUniverseInfo<'tcx>
110-
for Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::Normalize<T>>>
112+
for CanonicalTypeOpNormalizeGoal<'tcx, T>
111113
{
112114
fn to_universe_info(self, base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> {
113115
UniverseInfo(UniverseInfoInner::TypeOp(Rc::new(NormalizeQuery {
@@ -117,9 +119,7 @@ impl<'tcx, T: Copy + fmt::Display + TypeFoldable<TyCtxt<'tcx>> + 'tcx> ToUnivers
117119
}
118120
}
119121

120-
impl<'tcx> ToUniverseInfo<'tcx>
121-
for Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::AscribeUserType<'tcx>>>
122-
{
122+
impl<'tcx> ToUniverseInfo<'tcx> for CanonicalTypeOpAscribeUserTypeGoal<'tcx> {
123123
fn to_universe_info(self, base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> {
124124
UniverseInfo(UniverseInfoInner::TypeOp(Rc::new(AscribeUserTypeQuery {
125125
canonical_query: self,
@@ -128,7 +128,7 @@ impl<'tcx> ToUniverseInfo<'tcx>
128128
}
129129
}
130130

131-
impl<'tcx, F> ToUniverseInfo<'tcx> for Canonical<'tcx, type_op::custom::CustomTypeOp<F>> {
131+
impl<'tcx, F> ToUniverseInfo<'tcx> for CanonicalQueryInput<'tcx, type_op::custom::CustomTypeOp<F>> {
132132
fn to_universe_info(self, _base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> {
133133
// We can't rerun custom type ops.
134134
UniverseInfo::other()
@@ -211,16 +211,15 @@ trait TypeOpInfo<'tcx> {
211211
}
212212

213213
struct PredicateQuery<'tcx> {
214-
canonical_query:
215-
Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::prove_predicate::ProvePredicate<'tcx>>>,
214+
canonical_query: CanonicalTypeOpProvePredicateGoal<'tcx>,
216215
base_universe: ty::UniverseIndex,
217216
}
218217

219218
impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
220219
fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> Diag<'tcx> {
221220
tcx.dcx().create_err(HigherRankedLifetimeError {
222221
cause: Some(HigherRankedErrorCause::CouldNotProve {
223-
predicate: self.canonical_query.value.value.predicate.to_string(),
222+
predicate: self.canonical_query.canonical.value.value.predicate.to_string(),
224223
}),
225224
span,
226225
})
@@ -253,7 +252,7 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
253252
}
254253

255254
struct NormalizeQuery<'tcx, T> {
256-
canonical_query: Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::Normalize<T>>>,
255+
canonical_query: CanonicalTypeOpNormalizeGoal<'tcx, T>,
257256
base_universe: ty::UniverseIndex,
258257
}
259258

@@ -264,7 +263,7 @@ where
264263
fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> Diag<'tcx> {
265264
tcx.dcx().create_err(HigherRankedLifetimeError {
266265
cause: Some(HigherRankedErrorCause::CouldNotNormalize {
267-
value: self.canonical_query.value.value.value.to_string(),
266+
value: self.canonical_query.canonical.value.value.value.to_string(),
268267
}),
269268
span,
270269
})
@@ -306,7 +305,7 @@ where
306305
}
307306

308307
struct AscribeUserTypeQuery<'tcx> {
309-
canonical_query: Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::AscribeUserType<'tcx>>>,
308+
canonical_query: CanonicalTypeOpAscribeUserTypeGoal<'tcx>,
310309
base_universe: ty::UniverseIndex,
311310
}
312311

Diff for: compiler/rustc_borrowck/src/type_check/canonical.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
137137
let _: Result<_, ErrorGuaranteed> = self.fully_perform_op(
138138
locations,
139139
category,
140-
param_env.and(type_op::prove_predicate::ProvePredicate::new(predicate)),
140+
param_env.and(type_op::prove_predicate::ProvePredicate { predicate }),
141141
);
142142
}
143143

@@ -162,7 +162,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
162162
let result: Result<_, ErrorGuaranteed> = self.fully_perform_op(
163163
location.to_locations(),
164164
category,
165-
param_env.and(type_op::normalize::Normalize::new(value)),
165+
param_env.and(type_op::normalize::Normalize { value }),
166166
);
167167
result.unwrap_or(value)
168168
}
@@ -223,7 +223,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
223223
let _: Result<_, ErrorGuaranteed> = self.fully_perform_op(
224224
Locations::All(span),
225225
ConstraintCategory::Boring,
226-
self.param_env.and(type_op::ascribe_user_type::AscribeUserType::new(mir_ty, user_ty)),
226+
self.param_env.and(type_op::ascribe_user_type::AscribeUserType { mir_ty, user_ty }),
227227
);
228228
}
229229

Diff for: compiler/rustc_borrowck/src/type_check/free_region_relations.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
280280
}
281281
let TypeOpOutput { output: norm_ty, constraints: constraints_normalize, .. } = self
282282
.param_env
283-
.and(type_op::normalize::Normalize::new(ty))
283+
.and(type_op::normalize::Normalize { value: ty })
284284
.fully_perform(self.infcx, span)
285285
.unwrap_or_else(|guar| TypeOpOutput {
286286
output: Ty::new_error(self.infcx.tcx, guar),
@@ -318,7 +318,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
318318
for &(ty, _) in tcx.assumed_wf_types(tcx.local_parent(defining_ty_def_id)) {
319319
let result: Result<_, ErrorGuaranteed> = self
320320
.param_env
321-
.and(type_op::normalize::Normalize::new(ty))
321+
.and(type_op::normalize::Normalize { value: ty })
322322
.fully_perform(self.infcx, span);
323323
let Ok(TypeOpOutput { output: norm_ty, constraints: c, .. }) = result else {
324324
continue;
@@ -373,7 +373,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
373373
) -> Option<&'tcx QueryRegionConstraints<'tcx>> {
374374
let TypeOpOutput { output: bounds, constraints, .. } = self
375375
.param_env
376-
.and(type_op::implied_outlives_bounds::ImpliedOutlivesBounds { ty })
376+
.and(type_op::ImpliedOutlivesBounds { ty })
377377
.fully_perform(self.infcx, span)
378378
.map_err(|_: ErrorGuaranteed| debug!("failed to compute implied bounds {:?}", ty))
379379
.ok()?;

Diff for: compiler/rustc_borrowck/src/type_check/liveness/trace.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
1111
use rustc_mir_dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex};
1212
use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex};
1313
use rustc_span::DUMMY_SP;
14-
use rustc_trait_selection::traits::query::type_op::outlives::DropckOutlives;
15-
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
14+
use rustc_trait_selection::traits::query::type_op::{DropckOutlives, TypeOp, TypeOpOutput};
1615
use tracing::debug;
1716

1817
use crate::location::RichLocation;
@@ -632,7 +631,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
632631

633632
match typeck
634633
.param_env
635-
.and(DropckOutlives::new(dropped_ty))
634+
.and(DropckOutlives { dropped_ty })
636635
.fully_perform(typeck.infcx, DUMMY_SP)
637636
{
638637
Ok(TypeOpOutput { output, constraints, .. }) => {

Diff for: compiler/rustc_hir_analysis/messages.ftl

+4-2
Original file line numberDiff line numberDiff line change
@@ -356,12 +356,14 @@ hir_analysis_only_current_traits_arbitrary = only traits defined in the current
356356
357357
hir_analysis_only_current_traits_foreign = this is not defined in the current crate because this is a foreign trait
358358
359-
hir_analysis_only_current_traits_label = impl doesn't use only types from inside the current crate
360-
361359
hir_analysis_only_current_traits_name = this is not defined in the current crate because {$name} are always foreign
362360
363361
hir_analysis_only_current_traits_note = define and implement a trait or new type instead
364362
363+
hir_analysis_only_current_traits_note_more_info = for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
364+
365+
hir_analysis_only_current_traits_note_uncovered = impl doesn't have any local type before any uncovered type parameters
366+
365367
hir_analysis_only_current_traits_opaque = type alias impl trait is treated as if it were foreign, because its hidden type could be from a foreign crate
366368
367369
hir_analysis_only_current_traits_outside = only traits defined in the current crate can be implemented for types defined outside of the crate

Diff for: compiler/rustc_hir_analysis/src/errors.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1434,24 +1434,27 @@ pub(crate) enum OnlyCurrentTraits {
14341434
#[diag(hir_analysis_only_current_traits_outside, code = E0117)]
14351435
Outside {
14361436
#[primary_span]
1437-
#[label(hir_analysis_only_current_traits_label)]
14381437
span: Span,
1438+
#[note(hir_analysis_only_current_traits_note_uncovered)]
1439+
#[note(hir_analysis_only_current_traits_note_more_info)]
14391440
#[note(hir_analysis_only_current_traits_note)]
14401441
note: (),
14411442
},
14421443
#[diag(hir_analysis_only_current_traits_primitive, code = E0117)]
14431444
Primitive {
14441445
#[primary_span]
1445-
#[label(hir_analysis_only_current_traits_label)]
14461446
span: Span,
1447+
#[note(hir_analysis_only_current_traits_note_uncovered)]
1448+
#[note(hir_analysis_only_current_traits_note_more_info)]
14471449
#[note(hir_analysis_only_current_traits_note)]
14481450
note: (),
14491451
},
14501452
#[diag(hir_analysis_only_current_traits_arbitrary, code = E0117)]
14511453
Arbitrary {
14521454
#[primary_span]
1453-
#[label(hir_analysis_only_current_traits_label)]
14541455
span: Span,
1456+
#[note(hir_analysis_only_current_traits_note_uncovered)]
1457+
#[note(hir_analysis_only_current_traits_note_more_info)]
14551458
#[note(hir_analysis_only_current_traits_note)]
14561459
note: (),
14571460
},

0 commit comments

Comments
 (0)