rustc::hir::def_id::DefId,
>,
[few] resolve_lifetimes: rustc::middle::resolve_lifetime::ResolveLifetimes,
- [decode] generic_predicates: rustc::ty::GenericPredicates<'tcx>,
[few] lint_levels: rustc::lint::LintLevelMap,
[few] stability_index: rustc::middle::stability::Index<'tcx>,
[few] features: syntax::feature_gate::Features,
/// predicate gets in the way of some checks, which are intended
/// to operate over only the actual where-clauses written by the
/// user.)
- query predicates_of(key: DefId) -> &'tcx ty::GenericPredicates<'tcx> {
+ query predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
cache_on_disk_if { key.is_local() }
}
/// predicates (where-clauses) directly defined on it. This is
/// equal to the `explicit_predicates_of` predicates plus the
/// `inferred_outlives_of` predicates.
- query predicates_defined_on(_: DefId)
- -> &'tcx ty::GenericPredicates<'tcx> {}
+ query predicates_defined_on(_: DefId) -> ty::GenericPredicates<'tcx> {}
/// Returns the predicates written explicitly by the user.
- query explicit_predicates_of(_: DefId)
- -> &'tcx ty::GenericPredicates<'tcx> {}
+ query explicit_predicates_of(_: DefId) -> ty::GenericPredicates<'tcx> {}
/// Returns the inferred outlives predicates (e.g., for `struct
/// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`).
/// evaluate them even during type conversion, often before the
/// full predicates are available (note that supertraits have
/// additional acyclicity requirements).
- query super_predicates_of(key: DefId) -> &'tcx ty::GenericPredicates<'tcx> {
+ query super_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
desc { |tcx| "computing the supertraits of `{}`", tcx.def_path_str(key) }
}
/// To avoid cycles within the predicates of a single item we compute
/// per-type-parameter predicates for resolving `T::AssocTy`.
- query type_param_predicates(key: (DefId, DefId))
- -> &'tcx ty::GenericPredicates<'tcx> {
+ query type_param_predicates(key: (DefId, DefId)) -> ty::GenericPredicates<'tcx> {
no_force
desc { |tcx| "computing the bounds for type parameter `{}`", {
let id = tcx.hir().as_local_hir_id(key.1).unwrap();
// The predicates will contain default bounds like `T: Sized`. We need to
// remove these bounds, and add `T: ?Sized` to any untouched type parameters.
- let predicates = &tcx.predicates_of(impl_def_id).predicates;
+ let predicates = tcx.predicates_of(impl_def_id).predicates;
let mut pretty_predicates = Vec::with_capacity(
predicates.len() + types_without_default_bounds.len());
use crate::ty::{self, Ty, TyCtxt};
use crate::ty::subst::SubstsRef;
use crate::mir::interpret::Allocation;
+use syntax_pos::Span;
/// The shorthand encoding uses an enum's variant index `usize`
/// and is offset by this value so it never matches a real variant.
Ok(())
}
-pub fn encode_predicates<'tcx, E, C>(encoder: &mut E,
- predicates: &ty::GenericPredicates<'tcx>,
- cache: C)
- -> Result<(), E::Error>
+pub fn encode_spanned_predicates<'tcx, E, C>(
+ encoder: &mut E,
+ predicates: &'tcx [(ty::Predicate<'tcx>, Span)],
+ cache: C,
+) -> Result<(), E::Error>
where E: TyEncoder,
C: for<'b> Fn(&'b mut E) -> &'b mut FxHashMap<ty::Predicate<'tcx>, usize>,
{
- predicates.parent.encode(encoder)?;
- predicates.predicates.len().encode(encoder)?;
- for (predicate, span) in &predicates.predicates {
+ predicates.len().encode(encoder)?;
+ for (predicate, span) in predicates {
encode_with_shorthand(encoder, predicate, &cache)?;
span.encode(encoder)?;
}
}
#[inline]
-pub fn decode_predicates<D>(decoder: &mut D) -> Result<ty::GenericPredicates<'tcx>, D::Error>
+pub fn decode_spanned_predicates<D>(
+ decoder: &mut D,
+) -> Result<&'tcx [(ty::Predicate<'tcx>, Span)], D::Error>
where
D: TyDecoder<'tcx>,
{
- Ok(ty::GenericPredicates {
- parent: Decodable::decode(decoder)?,
- predicates: (0..decoder.read_usize()?).map(|_| {
+ let tcx = decoder.tcx();
+ Ok(tcx.arena.alloc_from_iter(
+ (0..decoder.read_usize()?).map(|_| {
// Handle shorthands first, if we have an usize > 0x80.
let predicate = if decoder.positioned_at_shorthand() {
let pos = decoder.read_usize()?;
Ok((predicate, Decodable::decode(decoder)?))
})
.collect::<Result<Vec<_>, _>>()?,
- })
+ ))
}
#[inline]
use $crate::ty::subst::SubstsRef;
use $crate::hir::def_id::{CrateNum};
+ use syntax_pos::Span;
+
use super::$DecoderName;
impl<$($typaram ),*> Decoder for $DecoderName<$($typaram),*> {
}
}
- impl<$($typaram),*> SpecializedDecoder<ty::GenericPredicates<'tcx>>
+ impl<$($typaram),*> SpecializedDecoder<&'tcx [(ty::Predicate<'tcx>, Span)]>
for $DecoderName<$($typaram),*> {
fn specialized_decode(&mut self)
- -> Result<ty::GenericPredicates<'tcx>, Self::Error> {
- decode_predicates(self)
+ -> Result<&'tcx [(ty::Predicate<'tcx>, Span)], Self::Error> {
+ decode_spanned_predicates(self)
}
}
}
}
-pub struct Common<'tcx> {
- pub empty_predicates: ty::GenericPredicates<'tcx>,
-}
-
pub struct CommonTypes<'tcx> {
pub unit: Ty<'tcx>,
pub bool: Ty<'tcx>,
pub prof: SelfProfilerRef,
- /// Common objects.
- pub common: Common<'tcx>,
-
/// Common types, pre-interned for your convenience.
pub types: CommonTypes<'tcx>,
s.fatal(&err);
});
let interners = CtxtInterners::new(&arenas.interner);
- let common = Common {
- empty_predicates: ty::GenericPredicates {
- parent: None,
- predicates: vec![],
- },
- };
let common_types = CommonTypes::new(&interners);
let common_lifetimes = CommonLifetimes::new(&interners);
let common_consts = CommonConsts::new(&interners, &common_types);
interners,
dep_graph,
prof: s.prof.clone(),
- common,
types: common_types,
lifetimes: common_lifetimes,
consts: common_consts,
}
/// Bounds on generics.
-#[derive(Clone, Default, Debug, HashStable)]
+#[derive(Copy, Clone, Default, Debug, RustcEncodable, RustcDecodable, HashStable)]
pub struct GenericPredicates<'tcx> {
pub parent: Option<DefId>,
- pub predicates: Vec<(Predicate<'tcx>, Span)>,
+ pub predicates: &'tcx [(Predicate<'tcx>, Span)],
}
-impl<'tcx> rustc_serialize::UseSpecializedEncodable for GenericPredicates<'tcx> {}
-impl<'tcx> rustc_serialize::UseSpecializedDecodable for GenericPredicates<'tcx> {}
-
impl<'tcx> GenericPredicates<'tcx> {
pub fn instantiate(
&self,
}
#[inline]
- pub fn predicates(&self, tcx: TyCtxt<'tcx>) -> &'tcx GenericPredicates<'tcx> {
+ pub fn predicates(&self, tcx: TyCtxt<'tcx>) -> GenericPredicates<'tcx> {
tcx.predicates_of(self.did)
}
def_id: sized_trait,
substs: tcx.mk_substs_trait(ty, &[])
}).to_predicate();
- let predicates = &tcx.predicates_of(self.did).predicates;
+ let predicates = tcx.predicates_of(self.did).predicates;
if predicates.iter().any(|(p, _)| *p == sized_predicate) {
vec![]
} else {
}
}
-impl<'a, 'tcx, E> SpecializedEncoder<ty::GenericPredicates<'tcx>> for CacheEncoder<'a, 'tcx, E>
+impl<'a, 'tcx, E> SpecializedEncoder<&'tcx [(ty::Predicate<'tcx>, Span)]>
+ for CacheEncoder<'a, 'tcx, E>
where
E: 'a + TyEncoder,
{
#[inline]
fn specialized_encode(&mut self,
- predicates: &ty::GenericPredicates<'tcx>)
+ predicates: &&'tcx [(ty::Predicate<'tcx>, Span)])
-> Result<(), Self::Error> {
- ty_codec::encode_predicates(self, predicates,
+ ty_codec::encode_spanned_predicates(self, predicates,
|encoder| &mut encoder.predicate_shorthands)
}
}
}
}
-BraceStructTypeFoldableImpl! {
- impl<'tcx> TypeFoldable<'tcx> for ty::GenericPredicates<'tcx> {
- parent, predicates
- }
-}
-
impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<ty::Predicate<'tcx>> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
// This code is hot enough that it's worth specializing for a list of
if cx.tcx.features().trivial_bounds {
let def_id = cx.tcx.hir().local_def_id(item.hir_id);
let predicates = cx.tcx.predicates_of(def_id);
- for &(predicate, span) in &predicates.predicates {
+ for &(predicate, span) in predicates.predicates {
let predicate_kind_name = match predicate {
Trait(..) => "Trait",
TypeOutlives(..) |
}
ty::Opaque(def, _) => {
let mut has_emitted = false;
- for (predicate, _) in &cx.tcx.predicates_of(def).predicates {
+ for (predicate, _) in cx.tcx.predicates_of(def).predicates {
if let ty::Predicate::Trait(ref poly_trait_predicate) = predicate {
let trait_ref = poly_trait_predicate.skip_binder().trait_ref;
let def_id = trait_ref.def_id;
generics_of => {
tcx.arena.alloc(cdata.get_generics(def_id.index, tcx.sess))
}
- predicates_of => { tcx.arena.alloc(cdata.get_predicates(def_id.index, tcx)) }
- predicates_defined_on => {
- tcx.arena.alloc(cdata.get_predicates_defined_on(def_id.index, tcx))
- }
- super_predicates_of => { tcx.arena.alloc(cdata.get_super_predicates(def_id.index, tcx)) }
+ predicates_of => { cdata.get_predicates(def_id.index, tcx) }
+ predicates_defined_on => { cdata.get_predicates_defined_on(def_id.index, tcx) }
+ super_predicates_of => { cdata.get_super_predicates(def_id.index, tcx) }
trait_def => {
tcx.arena.alloc(cdata.get_trait_def(def_id.index, tcx.sess))
}
}
}
-impl<'tcx> SpecializedEncoder<ty::GenericPredicates<'tcx>> for EncodeContext<'tcx> {
+impl<'tcx> SpecializedEncoder<&'tcx [(ty::Predicate<'tcx>, Span)]> for EncodeContext<'tcx> {
fn specialized_encode(&mut self,
- predicates: &ty::GenericPredicates<'tcx>)
+ predicates: &&'tcx [(ty::Predicate<'tcx>, Span)])
-> Result<(), Self::Error> {
- ty_codec::encode_predicates(self, predicates, |ecx| &mut ecx.predicate_shorthands)
+ ty_codec::encode_spanned_predicates(self, predicates, |ecx| &mut ecx.predicate_shorthands)
}
}
fn encode_predicates(&mut self, def_id: DefId) {
debug!("EncodeContext::encode_predicates({:?})", def_id);
- record!(self.per_def.predicates[def_id] <- &*self.tcx.predicates_of(def_id));
+ record!(self.per_def.predicates[def_id] <- self.tcx.predicates_of(def_id));
}
fn encode_predicates_defined_on(&mut self, def_id: DefId) {
debug!("EncodeContext::encode_predicates_defined_on({:?})", def_id);
record!(self.per_def.predicates_defined_on[def_id] <-
- &*self.tcx.predicates_defined_on(def_id))
+ self.tcx.predicates_defined_on(def_id))
}
fn encode_info_for_trait_item(&mut self, def_id: DefId) {
paren_sugar: trait_def.paren_sugar,
has_auto_impl: self.tcx.trait_is_auto(def_id),
is_marker: trait_def.is_marker,
- super_predicates: self.lazy(&*tcx.super_predicates_of(def_id)),
+ super_predicates: self.lazy(tcx.super_predicates_of(def_id)),
};
EntryKind::Trait(self.lazy(data))
}
hir::ItemKind::TraitAlias(..) => {
let data = TraitAliasData {
- super_predicates: self.lazy(&*tcx.super_predicates_of(def_id)),
+ super_predicates: self.lazy(tcx.super_predicates_of(def_id)),
};
EntryKind::TraitAlias(self.lazy(data))
let mut current = def_id;
loop {
let predicates = tcx.predicates_of(current);
- for (predicate, _) in &predicates.predicates {
+ for (predicate, _) in predicates.predicates {
match predicate {
| Predicate::RegionOutlives(_)
| Predicate::TypeOutlives(_)
fn visit_trait(&mut self, trait_ref: TraitRef<'tcx>) -> bool {
self.skeleton().visit_trait(trait_ref)
}
- fn visit_predicates(&mut self, predicates: &ty::GenericPredicates<'tcx>) -> bool {
+ fn visit_predicates(&mut self, predicates: ty::GenericPredicates<'tcx>) -> bool {
self.skeleton().visit_predicates(predicates)
}
}
(!self.def_id_visitor.shallow() && substs.visit_with(self))
}
- fn visit_predicates(&mut self, predicates: &ty::GenericPredicates<'tcx>) -> bool {
+ fn visit_predicates(&mut self, predicates: ty::GenericPredicates<'tcx>) -> bool {
let ty::GenericPredicates { parent: _, predicates } = predicates;
for (predicate, _span) in predicates {
match predicate {
let implemented_from_env = Clause::ForAll(ty::Binder::bind(implemented_from_env));
- let predicates = &tcx.predicates_defined_on(def_id).predicates;
+ let predicates = tcx.predicates_defined_on(def_id).predicates;
// Warning: these where clauses are not substituted for bound vars yet,
// so that we don't need to adjust binders in the `FromEnv` rules below
let trait_pred = ty::TraitPredicate { trait_ref }.lower();
// `WC`
- let predicates = &tcx.predicates_of(def_id).predicates;
+ let predicates = tcx.predicates_of(def_id).predicates;
let where_clauses = predicates
.iter()
.map(|(wc, _)| wc.lower())
/// but this can lead to cycle errors. The problem is that we have
/// to do this resolution *in order to create the predicates in
/// the first place*. Hence, we have this "special pass".
- fn get_type_parameter_bounds(&self, span: Span, def_id: DefId)
- -> &'tcx ty::GenericPredicates<'tcx>;
+ fn get_type_parameter_bounds(&self, span: Span, def_id: DefId) -> ty::GenericPredicates<'tcx>;
/// Returns the lifetime to use when a lifetime is omitted (and not elided).
fn re_infer(
ensure_drop_predicates_are_implied_by_item_defn(
tcx,
drop_impl_did,
- &dtor_predicates,
+ dtor_predicates,
adt_def.did,
self_to_impl_substs,
)
fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
tcx: TyCtxt<'tcx>,
drop_impl_did: DefId,
- dtor_predicates: &ty::GenericPredicates<'tcx>,
+ dtor_predicates: ty::GenericPredicates<'tcx>,
self_type_did: DefId,
self_to_impl_substs: SubstsRef<'tcx>,
) -> Result<(), ErrorReported> {
// just to look for all the predicates directly.
assert_eq!(dtor_predicates.parent, None);
- for (predicate, _) in &dtor_predicates.predicates {
+ for (predicate, _) in dtor_predicates.predicates {
// (We do not need to worry about deep analysis of type
// expressions etc because the Drop impls are already forced
// to take on a structure that is roughly an alpha-renaming of
self.tcx
}
- fn get_type_parameter_bounds(&self, _: Span, def_id: DefId)
- -> &'tcx ty::GenericPredicates<'tcx>
- {
+ fn get_type_parameter_bounds(&self, _: Span, def_id: DefId) -> ty::GenericPredicates<'tcx> {
let tcx = self.tcx;
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
let item_id = tcx.hir().ty_param_owner(hir_id);
let item_def_id = tcx.hir().local_def_id(item_id);
let generics = tcx.generics_of(item_def_id);
let index = generics.param_def_id_to_index[&def_id];
- tcx.arena.alloc(ty::GenericPredicates {
+ ty::GenericPredicates {
parent: None,
- predicates: self.param_env.caller_bounds.iter().filter_map(|&predicate| {
- match predicate {
+ predicates: tcx.arena.alloc_from_iter(
+ self.param_env.caller_bounds.iter().filter_map(|&predicate| match predicate {
ty::Predicate::Trait(ref data)
if data.skip_binder().self_ty().is_param(index) => {
// HACK(eddyb) should get the original `Span`.
Some((predicate, span))
}
_ => None
- }
- }).collect()
- })
+ }),
+ ),
+ }
}
fn re_infer(
"check_opaque_types: may define, predicates={:#?}",
predicates,
);
- for &(pred, _) in predicates.predicates.iter() {
+ for &(pred, _) in predicates.predicates {
let substituted_pred = pred.subst(fcx.tcx, substs);
// Avoid duplication of predicates that contain no parameters, for example.
if !predicates.predicates.iter().any(|&(p, _)| p == substituted_pred) {
identify_constrained_generic_params(
tcx,
- &ty_predicates,
+ ty_predicates,
None,
&mut constrained_parameters,
);
self.tcx
}
- fn get_type_parameter_bounds(&self, span: Span, def_id: DefId)
- -> &'tcx ty::GenericPredicates<'tcx> {
+ fn get_type_parameter_bounds(&self, span: Span, def_id: DefId) -> ty::GenericPredicates<'tcx> {
self.tcx
.at(span)
.type_param_predicates((self.item_def_id, def_id))
fn type_param_predicates(
tcx: TyCtxt<'_>,
(item_def_id, def_id): (DefId, DefId),
-) -> &ty::GenericPredicates<'_> {
+) -> ty::GenericPredicates<'_> {
use rustc::hir::*;
// In the AST, bounds can derive from two places. Either
tcx.generics_of(item_def_id).parent
};
- let result = parent.map_or(&tcx.common.empty_predicates, |parent| {
+ let mut result = parent.map(|parent| {
let icx = ItemCtxt::new(tcx, parent);
icx.get_type_parameter_bounds(DUMMY_SP, def_id)
- });
+ }).unwrap_or_default();
let mut extend = None;
let item_hir_id = tcx.hir().as_local_hir_id(item_def_id).unwrap();
};
let icx = ItemCtxt::new(tcx, item_def_id);
- let mut result = (*result).clone();
- result.predicates.extend(extend.into_iter());
- result.predicates.extend(
+ let extra_predicates = extend.into_iter().chain(
icx.type_parameter_bounds_in_generics(ast_generics, param_id, ty, OnlySelfBounds(true))
.into_iter()
.filter(|(predicate, _)| {
ty::Predicate::Trait(ref data) => data.skip_binder().self_ty().is_param(index),
_ => false,
}
- })
+ }),
+ );
+ result.predicates = tcx.arena.alloc_from_iter(
+ result.predicates.iter().copied().chain(extra_predicates),
);
- tcx.arena.alloc(result)
+ result
}
impl ItemCtxt<'tcx> {
fn super_predicates_of(
tcx: TyCtxt<'_>,
trait_def_id: DefId,
-) -> &ty::GenericPredicates<'_> {
+) -> ty::GenericPredicates<'_> {
debug!("super_predicates(trait_def_id={:?})", trait_def_id);
let trait_hir_id = tcx.hir().as_local_hir_id(trait_def_id).unwrap();
generics, item.hir_id, self_param_ty, OnlySelfBounds(!is_trait_alias));
// Combine the two lists to form the complete set of superbounds:
- let superbounds: Vec<_> = superbounds1.into_iter().chain(superbounds2).collect();
+ let superbounds = &*tcx.arena.alloc_from_iter(
+ superbounds1.into_iter().chain(superbounds2)
+ );
// Now require that immediate supertraits are converted,
// which will, in turn, reach indirect supertraits.
- for &(pred, span) in &superbounds {
+ for &(pred, span) in superbounds {
debug!("superbound: {:?}", pred);
if let ty::Predicate::Trait(bound) = pred {
tcx.at(span).super_predicates_of(bound.def_id());
}
}
- tcx.arena.alloc(ty::GenericPredicates {
+ ty::GenericPredicates {
parent: None,
predicates: superbounds,
- })
+ }
}
fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::TraitDef {
fn predicates_defined_on(
tcx: TyCtxt<'_>,
def_id: DefId,
-) -> &ty::GenericPredicates<'_> {
+) -> ty::GenericPredicates<'_> {
debug!("predicates_defined_on({:?})", def_id);
let mut result = tcx.explicit_predicates_of(def_id);
debug!(
def_id,
inferred_outlives,
);
- let mut predicates = (*result).clone();
- predicates.predicates.extend(inferred_outlives.iter().map(|&p| (p, span)));
- result = tcx.arena.alloc(predicates);
+ result.predicates = tcx.arena.alloc_from_iter(
+ result.predicates.iter().copied().chain(
+ // FIXME(eddyb) use better spans - maybe add `Span`s
+ // to `inferred_outlives_of` predicates as well?
+ inferred_outlives.iter().map(|&p| (p, span)),
+ ),
+ );
}
debug!("predicates_defined_on({:?}) = {:?}", def_id, result);
result
/// Returns a list of all type predicates (explicit and implicit) for the definition with
/// ID `def_id`. This includes all predicates returned by `predicates_defined_on`, plus
/// `Self: Trait` predicates for traits.
-fn predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::GenericPredicates<'_> {
+fn predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicates<'_> {
let mut result = tcx.predicates_defined_on(def_id);
if tcx.is_trait(def_id) {
// used, and adding the predicate into this list ensures
// that this is done.
let span = tcx.def_span(def_id);
- let mut predicates = (*result).clone();
- predicates.predicates.push((ty::TraitRef::identity(tcx, def_id).to_predicate(), span));
- result = tcx.arena.alloc(predicates);
+ result.predicates = tcx.arena.alloc_from_iter(
+ result.predicates.iter().copied().chain(
+ std::iter::once((ty::TraitRef::identity(tcx, def_id).to_predicate(), span))
+ ),
+ );
}
debug!("predicates_of(def_id={:?}) = {:?}", def_id, result);
result
fn explicit_predicates_of(
tcx: TyCtxt<'_>,
def_id: DefId,
-) -> &ty::GenericPredicates<'_> {
+) -> ty::GenericPredicates<'_> {
use rustc::hir::*;
use rustc_data_structures::fx::FxHashSet;
/// A data structure with unique elements, which preserves order of insertion.
/// Preserving the order of insertion is important here so as not to break
/// compile-fail UI tests.
+ // FIXME(eddyb) just use `IndexSet` from `indexmap`.
struct UniquePredicates<'tcx> {
predicates: Vec<(ty::Predicate<'tcx>, Span)>,
uniques: FxHashSet<(ty::Predicate<'tcx>, Span)>,
let bounds_predicates = bounds.predicates(tcx, opaque_ty);
if impl_trait_fn.is_some() {
// opaque types
- return tcx.arena.alloc(ty::GenericPredicates {
+ return ty::GenericPredicates {
parent: None,
- predicates: bounds_predicates,
- });
+ predicates: tcx.arena.alloc_from_iter(bounds_predicates),
+ };
} else {
// named opaque types
predicates.extend(bounds_predicates);
);
}
- let result = tcx.arena.alloc(ty::GenericPredicates {
+ let result = ty::GenericPredicates {
parent: generics.parent,
- predicates,
- });
+ predicates: tcx.arena.alloc_from_iter(predicates),
+ };
debug!("explicit_predicates_of(def_id={:?}) = {:?}", def_id, result);
result
}
pub fn identify_constrained_generic_params<'tcx>(
tcx: TyCtxt<'tcx>,
- predicates: &ty::GenericPredicates<'tcx>,
+ predicates: ty::GenericPredicates<'tcx>,
impl_trait_ref: Option<ty::TraitRef<'tcx>>,
input_parameters: &mut FxHashSet<Parameter>,
) {
- let mut predicates = predicates.predicates.clone();
+ let mut predicates = predicates.predicates.to_vec();
setup_constraining_predicates(tcx, &mut predicates, impl_trait_ref, input_parameters);
}
let mut input_parameters = cgp::parameters_for_impl(impl_self_ty, impl_trait_ref);
cgp::identify_constrained_generic_params(
- tcx, &impl_predicates, impl_trait_ref, &mut input_parameters);
+ tcx, impl_predicates, impl_trait_ref, &mut input_parameters);
// Disallow unconstrained lifetimes, but only if they appear in assoc types.
let lifetimes_in_associated_types: FxHashSet<_> = impl_item_refs.iter()
let mut required_predicates = RequiredPredicates::default();
// process predicates and convert to `RequiredPredicates` entry, see below
- for (pred, _) in predicates.predicates.iter() {
+ for (pred, _) in predicates.predicates {
match pred {
ty::Predicate::TypeOutlives(predicate) => {
let OutlivesPredicate(ref ty, ref reg) = predicate.skip_binder();
// regardless of the choice of `T`.
let params = (
self.cx.tcx.generics_of(param_env_def_id),
- &&self.cx.tcx.common.empty_predicates,
+ ty::GenericPredicates::default(),
).clean(self.cx).params;
Generics {
let mut generic_params = (
tcx.generics_of(param_env_def_id),
- &tcx.explicit_predicates_of(param_env_def_id),
+ tcx.explicit_predicates_of(param_env_def_id),
).clean(self.cx).params;
let mut has_sized = FxHashSet::default();
unsafety: hir::Unsafety::Normal,
generics: (
self.cx.tcx.generics_of(impl_def_id),
- &self.cx.tcx.explicit_predicates_of(impl_def_id),
+ self.cx.tcx.explicit_predicates_of(impl_def_id),
).clean(self.cx),
provided_trait_methods,
// FIXME(eddyb) compute both `trait_` and `for_` from
let auto_trait = cx.tcx.trait_def(did).has_auto_impl;
let trait_items = cx.tcx.associated_items(did).map(|item| item.clean(cx)).collect();
let predicates = cx.tcx.predicates_of(did);
- let generics = (cx.tcx.generics_of(did), &predicates).clean(cx);
+ let generics = (cx.tcx.generics_of(did), predicates).clean(cx);
let generics = filter_non_trait_generics(did, generics);
let (generics, supertrait_bounds) = separate_supertrait_bounds(generics);
let is_spotlight = load_attrs(cx, did).clean(cx).has_doc_flag(sym::spotlight);
let asyncness = cx.tcx.asyncness(did);
let predicates = cx.tcx.predicates_of(did);
let (generics, decl) = clean::enter_impl_trait(cx, || {
- ((cx.tcx.generics_of(did), &predicates).clean(cx), (did, sig).clean(cx))
+ ((cx.tcx.generics_of(did), predicates).clean(cx), (did, sig).clean(cx))
});
let (all_types, ret_types) = clean::get_all_types(&generics, &decl, cx);
clean::Function {
let predicates = cx.tcx.explicit_predicates_of(did);
clean::Enum {
- generics: (cx.tcx.generics_of(did), &predicates).clean(cx),
+ generics: (cx.tcx.generics_of(did), predicates).clean(cx),
variants_stripped: false,
variants: cx.tcx.adt_def(did).variants.clean(cx),
}
CtorKind::Fn => doctree::Tuple,
CtorKind::Const => doctree::Unit,
},
- generics: (cx.tcx.generics_of(did), &predicates).clean(cx),
+ generics: (cx.tcx.generics_of(did), predicates).clean(cx),
fields: variant.fields.clean(cx),
fields_stripped: false,
}
clean::Union {
struct_type: doctree::Plain,
- generics: (cx.tcx.generics_of(did), &predicates).clean(cx),
+ generics: (cx.tcx.generics_of(did), predicates).clean(cx),
fields: variant.fields.clean(cx),
fields_stripped: false,
}
clean::Typedef {
type_: cx.tcx.type_of(did).clean(cx),
- generics: (cx.tcx.generics_of(did), &predicates).clean(cx),
+ generics: (cx.tcx.generics_of(did), predicates).clean(cx),
}
}
}
}).collect::<Vec<_>>(),
clean::enter_impl_trait(cx, || {
- (tcx.generics_of(did), &predicates).clean(cx)
+ (tcx.generics_of(did), predicates).clean(cx)
}),
)
};
}
}
-impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
- &'a &'tcx ty::GenericPredicates<'tcx>) {
+impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx>) {
fn clean(&self, cx: &DocContext<'_>) -> Generics {
use self::WherePredicate as WP;
use std::collections::BTreeMap;
}
ty::AssocKind::Method => {
let generics = (cx.tcx.generics_of(self.def_id),
- &cx.tcx.explicit_predicates_of(self.def_id)).clean(cx);
+ cx.tcx.explicit_predicates_of(self.def_id)).clean(cx);
let sig = cx.tcx.fn_sig(self.def_id);
let mut decl = (self.def_id, sig).clean(cx);
// all of the generics from there and then look for bounds that are
// applied to this associated type in question.
let predicates = cx.tcx.explicit_predicates_of(did);
- let generics = (cx.tcx.generics_of(did), &predicates).clean(cx);
+ let generics = (cx.tcx.generics_of(did), predicates).clean(cx);
let mut bounds = generics.where_predicates.iter().filter_map(|pred| {
let (name, self_type, trait_, bounds) = match *pred {
WherePredicate::BoundPredicate {