Reformat using the new identifier sorting from rustfmt
This commit is contained in:
@@ -20,20 +20,20 @@ use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableEx
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
pub use rustc_next_trait_solver::coherence::*;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_span::{DUMMY_SP, Span};
|
||||
use tracing::{debug, instrument, warn};
|
||||
|
||||
use super::ObligationCtxt;
|
||||
use crate::error_reporting::traits::suggest_new_overflow_limit;
|
||||
use crate::infer::outlives::env::OutlivesEnvironment;
|
||||
use crate::infer::InferOk;
|
||||
use crate::infer::outlives::env::OutlivesEnvironment;
|
||||
use crate::solve::inspect::{InspectGoal, ProofTreeInferCtxtExt, ProofTreeVisitor};
|
||||
use crate::solve::{deeply_normalize_for_diagnostics, inspect};
|
||||
use crate::traits::query::evaluate_obligation::InferCtxtExt;
|
||||
use crate::traits::select::IntercrateAmbiguityCause;
|
||||
use crate::traits::{
|
||||
util, FulfillmentErrorCode, NormalizeExt, Obligation, ObligationCause, PredicateObligation,
|
||||
SelectionContext, SkipLeakCheck,
|
||||
FulfillmentErrorCode, NormalizeExt, Obligation, ObligationCause, PredicateObligation,
|
||||
SelectionContext, SkipLeakCheck, util,
|
||||
};
|
||||
|
||||
pub struct OverlapResult<'tcx> {
|
||||
@@ -346,10 +346,9 @@ fn impl_intersection_has_impossible_obligation<'a, 'cx, 'tcx>(
|
||||
overflowing_predicates: ambiguities
|
||||
.into_iter()
|
||||
.filter(|error| {
|
||||
matches!(
|
||||
error.code,
|
||||
FulfillmentErrorCode::Ambiguity { overflow: Some(true) }
|
||||
)
|
||||
matches!(error.code, FulfillmentErrorCode::Ambiguity {
|
||||
overflow: Some(true)
|
||||
})
|
||||
})
|
||||
.map(|e| infcx.resolve_vars_if_possible(e.obligation.predicate))
|
||||
.collect(),
|
||||
@@ -470,16 +469,13 @@ fn plug_infer_with_placeholders<'tcx>(
|
||||
// Comparing against a type variable never registers hidden types anyway
|
||||
DefineOpaqueTypes::Yes,
|
||||
ty,
|
||||
Ty::new_placeholder(
|
||||
self.infcx.tcx,
|
||||
ty::Placeholder {
|
||||
universe: self.universe,
|
||||
bound: ty::BoundTy {
|
||||
var: self.next_var(),
|
||||
kind: ty::BoundTyKind::Anon,
|
||||
},
|
||||
Ty::new_placeholder(self.infcx.tcx, ty::Placeholder {
|
||||
universe: self.universe,
|
||||
bound: ty::BoundTy {
|
||||
var: self.next_var(),
|
||||
kind: ty::BoundTyKind::Anon,
|
||||
},
|
||||
),
|
||||
}),
|
||||
)
|
||||
else {
|
||||
bug!("we always expect to be able to plug an infer var with placeholder")
|
||||
@@ -499,10 +495,10 @@ fn plug_infer_with_placeholders<'tcx>(
|
||||
// registration happening anyway.
|
||||
DefineOpaqueTypes::Yes,
|
||||
ct,
|
||||
ty::Const::new_placeholder(
|
||||
self.infcx.tcx,
|
||||
ty::Placeholder { universe: self.universe, bound: self.next_var() },
|
||||
),
|
||||
ty::Const::new_placeholder(self.infcx.tcx, ty::Placeholder {
|
||||
universe: self.universe,
|
||||
bound: self.next_var(),
|
||||
}),
|
||||
)
|
||||
else {
|
||||
bug!("we always expect to be able to plug an infer var with placeholder")
|
||||
@@ -527,16 +523,13 @@ fn plug_infer_with_placeholders<'tcx>(
|
||||
// Lifetimes don't contain opaque types (or any types for that matter).
|
||||
DefineOpaqueTypes::Yes,
|
||||
r,
|
||||
ty::Region::new_placeholder(
|
||||
self.infcx.tcx,
|
||||
ty::Placeholder {
|
||||
universe: self.universe,
|
||||
bound: ty::BoundRegion {
|
||||
var: self.next_var(),
|
||||
kind: ty::BoundRegionKind::BrAnon,
|
||||
},
|
||||
ty::Region::new_placeholder(self.infcx.tcx, ty::Placeholder {
|
||||
universe: self.universe,
|
||||
bound: ty::BoundRegion {
|
||||
var: self.next_var(),
|
||||
kind: ty::BoundRegionKind::BrAnon,
|
||||
},
|
||||
),
|
||||
}),
|
||||
)
|
||||
else {
|
||||
bug!("we always expect to be able to plug an infer var with placeholder")
|
||||
|
||||
@@ -16,7 +16,7 @@ use rustc_middle::mir::interpret::ErrorHandled;
|
||||
use rustc_middle::traits::ObligationCause;
|
||||
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
|
||||
use rustc_middle::ty::{self, TyCtxt, TypeVisitable, TypeVisitableExt, TypeVisitor};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_span::{DUMMY_SP, Span};
|
||||
use tracing::{debug, instrument};
|
||||
|
||||
use crate::traits::ObligationCtxt;
|
||||
|
||||
@@ -18,8 +18,8 @@ use tracing::{debug, debug_span, instrument};
|
||||
use super::project::{self, ProjectAndUnifyResult};
|
||||
use super::select::SelectionContext;
|
||||
use super::{
|
||||
const_evaluatable, wf, EvaluationResult, FulfillmentError, FulfillmentErrorCode,
|
||||
PredicateObligation, ScrubbedTraitError, Unimplemented,
|
||||
EvaluationResult, FulfillmentError, FulfillmentErrorCode, PredicateObligation,
|
||||
ScrubbedTraitError, Unimplemented, const_evaluatable, wf,
|
||||
};
|
||||
use crate::error_reporting::InferCtxtErrorExt;
|
||||
use crate::infer::{InferCtxt, TyOrConstInferVar};
|
||||
|
||||
@@ -35,20 +35,20 @@ use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt};
|
||||
use rustc_middle::ty::{
|
||||
self, GenericArgs, GenericArgsRef, Ty, TyCtxt, TypeFolder, TypeSuperVisitable, Upcast,
|
||||
};
|
||||
use rustc_span::def_id::DefId;
|
||||
use rustc_span::Span;
|
||||
use rustc_span::def_id::DefId;
|
||||
use tracing::{debug, instrument};
|
||||
|
||||
pub use self::coherence::{
|
||||
add_placeholder_note, orphan_check_trait_ref, overlapping_impls, InCrate, IsFirstInputType,
|
||||
OrphanCheckErr, OrphanCheckMode, OverlapResult, UncoveredTyParams,
|
||||
InCrate, IsFirstInputType, OrphanCheckErr, OrphanCheckMode, OverlapResult, UncoveredTyParams,
|
||||
add_placeholder_note, orphan_check_trait_ref, overlapping_impls,
|
||||
};
|
||||
pub use self::engine::{ObligationCtxt, TraitEngineExt};
|
||||
pub use self::fulfill::{FulfillmentContext, OldSolverError, PendingPredicateObligation};
|
||||
pub use self::normalize::NormalizeExt;
|
||||
pub use self::object_safety::{
|
||||
hir_ty_lowering_object_safety_violations, is_vtable_safe_method,
|
||||
object_safety_violations_for_assoc_item, ObjectSafetyViolation,
|
||||
ObjectSafetyViolation, hir_ty_lowering_object_safety_violations, is_vtable_safe_method,
|
||||
object_safety_violations_for_assoc_item,
|
||||
};
|
||||
pub use self::project::{normalize_inherent_projection, normalize_projection_ty};
|
||||
pub use self::select::{
|
||||
@@ -59,13 +59,13 @@ pub use self::specialize::specialization_graph::{
|
||||
FutureCompatOverlapError, FutureCompatOverlapErrorKind,
|
||||
};
|
||||
pub use self::specialize::{
|
||||
specialization_graph, translate_args, translate_args_with_cause, OverlapError,
|
||||
OverlapError, specialization_graph, translate_args, translate_args_with_cause,
|
||||
};
|
||||
pub use self::structural_normalize::StructurallyNormalizeExt;
|
||||
pub use self::util::{
|
||||
elaborate, expand_trait_aliases, impl_item_is_final, supertraits,
|
||||
BoundVarReplacer, PlaceholderReplacer, TraitAliasExpander, TraitAliasExpansionInfo, elaborate,
|
||||
expand_trait_aliases, impl_item_is_final, supertraits,
|
||||
transitive_bounds_that_define_assoc_item, upcast_choices, with_replaced_escaping_bound_vars,
|
||||
BoundVarReplacer, PlaceholderReplacer, TraitAliasExpander, TraitAliasExpansionInfo,
|
||||
};
|
||||
use crate::error_reporting::InferCtxtErrorExt;
|
||||
use crate::infer::outlives::env::OutlivesEnvironment;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//! Deeply normalize types using the old trait solver.
|
||||
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_infer::infer::at::At;
|
||||
use rustc_infer::infer::InferOk;
|
||||
use rustc_infer::infer::at::At;
|
||||
use rustc_infer::traits::{
|
||||
FromSolverError, Normalized, Obligation, PredicateObligation, TraitEngine,
|
||||
};
|
||||
@@ -14,11 +14,11 @@ use rustc_middle::ty::{
|
||||
use tracing::{debug, instrument};
|
||||
|
||||
use super::{
|
||||
project, with_replaced_escaping_bound_vars, BoundVarReplacer, PlaceholderReplacer,
|
||||
SelectionContext,
|
||||
BoundVarReplacer, PlaceholderReplacer, SelectionContext, project,
|
||||
with_replaced_escaping_bound_vars,
|
||||
};
|
||||
use crate::error_reporting::traits::OverflowCause;
|
||||
use crate::error_reporting::InferCtxtErrorExt;
|
||||
use crate::error_reporting::traits::OverflowCause;
|
||||
use crate::solve::NextSolverError;
|
||||
|
||||
#[extension(pub trait NormalizeExt<'tcx>)]
|
||||
|
||||
@@ -20,17 +20,17 @@ use rustc_middle::ty::{
|
||||
TypeFoldable, TypeFolder, TypeSuperFoldable, TypeSuperVisitable, TypeVisitable,
|
||||
TypeVisitableExt, TypeVisitor, Upcast,
|
||||
};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::Span;
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_target::abi::Abi;
|
||||
use smallvec::SmallVec;
|
||||
use tracing::{debug, instrument};
|
||||
|
||||
use super::elaborate;
|
||||
use crate::infer::TyCtxtInferExt;
|
||||
use crate::traits::query::evaluate_obligation::InferCtxtExt;
|
||||
pub use crate::traits::ObjectSafetyViolation;
|
||||
use crate::traits::{util, MethodViolationCode, Obligation, ObligationCause};
|
||||
use crate::traits::query::evaluate_obligation::InferCtxtExt;
|
||||
use crate::traits::{MethodViolationCode, Obligation, ObligationCause, util};
|
||||
|
||||
/// Returns the object safety violations that affect HIR ty lowering.
|
||||
///
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_infer::infer::resolve::OpportunisticRegionResolver;
|
||||
use rustc_infer::infer::InferOk;
|
||||
use rustc_infer::infer::resolve::OpportunisticRegionResolver;
|
||||
use rustc_macros::extension;
|
||||
use rustc_middle::infer::canonical::{OriginalQueryValues, QueryRegionConstraints};
|
||||
use rustc_middle::span_bug;
|
||||
|
||||
@@ -7,11 +7,11 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::lang_items::LangItem;
|
||||
use rustc_infer::infer::resolve::OpportunisticRegionResolver;
|
||||
use rustc_infer::infer::DefineOpaqueTypes;
|
||||
use rustc_infer::infer::resolve::OpportunisticRegionResolver;
|
||||
use rustc_infer::traits::ObligationCauseCode;
|
||||
use rustc_middle::traits::select::OverflowError;
|
||||
pub use rustc_middle::traits::Reveal;
|
||||
use rustc_middle::traits::select::OverflowError;
|
||||
use rustc_middle::traits::{BuiltinImplSource, ImplSource, ImplSourceUserDefinedData};
|
||||
use rustc_middle::ty::fast_reject::DeepRejectCtxt;
|
||||
use rustc_middle::ty::fold::TypeFoldable;
|
||||
@@ -22,9 +22,9 @@ use rustc_span::symbol::sym;
|
||||
use tracing::{debug, instrument};
|
||||
|
||||
use super::{
|
||||
specialization_graph, translate_args, util, MismatchedProjectionTypes, Normalized,
|
||||
NormalizedTerm, Obligation, ObligationCause, PredicateObligation, ProjectionCacheEntry,
|
||||
ProjectionCacheKey, Selection, SelectionContext, SelectionError,
|
||||
MismatchedProjectionTypes, Normalized, NormalizedTerm, Obligation, ObligationCause,
|
||||
PredicateObligation, ProjectionCacheEntry, ProjectionCacheKey, Selection, SelectionContext,
|
||||
SelectionError, specialization_graph, translate_args, util,
|
||||
};
|
||||
use crate::errors::InherentProjectionNormalizationOverflow;
|
||||
use crate::infer::{BoundRegionConversionTime, InferOk};
|
||||
@@ -1696,18 +1696,14 @@ fn confirm_closure_candidate<'cx, 'tcx>(
|
||||
} else {
|
||||
let upvars_projection_def_id =
|
||||
tcx.require_lang_item(LangItem::AsyncFnKindUpvars, None);
|
||||
let tupled_upvars_ty = Ty::new_projection(
|
||||
tcx,
|
||||
upvars_projection_def_id,
|
||||
[
|
||||
ty::GenericArg::from(kind_ty),
|
||||
Ty::from_closure_kind(tcx, ty::ClosureKind::FnOnce).into(),
|
||||
tcx.lifetimes.re_static.into(),
|
||||
sig.tupled_inputs_ty.into(),
|
||||
args.tupled_upvars_ty().into(),
|
||||
args.coroutine_captures_by_ref_ty().into(),
|
||||
],
|
||||
);
|
||||
let tupled_upvars_ty = Ty::new_projection(tcx, upvars_projection_def_id, [
|
||||
ty::GenericArg::from(kind_ty),
|
||||
Ty::from_closure_kind(tcx, ty::ClosureKind::FnOnce).into(),
|
||||
tcx.lifetimes.re_static.into(),
|
||||
sig.tupled_inputs_ty.into(),
|
||||
args.tupled_upvars_ty().into(),
|
||||
args.coroutine_captures_by_ref_ty().into(),
|
||||
]);
|
||||
sig.to_coroutine(
|
||||
tcx,
|
||||
args.parent_args(),
|
||||
@@ -1834,18 +1830,14 @@ fn confirm_async_closure_candidate<'cx, 'tcx>(
|
||||
// will project to the right upvars for the generator, appending the inputs and
|
||||
// coroutine upvars respecting the closure kind.
|
||||
// N.B. No need to register a `AsyncFnKindHelper` goal here, it's already in `nested`.
|
||||
let tupled_upvars_ty = Ty::new_projection(
|
||||
tcx,
|
||||
upvars_projection_def_id,
|
||||
[
|
||||
ty::GenericArg::from(kind_ty),
|
||||
Ty::from_closure_kind(tcx, goal_kind).into(),
|
||||
env_region.into(),
|
||||
sig.tupled_inputs_ty.into(),
|
||||
args.tupled_upvars_ty().into(),
|
||||
args.coroutine_captures_by_ref_ty().into(),
|
||||
],
|
||||
);
|
||||
let tupled_upvars_ty = Ty::new_projection(tcx, upvars_projection_def_id, [
|
||||
ty::GenericArg::from(kind_ty),
|
||||
Ty::from_closure_kind(tcx, goal_kind).into(),
|
||||
env_region.into(),
|
||||
sig.tupled_inputs_ty.into(),
|
||||
args.tupled_upvars_ty().into(),
|
||||
args.coroutine_captures_by_ref_ty().into(),
|
||||
]);
|
||||
sig.to_coroutine(
|
||||
tcx,
|
||||
args.parent_args(),
|
||||
@@ -1859,16 +1851,17 @@ fn confirm_async_closure_candidate<'cx, 'tcx>(
|
||||
name => bug!("no such associated type: {name}"),
|
||||
};
|
||||
let projection_term = match item_name {
|
||||
sym::CallOnceFuture | sym::Output => ty::AliasTerm::new(
|
||||
tcx,
|
||||
obligation.predicate.def_id,
|
||||
[self_ty, sig.tupled_inputs_ty],
|
||||
),
|
||||
sym::CallRefFuture => ty::AliasTerm::new(
|
||||
tcx,
|
||||
obligation.predicate.def_id,
|
||||
[ty::GenericArg::from(self_ty), sig.tupled_inputs_ty.into(), env_region.into()],
|
||||
),
|
||||
sym::CallOnceFuture | sym::Output => {
|
||||
ty::AliasTerm::new(tcx, obligation.predicate.def_id, [
|
||||
self_ty,
|
||||
sig.tupled_inputs_ty,
|
||||
])
|
||||
}
|
||||
sym::CallRefFuture => ty::AliasTerm::new(tcx, obligation.predicate.def_id, [
|
||||
ty::GenericArg::from(self_ty),
|
||||
sig.tupled_inputs_ty.into(),
|
||||
env_region.into(),
|
||||
]),
|
||||
name => bug!("no such associated type: {name}"),
|
||||
};
|
||||
|
||||
@@ -1888,20 +1881,17 @@ fn confirm_async_closure_candidate<'cx, 'tcx>(
|
||||
name => bug!("no such associated type: {name}"),
|
||||
};
|
||||
let projection_term = match item_name {
|
||||
sym::CallOnceFuture | sym::Output => ty::AliasTerm::new(
|
||||
tcx,
|
||||
obligation.predicate.def_id,
|
||||
[self_ty, Ty::new_tup(tcx, sig.inputs())],
|
||||
),
|
||||
sym::CallRefFuture => ty::AliasTerm::new(
|
||||
tcx,
|
||||
obligation.predicate.def_id,
|
||||
[
|
||||
ty::GenericArg::from(self_ty),
|
||||
Ty::new_tup(tcx, sig.inputs()).into(),
|
||||
env_region.into(),
|
||||
],
|
||||
),
|
||||
sym::CallOnceFuture | sym::Output => {
|
||||
ty::AliasTerm::new(tcx, obligation.predicate.def_id, [
|
||||
self_ty,
|
||||
Ty::new_tup(tcx, sig.inputs()),
|
||||
])
|
||||
}
|
||||
sym::CallRefFuture => ty::AliasTerm::new(tcx, obligation.predicate.def_id, [
|
||||
ty::GenericArg::from(self_ty),
|
||||
Ty::new_tup(tcx, sig.inputs()).into(),
|
||||
env_region.into(),
|
||||
]),
|
||||
name => bug!("no such associated type: {name}"),
|
||||
};
|
||||
|
||||
@@ -1924,11 +1914,11 @@ fn confirm_async_closure_candidate<'cx, 'tcx>(
|
||||
sym::CallOnceFuture | sym::Output => {
|
||||
ty::AliasTerm::new(tcx, obligation.predicate.def_id, [self_ty, sig.inputs()[0]])
|
||||
}
|
||||
sym::CallRefFuture => ty::AliasTerm::new(
|
||||
tcx,
|
||||
obligation.predicate.def_id,
|
||||
[ty::GenericArg::from(self_ty), sig.inputs()[0].into(), env_region.into()],
|
||||
),
|
||||
sym::CallRefFuture => ty::AliasTerm::new(tcx, obligation.predicate.def_id, [
|
||||
ty::GenericArg::from(self_ty),
|
||||
sig.inputs()[0].into(),
|
||||
env_region.into(),
|
||||
]),
|
||||
name => bug!("no such associated type: {name}"),
|
||||
};
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_middle::traits::query::{DropckConstraint, DropckOutlivesResult};
|
||||
use rustc_middle::ty::{self, EarlyBinder, ParamEnvAnd, Ty, TyCtxt};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_span::{DUMMY_SP, Span};
|
||||
use tracing::{debug, instrument};
|
||||
|
||||
use crate::traits::query::normalize::QueryNormalizeExt;
|
||||
use crate::traits::query::NoSolution;
|
||||
use crate::traits::query::normalize::QueryNormalizeExt;
|
||||
use crate::traits::{Normalized, ObligationCause, ObligationCtxt};
|
||||
|
||||
/// This returns true if the type `ty` is "trivial" for
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use rustc_macros::extension;
|
||||
use rustc_middle::span_bug;
|
||||
|
||||
use crate::infer::canonical::OriginalQueryValues;
|
||||
use crate::infer::InferCtxt;
|
||||
use crate::infer::canonical::OriginalQueryValues;
|
||||
use crate::traits::{
|
||||
EvaluationResult, ObligationCtxt, OverflowError, PredicateObligation, SelectionContext,
|
||||
};
|
||||
|
||||
@@ -13,8 +13,8 @@ use rustc_span::DUMMY_SP;
|
||||
use tracing::{debug, info, instrument};
|
||||
|
||||
use super::NoSolution;
|
||||
use crate::error_reporting::traits::OverflowCause;
|
||||
use crate::error_reporting::InferCtxtErrorExt;
|
||||
use crate::error_reporting::traits::OverflowCause;
|
||||
use crate::infer::at::At;
|
||||
use crate::infer::canonical::OriginalQueryValues;
|
||||
use crate::infer::{InferCtxt, InferOk};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
|
||||
use rustc_hir::def_id::{CRATE_DEF_ID, DefId};
|
||||
use rustc_infer::traits::Obligation;
|
||||
pub use rustc_middle::traits::query::type_op::AscribeUserType;
|
||||
use rustc_middle::traits::query::NoSolution;
|
||||
pub use rustc_middle::traits::query::type_op::AscribeUserType;
|
||||
use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
|
||||
use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt, UserArgs, UserSelfTy, UserType};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_span::{DUMMY_SP, Span};
|
||||
use tracing::{debug, instrument};
|
||||
|
||||
use crate::infer::canonical::{Canonical, CanonicalQueryResponse};
|
||||
|
||||
@@ -7,10 +7,10 @@ use rustc_middle::ty::{TyCtxt, TypeFoldable};
|
||||
use rustc_span::Span;
|
||||
use tracing::info;
|
||||
|
||||
use crate::infer::canonical::query_response;
|
||||
use crate::infer::InferCtxt;
|
||||
use crate::traits::query::type_op::TypeOpOutput;
|
||||
use crate::infer::canonical::query_response;
|
||||
use crate::traits::ObligationCtxt;
|
||||
use crate::traits::query::type_op::TypeOpOutput;
|
||||
|
||||
pub struct CustomTypeOp<F> {
|
||||
closure: F,
|
||||
|
||||
@@ -5,14 +5,14 @@ use rustc_macros::{HashStable, TypeFoldable, TypeVisitable};
|
||||
use rustc_middle::infer::canonical::CanonicalQueryResponse;
|
||||
use rustc_middle::traits::ObligationCause;
|
||||
use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt, TypeFolder, TypeVisitableExt};
|
||||
use rustc_span::def_id::CRATE_DEF_ID;
|
||||
use rustc_span::DUMMY_SP;
|
||||
use rustc_type_ir::outlives::{push_outlives_components, Component};
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use rustc_span::def_id::CRATE_DEF_ID;
|
||||
use rustc_type_ir::outlives::{Component, push_outlives_components};
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use tracing::debug;
|
||||
|
||||
use crate::traits::query::NoSolution;
|
||||
use crate::traits::{wf, ObligationCtxt};
|
||||
use crate::traits::{ObligationCtxt, wf};
|
||||
|
||||
#[derive(Copy, Clone, Debug, HashStable, TypeFoldable, TypeVisitable)]
|
||||
pub struct ImpliedOutlivesBounds<'tcx> {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::fmt;
|
||||
|
||||
pub use rustc_middle::traits::query::type_op::Normalize;
|
||||
use rustc_middle::traits::query::NoSolution;
|
||||
use rustc_middle::traits::ObligationCause;
|
||||
use rustc_middle::traits::query::NoSolution;
|
||||
pub use rustc_middle::traits::query::type_op::Normalize;
|
||||
use rustc_middle::ty::fold::TypeFoldable;
|
||||
use rustc_middle::ty::{self, Lift, ParamEnvAnd, Ty, TyCtxt, TypeVisitableExt};
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ use rustc_middle::traits::query::{DropckOutlivesResult, NoSolution};
|
||||
use rustc_middle::ty::{ParamEnvAnd, Ty, TyCtxt};
|
||||
|
||||
use crate::infer::canonical::{Canonical, CanonicalQueryResponse};
|
||||
use crate::traits::ObligationCtxt;
|
||||
use crate::traits::query::dropck_outlives::{
|
||||
compute_dropck_outlives_inner, trivial_dropck_outlives,
|
||||
};
|
||||
use crate::traits::ObligationCtxt;
|
||||
|
||||
#[derive(Copy, Clone, Debug, HashStable, TypeFoldable, TypeVisitable)]
|
||||
pub struct DropckOutlives<'tcx> {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use rustc_hir::LangItem;
|
||||
use rustc_infer::traits::Obligation;
|
||||
pub use rustc_middle::traits::query::type_op::ProvePredicate;
|
||||
use rustc_middle::traits::query::NoSolution;
|
||||
use rustc_middle::traits::ObligationCause;
|
||||
use rustc_middle::traits::query::NoSolution;
|
||||
pub use rustc_middle::traits::query::type_op::ProvePredicate;
|
||||
use rustc_middle::ty::{self, ParamEnvAnd, TyCtxt};
|
||||
|
||||
use crate::infer::canonical::{Canonical, CanonicalQueryResponse};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use rustc_infer::infer::relate::{
|
||||
self, structurally_relate_tys, Relate, RelateResult, TypeRelation,
|
||||
self, Relate, RelateResult, TypeRelation, structurally_relate_tys,
|
||||
};
|
||||
use rustc_middle::ty::error::{ExpectedFound, TypeError};
|
||||
use rustc_middle::ty::{self, InferConst, Ty, TyCtxt};
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
use hir::def_id::DefId;
|
||||
use hir::LangItem;
|
||||
use hir::def_id::DefId;
|
||||
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
|
||||
use rustc_hir as hir;
|
||||
use rustc_infer::traits::{Obligation, ObligationCause, PolyTraitObligation, SelectionError};
|
||||
|
||||
@@ -305,15 +305,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
let make_transmute_obl = |src, dst| {
|
||||
let transmute_trait = obligation.predicate.def_id();
|
||||
let assume = obligation.predicate.skip_binder().trait_ref.args.const_at(2);
|
||||
let trait_ref = ty::TraitRef::new(
|
||||
tcx,
|
||||
transmute_trait,
|
||||
[
|
||||
ty::GenericArg::from(dst),
|
||||
ty::GenericArg::from(src),
|
||||
ty::GenericArg::from(assume),
|
||||
],
|
||||
);
|
||||
let trait_ref = ty::TraitRef::new(tcx, transmute_trait, [
|
||||
ty::GenericArg::from(dst),
|
||||
ty::GenericArg::from(src),
|
||||
ty::GenericArg::from(assume),
|
||||
]);
|
||||
Obligation::with_depth(
|
||||
tcx,
|
||||
obligation.cause.clone(),
|
||||
@@ -324,11 +320,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
};
|
||||
|
||||
let make_freeze_obl = |ty| {
|
||||
let trait_ref = ty::TraitRef::new(
|
||||
tcx,
|
||||
tcx.require_lang_item(LangItem::Freeze, None),
|
||||
[ty::GenericArg::from(ty)],
|
||||
);
|
||||
let trait_ref =
|
||||
ty::TraitRef::new(tcx, tcx.require_lang_item(LangItem::Freeze, None), [
|
||||
ty::GenericArg::from(ty),
|
||||
]);
|
||||
Obligation::with_depth(
|
||||
tcx,
|
||||
obligation.cause.clone(),
|
||||
@@ -657,28 +652,20 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
let kind = ty::BoundTyKind::Param(param.def_id, param.name);
|
||||
let bound_var = ty::BoundVariableKind::Ty(kind);
|
||||
bound_vars.push(bound_var);
|
||||
Ty::new_bound(
|
||||
tcx,
|
||||
ty::INNERMOST,
|
||||
ty::BoundTy {
|
||||
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
|
||||
kind,
|
||||
},
|
||||
)
|
||||
Ty::new_bound(tcx, ty::INNERMOST, ty::BoundTy {
|
||||
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
|
||||
kind,
|
||||
})
|
||||
.into()
|
||||
}
|
||||
GenericParamDefKind::Lifetime => {
|
||||
let kind = ty::BoundRegionKind::BrNamed(param.def_id, param.name);
|
||||
let bound_var = ty::BoundVariableKind::Region(kind);
|
||||
bound_vars.push(bound_var);
|
||||
ty::Region::new_bound(
|
||||
tcx,
|
||||
ty::INNERMOST,
|
||||
ty::BoundRegion {
|
||||
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
|
||||
kind,
|
||||
},
|
||||
)
|
||||
ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
|
||||
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
|
||||
kind,
|
||||
})
|
||||
.into()
|
||||
}
|
||||
GenericParamDefKind::Const { .. } => {
|
||||
@@ -921,11 +908,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
),
|
||||
ty::CoroutineClosure(_, args) => {
|
||||
args.as_coroutine_closure().coroutine_closure_sig().map_bound(|sig| {
|
||||
ty::TraitRef::new(
|
||||
self.tcx(),
|
||||
obligation.predicate.def_id(),
|
||||
[self_ty, sig.tupled_inputs_ty],
|
||||
)
|
||||
ty::TraitRef::new(self.tcx(), obligation.predicate.def_id(), [
|
||||
self_ty,
|
||||
sig.tupled_inputs_ty,
|
||||
])
|
||||
})
|
||||
}
|
||||
_ => {
|
||||
@@ -951,22 +937,20 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
ty::CoroutineClosure(_, args) => {
|
||||
let args = args.as_coroutine_closure();
|
||||
let trait_ref = args.coroutine_closure_sig().map_bound(|sig| {
|
||||
ty::TraitRef::new(
|
||||
self.tcx(),
|
||||
obligation.predicate.def_id(),
|
||||
[self_ty, sig.tupled_inputs_ty],
|
||||
)
|
||||
ty::TraitRef::new(self.tcx(), obligation.predicate.def_id(), [
|
||||
self_ty,
|
||||
sig.tupled_inputs_ty,
|
||||
])
|
||||
});
|
||||
(trait_ref, args.kind_ty())
|
||||
}
|
||||
ty::FnDef(..) | ty::FnPtr(..) => {
|
||||
let sig = self_ty.fn_sig(tcx);
|
||||
let trait_ref = sig.map_bound(|sig| {
|
||||
ty::TraitRef::new(
|
||||
self.tcx(),
|
||||
obligation.predicate.def_id(),
|
||||
[self_ty, Ty::new_tup(tcx, sig.inputs())],
|
||||
)
|
||||
ty::TraitRef::new(self.tcx(), obligation.predicate.def_id(), [
|
||||
self_ty,
|
||||
Ty::new_tup(tcx, sig.inputs()),
|
||||
])
|
||||
});
|
||||
|
||||
// We must additionally check that the return type impls `Future`.
|
||||
@@ -990,11 +974,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
let args = args.as_closure();
|
||||
let sig = args.sig();
|
||||
let trait_ref = sig.map_bound(|sig| {
|
||||
ty::TraitRef::new(
|
||||
self.tcx(),
|
||||
obligation.predicate.def_id(),
|
||||
[self_ty, sig.inputs()[0]],
|
||||
)
|
||||
ty::TraitRef::new(self.tcx(), obligation.predicate.def_id(), [
|
||||
self_ty,
|
||||
sig.inputs()[0],
|
||||
])
|
||||
});
|
||||
|
||||
// We must additionally check that the return type impls `Future`.
|
||||
@@ -1310,11 +1293,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
// Construct the nested `TailField<T>: Unsize<TailField<U>>` predicate.
|
||||
let tail_unsize_obligation = obligation.with(
|
||||
tcx,
|
||||
ty::TraitRef::new(
|
||||
tcx,
|
||||
obligation.predicate.def_id(),
|
||||
[source_tail, target_tail],
|
||||
),
|
||||
ty::TraitRef::new(tcx, obligation.predicate.def_id(), [
|
||||
source_tail,
|
||||
target_tail,
|
||||
]),
|
||||
);
|
||||
nested.push(tail_unsize_obligation);
|
||||
|
||||
|
||||
@@ -12,25 +12,25 @@ use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_errors::{Diag, EmissionGuarantee};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::LangItem;
|
||||
use rustc_infer::infer::relate::TypeRelation;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_infer::infer::BoundRegionConversionTime::{self, HigherRankedType};
|
||||
use rustc_infer::infer::DefineOpaqueTypes;
|
||||
use rustc_infer::infer::relate::TypeRelation;
|
||||
use rustc_infer::traits::TraitObligation;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::dep_graph::{dep_kinds, DepNodeIndex};
|
||||
use rustc_middle::dep_graph::{DepNodeIndex, dep_kinds};
|
||||
use rustc_middle::mir::interpret::ErrorHandled;
|
||||
pub use rustc_middle::traits::select::*;
|
||||
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
|
||||
use rustc_middle::ty::error::TypeErrorToStringExt;
|
||||
use rustc_middle::ty::print::{with_no_trimmed_paths, PrintTraitRefExt as _};
|
||||
use rustc_middle::ty::print::{PrintTraitRefExt as _, with_no_trimmed_paths};
|
||||
use rustc_middle::ty::{
|
||||
self, GenericArgsRef, PolyProjectionPredicate, Ty, TyCtxt, TypeFoldable, TypeVisitableExt,
|
||||
Upcast,
|
||||
};
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::Symbol;
|
||||
use rustc_span::symbol::sym;
|
||||
use tracing::{debug, instrument, trace};
|
||||
|
||||
use self::EvaluationResult::*;
|
||||
@@ -39,9 +39,9 @@ use super::coherence::{self, Conflict};
|
||||
use super::project::ProjectionTermObligation;
|
||||
use super::util::closure_trait_ref_and_return_type;
|
||||
use super::{
|
||||
const_evaluatable, project, util, wf, ImplDerivedCause, Normalized, Obligation,
|
||||
ObligationCause, ObligationCauseCode, Overflow, PolyTraitObligation, PredicateObligation,
|
||||
Selection, SelectionError, SelectionResult, TraitQueryMode,
|
||||
ImplDerivedCause, Normalized, Obligation, ObligationCause, ObligationCauseCode, Overflow,
|
||||
PolyTraitObligation, PredicateObligation, Selection, SelectionError, SelectionResult,
|
||||
TraitQueryMode, const_evaluatable, project, util, wf,
|
||||
};
|
||||
use crate::error_reporting::InferCtxtErrorExt;
|
||||
use crate::infer::{InferCtxt, InferCtxtExt, InferOk, TypeFreshener};
|
||||
@@ -2449,11 +2449,9 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||
} else {
|
||||
// If this is an ill-formed auto/built-in trait, then synthesize
|
||||
// new error args for the missing generics.
|
||||
let err_args = ty::GenericArgs::extend_with_error(
|
||||
tcx,
|
||||
trait_def_id,
|
||||
&[normalized_ty.into()],
|
||||
);
|
||||
let err_args = ty::GenericArgs::extend_with_error(tcx, trait_def_id, &[
|
||||
normalized_ty.into(),
|
||||
]);
|
||||
ty::TraitRef::new_from_args(tcx, trait_def_id, err_args)
|
||||
};
|
||||
|
||||
|
||||
@@ -21,16 +21,16 @@ use rustc_middle::query::LocalCrate;
|
||||
use rustc_middle::ty::print::PrintTraitRefExt as _;
|
||||
use rustc_middle::ty::{self, GenericArgsRef, ImplSubject, Ty, TyCtxt, TypeVisitableExt};
|
||||
use rustc_session::lint::builtin::{COHERENCE_LEAK_CHECK, ORDER_DEPENDENT_TRAIT_OBJECTS};
|
||||
use rustc_span::{sym, ErrorGuaranteed, Span, DUMMY_SP};
|
||||
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, sym};
|
||||
use specialization_graph::GraphExt;
|
||||
use tracing::{debug, instrument};
|
||||
|
||||
use super::{util, SelectionContext};
|
||||
use super::{SelectionContext, util};
|
||||
use crate::error_reporting::traits::to_pretty_impl_header;
|
||||
use crate::errors::NegativePositiveConflict;
|
||||
use crate::infer::{InferCtxt, InferOk, TyCtxtInferExt};
|
||||
use crate::traits::select::IntercrateAmbiguityCause;
|
||||
use crate::traits::{coherence, FutureCompatOverlapErrorKind, ObligationCause, ObligationCtxt};
|
||||
use crate::traits::{FutureCompatOverlapErrorKind, ObligationCause, ObligationCtxt, coherence};
|
||||
|
||||
/// Information pertinent to an overlapping impl error.
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -11,7 +11,7 @@ use rustc_middle::ty::{
|
||||
TypeVisitableExt, Upcast,
|
||||
};
|
||||
use rustc_span::Span;
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use tracing::debug;
|
||||
|
||||
use super::{NormalizeExt, ObligationCause, PredicateObligation, SelectionContext};
|
||||
@@ -223,15 +223,11 @@ pub(crate) fn closure_trait_ref_and_return_type<'tcx>(
|
||||
TupleArgumentsFlag::Yes => Ty::new_tup(tcx, sig.skip_binder().inputs()),
|
||||
};
|
||||
let trait_ref = if tcx.has_host_param(fn_trait_def_id) {
|
||||
ty::TraitRef::new(
|
||||
tcx,
|
||||
fn_trait_def_id,
|
||||
[
|
||||
ty::GenericArg::from(self_ty),
|
||||
ty::GenericArg::from(arguments_tuple),
|
||||
ty::GenericArg::from(fn_host_effect),
|
||||
],
|
||||
)
|
||||
ty::TraitRef::new(tcx, fn_trait_def_id, [
|
||||
ty::GenericArg::from(self_ty),
|
||||
ty::GenericArg::from(arguments_tuple),
|
||||
ty::GenericArg::from(fn_host_effect),
|
||||
])
|
||||
} else {
|
||||
ty::TraitRef::new(tcx, fn_trait_def_id, [self_ty, arguments_tuple])
|
||||
};
|
||||
|
||||
@@ -8,8 +8,8 @@ use rustc_middle::query::Providers;
|
||||
use rustc_middle::ty::{
|
||||
self, GenericArgs, GenericParamDefKind, Ty, TyCtxt, TypeVisitableExt, Upcast, VtblEntry,
|
||||
};
|
||||
use rustc_span::{sym, Span, DUMMY_SP};
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use rustc_span::{DUMMY_SP, Span, sym};
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use tracing::debug;
|
||||
|
||||
use crate::errors::DumpVTableEntries;
|
||||
|
||||
@@ -8,8 +8,8 @@ use rustc_middle::ty::{
|
||||
self, GenericArg, GenericArgKind, GenericArgsRef, Ty, TyCtxt, TypeSuperVisitable,
|
||||
TypeVisitable, TypeVisitableExt, TypeVisitor,
|
||||
};
|
||||
use rustc_span::def_id::{DefId, LocalDefId, CRATE_DEF_ID};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_span::def_id::{CRATE_DEF_ID, DefId, LocalDefId};
|
||||
use rustc_span::{DUMMY_SP, Span};
|
||||
use tracing::{debug, instrument, trace};
|
||||
|
||||
use crate::infer::InferCtxt;
|
||||
|
||||
Reference in New Issue
Block a user