move Constness into TraitPredicate
This commit is contained in:
parent
04c9901a08
commit
32390a0df6
49 changed files with 157 additions and 124 deletions
|
@ -2751,6 +2751,15 @@ pub enum Constness {
|
||||||
NotConst,
|
NotConst,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for Constness {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.write_str(match *self {
|
||||||
|
Self::Const => "const",
|
||||||
|
Self::NotConst => "non-const",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Encodable, Debug, HashStable_Generic)]
|
#[derive(Copy, Clone, Encodable, Debug, HashStable_Generic)]
|
||||||
pub struct FnHeader {
|
pub struct FnHeader {
|
||||||
pub unsafety: Unsafety,
|
pub unsafety: Unsafety,
|
||||||
|
|
|
@ -124,7 +124,7 @@ impl Elaborator<'tcx> {
|
||||||
|
|
||||||
let bound_predicate = obligation.predicate.kind();
|
let bound_predicate = obligation.predicate.kind();
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(data, _) => {
|
ty::PredicateKind::Trait(data) => {
|
||||||
// Get predicates declared on the trait.
|
// Get predicates declared on the trait.
|
||||||
let predicates = tcx.super_predicates_of(data.def_id());
|
let predicates = tcx.super_predicates_of(data.def_id());
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints {
|
||||||
let predicates = cx.tcx.explicit_predicates_of(item.def_id);
|
let predicates = cx.tcx.explicit_predicates_of(item.def_id);
|
||||||
for &(predicate, span) in predicates.predicates {
|
for &(predicate, span) in predicates.predicates {
|
||||||
let trait_predicate = match predicate.kind().skip_binder() {
|
let trait_predicate = match predicate.kind().skip_binder() {
|
||||||
Trait(trait_predicate, _constness) => trait_predicate,
|
Trait(trait_predicate) => trait_predicate,
|
||||||
_ => continue,
|
_ => continue,
|
||||||
};
|
};
|
||||||
let def_id = trait_predicate.trait_ref.def_id;
|
let def_id = trait_predicate.trait_ref.def_id;
|
||||||
|
|
|
@ -211,7 +211,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
|
||||||
let mut has_emitted = false;
|
let mut has_emitted = false;
|
||||||
for &(predicate, _) in cx.tcx.explicit_item_bounds(def) {
|
for &(predicate, _) in cx.tcx.explicit_item_bounds(def) {
|
||||||
// We only look at the `DefId`, so it is safe to skip the binder here.
|
// We only look at the `DefId`, so it is safe to skip the binder here.
|
||||||
if let ty::PredicateKind::Trait(ref poly_trait_predicate, _) =
|
if let ty::PredicateKind::Trait(ref poly_trait_predicate) =
|
||||||
predicate.kind().skip_binder()
|
predicate.kind().skip_binder()
|
||||||
{
|
{
|
||||||
let def_id = poly_trait_predicate.trait_ref.def_id;
|
let def_id = poly_trait_predicate.trait_ref.def_id;
|
||||||
|
|
|
@ -2169,7 +2169,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
let generic_predicates = self.super_predicates_of(trait_did);
|
let generic_predicates = self.super_predicates_of(trait_did);
|
||||||
|
|
||||||
for (predicate, _) in generic_predicates.predicates {
|
for (predicate, _) in generic_predicates.predicates {
|
||||||
if let ty::PredicateKind::Trait(data, _) = predicate.kind().skip_binder() {
|
if let ty::PredicateKind::Trait(data) = predicate.kind().skip_binder() {
|
||||||
if set.insert(data.def_id()) {
|
if set.insert(data.def_id()) {
|
||||||
stack.push(data.def_id());
|
stack.push(data.def_id());
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ impl<T> ExpectedFound<T> {
|
||||||
#[derive(Clone, Debug, TypeFoldable)]
|
#[derive(Clone, Debug, TypeFoldable)]
|
||||||
pub enum TypeError<'tcx> {
|
pub enum TypeError<'tcx> {
|
||||||
Mismatch,
|
Mismatch,
|
||||||
|
ConstnessMismatch(ExpectedFound<hir::Constness>),
|
||||||
UnsafetyMismatch(ExpectedFound<hir::Unsafety>),
|
UnsafetyMismatch(ExpectedFound<hir::Unsafety>),
|
||||||
AbiMismatch(ExpectedFound<abi::Abi>),
|
AbiMismatch(ExpectedFound<abi::Abi>),
|
||||||
Mutability,
|
Mutability,
|
||||||
|
@ -106,6 +107,9 @@ impl<'tcx> fmt::Display for TypeError<'tcx> {
|
||||||
CyclicTy(_) => write!(f, "cyclic type of infinite size"),
|
CyclicTy(_) => write!(f, "cyclic type of infinite size"),
|
||||||
CyclicConst(_) => write!(f, "encountered a self-referencing constant"),
|
CyclicConst(_) => write!(f, "encountered a self-referencing constant"),
|
||||||
Mismatch => write!(f, "types differ"),
|
Mismatch => write!(f, "types differ"),
|
||||||
|
ConstnessMismatch(values) => {
|
||||||
|
write!(f, "expected {} fn, found {} fn", values.expected, values.found)
|
||||||
|
}
|
||||||
UnsafetyMismatch(values) => {
|
UnsafetyMismatch(values) => {
|
||||||
write!(f, "expected {} fn, found {} fn", values.expected, values.found)
|
write!(f, "expected {} fn, found {} fn", values.expected, values.found)
|
||||||
}
|
}
|
||||||
|
@ -213,9 +217,11 @@ impl<'tcx> TypeError<'tcx> {
|
||||||
pub fn must_include_note(&self) -> bool {
|
pub fn must_include_note(&self) -> bool {
|
||||||
use self::TypeError::*;
|
use self::TypeError::*;
|
||||||
match self {
|
match self {
|
||||||
CyclicTy(_) | CyclicConst(_) | UnsafetyMismatch(_) | Mismatch | AbiMismatch(_)
|
CyclicTy(_) | CyclicConst(_) | UnsafetyMismatch(_) | ConstnessMismatch(_)
|
||||||
| FixedArraySize(_) | ArgumentSorts(..) | Sorts(_) | IntMismatch(_)
|
| Mismatch | AbiMismatch(_) | FixedArraySize(_) | ArgumentSorts(..) | Sorts(_)
|
||||||
| FloatMismatch(_) | VariadicMismatch(_) | TargetFeatureCast(_) => false,
|
| IntMismatch(_) | FloatMismatch(_) | VariadicMismatch(_) | TargetFeatureCast(_) => {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
Mutability
|
Mutability
|
||||||
| ArgumentMutability(_)
|
| ArgumentMutability(_)
|
||||||
|
|
|
@ -216,7 +216,7 @@ impl FlagComputation {
|
||||||
|
|
||||||
fn add_predicate_atom(&mut self, atom: ty::PredicateKind<'_>) {
|
fn add_predicate_atom(&mut self, atom: ty::PredicateKind<'_>) {
|
||||||
match atom {
|
match atom {
|
||||||
ty::PredicateKind::Trait(trait_pred, _constness) => {
|
ty::PredicateKind::Trait(trait_pred) => {
|
||||||
self.add_substs(trait_pred.trait_ref.substs);
|
self.add_substs(trait_pred.trait_ref.substs);
|
||||||
}
|
}
|
||||||
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => {
|
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => {
|
||||||
|
|
|
@ -456,7 +456,7 @@ pub enum PredicateKind<'tcx> {
|
||||||
/// A trait predicate will have `Constness::Const` if it originates
|
/// A trait predicate will have `Constness::Const` if it originates
|
||||||
/// from a bound on a `const fn` without the `?const` opt-out (e.g.,
|
/// from a bound on a `const fn` without the `?const` opt-out (e.g.,
|
||||||
/// `const fn foobar<Foo: Bar>() {}`).
|
/// `const fn foobar<Foo: Bar>() {}`).
|
||||||
Trait(TraitPredicate<'tcx>, Constness),
|
Trait(TraitPredicate<'tcx>),
|
||||||
|
|
||||||
/// `where 'a: 'b`
|
/// `where 'a: 'b`
|
||||||
RegionOutlives(RegionOutlivesPredicate<'tcx>),
|
RegionOutlives(RegionOutlivesPredicate<'tcx>),
|
||||||
|
@ -612,6 +612,11 @@ impl<'tcx> Predicate<'tcx> {
|
||||||
#[derive(HashStable, TypeFoldable)]
|
#[derive(HashStable, TypeFoldable)]
|
||||||
pub struct TraitPredicate<'tcx> {
|
pub struct TraitPredicate<'tcx> {
|
||||||
pub trait_ref: TraitRef<'tcx>,
|
pub trait_ref: TraitRef<'tcx>,
|
||||||
|
|
||||||
|
/// A trait predicate will have `Constness::Const` if it originates
|
||||||
|
/// from a bound on a `const fn` without the `?const` opt-out (e.g.,
|
||||||
|
/// `const fn foobar<Foo: Bar>() {}`).
|
||||||
|
pub constness: hir::Constness,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type PolyTraitPredicate<'tcx> = ty::Binder<'tcx, TraitPredicate<'tcx>>;
|
pub type PolyTraitPredicate<'tcx> = ty::Binder<'tcx, TraitPredicate<'tcx>>;
|
||||||
|
@ -745,7 +750,10 @@ impl ToPredicate<'tcx> for PredicateKind<'tcx> {
|
||||||
|
|
||||||
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<TraitRef<'tcx>> {
|
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<TraitRef<'tcx>> {
|
||||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
PredicateKind::Trait(ty::TraitPredicate { trait_ref: self.value }, self.constness)
|
PredicateKind::Trait(ty::TraitPredicate {
|
||||||
|
trait_ref: self.value,
|
||||||
|
constness: self.constness,
|
||||||
|
})
|
||||||
.to_predicate(tcx)
|
.to_predicate(tcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -754,15 +762,15 @@ impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<PolyTraitRef<'tcx>> {
|
||||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
self.value
|
self.value
|
||||||
.map_bound(|trait_ref| {
|
.map_bound(|trait_ref| {
|
||||||
PredicateKind::Trait(ty::TraitPredicate { trait_ref }, self.constness)
|
PredicateKind::Trait(ty::TraitPredicate { trait_ref, constness: self.constness })
|
||||||
})
|
})
|
||||||
.to_predicate(tcx)
|
.to_predicate(tcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<PolyTraitPredicate<'tcx>> {
|
impl<'tcx> ToPredicate<'tcx> for PolyTraitPredicate<'tcx> {
|
||||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
self.value.map_bound(|value| PredicateKind::Trait(value, self.constness)).to_predicate(tcx)
|
self.map_bound(PredicateKind::Trait).to_predicate(tcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -788,8 +796,8 @@ impl<'tcx> Predicate<'tcx> {
|
||||||
pub fn to_opt_poly_trait_ref(self) -> Option<ConstnessAnd<PolyTraitRef<'tcx>>> {
|
pub fn to_opt_poly_trait_ref(self) -> Option<ConstnessAnd<PolyTraitRef<'tcx>>> {
|
||||||
let predicate = self.kind();
|
let predicate = self.kind();
|
||||||
match predicate.skip_binder() {
|
match predicate.skip_binder() {
|
||||||
PredicateKind::Trait(t, constness) => {
|
PredicateKind::Trait(t) => {
|
||||||
Some(ConstnessAnd { constness, value: predicate.rebind(t.trait_ref) })
|
Some(ConstnessAnd { constness: t.constness, value: predicate.rebind(t.trait_ref) })
|
||||||
}
|
}
|
||||||
PredicateKind::Projection(..)
|
PredicateKind::Projection(..)
|
||||||
| PredicateKind::Subtype(..)
|
| PredicateKind::Subtype(..)
|
||||||
|
|
|
@ -630,7 +630,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
for (predicate, _) in bounds {
|
for (predicate, _) in bounds {
|
||||||
let predicate = predicate.subst(self.tcx(), substs);
|
let predicate = predicate.subst(self.tcx(), substs);
|
||||||
let bound_predicate = predicate.kind();
|
let bound_predicate = predicate.kind();
|
||||||
if let ty::PredicateKind::Trait(pred, _) = bound_predicate.skip_binder() {
|
if let ty::PredicateKind::Trait(pred) = bound_predicate.skip_binder() {
|
||||||
let trait_ref = bound_predicate.rebind(pred.trait_ref);
|
let trait_ref = bound_predicate.rebind(pred.trait_ref);
|
||||||
// Don't print +Sized, but rather +?Sized if absent.
|
// Don't print +Sized, but rather +?Sized if absent.
|
||||||
if Some(trait_ref.def_id()) == self.tcx().lang_items().sized_trait() {
|
if Some(trait_ref.def_id()) == self.tcx().lang_items().sized_trait() {
|
||||||
|
@ -2264,10 +2264,7 @@ define_print_and_forward_display! {
|
||||||
|
|
||||||
ty::PredicateKind<'tcx> {
|
ty::PredicateKind<'tcx> {
|
||||||
match *self {
|
match *self {
|
||||||
ty::PredicateKind::Trait(ref data, constness) => {
|
ty::PredicateKind::Trait(ref data) => {
|
||||||
if let hir::Constness::Const = constness {
|
|
||||||
p!("const ");
|
|
||||||
}
|
|
||||||
p!(print(data))
|
p!(print(data))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Subtype(predicate) => p!(print(predicate)),
|
ty::PredicateKind::Subtype(predicate) => p!(print(predicate)),
|
||||||
|
|
|
@ -200,6 +200,20 @@ impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'tcx> Relate<'tcx> for ast::Constness {
|
||||||
|
fn relate<R: TypeRelation<'tcx>>(
|
||||||
|
relation: &mut R,
|
||||||
|
a: ast::Constness,
|
||||||
|
b: ast::Constness,
|
||||||
|
) -> RelateResult<'tcx, ast::Constness> {
|
||||||
|
if a != b {
|
||||||
|
Err(TypeError::ConstnessMismatch(expected_found(relation, a, b)))
|
||||||
|
} else {
|
||||||
|
Ok(a)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'tcx> Relate<'tcx> for ast::Unsafety {
|
impl<'tcx> Relate<'tcx> for ast::Unsafety {
|
||||||
fn relate<R: TypeRelation<'tcx>>(
|
fn relate<R: TypeRelation<'tcx>>(
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
|
@ -767,7 +781,10 @@ impl<'tcx> Relate<'tcx> for ty::TraitPredicate<'tcx> {
|
||||||
a: ty::TraitPredicate<'tcx>,
|
a: ty::TraitPredicate<'tcx>,
|
||||||
b: ty::TraitPredicate<'tcx>,
|
b: ty::TraitPredicate<'tcx>,
|
||||||
) -> RelateResult<'tcx, ty::TraitPredicate<'tcx>> {
|
) -> RelateResult<'tcx, ty::TraitPredicate<'tcx>> {
|
||||||
Ok(ty::TraitPredicate { trait_ref: relation.relate(a.trait_ref, b.trait_ref)? })
|
Ok(ty::TraitPredicate {
|
||||||
|
trait_ref: relation.relate(a.trait_ref, b.trait_ref)?,
|
||||||
|
constness: relation.relate(a.constness, b.constness)?,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,6 +155,9 @@ impl fmt::Debug for ty::ParamConst {
|
||||||
|
|
||||||
impl fmt::Debug for ty::TraitPredicate<'tcx> {
|
impl fmt::Debug for ty::TraitPredicate<'tcx> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
if let hir::Constness::Const = self.constness {
|
||||||
|
write!(f, "const ")?;
|
||||||
|
}
|
||||||
write!(f, "TraitPredicate({:?})", self.trait_ref)
|
write!(f, "TraitPredicate({:?})", self.trait_ref)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,12 +177,7 @@ impl fmt::Debug for ty::Predicate<'tcx> {
|
||||||
impl fmt::Debug for ty::PredicateKind<'tcx> {
|
impl fmt::Debug for ty::PredicateKind<'tcx> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
ty::PredicateKind::Trait(ref a, constness) => {
|
ty::PredicateKind::Trait(ref a) => a.fmt(f),
|
||||||
if let hir::Constness::Const = constness {
|
|
||||||
write!(f, "const ")?;
|
|
||||||
}
|
|
||||||
a.fmt(f)
|
|
||||||
}
|
|
||||||
ty::PredicateKind::Subtype(ref pair) => pair.fmt(f),
|
ty::PredicateKind::Subtype(ref pair) => pair.fmt(f),
|
||||||
ty::PredicateKind::RegionOutlives(ref pair) => pair.fmt(f),
|
ty::PredicateKind::RegionOutlives(ref pair) => pair.fmt(f),
|
||||||
ty::PredicateKind::TypeOutlives(ref pair) => pair.fmt(f),
|
ty::PredicateKind::TypeOutlives(ref pair) => pair.fmt(f),
|
||||||
|
@ -366,7 +364,8 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ExistentialPredicate<'a> {
|
||||||
impl<'a, 'tcx> Lift<'tcx> for ty::TraitPredicate<'a> {
|
impl<'a, 'tcx> Lift<'tcx> for ty::TraitPredicate<'a> {
|
||||||
type Lifted = ty::TraitPredicate<'tcx>;
|
type Lifted = ty::TraitPredicate<'tcx>;
|
||||||
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<ty::TraitPredicate<'tcx>> {
|
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<ty::TraitPredicate<'tcx>> {
|
||||||
tcx.lift(self.trait_ref).map(|trait_ref| ty::TraitPredicate { trait_ref })
|
tcx.lift(self.trait_ref)
|
||||||
|
.map(|trait_ref| ty::TraitPredicate { trait_ref, constness: self.constness })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,9 +418,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::PredicateKind<'a> {
|
||||||
type Lifted = ty::PredicateKind<'tcx>;
|
type Lifted = ty::PredicateKind<'tcx>;
|
||||||
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
||||||
match self {
|
match self {
|
||||||
ty::PredicateKind::Trait(data, constness) => {
|
ty::PredicateKind::Trait(data) => tcx.lift(data).map(ty::PredicateKind::Trait),
|
||||||
tcx.lift(data).map(|data| ty::PredicateKind::Trait(data, constness))
|
|
||||||
}
|
|
||||||
ty::PredicateKind::Subtype(data) => tcx.lift(data).map(ty::PredicateKind::Subtype),
|
ty::PredicateKind::Subtype(data) => tcx.lift(data).map(ty::PredicateKind::Subtype),
|
||||||
ty::PredicateKind::RegionOutlives(data) => {
|
ty::PredicateKind::RegionOutlives(data) => {
|
||||||
tcx.lift(data).map(ty::PredicateKind::RegionOutlives)
|
tcx.lift(data).map(ty::PredicateKind::RegionOutlives)
|
||||||
|
@ -584,6 +581,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::error::TypeError<'a> {
|
||||||
|
|
||||||
Some(match self {
|
Some(match self {
|
||||||
Mismatch => Mismatch,
|
Mismatch => Mismatch,
|
||||||
|
ConstnessMismatch(x) => ConstnessMismatch(x),
|
||||||
UnsafetyMismatch(x) => UnsafetyMismatch(x),
|
UnsafetyMismatch(x) => UnsafetyMismatch(x),
|
||||||
AbiMismatch(x) => AbiMismatch(x),
|
AbiMismatch(x) => AbiMismatch(x),
|
||||||
Mutability => Mutability,
|
Mutability => Mutability,
|
||||||
|
|
|
@ -876,7 +876,10 @@ impl<'tcx> PolyTraitRef<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_poly_trait_predicate(&self) -> ty::PolyTraitPredicate<'tcx> {
|
pub fn to_poly_trait_predicate(&self) -> ty::PolyTraitPredicate<'tcx> {
|
||||||
self.map_bound(|trait_ref| ty::TraitPredicate { trait_ref })
|
self.map_bound(|trait_ref| ty::TraitPredicate {
|
||||||
|
trait_ref,
|
||||||
|
constness: hir::Constness::NotConst,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2688,10 +2688,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
category: ConstraintCategory,
|
category: ConstraintCategory,
|
||||||
) {
|
) {
|
||||||
self.prove_predicates(
|
self.prove_predicates(
|
||||||
Some(ty::PredicateKind::Trait(
|
Some(ty::PredicateKind::Trait(ty::TraitPredicate {
|
||||||
ty::TraitPredicate { trait_ref },
|
trait_ref,
|
||||||
hir::Constness::NotConst,
|
constness: hir::Constness::NotConst,
|
||||||
)),
|
})),
|
||||||
locations,
|
locations,
|
||||||
category,
|
category,
|
||||||
);
|
);
|
||||||
|
|
|
@ -423,7 +423,7 @@ impl Checker<'mir, 'tcx> {
|
||||||
ty::PredicateKind::Subtype(_) => {
|
ty::PredicateKind::Subtype(_) => {
|
||||||
bug!("subtype predicate on function: {:#?}", predicate)
|
bug!("subtype predicate on function: {:#?}", predicate)
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Trait(pred, _constness) => {
|
ty::PredicateKind::Trait(pred) => {
|
||||||
if Some(pred.def_id()) == tcx.lang_items().sized_trait() {
|
if Some(pred.def_id()) == tcx.lang_items().sized_trait() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -817,7 +817,10 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> {
|
||||||
let obligation = Obligation::new(
|
let obligation = Obligation::new(
|
||||||
ObligationCause::dummy(),
|
ObligationCause::dummy(),
|
||||||
param_env,
|
param_env,
|
||||||
Binder::dummy(TraitPredicate { trait_ref }),
|
Binder::dummy(TraitPredicate {
|
||||||
|
trait_ref,
|
||||||
|
constness: hir::Constness::Const,
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
let implsrc = tcx.infer_ctxt().enter(|infcx| {
|
let implsrc = tcx.infer_ctxt().enter(|infcx| {
|
||||||
|
|
|
@ -132,7 +132,7 @@ impl<'a, 'tcx> FunctionItemRefChecker<'a, 'tcx> {
|
||||||
|
|
||||||
/// If the given predicate is the trait `fmt::Pointer`, returns the bound parameter type.
|
/// If the given predicate is the trait `fmt::Pointer`, returns the bound parameter type.
|
||||||
fn is_pointer_trait(&self, bound: &PredicateKind<'tcx>) -> Option<Ty<'tcx>> {
|
fn is_pointer_trait(&self, bound: &PredicateKind<'tcx>) -> Option<Ty<'tcx>> {
|
||||||
if let ty::PredicateKind::Trait(predicate, _) = bound {
|
if let ty::PredicateKind::Trait(predicate) = bound {
|
||||||
if self.tcx.is_diagnostic_item(sym::pointer_trait, predicate.def_id()) {
|
if self.tcx.is_diagnostic_item(sym::pointer_trait, predicate.def_id()) {
|
||||||
Some(predicate.trait_ref.self_ty())
|
Some(predicate.trait_ref.self_ty())
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -122,7 +122,7 @@ where
|
||||||
|
|
||||||
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ControlFlow<V::BreakTy> {
|
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ControlFlow<V::BreakTy> {
|
||||||
match predicate.kind().skip_binder() {
|
match predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(ty::TraitPredicate { trait_ref }, _) => {
|
ty::PredicateKind::Trait(ty::TraitPredicate { trait_ref, constness: _ }) => {
|
||||||
self.visit_trait(trait_ref)
|
self.visit_trait(trait_ref)
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(ty::ProjectionPredicate { projection_ty, ty }) => {
|
ty::PredicateKind::Projection(ty::ProjectionPredicate { projection_ty, ty }) => {
|
||||||
|
|
|
@ -2657,7 +2657,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
let obligations = predicates.predicates.iter().filter_map(|&(pred, _)| {
|
let obligations = predicates.predicates.iter().filter_map(|&(pred, _)| {
|
||||||
let bound_predicate = pred.kind();
|
let bound_predicate = pred.kind();
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(data, _) => {
|
ty::PredicateKind::Trait(data) => {
|
||||||
// The order here needs to match what we would get from `subst_supertrait`
|
// The order here needs to match what we would get from `subst_supertrait`
|
||||||
let pred_bound_vars = bound_predicate.bound_vars();
|
let pred_bound_vars = bound_predicate.bound_vars();
|
||||||
let mut all_bound_vars = bound_vars.clone();
|
let mut all_bound_vars = bound_vars.clone();
|
||||||
|
|
|
@ -285,6 +285,7 @@ impl AutoTraitFinder<'tcx> {
|
||||||
def_id: trait_did,
|
def_id: trait_did,
|
||||||
substs: infcx.tcx.mk_substs_trait(ty, &[]),
|
substs: infcx.tcx.mk_substs_trait(ty, &[]),
|
||||||
},
|
},
|
||||||
|
constness: hir::Constness::NotConst,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let computed_preds = param_env.caller_bounds().iter();
|
let computed_preds = param_env.caller_bounds().iter();
|
||||||
|
@ -344,10 +345,7 @@ impl AutoTraitFinder<'tcx> {
|
||||||
Err(SelectionError::Unimplemented) => {
|
Err(SelectionError::Unimplemented) => {
|
||||||
if self.is_param_no_infer(pred.skip_binder().trait_ref.substs) {
|
if self.is_param_no_infer(pred.skip_binder().trait_ref.substs) {
|
||||||
already_visited.remove(&pred);
|
already_visited.remove(&pred);
|
||||||
self.add_user_pred(
|
self.add_user_pred(&mut user_computed_preds, pred.to_predicate(self.tcx));
|
||||||
&mut user_computed_preds,
|
|
||||||
pred.without_const().to_predicate(self.tcx),
|
|
||||||
);
|
|
||||||
predicates.push_back(pred);
|
predicates.push_back(pred);
|
||||||
} else {
|
} else {
|
||||||
debug!(
|
debug!(
|
||||||
|
@ -414,10 +412,8 @@ impl AutoTraitFinder<'tcx> {
|
||||||
) {
|
) {
|
||||||
let mut should_add_new = true;
|
let mut should_add_new = true;
|
||||||
user_computed_preds.retain(|&old_pred| {
|
user_computed_preds.retain(|&old_pred| {
|
||||||
if let (
|
if let (ty::PredicateKind::Trait(new_trait), ty::PredicateKind::Trait(old_trait)) =
|
||||||
ty::PredicateKind::Trait(new_trait, _),
|
(new_pred.kind().skip_binder(), old_pred.kind().skip_binder())
|
||||||
ty::PredicateKind::Trait(old_trait, _),
|
|
||||||
) = (new_pred.kind().skip_binder(), old_pred.kind().skip_binder())
|
|
||||||
{
|
{
|
||||||
if new_trait.def_id() == old_trait.def_id() {
|
if new_trait.def_id() == old_trait.def_id() {
|
||||||
let new_substs = new_trait.trait_ref.substs;
|
let new_substs = new_trait.trait_ref.substs;
|
||||||
|
@ -638,7 +634,7 @@ impl AutoTraitFinder<'tcx> {
|
||||||
|
|
||||||
let bound_predicate = predicate.kind();
|
let bound_predicate = predicate.kind();
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(p, _) => {
|
ty::PredicateKind::Trait(p) => {
|
||||||
// Add this to `predicates` so that we end up calling `select`
|
// Add this to `predicates` so that we end up calling `select`
|
||||||
// with it. If this predicate ends up being unimplemented,
|
// with it. If this predicate ends up being unimplemented,
|
||||||
// then `evaluate_predicates` will handle adding it the `ParamEnv`
|
// then `evaluate_predicates` will handle adding it the `ParamEnv`
|
||||||
|
|
|
@ -277,7 +277,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
let bound_predicate = obligation.predicate.kind();
|
let bound_predicate = obligation.predicate.kind();
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(trait_predicate, _) => {
|
ty::PredicateKind::Trait(trait_predicate) => {
|
||||||
let trait_predicate = bound_predicate.rebind(trait_predicate);
|
let trait_predicate = bound_predicate.rebind(trait_predicate);
|
||||||
let trait_predicate = self.resolve_vars_if_possible(trait_predicate);
|
let trait_predicate = self.resolve_vars_if_possible(trait_predicate);
|
||||||
|
|
||||||
|
@ -518,8 +518,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
);
|
);
|
||||||
trait_pred
|
trait_pred
|
||||||
});
|
});
|
||||||
let unit_obligation =
|
let unit_obligation = obligation.with(predicate.to_predicate(tcx));
|
||||||
obligation.with(predicate.without_const().to_predicate(tcx));
|
|
||||||
if self.predicate_may_hold(&unit_obligation) {
|
if self.predicate_may_hold(&unit_obligation) {
|
||||||
err.note("this trait is implemented for `()`.");
|
err.note("this trait is implemented for `()`.");
|
||||||
err.note(
|
err.note(
|
||||||
|
@ -1148,7 +1147,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
// FIXME: It should be possible to deal with `ForAll` in a cleaner way.
|
// FIXME: It should be possible to deal with `ForAll` in a cleaner way.
|
||||||
let bound_error = error.kind();
|
let bound_error = error.kind();
|
||||||
let (cond, error) = match (cond.kind().skip_binder(), bound_error.skip_binder()) {
|
let (cond, error) = match (cond.kind().skip_binder(), bound_error.skip_binder()) {
|
||||||
(ty::PredicateKind::Trait(..), ty::PredicateKind::Trait(error, _)) => {
|
(ty::PredicateKind::Trait(..), ty::PredicateKind::Trait(error)) => {
|
||||||
(cond, bound_error.rebind(error))
|
(cond, bound_error.rebind(error))
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -1159,7 +1158,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
for obligation in super::elaborate_predicates(self.tcx, std::iter::once(cond)) {
|
for obligation in super::elaborate_predicates(self.tcx, std::iter::once(cond)) {
|
||||||
let bound_predicate = obligation.predicate.kind();
|
let bound_predicate = obligation.predicate.kind();
|
||||||
if let ty::PredicateKind::Trait(implication, _) = bound_predicate.skip_binder() {
|
if let ty::PredicateKind::Trait(implication) = bound_predicate.skip_binder() {
|
||||||
let error = error.to_poly_trait_ref();
|
let error = error.to_poly_trait_ref();
|
||||||
let implication = bound_predicate.rebind(implication.trait_ref);
|
let implication = bound_predicate.rebind(implication.trait_ref);
|
||||||
// FIXME: I'm just not taking associated types at all here.
|
// FIXME: I'm just not taking associated types at all here.
|
||||||
|
@ -1536,7 +1535,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
let bound_predicate = predicate.kind();
|
let bound_predicate = predicate.kind();
|
||||||
let mut err = match bound_predicate.skip_binder() {
|
let mut err = match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(data, _) => {
|
ty::PredicateKind::Trait(data) => {
|
||||||
let trait_ref = bound_predicate.rebind(data.trait_ref);
|
let trait_ref = bound_predicate.rebind(data.trait_ref);
|
||||||
debug!("trait_ref {:?}", trait_ref);
|
debug!("trait_ref {:?}", trait_ref);
|
||||||
|
|
||||||
|
@ -1803,7 +1802,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
match (obligation.predicate.kind().skip_binder(), obligation.cause.code.peel_derives())
|
match (obligation.predicate.kind().skip_binder(), obligation.cause.code.peel_derives())
|
||||||
{
|
{
|
||||||
(
|
(
|
||||||
ty::PredicateKind::Trait(pred, _),
|
ty::PredicateKind::Trait(pred),
|
||||||
&ObligationCauseCode::BindingObligation(item_def_id, span),
|
&ObligationCauseCode::BindingObligation(item_def_id, span),
|
||||||
) => (pred, item_def_id, span),
|
) => (pred, item_def_id, span),
|
||||||
_ => return,
|
_ => return,
|
||||||
|
|
|
@ -1386,7 +1386,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
// bound was introduced. At least one generator should be present for this diagnostic to be
|
// bound was introduced. At least one generator should be present for this diagnostic to be
|
||||||
// modified.
|
// modified.
|
||||||
let (mut trait_ref, mut target_ty) = match obligation.predicate.kind().skip_binder() {
|
let (mut trait_ref, mut target_ty) = match obligation.predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(p, _) => (Some(p.trait_ref), Some(p.self_ty())),
|
ty::PredicateKind::Trait(p) => (Some(p.trait_ref), Some(p.self_ty())),
|
||||||
_ => (None, None),
|
_ => (None, None),
|
||||||
};
|
};
|
||||||
let mut generator = None;
|
let mut generator = None;
|
||||||
|
|
|
@ -352,7 +352,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||||
// Evaluation will discard candidates using the leak check.
|
// Evaluation will discard candidates using the leak check.
|
||||||
// This means we need to pass it the bound version of our
|
// This means we need to pass it the bound version of our
|
||||||
// predicate.
|
// predicate.
|
||||||
ty::PredicateKind::Trait(trait_ref, _constness) => {
|
ty::PredicateKind::Trait(trait_ref) => {
|
||||||
let trait_obligation = obligation.with(binder.rebind(trait_ref));
|
let trait_obligation = obligation.with(binder.rebind(trait_ref));
|
||||||
|
|
||||||
self.process_trait_obligation(
|
self.process_trait_obligation(
|
||||||
|
@ -388,7 +388,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Some(pred) => match pred {
|
Some(pred) => match pred {
|
||||||
ty::PredicateKind::Trait(data, _) => {
|
ty::PredicateKind::Trait(data) => {
|
||||||
let trait_obligation = obligation.with(Binder::dummy(data));
|
let trait_obligation = obligation.with(Binder::dummy(data));
|
||||||
|
|
||||||
self.process_trait_obligation(
|
self.process_trait_obligation(
|
||||||
|
|
|
@ -280,7 +280,7 @@ fn predicate_references_self(
|
||||||
let self_ty = tcx.types.self_param;
|
let self_ty = tcx.types.self_param;
|
||||||
let has_self_ty = |arg: &GenericArg<'_>| arg.walk().any(|arg| arg == self_ty.into());
|
let has_self_ty = |arg: &GenericArg<'_>| arg.walk().any(|arg| arg == self_ty.into());
|
||||||
match predicate.kind().skip_binder() {
|
match predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(ref data, _) => {
|
ty::PredicateKind::Trait(ref data) => {
|
||||||
// In the case of a trait predicate, we can skip the "self" type.
|
// In the case of a trait predicate, we can skip the "self" type.
|
||||||
if data.trait_ref.substs[1..].iter().any(has_self_ty) { Some(sp) } else { None }
|
if data.trait_ref.substs[1..].iter().any(has_self_ty) { Some(sp) } else { None }
|
||||||
}
|
}
|
||||||
|
@ -331,7 +331,7 @@ fn generics_require_sized_self(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||||
let predicates = predicates.instantiate_identity(tcx).predicates;
|
let predicates = predicates.instantiate_identity(tcx).predicates;
|
||||||
elaborate_predicates(tcx, predicates.into_iter()).any(|obligation| {
|
elaborate_predicates(tcx, predicates.into_iter()).any(|obligation| {
|
||||||
match obligation.predicate.kind().skip_binder() {
|
match obligation.predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(ref trait_pred, _) => {
|
ty::PredicateKind::Trait(ref trait_pred) => {
|
||||||
trait_pred.def_id() == sized_def_id && trait_pred.self_ty().is_param(0)
|
trait_pred.def_id() == sized_def_id && trait_pred.self_ty().is_param(0)
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(..)
|
ty::PredicateKind::Projection(..)
|
||||||
|
|
|
@ -15,7 +15,7 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> {
|
||||||
// `&T`, accounts for about 60% percentage of the predicates
|
// `&T`, accounts for about 60% percentage of the predicates
|
||||||
// we have to prove. No need to canonicalize and all that for
|
// we have to prove. No need to canonicalize and all that for
|
||||||
// such cases.
|
// such cases.
|
||||||
if let ty::PredicateKind::Trait(trait_ref, _) = key.value.predicate.kind().skip_binder() {
|
if let ty::PredicateKind::Trait(trait_ref) = key.value.predicate.kind().skip_binder() {
|
||||||
if let Some(sized_def_id) = tcx.lang_items().sized_trait() {
|
if let Some(sized_def_id) = tcx.lang_items().sized_trait() {
|
||||||
if trait_ref.def_id() == sized_def_id {
|
if trait_ref.def_id() == sized_def_id {
|
||||||
if trait_ref.self_ty().is_trivially_sized(tcx) {
|
if trait_ref.self_ty().is_trivially_sized(tcx) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||||
use rustc_middle::ty::relate::TypeRelation;
|
use rustc_middle::ty::relate::TypeRelation;
|
||||||
use rustc_middle::ty::subst::{GenericArgKind, Subst, SubstsRef};
|
use rustc_middle::ty::subst::{GenericArgKind, Subst, SubstsRef};
|
||||||
use rustc_middle::ty::{self, PolyProjectionPredicate, ToPolyTraitRef, ToPredicate};
|
use rustc_middle::ty::{self, PolyProjectionPredicate, ToPolyTraitRef, ToPredicate};
|
||||||
use rustc_middle::ty::{Ty, TyCtxt, TypeFoldable, WithConstness};
|
use rustc_middle::ty::{Ty, TyCtxt, TypeFoldable};
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
|
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
|
@ -454,7 +454,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
let result = ensure_sufficient_stack(|| {
|
let result = ensure_sufficient_stack(|| {
|
||||||
let bound_predicate = obligation.predicate.kind();
|
let bound_predicate = obligation.predicate.kind();
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(t, _) => {
|
ty::PredicateKind::Trait(t) => {
|
||||||
let t = bound_predicate.rebind(t);
|
let t = bound_predicate.rebind(t);
|
||||||
debug_assert!(!t.has_escaping_bound_vars());
|
debug_assert!(!t.has_escaping_bound_vars());
|
||||||
let obligation = obligation.with(t);
|
let obligation = obligation.with(t);
|
||||||
|
@ -762,8 +762,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
// if the regions match exactly.
|
// if the regions match exactly.
|
||||||
let cycle = stack.iter().skip(1).take_while(|s| s.depth >= cycle_depth);
|
let cycle = stack.iter().skip(1).take_while(|s| s.depth >= cycle_depth);
|
||||||
let tcx = self.tcx();
|
let tcx = self.tcx();
|
||||||
let cycle =
|
let cycle = cycle.map(|stack| stack.obligation.predicate.to_predicate(tcx));
|
||||||
cycle.map(|stack| stack.obligation.predicate.without_const().to_predicate(tcx));
|
|
||||||
if self.coinductive_match(cycle) {
|
if self.coinductive_match(cycle) {
|
||||||
debug!("evaluate_stack --> recursive, coinductive");
|
debug!("evaluate_stack --> recursive, coinductive");
|
||||||
Some(EvaluatedToOk)
|
Some(EvaluatedToOk)
|
||||||
|
@ -873,7 +872,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
|
|
||||||
fn coinductive_predicate(&self, predicate: ty::Predicate<'tcx>) -> bool {
|
fn coinductive_predicate(&self, predicate: ty::Predicate<'tcx>) -> bool {
|
||||||
let result = match predicate.kind().skip_binder() {
|
let result = match predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(ref data, _) => self.tcx().trait_is_auto(data.def_id()),
|
ty::PredicateKind::Trait(ref data) => self.tcx().trait_is_auto(data.def_id()),
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
debug!(?predicate, ?result, "coinductive_predicate");
|
debug!(?predicate, ?result, "coinductive_predicate");
|
||||||
|
@ -1213,7 +1212,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter_map(|(idx, bound)| {
|
.filter_map(|(idx, bound)| {
|
||||||
let bound_predicate = bound.kind();
|
let bound_predicate = bound.kind();
|
||||||
if let ty::PredicateKind::Trait(pred, _) = bound_predicate.skip_binder() {
|
if let ty::PredicateKind::Trait(pred) = bound_predicate.skip_binder() {
|
||||||
let bound = bound_predicate.rebind(pred.trait_ref);
|
let bound = bound_predicate.rebind(pred.trait_ref);
|
||||||
if self.infcx.probe(|_| {
|
if self.infcx.probe(|_| {
|
||||||
match self.match_normalize_trait_ref(
|
match self.match_normalize_trait_ref(
|
||||||
|
|
|
@ -108,7 +108,7 @@ pub fn predicate_obligations<'a, 'tcx>(
|
||||||
|
|
||||||
// It's ok to skip the binder here because wf code is prepared for it
|
// It's ok to skip the binder here because wf code is prepared for it
|
||||||
match predicate.kind().skip_binder() {
|
match predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(t, _) => {
|
ty::PredicateKind::Trait(t) => {
|
||||||
wf.compute_trait_ref(&t.trait_ref, Elaborate::None);
|
wf.compute_trait_ref(&t.trait_ref, Elaborate::None);
|
||||||
}
|
}
|
||||||
ty::PredicateKind::RegionOutlives(..) => {}
|
ty::PredicateKind::RegionOutlives(..) => {}
|
||||||
|
@ -226,7 +226,7 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Trait(pred, _) => {
|
ty::PredicateKind::Trait(pred) => {
|
||||||
// An associated item obligation born out of the `trait` failed to be met. An example
|
// An associated item obligation born out of the `trait` failed to be met. An example
|
||||||
// can be seen in `ui/associated-types/point-at-type-on-obligation-failure-2.rs`.
|
// can be seen in `ui/associated-types/point-at-type-on-obligation-failure-2.rs`.
|
||||||
debug!("extended_cause_with_original_assoc_item_obligation trait proj {:?}", pred);
|
debug!("extended_cause_with_original_assoc_item_obligation trait proj {:?}", pred);
|
||||||
|
|
|
@ -87,7 +87,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'
|
||||||
ty::PredicateKind::TypeWellFormedFromEnv(ty) => {
|
ty::PredicateKind::TypeWellFormedFromEnv(ty) => {
|
||||||
chalk_ir::DomainGoal::FromEnv(chalk_ir::FromEnv::Ty(ty.lower_into(interner)))
|
chalk_ir::DomainGoal::FromEnv(chalk_ir::FromEnv::Ty(ty.lower_into(interner)))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Trait(predicate, _) => chalk_ir::DomainGoal::FromEnv(
|
ty::PredicateKind::Trait(predicate) => chalk_ir::DomainGoal::FromEnv(
|
||||||
chalk_ir::FromEnv::Trait(predicate.trait_ref.lower_into(interner)),
|
chalk_ir::FromEnv::Trait(predicate.trait_ref.lower_into(interner)),
|
||||||
),
|
),
|
||||||
ty::PredicateKind::RegionOutlives(predicate) => chalk_ir::DomainGoal::Holds(
|
ty::PredicateKind::RegionOutlives(predicate) => chalk_ir::DomainGoal::Holds(
|
||||||
|
@ -137,7 +137,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
|
||||||
collect_bound_vars(interner, interner.tcx, self.kind());
|
collect_bound_vars(interner, interner.tcx, self.kind());
|
||||||
|
|
||||||
let value = match predicate {
|
let value = match predicate {
|
||||||
ty::PredicateKind::Trait(predicate, _) => {
|
ty::PredicateKind::Trait(predicate) => {
|
||||||
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
||||||
chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner)),
|
chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner)),
|
||||||
))
|
))
|
||||||
|
@ -569,7 +569,7 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_ir::QuantifiedWhereClause<RustInterner<'
|
||||||
let (predicate, binders, _named_regions) =
|
let (predicate, binders, _named_regions) =
|
||||||
collect_bound_vars(interner, interner.tcx, self.kind());
|
collect_bound_vars(interner, interner.tcx, self.kind());
|
||||||
let value = match predicate {
|
let value = match predicate {
|
||||||
ty::PredicateKind::Trait(predicate, _) => {
|
ty::PredicateKind::Trait(predicate) => {
|
||||||
Some(chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner)))
|
Some(chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner)))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::RegionOutlives(predicate) => {
|
ty::PredicateKind::RegionOutlives(predicate) => {
|
||||||
|
@ -702,7 +702,7 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_solve::rust_ir::QuantifiedInlineBound<Ru
|
||||||
let (predicate, binders, _named_regions) =
|
let (predicate, binders, _named_regions) =
|
||||||
collect_bound_vars(interner, interner.tcx, self.kind());
|
collect_bound_vars(interner, interner.tcx, self.kind());
|
||||||
match predicate {
|
match predicate {
|
||||||
ty::PredicateKind::Trait(predicate, _) => Some(chalk_ir::Binders::new(
|
ty::PredicateKind::Trait(predicate) => Some(chalk_ir::Binders::new(
|
||||||
binders,
|
binders,
|
||||||
chalk_solve::rust_ir::InlineBound::TraitBound(
|
chalk_solve::rust_ir::InlineBound::TraitBound(
|
||||||
predicate.trait_ref.lower_into(interner),
|
predicate.trait_ref.lower_into(interner),
|
||||||
|
|
|
@ -1340,7 +1340,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
|
|
||||||
let bound_predicate = obligation.predicate.kind();
|
let bound_predicate = obligation.predicate.kind();
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(pred, _) => {
|
ty::PredicateKind::Trait(pred) => {
|
||||||
let pred = bound_predicate.rebind(pred);
|
let pred = bound_predicate.rebind(pred);
|
||||||
associated_types.entry(span).or_default().extend(
|
associated_types.entry(span).or_default().extend(
|
||||||
tcx.associated_items(pred.def_id())
|
tcx.associated_items(pred.def_id())
|
||||||
|
|
|
@ -606,16 +606,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let mut suggest_box = !obligations.is_empty();
|
let mut suggest_box = !obligations.is_empty();
|
||||||
for o in obligations {
|
for o in obligations {
|
||||||
match o.predicate.kind().skip_binder() {
|
match o.predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(t, constness) => {
|
ty::PredicateKind::Trait(t) => {
|
||||||
let pred = ty::PredicateKind::Trait(
|
let pred = ty::PredicateKind::Trait(ty::TraitPredicate {
|
||||||
ty::TraitPredicate {
|
|
||||||
trait_ref: ty::TraitRef {
|
trait_ref: ty::TraitRef {
|
||||||
def_id: t.def_id(),
|
def_id: t.def_id(),
|
||||||
substs: self.infcx.tcx.mk_substs_trait(outer_ty, &[]),
|
substs: self.infcx.tcx.mk_substs_trait(outer_ty, &[]),
|
||||||
},
|
},
|
||||||
},
|
constness: t.constness,
|
||||||
constness,
|
});
|
||||||
);
|
|
||||||
let obl = Obligation::new(
|
let obl = Obligation::new(
|
||||||
o.cause.clone(),
|
o.cause.clone(),
|
||||||
self.param_env,
|
self.param_env,
|
||||||
|
|
|
@ -587,9 +587,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
||||||
debug!("coerce_unsized resolve step: {:?}", obligation);
|
debug!("coerce_unsized resolve step: {:?}", obligation);
|
||||||
let bound_predicate = obligation.predicate.kind();
|
let bound_predicate = obligation.predicate.kind();
|
||||||
let trait_pred = match bound_predicate.skip_binder() {
|
let trait_pred = match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(trait_pred, _)
|
ty::PredicateKind::Trait(trait_pred) if traits.contains(&trait_pred.def_id()) => {
|
||||||
if traits.contains(&trait_pred.def_id()) =>
|
|
||||||
{
|
|
||||||
if unsize_did == trait_pred.def_id() {
|
if unsize_did == trait_pred.def_id() {
|
||||||
let self_ty = trait_pred.self_ty();
|
let self_ty = trait_pred.self_ty();
|
||||||
let unsize_ty = trait_pred.trait_ref.substs[1].expect_ty();
|
let unsize_ty = trait_pred.trait_ref.substs[1].expect_ty();
|
||||||
|
|
|
@ -229,7 +229,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
|
||||||
let predicate = predicate.kind();
|
let predicate = predicate.kind();
|
||||||
let p = p.kind();
|
let p = p.kind();
|
||||||
match (predicate.skip_binder(), p.skip_binder()) {
|
match (predicate.skip_binder(), p.skip_binder()) {
|
||||||
(ty::PredicateKind::Trait(a, _), ty::PredicateKind::Trait(b, _)) => {
|
(ty::PredicateKind::Trait(a), ty::PredicateKind::Trait(b)) => {
|
||||||
relator.relate(predicate.rebind(a), p.rebind(b)).is_ok()
|
relator.relate(predicate.rebind(a), p.rebind(b)).is_ok()
|
||||||
}
|
}
|
||||||
(ty::PredicateKind::Projection(a), ty::PredicateKind::Projection(b)) => {
|
(ty::PredicateKind::Projection(a), ty::PredicateKind::Projection(b)) => {
|
||||||
|
|
|
@ -796,7 +796,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
bound_predicate.rebind(data).required_poly_trait_ref(self.tcx),
|
bound_predicate.rebind(data).required_poly_trait_ref(self.tcx),
|
||||||
obligation,
|
obligation,
|
||||||
)),
|
)),
|
||||||
ty::PredicateKind::Trait(data, _) => {
|
ty::PredicateKind::Trait(data) => {
|
||||||
Some((bound_predicate.rebind(data).to_poly_trait_ref(), obligation))
|
Some((bound_predicate.rebind(data).to_poly_trait_ref(), obligation))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Subtype(..) => None,
|
ty::PredicateKind::Subtype(..) => None,
|
||||||
|
|
|
@ -923,7 +923,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let ty::PredicateKind::Trait(predicate, _) =
|
if let ty::PredicateKind::Trait(predicate) =
|
||||||
error.obligation.predicate.kind().skip_binder()
|
error.obligation.predicate.kind().skip_binder()
|
||||||
{
|
{
|
||||||
// Collect the argument position for all arguments that could have caused this
|
// Collect the argument position for all arguments that could have caused this
|
||||||
|
@ -974,7 +974,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
if let hir::ExprKind::Path(qpath) = &path.kind {
|
if let hir::ExprKind::Path(qpath) = &path.kind {
|
||||||
if let hir::QPath::Resolved(_, path) = &qpath {
|
if let hir::QPath::Resolved(_, path) = &qpath {
|
||||||
for error in errors {
|
for error in errors {
|
||||||
if let ty::PredicateKind::Trait(predicate, _) =
|
if let ty::PredicateKind::Trait(predicate) =
|
||||||
error.obligation.predicate.kind().skip_binder()
|
error.obligation.predicate.kind().skip_binder()
|
||||||
{
|
{
|
||||||
// If any of the type arguments in this path segment caused the
|
// If any of the type arguments in this path segment caused the
|
||||||
|
|
|
@ -194,7 +194,7 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
|
||||||
predicates: tcx.arena.alloc_from_iter(
|
predicates: tcx.arena.alloc_from_iter(
|
||||||
self.param_env.caller_bounds().iter().filter_map(|predicate| {
|
self.param_env.caller_bounds().iter().filter_map(|predicate| {
|
||||||
match predicate.kind().skip_binder() {
|
match predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(data, _) if data.self_ty().is_param(index) => {
|
ty::PredicateKind::Trait(data) if data.self_ty().is_param(index) => {
|
||||||
// HACK(eddyb) should get the original `Span`.
|
// HACK(eddyb) should get the original `Span`.
|
||||||
let span = tcx.def_span(def_id);
|
let span = tcx.def_span(def_id);
|
||||||
Some((predicate, span))
|
Some((predicate, span))
|
||||||
|
|
|
@ -507,7 +507,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
|
||||||
traits::elaborate_predicates(self.tcx, predicates.predicates.iter().copied())
|
traits::elaborate_predicates(self.tcx, predicates.predicates.iter().copied())
|
||||||
// We don't care about regions here.
|
// We don't care about regions here.
|
||||||
.filter_map(|obligation| match obligation.predicate.kind().skip_binder() {
|
.filter_map(|obligation| match obligation.predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(trait_pred, _) if trait_pred.def_id() == sized_def_id => {
|
ty::PredicateKind::Trait(trait_pred) if trait_pred.def_id() == sized_def_id => {
|
||||||
let span = iter::zip(&predicates.predicates, &predicates.spans)
|
let span = iter::zip(&predicates.predicates, &predicates.spans)
|
||||||
.find_map(
|
.find_map(
|
||||||
|(p, span)| {
|
|(p, span)| {
|
||||||
|
|
|
@ -832,7 +832,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||||
let bounds = self.param_env.caller_bounds().iter().filter_map(|predicate| {
|
let bounds = self.param_env.caller_bounds().iter().filter_map(|predicate| {
|
||||||
let bound_predicate = predicate.kind();
|
let bound_predicate = predicate.kind();
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(trait_predicate, _) => {
|
ty::PredicateKind::Trait(trait_predicate) => {
|
||||||
match *trait_predicate.trait_ref.self_ty().kind() {
|
match *trait_predicate.trait_ref.self_ty().kind() {
|
||||||
ty::Param(p) if p == param_ty => {
|
ty::Param(p) if p == param_ty => {
|
||||||
Some(bound_predicate.rebind(trait_predicate.trait_ref))
|
Some(bound_predicate.rebind(trait_predicate.trait_ref))
|
||||||
|
|
|
@ -683,7 +683,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let mut collect_type_param_suggestions =
|
let mut collect_type_param_suggestions =
|
||||||
|self_ty: Ty<'tcx>, parent_pred: &ty::Predicate<'tcx>, obligation: &str| {
|
|self_ty: Ty<'tcx>, parent_pred: &ty::Predicate<'tcx>, obligation: &str| {
|
||||||
// We don't care about regions here, so it's fine to skip the binder here.
|
// We don't care about regions here, so it's fine to skip the binder here.
|
||||||
if let (ty::Param(_), ty::PredicateKind::Trait(p, _)) =
|
if let (ty::Param(_), ty::PredicateKind::Trait(p)) =
|
||||||
(self_ty.kind(), parent_pred.kind().skip_binder())
|
(self_ty.kind(), parent_pred.kind().skip_binder())
|
||||||
{
|
{
|
||||||
if let ty::Adt(def, _) = p.trait_ref.self_ty().kind() {
|
if let ty::Adt(def, _) = p.trait_ref.self_ty().kind() {
|
||||||
|
@ -763,7 +763,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
bound_span_label(projection_ty.self_ty(), &obligation, &quiet);
|
bound_span_label(projection_ty.self_ty(), &obligation, &quiet);
|
||||||
Some((obligation, projection_ty.self_ty()))
|
Some((obligation, projection_ty.self_ty()))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Trait(poly_trait_ref, _) => {
|
ty::PredicateKind::Trait(poly_trait_ref) => {
|
||||||
let p = poly_trait_ref.trait_ref;
|
let p = poly_trait_ref.trait_ref;
|
||||||
let self_ty = p.self_ty();
|
let self_ty = p.self_ty();
|
||||||
let path = p.print_only_trait_path();
|
let path = p.print_only_trait_path();
|
||||||
|
@ -1200,7 +1200,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
match p.kind().skip_binder() {
|
match p.kind().skip_binder() {
|
||||||
// Hide traits if they are present in predicates as they can be fixed without
|
// Hide traits if they are present in predicates as they can be fixed without
|
||||||
// having to implement them.
|
// having to implement them.
|
||||||
ty::PredicateKind::Trait(t, _) => t.def_id() == info.def_id,
|
ty::PredicateKind::Trait(t) => t.def_id() == info.def_id,
|
||||||
ty::PredicateKind::Projection(p) => {
|
ty::PredicateKind::Projection(p) => {
|
||||||
p.projection_ty.item_def_id == info.def_id
|
p.projection_ty.item_def_id == info.def_id
|
||||||
}
|
}
|
||||||
|
|
|
@ -689,7 +689,7 @@ fn bounds_from_generic_predicates<'tcx>(
|
||||||
debug!("predicate {:?}", predicate);
|
debug!("predicate {:?}", predicate);
|
||||||
let bound_predicate = predicate.kind();
|
let bound_predicate = predicate.kind();
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(trait_predicate, _) => {
|
ty::PredicateKind::Trait(trait_predicate) => {
|
||||||
let entry = types.entry(trait_predicate.self_ty()).or_default();
|
let entry = types.entry(trait_predicate.self_ty()).or_default();
|
||||||
let def_id = trait_predicate.def_id();
|
let def_id = trait_predicate.def_id();
|
||||||
if Some(def_id) != tcx.lang_items().sized_trait() {
|
if Some(def_id) != tcx.lang_items().sized_trait() {
|
||||||
|
|
|
@ -640,7 +640,7 @@ fn type_param_predicates(
|
||||||
)
|
)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|(predicate, _)| match predicate.kind().skip_binder() {
|
.filter(|(predicate, _)| match predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(data, _) => data.self_ty().is_param(index),
|
ty::PredicateKind::Trait(data) => data.self_ty().is_param(index),
|
||||||
_ => false,
|
_ => false,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -1198,7 +1198,7 @@ fn super_predicates_that_define_assoc_type(
|
||||||
// which will, in turn, reach indirect supertraits.
|
// which will, in turn, reach indirect supertraits.
|
||||||
for &(pred, span) in superbounds {
|
for &(pred, span) in superbounds {
|
||||||
debug!("superbound: {:?}", pred);
|
debug!("superbound: {:?}", pred);
|
||||||
if let ty::PredicateKind::Trait(bound, _) = pred.kind().skip_binder() {
|
if let ty::PredicateKind::Trait(bound) = pred.kind().skip_binder() {
|
||||||
tcx.at(span).super_predicates_of(bound.def_id());
|
tcx.at(span).super_predicates_of(bound.def_id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2439,7 +2439,7 @@ fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicat
|
||||||
.iter()
|
.iter()
|
||||||
.copied()
|
.copied()
|
||||||
.filter(|(pred, _)| match pred.kind().skip_binder() {
|
.filter(|(pred, _)| match pred.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(tr, _) => !is_assoc_item_ty(tr.self_ty()),
|
ty::PredicateKind::Trait(tr) => !is_assoc_item_ty(tr.self_ty()),
|
||||||
ty::PredicateKind::Projection(proj) => {
|
ty::PredicateKind::Projection(proj) => {
|
||||||
!is_assoc_item_ty(proj.projection_ty.self_ty())
|
!is_assoc_item_ty(proj.projection_ty.self_ty())
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ fn associated_type_bounds<'tcx>(
|
||||||
|
|
||||||
let bounds_from_parent = trait_predicates.predicates.iter().copied().filter(|(pred, _)| {
|
let bounds_from_parent = trait_predicates.predicates.iter().copied().filter(|(pred, _)| {
|
||||||
match pred.kind().skip_binder() {
|
match pred.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(tr, _) => tr.self_ty() == item_ty,
|
ty::PredicateKind::Trait(tr) => tr.self_ty() == item_ty,
|
||||||
ty::PredicateKind::Projection(proj) => proj.projection_ty.self_ty() == item_ty,
|
ty::PredicateKind::Projection(proj) => proj.projection_ty.self_ty() == item_ty,
|
||||||
ty::PredicateKind::TypeOutlives(outlives) => outlives.0 == item_ty,
|
ty::PredicateKind::TypeOutlives(outlives) => outlives.0 == item_ty,
|
||||||
_ => false,
|
_ => false,
|
||||||
|
|
|
@ -366,7 +366,10 @@ fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tc
|
||||||
_ if predicate.is_global() => (),
|
_ if predicate.is_global() => (),
|
||||||
// We allow specializing on explicitly marked traits with no associated
|
// We allow specializing on explicitly marked traits with no associated
|
||||||
// items.
|
// items.
|
||||||
ty::PredicateKind::Trait(pred, hir::Constness::NotConst) => {
|
ty::PredicateKind::Trait(ty::TraitPredicate {
|
||||||
|
trait_ref,
|
||||||
|
constness: hir::Constness::NotConst,
|
||||||
|
}) => {
|
||||||
if !matches!(
|
if !matches!(
|
||||||
trait_predicate_kind(tcx, predicate),
|
trait_predicate_kind(tcx, predicate),
|
||||||
Some(TraitSpecializationKind::Marker)
|
Some(TraitSpecializationKind::Marker)
|
||||||
|
@ -376,7 +379,7 @@ fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tc
|
||||||
span,
|
span,
|
||||||
&format!(
|
&format!(
|
||||||
"cannot specialize on trait `{}`",
|
"cannot specialize on trait `{}`",
|
||||||
tcx.def_path_str(pred.def_id()),
|
tcx.def_path_str(trait_ref.def_id),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.emit()
|
.emit()
|
||||||
|
@ -394,10 +397,11 @@ fn trait_predicate_kind<'tcx>(
|
||||||
predicate: ty::Predicate<'tcx>,
|
predicate: ty::Predicate<'tcx>,
|
||||||
) -> Option<TraitSpecializationKind> {
|
) -> Option<TraitSpecializationKind> {
|
||||||
match predicate.kind().skip_binder() {
|
match predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(pred, hir::Constness::NotConst) => {
|
ty::PredicateKind::Trait(ty::TraitPredicate {
|
||||||
Some(tcx.trait_def(pred.def_id()).specialization_kind)
|
trait_ref,
|
||||||
}
|
constness: hir::Constness::NotConst,
|
||||||
ty::PredicateKind::Trait(_, hir::Constness::Const)
|
}) => Some(tcx.trait_def(trait_ref.def_id).specialization_kind),
|
||||||
|
ty::PredicateKind::Trait(_)
|
||||||
| ty::PredicateKind::RegionOutlives(_)
|
| ty::PredicateKind::RegionOutlives(_)
|
||||||
| ty::PredicateKind::TypeOutlives(_)
|
| ty::PredicateKind::TypeOutlives(_)
|
||||||
| ty::PredicateKind::Projection(_)
|
| ty::PredicateKind::Projection(_)
|
||||||
|
|
|
@ -316,7 +316,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
|
||||||
let bound_predicate = pred.kind();
|
let bound_predicate = pred.kind();
|
||||||
let tcx = self.cx.tcx;
|
let tcx = self.cx.tcx;
|
||||||
let regions = match bound_predicate.skip_binder() {
|
let regions = match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(poly_trait_pred, _) => {
|
ty::PredicateKind::Trait(poly_trait_pred) => {
|
||||||
tcx.collect_referenced_late_bound_regions(&bound_predicate.rebind(poly_trait_pred))
|
tcx.collect_referenced_late_bound_regions(&bound_predicate.rebind(poly_trait_pred))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(poly_proj_pred) => {
|
ty::PredicateKind::Projection(poly_proj_pred) => {
|
||||||
|
@ -463,7 +463,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
|
||||||
.filter(|p| {
|
.filter(|p| {
|
||||||
!orig_bounds.contains(p)
|
!orig_bounds.contains(p)
|
||||||
|| match p.kind().skip_binder() {
|
|| match p.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(pred, _) => pred.def_id() == sized_trait,
|
ty::PredicateKind::Trait(pred) => pred.def_id() == sized_trait,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -325,7 +325,7 @@ impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {
|
||||||
fn clean(&self, cx: &mut DocContext<'_>) -> Option<WherePredicate> {
|
fn clean(&self, cx: &mut DocContext<'_>) -> Option<WherePredicate> {
|
||||||
let bound_predicate = self.kind();
|
let bound_predicate = self.kind();
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(pred, _) => Some(bound_predicate.rebind(pred).clean(cx)),
|
ty::PredicateKind::Trait(pred) => Some(bound_predicate.rebind(pred).clean(cx)),
|
||||||
ty::PredicateKind::RegionOutlives(pred) => pred.clean(cx),
|
ty::PredicateKind::RegionOutlives(pred) => pred.clean(cx),
|
||||||
ty::PredicateKind::TypeOutlives(pred) => pred.clean(cx),
|
ty::PredicateKind::TypeOutlives(pred) => pred.clean(cx),
|
||||||
ty::PredicateKind::Projection(pred) => Some(pred.clean(cx)),
|
ty::PredicateKind::Projection(pred) => Some(pred.clean(cx)),
|
||||||
|
@ -637,7 +637,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
|
||||||
let param_idx = (|| {
|
let param_idx = (|| {
|
||||||
let bound_p = p.kind();
|
let bound_p = p.kind();
|
||||||
match bound_p.skip_binder() {
|
match bound_p.skip_binder() {
|
||||||
ty::PredicateKind::Trait(pred, _constness) => {
|
ty::PredicateKind::Trait(pred) => {
|
||||||
if let ty::Param(param) = pred.self_ty().kind() {
|
if let ty::Param(param) = pred.self_ty().kind() {
|
||||||
return Some(param.index);
|
return Some(param.index);
|
||||||
}
|
}
|
||||||
|
@ -1555,9 +1555,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
||||||
.filter_map(|bound| {
|
.filter_map(|bound| {
|
||||||
let bound_predicate = bound.kind();
|
let bound_predicate = bound.kind();
|
||||||
let trait_ref = match bound_predicate.skip_binder() {
|
let trait_ref = match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(tr, _constness) => {
|
ty::PredicateKind::Trait(tr) => bound_predicate.rebind(tr.trait_ref),
|
||||||
bound_predicate.rebind(tr.trait_ref)
|
|
||||||
}
|
|
||||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(_ty, reg)) => {
|
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(_ty, reg)) => {
|
||||||
if let Some(r) = reg.clean(cx) {
|
if let Some(r) = reg.clean(cx) {
|
||||||
regions.push(GenericBound::Outlives(r));
|
regions.push(GenericBound::Outlives(r));
|
||||||
|
|
|
@ -139,7 +139,7 @@ fn trait_is_same_or_supertrait(cx: &DocContext<'_>, child: DefId, trait_: DefId)
|
||||||
.predicates
|
.predicates
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(pred, _)| {
|
.filter_map(|(pred, _)| {
|
||||||
if let ty::PredicateKind::Trait(pred, _) = pred.kind().skip_binder() {
|
if let ty::PredicateKind::Trait(pred) = pred.kind().skip_binder() {
|
||||||
if pred.trait_ref.self_ty() == self_ty { Some(pred.def_id()) } else { None }
|
if pred.trait_ref.self_ty() == self_ty { Some(pred.def_id()) } else { None }
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// ignore-test
|
// ignore-test
|
||||||
|
//
|
||||||
// FIXME: This test should fail since, within a const impl of `Foo`, the bound on `Foo::Bar` should
|
// FIXME: This test should fail since, within a const impl of `Foo`, the bound on `Foo::Bar` should
|
||||||
// require a const impl of `Add` for the associated type.
|
// require a const impl of `Add` for the associated type.
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
|
||||||
cx.tcx.infer_ctxt().enter(|infcx| {
|
cx.tcx.infer_ctxt().enter(|infcx| {
|
||||||
for FulfillmentError { obligation, .. } in send_errors {
|
for FulfillmentError { obligation, .. } in send_errors {
|
||||||
infcx.maybe_note_obligation_cause_for_async_await(db, &obligation);
|
infcx.maybe_note_obligation_cause_for_async_await(db, &obligation);
|
||||||
if let Trait(trait_pred, _) = obligation.predicate.kind().skip_binder() {
|
if let Trait(trait_pred) = obligation.predicate.kind().skip_binder() {
|
||||||
db.note(&format!(
|
db.note(&format!(
|
||||||
"`{}` doesn't implement `{}`",
|
"`{}` doesn't implement `{}`",
|
||||||
trait_pred.self_ty(),
|
trait_pred.self_ty(),
|
||||||
|
|
|
@ -121,7 +121,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
|
||||||
.filter_map(|obligation| {
|
.filter_map(|obligation| {
|
||||||
// Note that we do not want to deal with qualified predicates here.
|
// Note that we do not want to deal with qualified predicates here.
|
||||||
match obligation.predicate.kind().no_bound_vars() {
|
match obligation.predicate.kind().no_bound_vars() {
|
||||||
Some(ty::PredicateKind::Trait(pred, _)) if pred.def_id() != sized_trait => Some(pred),
|
Some(ty::PredicateKind::Trait(pred)) if pred.def_id() != sized_trait => Some(pred),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -45,7 +45,7 @@ fn get_trait_predicates_for_trait_id<'tcx>(
|
||||||
let mut preds = Vec::new();
|
let mut preds = Vec::new();
|
||||||
for (pred, _) in generics.predicates {
|
for (pred, _) in generics.predicates {
|
||||||
if_chain! {
|
if_chain! {
|
||||||
if let PredicateKind::Trait(poly_trait_pred, _) = pred.kind().skip_binder();
|
if let PredicateKind::Trait(poly_trait_pred) = pred.kind().skip_binder();
|
||||||
let trait_pred = cx.tcx.erase_late_bound_regions(pred.kind().rebind(poly_trait_pred));
|
let trait_pred = cx.tcx.erase_late_bound_regions(pred.kind().rebind(poly_trait_pred));
|
||||||
if let Some(trait_def_id) = trait_id;
|
if let Some(trait_def_id) = trait_id;
|
||||||
if trait_def_id == trait_pred.trait_ref.def_id;
|
if trait_def_id == trait_pred.trait_ref.def_id;
|
||||||
|
|
|
@ -36,7 +36,7 @@ pub fn is_min_const_fn(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, msrv: Option<&Ru
|
||||||
ty::PredicateKind::ObjectSafe(_) => panic!("object safe predicate on function: {:#?}", predicate),
|
ty::PredicateKind::ObjectSafe(_) => panic!("object safe predicate on function: {:#?}", predicate),
|
||||||
ty::PredicateKind::ClosureKind(..) => panic!("closure kind predicate on function: {:#?}", predicate),
|
ty::PredicateKind::ClosureKind(..) => panic!("closure kind predicate on function: {:#?}", predicate),
|
||||||
ty::PredicateKind::Subtype(_) => panic!("subtype predicate on function: {:#?}", predicate),
|
ty::PredicateKind::Subtype(_) => panic!("subtype predicate on function: {:#?}", predicate),
|
||||||
ty::PredicateKind::Trait(pred, _) => {
|
ty::PredicateKind::Trait(pred) => {
|
||||||
if Some(pred.def_id()) == tcx.lang_items().sized_trait() {
|
if Some(pred.def_id()) == tcx.lang_items().sized_trait() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,7 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||||
ty::Tuple(substs) => substs.types().any(|ty| is_must_use_ty(cx, ty)),
|
ty::Tuple(substs) => substs.types().any(|ty| is_must_use_ty(cx, ty)),
|
||||||
ty::Opaque(ref def_id, _) => {
|
ty::Opaque(ref def_id, _) => {
|
||||||
for (predicate, _) in cx.tcx.explicit_item_bounds(*def_id) {
|
for (predicate, _) in cx.tcx.explicit_item_bounds(*def_id) {
|
||||||
if let ty::PredicateKind::Trait(trait_predicate, _) = predicate.kind().skip_binder() {
|
if let ty::PredicateKind::Trait(trait_predicate) = predicate.kind().skip_binder() {
|
||||||
if must_use_attr(cx.tcx.get_attrs(trait_predicate.trait_ref.def_id)).is_some() {
|
if must_use_attr(cx.tcx.get_attrs(trait_predicate.trait_ref.def_id)).is_some() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue