Skip to content

Commit 0810f88

Browse files
committed
Move/merge impls out of ty/mod.rs
1 parent 3c0e0ce commit 0810f88

File tree

2 files changed

+26
-28
lines changed

2 files changed

+26
-28
lines changed

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use rustc_serialize::{Decodable, Encodable};
4444
use rustc_session::lint::LintBuffer;
4545
pub use rustc_session::lint::RegisteredTools;
4646
use rustc_span::hygiene::MacroKind;
47-
use rustc_span::symbol::{kw, sym, Ident, Symbol};
47+
use rustc_span::symbol::{sym, Ident, Symbol};
4848
use rustc_span::{ExpnId, ExpnKind, Span};
4949
use rustc_target::abi::{Align, FieldIdx, Integer, IntegerType, VariantIdx};
5050
pub use rustc_target::abi::{ReprFlags, ReprOptions};
@@ -338,14 +338,6 @@ pub struct CReaderCacheKey {
338338
pub pos: usize,
339339
}
340340

341-
impl ty::EarlyBoundRegion {
342-
/// Does this early bound region have a name? Early bound regions normally
343-
/// always have names except when using anonymous lifetimes (`'_`).
344-
pub fn has_name(&self) -> bool {
345-
self.name != kw::UnderscoreLifetime && self.name != kw::Empty
346-
}
347-
}
348-
349341
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
350342
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
351343
/// A clause is something that can appear in where bounds or be inferred
@@ -427,24 +419,6 @@ pub struct BoundConst<'tcx> {
427419
pub ty: Ty<'tcx>,
428420
}
429421

430-
// FIXME(ecstaticmorse): Audit all occurrences of `without_const().to_predicate(tcx)` to ensure that
431-
// the constness of trait bounds is being propagated correctly.
432-
impl<'tcx> PolyTraitRef<'tcx> {
433-
#[inline]
434-
pub fn with_constness(self, constness: BoundConstness) -> PolyTraitPredicate<'tcx> {
435-
self.map_bound(|trait_ref| ty::TraitPredicate {
436-
trait_ref,
437-
constness,
438-
polarity: ty::ImplPolarity::Positive,
439-
})
440-
}
441-
442-
#[inline]
443-
pub fn without_const(self) -> PolyTraitPredicate<'tcx> {
444-
self.with_constness(BoundConstness::NotConst)
445-
}
446-
}
447-
448422
#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable)]
449423
pub struct Destructor {
450424
/// The `DefId` of the destructor method

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
use crate::infer::canonical::Canonical;
66
use crate::ty::subst::{GenericArg, InternalSubsts, SubstsRef};
77
use crate::ty::visit::ValidateBoundVars;
8-
use crate::ty::InferTy::*;
98
use crate::ty::{
109
self, AdtDef, Discr, Term, Ty, TyCtxt, TypeFlags, TypeSuperVisitable, TypeVisitable,
1110
TypeVisitableExt, TypeVisitor,
1211
};
12+
use crate::ty::{BoundConstness, InferTy::*, PolyTraitPredicate};
1313
use crate::ty::{List, ParamEnv};
1414
use hir::def::DefKind;
1515
use polonius_engine::Atom;
@@ -895,6 +895,22 @@ impl<'tcx> PolyTraitRef<'tcx> {
895895
pub fn def_id(&self) -> DefId {
896896
self.skip_binder().def_id
897897
}
898+
899+
#[inline]
900+
pub fn with_constness(self, constness: BoundConstness) -> PolyTraitPredicate<'tcx> {
901+
self.map_bound(|trait_ref| ty::TraitPredicate {
902+
trait_ref,
903+
constness,
904+
polarity: ty::ImplPolarity::Positive,
905+
})
906+
}
907+
908+
// FIXME(ecstaticmorse): Audit all occurrences of `without_const().to_predicate(tcx)` to ensure that
909+
// the constness of trait bounds is being propagated correctly.
910+
#[inline]
911+
pub fn without_const(self) -> PolyTraitPredicate<'tcx> {
912+
self.with_constness(BoundConstness::NotConst)
913+
}
898914
}
899915

900916
impl<'tcx> IntoDiagnosticArg for TraitRef<'tcx> {
@@ -1451,6 +1467,14 @@ pub struct EarlyBoundRegion {
14511467
pub name: Symbol,
14521468
}
14531469

1470+
impl EarlyBoundRegion {
1471+
/// Does this early bound region have a name? Early bound regions normally
1472+
/// always have names except when using anonymous lifetimes (`'_`).
1473+
pub fn has_name(&self) -> bool {
1474+
self.name != kw::UnderscoreLifetime && self.name != kw::Empty
1475+
}
1476+
}
1477+
14541478
impl fmt::Debug for EarlyBoundRegion {
14551479
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
14561480
write!(f, "{}, {}", self.index, self.name)

0 commit comments

Comments
 (0)