summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_middle/src/traits
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_middle/src/traits')
-rw-r--r--compiler/rustc_middle/src/traits/chalk.rs89
-rw-r--r--compiler/rustc_middle/src/traits/mod.rs2
-rw-r--r--compiler/rustc_middle/src/traits/query.rs23
-rw-r--r--compiler/rustc_middle/src/traits/select.rs4
-rw-r--r--compiler/rustc_middle/src/traits/specialization_graph.rs9
5 files changed, 58 insertions, 69 deletions
diff --git a/compiler/rustc_middle/src/traits/chalk.rs b/compiler/rustc_middle/src/traits/chalk.rs
index 6d4af8bea..fcc8f457a 100644
--- a/compiler/rustc_middle/src/traits/chalk.rs
+++ b/compiler/rustc_middle/src/traits/chalk.rs
@@ -159,18 +159,20 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
}
chalk_ir::TyKind::Array(ty, len) => Some(write!(fmt, "[{:?}; {:?}]", ty, len)),
chalk_ir::TyKind::Slice(ty) => Some(write!(fmt, "[{:?}]", ty)),
- chalk_ir::TyKind::Tuple(len, substs) => Some((|| {
- write!(fmt, "(")?;
- for (idx, substitution) in substs.interned().iter().enumerate() {
- if idx == *len && *len != 1 {
- // Don't add a trailing comma if the tuple has more than one element
- write!(fmt, "{:?}", substitution)?;
- } else {
- write!(fmt, "{:?},", substitution)?;
+ chalk_ir::TyKind::Tuple(len, substs) => Some(
+ try {
+ write!(fmt, "(")?;
+ for (idx, substitution) in substs.interned().iter().enumerate() {
+ if idx == *len && *len != 1 {
+ // Don't add a trailing comma if the tuple has more than one element
+ write!(fmt, "{:?}", substitution)?;
+ } else {
+ write!(fmt, "{:?},", substitution)?;
+ }
}
- }
- write!(fmt, ")")
- })()),
+ write!(fmt, ")")?;
+ },
+ ),
_ => None,
}
}
@@ -210,7 +212,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
Box::new(chalk_ir::TyData { kind: ty, flags: flags })
}
- fn ty_data<'a>(self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData<Self> {
+ fn ty_data(self, ty: &Self::InternedType) -> &chalk_ir::TyData<Self> {
ty
}
@@ -218,10 +220,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
Box::new(lifetime)
}
- fn lifetime_data<'a>(
- self,
- lifetime: &'a Self::InternedLifetime,
- ) -> &'a chalk_ir::LifetimeData<Self> {
+ fn lifetime_data(self, lifetime: &Self::InternedLifetime) -> &chalk_ir::LifetimeData<Self> {
&lifetime
}
@@ -229,7 +228,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
Box::new(constant)
}
- fn const_data<'a>(self, constant: &'a Self::InternedConst) -> &'a chalk_ir::ConstData<Self> {
+ fn const_data(self, constant: &Self::InternedConst) -> &chalk_ir::ConstData<Self> {
&constant
}
@@ -246,10 +245,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
Box::new(data)
}
- fn generic_arg_data<'a>(
- self,
- data: &'a Self::InternedGenericArg,
- ) -> &'a chalk_ir::GenericArgData<Self> {
+ fn generic_arg_data(self, data: &Self::InternedGenericArg) -> &chalk_ir::GenericArgData<Self> {
&data
}
@@ -257,7 +253,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
Box::new(goal)
}
- fn goal_data<'a>(self, goal: &'a Self::InternedGoal) -> &'a chalk_ir::GoalData<Self> {
+ fn goal_data(self, goal: &Self::InternedGoal) -> &chalk_ir::GoalData<Self> {
&goal
}
@@ -268,7 +264,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
data.into_iter().collect::<Result<Vec<_>, _>>()
}
- fn goals_data<'a>(self, goals: &'a Self::InternedGoals) -> &'a [chalk_ir::Goal<Self>] {
+ fn goals_data(self, goals: &Self::InternedGoals) -> &[chalk_ir::Goal<Self>] {
goals
}
@@ -279,10 +275,10 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
data.into_iter().collect::<Result<Vec<_>, _>>()
}
- fn substitution_data<'a>(
+ fn substitution_data(
self,
- substitution: &'a Self::InternedSubstitution,
- ) -> &'a [chalk_ir::GenericArg<Self>] {
+ substitution: &Self::InternedSubstitution,
+ ) -> &[chalk_ir::GenericArg<Self>] {
substitution
}
@@ -293,10 +289,10 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
Box::new(data)
}
- fn program_clause_data<'a>(
+ fn program_clause_data(
self,
- clause: &'a Self::InternedProgramClause,
- ) -> &'a chalk_ir::ProgramClauseData<Self> {
+ clause: &Self::InternedProgramClause,
+ ) -> &chalk_ir::ProgramClauseData<Self> {
&clause
}
@@ -307,10 +303,10 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
data.into_iter().collect::<Result<Vec<_>, _>>()
}
- fn program_clauses_data<'a>(
+ fn program_clauses_data(
self,
- clauses: &'a Self::InternedProgramClauses,
- ) -> &'a [chalk_ir::ProgramClause<Self>] {
+ clauses: &Self::InternedProgramClauses,
+ ) -> &[chalk_ir::ProgramClause<Self>] {
clauses
}
@@ -321,10 +317,10 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
data.into_iter().collect::<Result<Vec<_>, _>>()
}
- fn quantified_where_clauses_data<'a>(
+ fn quantified_where_clauses_data(
self,
- clauses: &'a Self::InternedQuantifiedWhereClauses,
- ) -> &'a [chalk_ir::QuantifiedWhereClause<Self>] {
+ clauses: &Self::InternedQuantifiedWhereClauses,
+ ) -> &[chalk_ir::QuantifiedWhereClause<Self>] {
clauses
}
@@ -335,10 +331,10 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
data.into_iter().collect::<Result<Vec<_>, _>>()
}
- fn variable_kinds_data<'a>(
+ fn variable_kinds_data(
self,
- parameter_kinds: &'a Self::InternedVariableKinds,
- ) -> &'a [chalk_ir::VariableKind<Self>] {
+ parameter_kinds: &Self::InternedVariableKinds,
+ ) -> &[chalk_ir::VariableKind<Self>] {
parameter_kinds
}
@@ -349,10 +345,10 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
data.into_iter().collect::<Result<Vec<_>, _>>()
}
- fn canonical_var_kinds_data<'a>(
+ fn canonical_var_kinds_data(
self,
- canonical_var_kinds: &'a Self::InternedCanonicalVarKinds,
- ) -> &'a [chalk_ir::CanonicalVarKind<Self>] {
+ canonical_var_kinds: &Self::InternedCanonicalVarKinds,
+ ) -> &[chalk_ir::CanonicalVarKind<Self>] {
canonical_var_kinds
}
@@ -363,10 +359,10 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
data.into_iter().collect::<Result<Vec<_>, _>>()
}
- fn constraints_data<'a>(
+ fn constraints_data(
self,
- constraints: &'a Self::InternedConstraints,
- ) -> &'a [chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>] {
+ constraints: &Self::InternedConstraints,
+ ) -> &[chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>] {
constraints
}
@@ -377,10 +373,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
data.into_iter().collect::<Result<Vec<_>, _>>()
}
- fn variances_data<'a>(
- self,
- variances: &'a Self::InternedVariances,
- ) -> &'a [chalk_ir::Variance] {
+ fn variances_data(self, variances: &Self::InternedVariances) -> &[chalk_ir::Variance] {
variances
}
}
diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs
index 143435cb2..d00b26a5a 100644
--- a/compiler/rustc_middle/src/traits/mod.rs
+++ b/compiler/rustc_middle/src/traits/mod.rs
@@ -250,7 +250,7 @@ pub enum ObligationCauseCode<'tcx> {
TupleElem,
/// This is the trait reference from the given projection.
- ProjectionWf(ty::ProjectionTy<'tcx>),
+ ProjectionWf(ty::AliasTy<'tcx>),
/// Must satisfy all of the where-clause predicates of the
/// given item.
diff --git a/compiler/rustc_middle/src/traits/query.rs b/compiler/rustc_middle/src/traits/query.rs
index fb152b63f..615154a55 100644
--- a/compiler/rustc_middle/src/traits/query.rs
+++ b/compiler/rustc_middle/src/traits/query.rs
@@ -8,30 +8,25 @@
use crate::error::DropCheckOverflow;
use crate::infer::canonical::{Canonical, QueryResponse};
use crate::ty::error::TypeError;
-use crate::ty::subst::{GenericArg, SubstsRef};
+use crate::ty::subst::GenericArg;
use crate::ty::{self, Ty, TyCtxt};
-use rustc_hir::def_id::DefId;
use rustc_span::source_map::Span;
-use std::iter::FromIterator;
pub mod type_op {
use crate::ty::fold::TypeFoldable;
- use crate::ty::subst::UserSubsts;
- use crate::ty::{Predicate, Ty};
- use rustc_hir::def_id::DefId;
+ use crate::ty::{Predicate, Ty, UserType};
use std::fmt;
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, Lift)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct AscribeUserType<'tcx> {
pub mir_ty: Ty<'tcx>,
- pub def_id: DefId,
- pub user_substs: UserSubsts<'tcx>,
+ pub user_ty: UserType<'tcx>,
}
impl<'tcx> AscribeUserType<'tcx> {
- pub fn new(mir_ty: Ty<'tcx>, def_id: DefId, user_substs: UserSubsts<'tcx>) -> Self {
- Self { mir_ty, def_id, user_substs }
+ pub fn new(mir_ty: Ty<'tcx>, user_ty: UserType<'tcx>) -> Self {
+ Self { mir_ty, user_ty }
}
}
@@ -77,8 +72,7 @@ pub mod type_op {
}
}
-pub type CanonicalProjectionGoal<'tcx> =
- Canonical<'tcx, ty::ParamEnvAnd<'tcx, ty::ProjectionTy<'tcx>>>;
+pub type CanonicalProjectionGoal<'tcx> = Canonical<'tcx, ty::ParamEnvAnd<'tcx, ty::AliasTy<'tcx>>>;
pub type CanonicalTyGoal<'tcx> = Canonical<'tcx, ty::ParamEnvAnd<'tcx, Ty<'tcx>>>;
@@ -98,7 +92,7 @@ pub type CanonicalTypeOpProvePredicateGoal<'tcx> =
pub type CanonicalTypeOpNormalizeGoal<'tcx, T> =
Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::Normalize<T>>>;
-#[derive(Copy, Clone, Debug, HashStable)]
+#[derive(Copy, Clone, Debug, HashStable, PartialEq, Eq)]
pub struct NoSolution;
pub type Fallible<T> = Result<T, NoSolution>;
@@ -219,6 +213,5 @@ pub struct NormalizationResult<'tcx> {
pub enum OutlivesBound<'tcx> {
RegionSubRegion(ty::Region<'tcx>, ty::Region<'tcx>),
RegionSubParam(ty::Region<'tcx>, ty::ParamTy),
- RegionSubProjection(ty::Region<'tcx>, ty::ProjectionTy<'tcx>),
- RegionSubOpaque(ty::Region<'tcx>, DefId, SubstsRef<'tcx>),
+ RegionSubAlias(ty::Region<'tcx>, ty::AliasTy<'tcx>),
}
diff --git a/compiler/rustc_middle/src/traits/select.rs b/compiler/rustc_middle/src/traits/select.rs
index ec69864c9..1cc9fd526 100644
--- a/compiler/rustc_middle/src/traits/select.rs
+++ b/compiler/rustc_middle/src/traits/select.rs
@@ -131,7 +131,9 @@ pub enum SelectionCandidate<'tcx> {
/// Implementation of a `Fn`-family trait by one of the anonymous types
/// generated for an `||` expression.
- ClosureCandidate,
+ ClosureCandidate {
+ is_const: bool,
+ },
/// Implementation of a `Generator` trait by one of the anonymous types
/// generated for a generator.
diff --git a/compiler/rustc_middle/src/traits/specialization_graph.rs b/compiler/rustc_middle/src/traits/specialization_graph.rs
index cccedc9ec..aad5b2fbe 100644
--- a/compiler/rustc_middle/src/traits/specialization_graph.rs
+++ b/compiler/rustc_middle/src/traits/specialization_graph.rs
@@ -60,7 +60,7 @@ pub enum OverlapMode {
}
impl OverlapMode {
- pub fn get<'tcx>(tcx: TyCtxt<'tcx>, trait_id: DefId) -> OverlapMode {
+ pub fn get(tcx: TyCtxt<'_>, trait_id: DefId) -> OverlapMode {
let with_negative_coherence = tcx.features().with_negative_coherence;
let strict_coherence = tcx.has_attr(trait_id, sym::rustc_strict_coherence);
@@ -180,6 +180,7 @@ impl Iterator for Ancestors<'_> {
}
/// Information about the most specialized definition of an associated item.
+#[derive(Debug)]
pub struct LeafDef {
/// The associated item described by this `LeafDef`.
pub item: ty::AssocItem,
@@ -253,11 +254,11 @@ impl<'tcx> Ancestors<'tcx> {
///
/// Returns `Err` if an error was reported while building the specialization
/// graph.
-pub fn ancestors<'tcx>(
- tcx: TyCtxt<'tcx>,
+pub fn ancestors(
+ tcx: TyCtxt<'_>,
trait_def_id: DefId,
start_from_impl: DefId,
-) -> Result<Ancestors<'tcx>, ErrorGuaranteed> {
+) -> Result<Ancestors<'_>, ErrorGuaranteed> {
let specialization_graph = tcx.specialization_graph_of(trait_def_id);
if let Some(reported) = specialization_graph.has_errored {