Skip to content
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

Rollup of 7 pull requests #131827

Merged
merged 22 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9ce811c
Change orphan hint from "only" to "any uncovered type inside..."
cafce25 Jul 30, 2024
86a9959
Adjust orphan note in tests
cafce25 Jul 30, 2024
ca94dd5
Add more information link to orphan impls
cafce25 Aug 11, 2024
b89c620
Make new information notes instead of labels
cafce25 Sep 26, 2024
b1579e8
Setting up indirect access to external data for loongarch64-linux-{mu…
heiher Oct 11, 2024
0e73095
llvm: Tolerate propagated range metadata
maurer Oct 16, 2024
2e6f3bd
rustdoc-JSON: Rename "object safe" to "dyn compatible"
fmease Oct 12, 2024
47cfaa6
compiler: use `is_none_or` where it is clearly better
workingjubilee Oct 17, 2024
401f9b4
`ImpliedOutlivesBounds` to `rustc_middle`
lcnr Oct 15, 2024
9334d85
remove type_op constructors
lcnr Oct 15, 2024
f3ce557
`DropckOutlives` to `rustc_middle`
lcnr Oct 15, 2024
5834ba1
remove Canonical::unchecked_rebind, it's unused
lcnr Oct 15, 2024
3360c17
move `defining_opaque_types` out of `Canonical`
lcnr Oct 15, 2024
6cf4cb8
bless mir-opt tests
lcnr Oct 15, 2024
02982f2
extract `expr_assign_expected_bool_error`
lcnr Oct 17, 2024
21c57f5
Rollup merge of #128391 - cafce25:issue-128390, r=lcnr
matthiaskrgr Oct 17, 2024
9aee5d9
Rollup merge of #131583 - heiher:loong-issue-118053, r=jieyouxu
matthiaskrgr Oct 17, 2024
f6b699c
Rollup merge of #131595 - fmease:rustdoc-json-mv-obj-safe-dyn-compat,…
matthiaskrgr Oct 17, 2024
c1f3702
Rollup merge of #131748 - lcnr:typing-mode, r=compiler-errors
matthiaskrgr Oct 17, 2024
7ad2f60
Rollup merge of #131798 - maurer:range-inlining, r=durin42
matthiaskrgr Oct 17, 2024
887afd1
Rollup merge of #131815 - workingjubilee:did-you-mean-is-none-or, r=j…
matthiaskrgr Oct 17, 2024
c735655
Rollup merge of #131822 - lcnr:typeck-error-reporting, r=jieyouxu
matthiaskrgr Oct 17, 2024
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
29 changes: 14 additions & 15 deletions compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ use std::rc::Rc;

use rustc_errors::Diag;
use rustc_hir::def_id::LocalDefId;
use rustc_infer::infer::canonical::Canonical;
use rustc_infer::infer::canonical::CanonicalQueryInput;
use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData};
use rustc_infer::infer::{
InferCtxt, RegionResolutionError, RegionVariableOrigin, SubregionOrigin, TyCtxtInferExt as _,
};
use rustc_infer::traits::ObligationCause;
use rustc_infer::traits::query::{
CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpNormalizeGoal,
CanonicalTypeOpProvePredicateGoal,
};
use rustc_middle::ty::error::TypeError;
use rustc_middle::ty::{
self, RePlaceholder, Region, RegionVid, Ty, TyCtxt, TypeFoldable, UniverseIndex,
Expand Down Expand Up @@ -95,9 +99,7 @@ impl<'tcx> ToUniverseInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tc
}
}

impl<'tcx> ToUniverseInfo<'tcx>
for Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::prove_predicate::ProvePredicate<'tcx>>>
{
impl<'tcx> ToUniverseInfo<'tcx> for CanonicalTypeOpProvePredicateGoal<'tcx> {
fn to_universe_info(self, base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> {
UniverseInfo(UniverseInfoInner::TypeOp(Rc::new(PredicateQuery {
canonical_query: self,
Expand All @@ -107,7 +109,7 @@ impl<'tcx> ToUniverseInfo<'tcx>
}

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

impl<'tcx> ToUniverseInfo<'tcx>
for Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::AscribeUserType<'tcx>>>
{
impl<'tcx> ToUniverseInfo<'tcx> for CanonicalTypeOpAscribeUserTypeGoal<'tcx> {
fn to_universe_info(self, base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> {
UniverseInfo(UniverseInfoInner::TypeOp(Rc::new(AscribeUserTypeQuery {
canonical_query: self,
Expand All @@ -128,7 +128,7 @@ impl<'tcx> ToUniverseInfo<'tcx>
}
}

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

struct PredicateQuery<'tcx> {
canonical_query:
Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::prove_predicate::ProvePredicate<'tcx>>>,
canonical_query: CanonicalTypeOpProvePredicateGoal<'tcx>,
base_universe: ty::UniverseIndex,
}

impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> Diag<'tcx> {
tcx.dcx().create_err(HigherRankedLifetimeError {
cause: Some(HigherRankedErrorCause::CouldNotProve {
predicate: self.canonical_query.value.value.predicate.to_string(),
predicate: self.canonical_query.canonical.value.value.predicate.to_string(),
}),
span,
})
Expand Down Expand Up @@ -253,7 +252,7 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
}

struct NormalizeQuery<'tcx, T> {
canonical_query: Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::Normalize<T>>>,
canonical_query: CanonicalTypeOpNormalizeGoal<'tcx, T>,
base_universe: ty::UniverseIndex,
}

Expand All @@ -264,7 +263,7 @@ where
fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> Diag<'tcx> {
tcx.dcx().create_err(HigherRankedLifetimeError {
cause: Some(HigherRankedErrorCause::CouldNotNormalize {
value: self.canonical_query.value.value.value.to_string(),
value: self.canonical_query.canonical.value.value.value.to_string(),
}),
span,
})
Expand Down Expand Up @@ -306,7 +305,7 @@ where
}

struct AscribeUserTypeQuery<'tcx> {
canonical_query: Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::AscribeUserType<'tcx>>>,
canonical_query: CanonicalTypeOpAscribeUserTypeGoal<'tcx>,
base_universe: ty::UniverseIndex,
}

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_borrowck/src/type_check/canonical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
let _: Result<_, ErrorGuaranteed> = self.fully_perform_op(
locations,
category,
param_env.and(type_op::prove_predicate::ProvePredicate::new(predicate)),
param_env.and(type_op::prove_predicate::ProvePredicate { predicate }),
);
}

Expand All @@ -162,7 +162,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
let result: Result<_, ErrorGuaranteed> = self.fully_perform_op(
location.to_locations(),
category,
param_env.and(type_op::normalize::Normalize::new(value)),
param_env.and(type_op::normalize::Normalize { value }),
);
result.unwrap_or(value)
}
Expand Down Expand Up @@ -223,7 +223,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
let _: Result<_, ErrorGuaranteed> = self.fully_perform_op(
Locations::All(span),
ConstraintCategory::Boring,
self.param_env.and(type_op::ascribe_user_type::AscribeUserType::new(mir_ty, user_ty)),
self.param_env.and(type_op::ascribe_user_type::AscribeUserType { mir_ty, user_ty }),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
}
let TypeOpOutput { output: norm_ty, constraints: constraints_normalize, .. } = self
.param_env
.and(type_op::normalize::Normalize::new(ty))
.and(type_op::normalize::Normalize { value: ty })
.fully_perform(self.infcx, span)
.unwrap_or_else(|guar| TypeOpOutput {
output: Ty::new_error(self.infcx.tcx, guar),
Expand Down Expand Up @@ -318,7 +318,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
for &(ty, _) in tcx.assumed_wf_types(tcx.local_parent(defining_ty_def_id)) {
let result: Result<_, ErrorGuaranteed> = self
.param_env
.and(type_op::normalize::Normalize::new(ty))
.and(type_op::normalize::Normalize { value: ty })
.fully_perform(self.infcx, span);
let Ok(TypeOpOutput { output: norm_ty, constraints: c, .. }) = result else {
continue;
Expand Down Expand Up @@ -373,7 +373,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
) -> Option<&'tcx QueryRegionConstraints<'tcx>> {
let TypeOpOutput { output: bounds, constraints, .. } = self
.param_env
.and(type_op::implied_outlives_bounds::ImpliedOutlivesBounds { ty })
.and(type_op::ImpliedOutlivesBounds { ty })
.fully_perform(self.infcx, span)
.map_err(|_: ErrorGuaranteed| debug!("failed to compute implied bounds {:?}", ty))
.ok()?;
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_borrowck/src/type_check/liveness/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
use rustc_mir_dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex};
use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex};
use rustc_span::DUMMY_SP;
use rustc_trait_selection::traits::query::type_op::outlives::DropckOutlives;
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
use rustc_trait_selection::traits::query::type_op::{DropckOutlives, TypeOp, TypeOpOutput};
use tracing::debug;

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

match typeck
.param_env
.and(DropckOutlives::new(dropped_ty))
.and(DropckOutlives { dropped_ty })
.fully_perform(typeck.infcx, DUMMY_SP)
{
Ok(TypeOpOutput { output, constraints, .. }) => {
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_hir_analysis/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,14 @@ hir_analysis_only_current_traits_arbitrary = only traits defined in the current

hir_analysis_only_current_traits_foreign = this is not defined in the current crate because this is a foreign trait

hir_analysis_only_current_traits_label = impl doesn't use only types from inside the current crate

hir_analysis_only_current_traits_name = this is not defined in the current crate because {$name} are always foreign

hir_analysis_only_current_traits_note = define and implement a trait or new type instead

hir_analysis_only_current_traits_note_more_info = for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules

hir_analysis_only_current_traits_note_uncovered = impl doesn't have any local type before any uncovered type parameters

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

hir_analysis_only_current_traits_outside = only traits defined in the current crate can be implemented for types defined outside of the crate
Expand Down
9 changes: 6 additions & 3 deletions compiler/rustc_hir_analysis/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1434,24 +1434,27 @@ pub(crate) enum OnlyCurrentTraits {
#[diag(hir_analysis_only_current_traits_outside, code = E0117)]
Outside {
#[primary_span]
#[label(hir_analysis_only_current_traits_label)]
span: Span,
#[note(hir_analysis_only_current_traits_note_uncovered)]
#[note(hir_analysis_only_current_traits_note_more_info)]
#[note(hir_analysis_only_current_traits_note)]
note: (),
},
#[diag(hir_analysis_only_current_traits_primitive, code = E0117)]
Primitive {
#[primary_span]
#[label(hir_analysis_only_current_traits_label)]
span: Span,
#[note(hir_analysis_only_current_traits_note_uncovered)]
#[note(hir_analysis_only_current_traits_note_more_info)]
#[note(hir_analysis_only_current_traits_note)]
note: (),
},
#[diag(hir_analysis_only_current_traits_arbitrary, code = E0117)]
Arbitrary {
#[primary_span]
#[label(hir_analysis_only_current_traits_label)]
span: Span,
#[note(hir_analysis_only_current_traits_note_uncovered)]
#[note(hir_analysis_only_current_traits_note_more_info)]
#[note(hir_analysis_only_current_traits_note)]
note: (),
},
Expand Down
Loading
Loading