Skip to content

Commit a9a79f6

Browse files
oli-obkfee1-dead
authored andcommitted
Completely remove ConstnessAnd
1 parent a848c4b commit a9a79f6

File tree

24 files changed

+28
-72
lines changed

24 files changed

+28
-72
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use rustc_middle::ty::fold::TypeFoldable;
3131
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef, UserSubsts};
3232
use rustc_middle::ty::{
3333
self, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, OpaqueTypeKey, RegionVid,
34-
ToPredicate, Ty, TyCtxt, UserType, UserTypeAnnotationIndex, WithConstness,
34+
ToPredicate, Ty, TyCtxt, UserType, UserTypeAnnotationIndex,
3535
};
3636
use rustc_span::def_id::CRATE_DEF_ID;
3737
use rustc_span::{Span, DUMMY_SP};

compiler/rustc_infer/src/traits/engine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::infer::InferCtxt;
22
use crate::traits::Obligation;
33
use rustc_data_structures::fx::FxHashMap;
44
use rustc_hir::def_id::DefId;
5-
use rustc_middle::ty::{self, ToPredicate, Ty, WithConstness};
5+
use rustc_middle::ty::{self, ToPredicate, Ty};
66

77
use super::FulfillmentError;
88
use super::{ObligationCause, PredicateObligation};

compiler/rustc_infer/src/traits/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use smallvec::smallvec;
33
use crate::infer::outlives::components::{push_outlives_components, Component};
44
use crate::traits::{Obligation, ObligationCause, PredicateObligation};
55
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
6-
use rustc_middle::ty::{self, ToPredicate, TyCtxt, WithConstness};
6+
use rustc_middle::ty::{self, ToPredicate, TyCtxt};
77
use rustc_span::symbol::Ident;
88
use rustc_span::Span;
99

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -846,20 +846,6 @@ impl ToPredicate<'tcx> for Binder<'tcx, PredicateKind<'tcx>> {
846846
}
847847
}
848848

849-
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<PolyTraitRef<'tcx>> {
850-
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
851-
self.value
852-
.map_bound(|trait_ref| {
853-
PredicateKind::Trait(ty::TraitPredicate {
854-
trait_ref,
855-
constness: self.constness,
856-
polarity: ty::ImplPolarity::Positive,
857-
})
858-
})
859-
.to_predicate(tcx)
860-
}
861-
}
862-
863849
impl<'tcx> ToPredicate<'tcx> for PolyTraitPredicate<'tcx> {
864850
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
865851
self.map_bound(PredicateKind::Trait).to_predicate(tcx)
@@ -1391,33 +1377,23 @@ impl<'tcx> ParamEnv<'tcx> {
13911377
}
13921378
}
13931379

1394-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TypeFoldable)]
1395-
pub struct ConstnessAnd<T> {
1396-
pub constness: BoundConstness,
1397-
pub value: T,
1398-
}
1399-
14001380
// FIXME(ecstaticmorse): Audit all occurrences of `without_const().to_predicate(tcx)` to ensure that
14011381
// the constness of trait bounds is being propagated correctly.
1402-
pub trait WithConstness: Sized {
1403-
#[inline]
1404-
fn with_constness(self, constness: BoundConstness) -> ConstnessAnd<Self> {
1405-
ConstnessAnd { constness, value: self }
1406-
}
1407-
1382+
impl PolyTraitRef<'tcx> {
14081383
#[inline]
1409-
fn with_const_if_const(self) -> ConstnessAnd<Self> {
1410-
self.with_constness(BoundConstness::ConstIfConst)
1384+
pub fn with_constness(self, constness: BoundConstness) -> PolyTraitPredicate<'tcx> {
1385+
self.map_bound(|trait_ref| ty::TraitPredicate {
1386+
trait_ref,
1387+
constness,
1388+
polarity: ty::ImplPolarity::Positive,
1389+
})
14111390
}
1412-
14131391
#[inline]
1414-
fn without_const(self) -> ConstnessAnd<Self> {
1392+
pub fn without_const(self) -> PolyTraitPredicate<'tcx> {
14151393
self.with_constness(BoundConstness::NotConst)
14161394
}
14171395
}
14181396

1419-
impl<T> WithConstness for T {}
1420-
14211397
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TypeFoldable)]
14221398
pub struct ParamEnvAnd<'tcx, T> {
14231399
pub param_env: ParamEnv<'tcx>,

compiler/rustc_middle/src/ty/relate.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -218,19 +218,6 @@ impl<'tcx> Relate<'tcx> for ty::BoundConstness {
218218
}
219219
}
220220

221-
impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for ty::ConstnessAnd<T> {
222-
fn relate<R: TypeRelation<'tcx>>(
223-
relation: &mut R,
224-
a: ty::ConstnessAnd<T>,
225-
b: ty::ConstnessAnd<T>,
226-
) -> RelateResult<'tcx, ty::ConstnessAnd<T>> {
227-
Ok(ty::ConstnessAnd {
228-
constness: relation.relate(a.constness, b.constness)?,
229-
value: relation.relate(a.value, b.value)?,
230-
})
231-
}
232-
}
233-
234221
impl<'tcx> Relate<'tcx> for ast::Unsafety {
235222
fn relate<R: TypeRelation<'tcx>>(
236223
relation: &mut R,

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ use crate::infer::canonical::Canonical;
88
use crate::ty::fold::ValidateBoundVars;
99
use crate::ty::subst::{GenericArg, InternalSubsts, Subst, SubstsRef};
1010
use crate::ty::InferTy::{self, *};
11-
use crate::ty::{
12-
self, AdtDef, DefIdTree, Discr, Ty, TyCtxt, TypeFlags, TypeFoldable, WithConstness,
13-
};
11+
use crate::ty::{self, AdtDef, DefIdTree, Discr, Ty, TyCtxt, TypeFlags, TypeFoldable};
1412
use crate::ty::{DelaySpanBugEmitted, List, ParamEnv, TyS};
1513
use polonius_engine::Atom;
1614
use rustc_data_structures::captures::Captures;

compiler/rustc_trait_selection/src/autoderef.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::traits::{self, TraitEngine};
33
use rustc_errors::struct_span_err;
44
use rustc_hir as hir;
55
use rustc_infer::infer::InferCtxt;
6-
use rustc_middle::ty::{self, TraitRef, Ty, TyCtxt, WithConstness};
6+
use rustc_middle::ty::{self, TraitRef, Ty, TyCtxt};
77
use rustc_middle::ty::{ToPredicate, TypeFoldable};
88
use rustc_session::{DiagnosticMessageId, Limit};
99
use rustc_span::def_id::LOCAL_CRATE;

compiler/rustc_trait_selection/src/infer.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use rustc_middle::infer::canonical::{Canonical, CanonicalizedQueryResponse, Quer
99
use rustc_middle::traits::query::Fallible;
1010
use rustc_middle::ty::subst::SubstsRef;
1111
use rustc_middle::ty::ToPredicate;
12-
use rustc_middle::ty::WithConstness;
1312
use rustc_middle::ty::{self, Ty, TypeFoldable};
1413
use rustc_span::{Span, DUMMY_SP};
1514

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use rustc_middle::ty::error::ExpectedFound;
2424
use rustc_middle::ty::fold::TypeFolder;
2525
use rustc_middle::ty::{
2626
self, fast_reject, AdtKind, SubtypePredicate, ToPolyTraitRef, ToPredicate, Ty, TyCtxt,
27-
TypeFoldable, WithConstness,
27+
TypeFoldable,
2828
};
2929
use rustc_session::DiagnosticMessageId;
3030
use rustc_span::symbol::{kw, sym};

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_hir::lang_items::LangItem;
2121
use rustc_hir::{AsyncGeneratorKind, GeneratorKind, Node};
2222
use rustc_middle::ty::{
2323
self, suggest_arbitrary_trait_bound, suggest_constraining_type_param, AdtKind, DefIdTree,
24-
Infer, InferTy, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness,
24+
Infer, InferTy, ToPredicate, Ty, TyCtxt, TypeFoldable,
2525
};
2626
use rustc_middle::ty::{TypeAndMut, TypeckResults};
2727
use rustc_session::Limit;

0 commit comments

Comments
 (0)