Skip to content

Commit

Permalink
Add NotTrait PredicateKind
Browse files Browse the repository at this point in the history
  • Loading branch information
yaahc committed Jun 1, 2021
1 parent 7f9ab03 commit 93856e5
Show file tree
Hide file tree
Showing 23 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_infer/src/infer/outlives/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub fn explicit_outlives_bounds<'tcx>(
| ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateKind::ConstEquate(..)
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
ty::PredicateKind::NotTrait(..) => todo!("yaahc"),
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r_a, r_b)) => {
Some(OutlivesBound::RegionSubRegion(r_b, r_a))
}
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_infer/src/traits/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ impl Elaborator<'tcx> {

self.stack.extend(obligations);
}
ty::PredicateKind::NotTrait(_data, _) => {
todo!("yaahc")
}
ty::PredicateKind::WellFormed(..) => {
// Currently, we do not elaborate WF predicates,
// although we easily could.
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,7 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
for &(predicate, span) in predicates.predicates {
let predicate_kind_name = match predicate.kind().skip_binder() {
Trait(..) => "Trait",
NotTrait(..) => todo!("yaahc"),
TypeOutlives(..) |
RegionOutlives(..) => "Lifetime",

Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_middle/src/ty/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ impl FlagComputation {
ty::PredicateKind::Trait(trait_pred, _constness) => {
self.add_substs(trait_pred.trait_ref.substs);
}
ty::PredicateKind::NotTrait(_trait_pred, _constness) => {
todo!("yaahc")
}
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => {
self.add_region(a);
self.add_region(b);
Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,15 @@ pub enum PredicateKind<'tcx> {
/// `const fn foobar<Foo: Bar>() {}`).
Trait(TraitPredicate<'tcx>, Constness),

/// Corresponds to `where Foo: !Bar<A, B, C>`. `Foo` here would be
/// the `Self` type of the trait reference and `A`, `B`, and `C`
/// would be the type parameters.
///
/// 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>() {}`).
NotTrait(TraitPredicate<'tcx>, Constness),

/// `where 'a: 'b`
RegionOutlives(RegionOutlivesPredicate<'tcx>),

Expand Down Expand Up @@ -770,6 +779,7 @@ impl<'tcx> Predicate<'tcx> {
PredicateKind::Trait(t, constness) => {
Some(ConstnessAnd { constness, value: predicate.rebind(t.trait_ref) })
}
PredicateKind::NotTrait(..) => todo!("yaahc"),
PredicateKind::Projection(..)
| PredicateKind::Subtype(..)
| PredicateKind::RegionOutlives(..)
Expand All @@ -787,6 +797,7 @@ impl<'tcx> Predicate<'tcx> {
let predicate = self.kind();
match predicate.skip_binder() {
PredicateKind::TypeOutlives(data) => Some(predicate.rebind(data)),
PredicateKind::NotTrait(..) => todo!("yaahc"),
PredicateKind::Trait(..)
| PredicateKind::Projection(..)
| PredicateKind::Subtype(..)
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2197,6 +2197,9 @@ define_print_and_forward_display! {
}
p!(print(data))
}
ty::PredicateKind::NotTrait(ref _data, _constness) => {
todo!("yaahc")
}
ty::PredicateKind::Subtype(predicate) => p!(print(predicate)),
ty::PredicateKind::RegionOutlives(predicate) => p!(print(predicate)),
ty::PredicateKind::TypeOutlives(predicate) => p!(print(predicate)),
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_middle/src/ty/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ impl fmt::Debug for ty::PredicateKind<'tcx> {
}
a.fmt(f)
}
ty::PredicateKind::NotTrait(ref _a, _constness) => todo!("yaahc"),
ty::PredicateKind::Subtype(ref pair) => pair.fmt(f),
ty::PredicateKind::RegionOutlives(ref pair) => pair.fmt(f),
ty::PredicateKind::TypeOutlives(ref pair) => pair.fmt(f),
Expand Down Expand Up @@ -422,6 +423,9 @@ impl<'a, 'tcx> Lift<'tcx> for ty::PredicateKind<'a> {
ty::PredicateKind::Trait(data, constness) => {
tcx.lift(data).map(|data| ty::PredicateKind::Trait(data, constness))
}
ty::PredicateKind::NotTrait(_data, _constness) => {
todo!("yaahc")
}
ty::PredicateKind::Subtype(data) => tcx.lift(data).map(ty::PredicateKind::Subtype),
ty::PredicateKind::RegionOutlives(data) => {
tcx.lift(data).map(ty::PredicateKind::RegionOutlives)
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_mir/src/transform/check_consts/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,9 @@ impl Validator<'mir, 'tcx> {
_ => continue,
}
}
ty::PredicateKind::NotTrait(_pred, _constness) => {
todo!("yaahc")
}
}
}
match predicates.parent {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_trait_selection/src/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,7 @@ crate fn required_region_bounds(
| ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateKind::ConstEquate(..)
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
ty::PredicateKind::NotTrait(..) => todo!("yaahc"),
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ref t, ref r)) => {
// Search for a bound of the form `erased_self_ty
// : 'a`, but be wary of something like `for<'a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
err
}

ty::PredicateKind::NotTrait(_trait_predicate, _) => {
todo!("yaahc")
}

ty::PredicateKind::Subtype(predicate) => {
// Errors for Subtype predicates show up as
// `FulfillmentErrorCode::CodeSubtypeError`,
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_trait_selection/src/traits/fulfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
&mut pending_obligation.stalled_on,
)
}
ty::PredicateKind::NotTrait(_trait_ref, _constness) => {
todo!("yaahc")
}
ty::PredicateKind::Projection(data) => {
let project_obligation = obligation.with(binder.rebind(data));

Expand Down Expand Up @@ -398,6 +401,10 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
)
}

ty::PredicateKind::NotTrait(_data, _) => {
todo!("yaahc")
}

ty::PredicateKind::RegionOutlives(data) => {
match infcx.region_outlives_predicate(&obligation.cause, Binder::dummy(data)) {
Ok(()) => ProcessResult::Changed(vec![]),
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_trait_selection/src/traits/object_safety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ fn predicate_references_self(
// 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 }
}
ty::PredicateKind::NotTrait(ref _data, _) => {
todo!("yaahc")
}
ty::PredicateKind::Projection(ref data) => {
// And similarly for projections. This should be redundant with
// the previous check because any projection should have a
Expand Down Expand Up @@ -334,6 +337,9 @@ fn generics_require_sized_self(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
ty::PredicateKind::Trait(ref trait_pred, _) => {
trait_pred.def_id() == sized_def_id && trait_pred.self_ty().is_param(0)
}
ty::PredicateKind::NotTrait(ref _trait_pred, _) => {
todo!("yaahc")
}
ty::PredicateKind::Projection(..)
| ty::PredicateKind::Subtype(..)
| ty::PredicateKind::RegionOutlives(..)
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
self.evaluate_trait_predicate_recursively(previous_stack, obligation)
}

ty::PredicateKind::NotTrait(_t, _) => {
todo!("yaahc")
}

ty::PredicateKind::Subtype(p) => {
let p = bound_predicate.rebind(p);
// Does this code ever run?
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_trait_selection/src/traits/wf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ pub fn predicate_obligations<'a, 'tcx>(
ty::PredicateKind::Trait(t, _) => {
wf.compute_trait_ref(&t.trait_ref, Elaborate::None);
}
ty::PredicateKind::NotTrait(_t, _) => {
todo!("yaahc")
}
ty::PredicateKind::RegionOutlives(..) => {}
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty, _reg)) => {
wf.compute(ty.into());
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_traits/src/chalk/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'
ty::PredicateKind::Trait(predicate, _) => chalk_ir::DomainGoal::FromEnv(
chalk_ir::FromEnv::Trait(predicate.trait_ref.lower_into(interner)),
),
ty::PredicateKind::NotTrait(_predicate, _) => todo!("yaahc"),
ty::PredicateKind::RegionOutlives(predicate) => chalk_ir::DomainGoal::Holds(
chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
a: predicate.0.lower_into(interner),
Expand Down Expand Up @@ -142,6 +143,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner)),
))
}
ty::PredicateKind::NotTrait(_predicate, _) => todo!("yaahc"),
ty::PredicateKind::RegionOutlives(predicate) => {
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
Expand Down Expand Up @@ -572,6 +574,7 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_ir::QuantifiedWhereClause<RustInterner<'
ty::PredicateKind::Trait(predicate, _) => {
Some(chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner)))
}
ty::PredicateKind::NotTrait(_predicate, _) => todo!("yaahc"),
ty::PredicateKind::RegionOutlives(predicate) => {
Some(chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
a: predicate.0.lower_into(interner),
Expand Down Expand Up @@ -708,6 +711,7 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_solve::rust_ir::QuantifiedInlineBound<Ru
predicate.trait_ref.lower_into(interner),
),
)),
ty::PredicateKind::NotTrait(_predicate, _) => todo!("yaahc"),
ty::PredicateKind::Projection(predicate) => Some(chalk_ir::Binders::new(
binders,
chalk_solve::rust_ir::InlineBound::AliasEqBound(predicate.lower_into(interner)),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_traits/src/implied_outlives_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ fn compute_implied_outlives_bounds<'tcx>(
| ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateKind::ConstEquate(..)
| ty::PredicateKind::TypeWellFormedFromEnv(..) => vec![],
ty::PredicateKind::NotTrait(..) => todo!("yaahc"),
ty::PredicateKind::WellFormed(arg) => {
wf_args.push(arg);
vec![]
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_traits/src/normalize_erasing_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ fn normalize_after_erasing_regions<'tcx, T: TypeFoldable<'tcx> + PartialEq + Cop
fn not_outlives_predicate(p: &ty::Predicate<'tcx>) -> bool {
match p.kind().skip_binder() {
ty::PredicateKind::RegionOutlives(..) | ty::PredicateKind::TypeOutlives(..) => false,
ty::PredicateKind::NotTrait(..) => todo!("yaahc"),
ty::PredicateKind::Trait(..)
| ty::PredicateKind::Projection(..)
| ty::PredicateKind::WellFormed(..)
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ty::PredicateKind::Trait(data, _) => {
Some((bound_predicate.rebind(data).to_poly_trait_ref(), obligation))
}
ty::PredicateKind::NotTrait(_data, _) => {
todo!("yaahc")
}
ty::PredicateKind::Subtype(..) => None,
ty::PredicateKind::RegionOutlives(..) => None,
ty::PredicateKind::TypeOutlives(..) => None,
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_typeck/src/check/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,9 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
_ => None,
}
}
ty::PredicateKind::NotTrait(_trait_predicate, _) => {
todo!("yaahc")
}
ty::PredicateKind::Subtype(..)
| ty::PredicateKind::Projection(..)
| ty::PredicateKind::RegionOutlives(..)
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ fn trait_predicate_kind<'tcx>(
ty::PredicateKind::Trait(pred, hir::Constness::NotConst) => {
Some(tcx.trait_def(pred.def_id()).specialization_kind)
}
ty::PredicateKind::NotTrait(_pred, _) => {
todo!("yaahc")
}
ty::PredicateKind::Trait(_, hir::Constness::Const)
| ty::PredicateKind::RegionOutlives(_)
| ty::PredicateKind::TypeOutlives(_)
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_typeck/src/outlives/explicit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
)
}

ty::PredicateKind::NotTrait(..) => todo!("yaahc"),

ty::PredicateKind::Trait(..)
| ty::PredicateKind::Projection(..)
| ty::PredicateKind::WellFormed(..)
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {
let bound_predicate = self.kind();
match bound_predicate.skip_binder() {
ty::PredicateKind::Trait(pred, _) => Some(bound_predicate.rebind(pred).clean(cx)),
ty::PredicateKind::NotTrait(_pred, _) => todo!("yaahc"),
ty::PredicateKind::RegionOutlives(pred) => pred.clean(cx),
ty::PredicateKind::TypeOutlives(pred) => pred.clean(cx),
ty::PredicateKind::Projection(pred) => Some(pred.clean(cx)),
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub fn is_min_const_fn(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, msrv: Option<&Ru
_ => continue,
}
},
ty::PredicateKind::NotTrait(_pred, _) => todo!("yaahc"),
}
}
match predicates.parent {
Expand Down

0 comments on commit 93856e5

Please sign in to comment.