rustc: force all raw accesses to VecPerParamSpace through as_full_slice.
This commit is contained in:
parent
b354ae95a2
commit
77dc61b5c6
20 changed files with 52 additions and 85 deletions
|
@ -142,7 +142,7 @@ impl<'a, 'gcx, 'tcx> DeferredObligation<'tcx> {
|
||||||
// Auto trait obligations on `impl Trait`.
|
// Auto trait obligations on `impl Trait`.
|
||||||
if tcx.trait_has_default_impl(predicate.def_id()) {
|
if tcx.trait_has_default_impl(predicate.def_id()) {
|
||||||
let substs = predicate.skip_binder().trait_ref.substs;
|
let substs = predicate.skip_binder().trait_ref.substs;
|
||||||
if substs.types.as_slice().len() == 1 && substs.regions.is_empty() {
|
if substs.types.as_full_slice().len() == 1 && substs.regions.is_empty() {
|
||||||
if let ty::TyAnon(..) = predicate.skip_binder().self_ty().sty {
|
if let ty::TyAnon(..) = predicate.skip_binder().self_ty().sty {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,8 +209,8 @@ impl FlagComputation {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_substs(&mut self, substs: &subst::Substs) {
|
fn add_substs(&mut self, substs: &subst::Substs) {
|
||||||
self.add_tys(substs.types.as_slice());
|
self.add_tys(substs.types.as_full_slice());
|
||||||
for &r in &substs.regions {
|
for &r in substs.regions.as_full_slice() {
|
||||||
self.add_region(r);
|
self.add_region(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -971,7 +971,7 @@ impl<'tcx> TraitPredicate<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn input_types(&self) -> &[Ty<'tcx>] {
|
pub fn input_types(&self) -> &[Ty<'tcx>] {
|
||||||
self.trait_ref.substs.types.as_slice()
|
self.trait_ref.substs.types.as_full_slice()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn self_ty(&self) -> Ty<'tcx> {
|
pub fn self_ty(&self) -> Ty<'tcx> {
|
||||||
|
@ -1113,7 +1113,7 @@ impl<'tcx> Predicate<'tcx> {
|
||||||
pub fn walk_tys(&self) -> IntoIter<Ty<'tcx>> {
|
pub fn walk_tys(&self) -> IntoIter<Ty<'tcx>> {
|
||||||
let vec: Vec<_> = match *self {
|
let vec: Vec<_> = match *self {
|
||||||
ty::Predicate::Trait(ref data) => {
|
ty::Predicate::Trait(ref data) => {
|
||||||
data.0.trait_ref.substs.types.as_slice().to_vec()
|
data.0.trait_ref.substs.types.as_full_slice().to_vec()
|
||||||
}
|
}
|
||||||
ty::Predicate::Rfc1592(ref data) => {
|
ty::Predicate::Rfc1592(ref data) => {
|
||||||
return data.walk_tys()
|
return data.walk_tys()
|
||||||
|
@ -1128,7 +1128,8 @@ impl<'tcx> Predicate<'tcx> {
|
||||||
vec![]
|
vec![]
|
||||||
}
|
}
|
||||||
ty::Predicate::Projection(ref data) => {
|
ty::Predicate::Projection(ref data) => {
|
||||||
let trait_inputs = data.0.projection_ty.trait_ref.substs.types.as_slice();
|
let trait_inputs = data.0.projection_ty.trait_ref.substs
|
||||||
|
.types.as_full_slice();
|
||||||
trait_inputs.iter()
|
trait_inputs.iter()
|
||||||
.cloned()
|
.cloned()
|
||||||
.chain(Some(data.0.ty))
|
.chain(Some(data.0.ty))
|
||||||
|
@ -1220,7 +1221,7 @@ impl<'tcx> TraitRef<'tcx> {
|
||||||
// now this is all the types that appear in the
|
// now this is all the types that appear in the
|
||||||
// trait-reference, but it should eventually exclude
|
// trait-reference, but it should eventually exclude
|
||||||
// associated types.
|
// associated types.
|
||||||
self.substs.types.as_slice()
|
self.substs.types.as_full_slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2864,7 +2865,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
free_id_outlive: CodeExtent) -> Substs<'gcx> {
|
free_id_outlive: CodeExtent) -> Substs<'gcx> {
|
||||||
// map T => T
|
// map T => T
|
||||||
let mut types = VecPerParamSpace::empty();
|
let mut types = VecPerParamSpace::empty();
|
||||||
for def in generics.types.as_slice() {
|
for def in generics.types.as_full_slice() {
|
||||||
debug!("construct_parameter_environment(): push_types_from_defs: def={:?}",
|
debug!("construct_parameter_environment(): push_types_from_defs: def={:?}",
|
||||||
def);
|
def);
|
||||||
types.push(def.space, self.global_tcx().mk_param_from_def(def));
|
types.push(def.space, self.global_tcx().mk_param_from_def(def));
|
||||||
|
@ -2872,7 +2873,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
// map bound 'a => free 'a
|
// map bound 'a => free 'a
|
||||||
let mut regions = VecPerParamSpace::empty();
|
let mut regions = VecPerParamSpace::empty();
|
||||||
for def in generics.regions.as_slice() {
|
for def in generics.regions.as_full_slice() {
|
||||||
let region =
|
let region =
|
||||||
ReFree(FreeRegion { scope: free_id_outlive,
|
ReFree(FreeRegion { scope: free_id_outlive,
|
||||||
bound_region: def.to_bound_region() });
|
bound_region: def.to_bound_region() });
|
||||||
|
|
|
@ -433,7 +433,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for VecPerParamSpace<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
||||||
self.iter().any(|elem| elem.visit_with(visitor))
|
self.as_full_slice().iter().any(|elem| elem.visit_with(visitor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1211,19 +1211,19 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
||||||
TyTrait(ref obj) => {
|
TyTrait(ref obj) => {
|
||||||
let mut v = vec![obj.bounds.region_bound];
|
let mut v = vec![obj.bounds.region_bound];
|
||||||
v.extend_from_slice(obj.principal.skip_binder()
|
v.extend_from_slice(obj.principal.skip_binder()
|
||||||
.substs.regions.as_slice());
|
.substs.regions.as_full_slice());
|
||||||
v
|
v
|
||||||
}
|
}
|
||||||
TyEnum(_, substs) |
|
TyEnum(_, substs) |
|
||||||
TyStruct(_, substs) |
|
TyStruct(_, substs) |
|
||||||
TyAnon(_, substs) => {
|
TyAnon(_, substs) => {
|
||||||
substs.regions.as_slice().to_vec()
|
substs.regions.as_full_slice().to_vec()
|
||||||
}
|
}
|
||||||
TyClosure(_, ref substs) => {
|
TyClosure(_, ref substs) => {
|
||||||
substs.func_substs.regions.as_slice().to_vec()
|
substs.func_substs.regions.as_full_slice().to_vec()
|
||||||
}
|
}
|
||||||
TyProjection(ref data) => {
|
TyProjection(ref data) => {
|
||||||
data.trait_ref.substs.regions.as_slice().to_vec()
|
data.trait_ref.substs.regions.as_full_slice().to_vec()
|
||||||
}
|
}
|
||||||
TyFnDef(..) |
|
TyFnDef(..) |
|
||||||
TyFnPtr(_) |
|
TyFnPtr(_) |
|
||||||
|
|
|
@ -19,9 +19,6 @@ use ty::fold::{TypeFoldable, TypeFolder};
|
||||||
|
|
||||||
use serialize::{Encodable, Encoder, Decodable, Decoder};
|
use serialize::{Encodable, Encoder, Decodable, Decoder};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::iter::IntoIterator;
|
|
||||||
use std::slice::Iter;
|
|
||||||
use std::vec::{Vec, IntoIter};
|
|
||||||
use syntax_pos::{Span, DUMMY_SP};
|
use syntax_pos::{Span, DUMMY_SP};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -365,26 +362,14 @@ impl<T> VecPerParamSpace<T> {
|
||||||
&self.get_slice(space)[index]
|
&self.get_slice(space)[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter<'a>(&'a self) -> Iter<'a,T> {
|
|
||||||
self.content.iter()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn into_iter(self) -> IntoIter<T> {
|
|
||||||
self.content.into_iter()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iter_enumerated<'a>(&'a self) -> EnumeratedItems<'a,T> {
|
pub fn iter_enumerated<'a>(&'a self) -> EnumeratedItems<'a,T> {
|
||||||
EnumeratedItems::new(self)
|
EnumeratedItems::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_slice(&self) -> &[T] {
|
pub fn as_full_slice(&self) -> &[T] {
|
||||||
&self.content
|
&self.content
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_vec(self) -> Vec<T> {
|
|
||||||
self.content
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn all_vecs<P>(&self, mut pred: P) -> bool where
|
pub fn all_vecs<P>(&self, mut pred: P) -> bool where
|
||||||
P: FnMut(&[T]) -> bool,
|
P: FnMut(&[T]) -> bool,
|
||||||
{
|
{
|
||||||
|
@ -392,11 +377,11 @@ impl<T> VecPerParamSpace<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn all<P>(&self, pred: P) -> bool where P: FnMut(&T) -> bool {
|
pub fn all<P>(&self, pred: P) -> bool where P: FnMut(&T) -> bool {
|
||||||
self.iter().all(pred)
|
self.as_full_slice().iter().all(pred)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn any<P>(&self, pred: P) -> bool where P: FnMut(&T) -> bool {
|
pub fn any<P>(&self, pred: P) -> bool where P: FnMut(&T) -> bool {
|
||||||
self.iter().any(pred)
|
self.as_full_slice().iter().any(pred)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
|
@ -404,7 +389,7 @@ impl<T> VecPerParamSpace<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn map<U, P>(&self, pred: P) -> VecPerParamSpace<U> where P: FnMut(&T) -> U {
|
pub fn map<U, P>(&self, pred: P) -> VecPerParamSpace<U> where P: FnMut(&T) -> U {
|
||||||
let result = self.iter().map(pred).collect();
|
let result = self.as_full_slice().iter().map(pred).collect();
|
||||||
VecPerParamSpace::new_internal(result,
|
VecPerParamSpace::new_internal(result,
|
||||||
self.self_limit,
|
self.self_limit,
|
||||||
self.type_limit)
|
self.type_limit)
|
||||||
|
@ -478,29 +463,11 @@ impl<'a,T> Iterator for EnumeratedItems<'a,T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
let size = self.vec.as_slice().len();
|
let size = self.vec.as_full_slice().len();
|
||||||
(size, Some(size))
|
(size, Some(size))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> IntoIterator for VecPerParamSpace<T> {
|
|
||||||
type Item = T;
|
|
||||||
type IntoIter = IntoIter<T>;
|
|
||||||
|
|
||||||
fn into_iter(self) -> IntoIter<T> {
|
|
||||||
self.into_vec().into_iter()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a,T> IntoIterator for &'a VecPerParamSpace<T> {
|
|
||||||
type Item = &'a T;
|
|
||||||
type IntoIter = Iter<'a, T>;
|
|
||||||
|
|
||||||
fn into_iter(self) -> Iter<'a, T> {
|
|
||||||
self.as_slice().into_iter()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Public trait `Subst`
|
// Public trait `Subst`
|
||||||
|
|
|
@ -79,10 +79,10 @@ fn push_subtypes<'tcx>(stack: &mut Vec<Ty<'tcx>>, parent_ty: Ty<'tcx>) {
|
||||||
stack.push(mt.ty);
|
stack.push(mt.ty);
|
||||||
}
|
}
|
||||||
ty::TyProjection(ref data) => {
|
ty::TyProjection(ref data) => {
|
||||||
push_reversed(stack, data.trait_ref.substs.types.as_slice());
|
push_reversed(stack, data.trait_ref.substs.types.as_full_slice());
|
||||||
}
|
}
|
||||||
ty::TyTrait(box ty::TraitTy { ref principal, ref bounds }) => {
|
ty::TyTrait(box ty::TraitTy { ref principal, ref bounds }) => {
|
||||||
push_reversed(stack, principal.substs().types.as_slice());
|
push_reversed(stack, principal.substs().types.as_full_slice());
|
||||||
push_reversed(stack, &bounds.projection_bounds.iter().map(|pred| {
|
push_reversed(stack, &bounds.projection_bounds.iter().map(|pred| {
|
||||||
pred.0.ty
|
pred.0.ty
|
||||||
}).collect::<Vec<_>>());
|
}).collect::<Vec<_>>());
|
||||||
|
@ -90,17 +90,17 @@ fn push_subtypes<'tcx>(stack: &mut Vec<Ty<'tcx>>, parent_ty: Ty<'tcx>) {
|
||||||
ty::TyEnum(_, ref substs) |
|
ty::TyEnum(_, ref substs) |
|
||||||
ty::TyStruct(_, ref substs) |
|
ty::TyStruct(_, ref substs) |
|
||||||
ty::TyAnon(_, ref substs) => {
|
ty::TyAnon(_, ref substs) => {
|
||||||
push_reversed(stack, substs.types.as_slice());
|
push_reversed(stack, substs.types.as_full_slice());
|
||||||
}
|
}
|
||||||
ty::TyClosure(_, ref substs) => {
|
ty::TyClosure(_, ref substs) => {
|
||||||
push_reversed(stack, substs.func_substs.types.as_slice());
|
push_reversed(stack, substs.func_substs.types.as_full_slice());
|
||||||
push_reversed(stack, &substs.upvar_tys);
|
push_reversed(stack, &substs.upvar_tys);
|
||||||
}
|
}
|
||||||
ty::TyTuple(ref ts) => {
|
ty::TyTuple(ref ts) => {
|
||||||
push_reversed(stack, ts);
|
push_reversed(stack, ts);
|
||||||
}
|
}
|
||||||
ty::TyFnDef(_, substs, ref ft) => {
|
ty::TyFnDef(_, substs, ref ft) => {
|
||||||
push_reversed(stack, substs.types.as_slice());
|
push_reversed(stack, substs.types.as_full_slice());
|
||||||
push_sig_subtypes(stack, &ft.sig);
|
push_sig_subtypes(stack, &ft.sig);
|
||||||
}
|
}
|
||||||
ty::TyFnPtr(ref ft) => {
|
ty::TyFnPtr(ref ft) => {
|
||||||
|
|
|
@ -261,7 +261,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
|
||||||
let cause = self.cause(traits::MiscObligation);
|
let cause = self.cause(traits::MiscObligation);
|
||||||
self.out.extend(
|
self.out.extend(
|
||||||
trait_ref.substs.types
|
trait_ref.substs.types
|
||||||
.as_slice()
|
.as_full_slice()
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|ty| !ty.has_escaping_regions())
|
.filter(|ty| !ty.has_escaping_regions())
|
||||||
.map(|ty| traits::Obligation::new(cause.clone(),
|
.map(|ty| traits::Obligation::new(cause.clone(),
|
||||||
|
|
|
@ -515,7 +515,7 @@ fn encode_generics<'a, 'tcx>(rbml_w: &mut Encoder,
|
||||||
{
|
{
|
||||||
rbml_w.start_tag(tag);
|
rbml_w.start_tag(tag);
|
||||||
|
|
||||||
for param in &generics.types {
|
for param in generics.types.as_full_slice() {
|
||||||
rbml_w.start_tag(tag_type_param_def);
|
rbml_w.start_tag(tag_type_param_def);
|
||||||
tyencode::enc_type_param_def(rbml_w.writer, &ecx.ty_str_ctxt(), param);
|
tyencode::enc_type_param_def(rbml_w.writer, &ecx.ty_str_ctxt(), param);
|
||||||
rbml_w.mark_stable_position();
|
rbml_w.mark_stable_position();
|
||||||
|
@ -523,7 +523,7 @@ fn encode_generics<'a, 'tcx>(rbml_w: &mut Encoder,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Region parameters
|
// Region parameters
|
||||||
for param in &generics.regions {
|
for param in generics.regions.as_full_slice() {
|
||||||
rbml_w.start_tag(tag_region_param_def);
|
rbml_w.start_tag(tag_region_param_def);
|
||||||
tyencode::enc_region_param_def(rbml_w.writer, &ecx.ty_str_ctxt(), param);
|
tyencode::enc_region_param_def(rbml_w.writer, &ecx.ty_str_ctxt(), param);
|
||||||
rbml_w.mark_stable_position();
|
rbml_w.mark_stable_position();
|
||||||
|
|
|
@ -252,7 +252,7 @@ impl<'a, 'tcx> Instance<'tcx> {
|
||||||
// and should not matter anyhow.
|
// and should not matter anyhow.
|
||||||
let instance_ty = scx.tcx().erase_regions(&instance_ty.ty);
|
let instance_ty = scx.tcx().erase_regions(&instance_ty.ty);
|
||||||
|
|
||||||
let hash = get_symbol_hash(scx, &def_path, instance_ty, substs.types.as_slice());
|
let hash = get_symbol_hash(scx, &def_path, instance_ty, substs.types.as_full_slice());
|
||||||
|
|
||||||
let mut buffer = SymbolPathBuffer {
|
let mut buffer = SymbolPathBuffer {
|
||||||
names: Vec::with_capacity(def_path.data.len())
|
names: Vec::with_capacity(def_path.data.len())
|
||||||
|
|
|
@ -358,7 +358,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
name_to_append_suffix_to: &mut String)
|
name_to_append_suffix_to: &mut String)
|
||||||
-> DIArray
|
-> DIArray
|
||||||
{
|
{
|
||||||
let actual_types = param_substs.types.as_slice();
|
let actual_types = param_substs.types.as_full_slice();
|
||||||
|
|
||||||
if actual_types.is_empty() {
|
if actual_types.is_empty() {
|
||||||
return create_DIArray(DIB(cx), &[]);
|
return create_DIArray(DIB(cx), &[]);
|
||||||
|
@ -381,7 +381,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
|
|
||||||
// Again, only create type information if full debuginfo is enabled
|
// Again, only create type information if full debuginfo is enabled
|
||||||
let template_params: Vec<_> = if cx.sess().opts.debuginfo == FullDebugInfo {
|
let template_params: Vec<_> = if cx.sess().opts.debuginfo == FullDebugInfo {
|
||||||
generics.types.as_slice().iter().enumerate().map(|(i, param)| {
|
generics.types.as_full_slice().iter().enumerate().map(|(i, param)| {
|
||||||
let actual_type = cx.tcx().normalize_associated_type(&actual_types[i]);
|
let actual_type = cx.tcx().normalize_associated_type(&actual_types[i]);
|
||||||
let actual_type_metadata = type_metadata(cx, actual_type, syntax_pos::DUMMY_SP);
|
let actual_type_metadata = type_metadata(cx, actual_type, syntax_pos::DUMMY_SP);
|
||||||
let name = CString::new(param.name.as_str().as_bytes()).unwrap();
|
let name = CString::new(param.name.as_str().as_bytes()).unwrap();
|
||||||
|
|
|
@ -181,7 +181,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
|
|
||||||
output.push('<');
|
output.push('<');
|
||||||
|
|
||||||
for &type_parameter in &substs.types {
|
for &type_parameter in substs.types.as_full_slice() {
|
||||||
push_debuginfo_type_name(cx, type_parameter, true, output);
|
push_debuginfo_type_name(cx, type_parameter, true, output);
|
||||||
output.push_str(", ");
|
output.push_str(", ");
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,7 +181,7 @@ impl<'tcx> fmt::Display for Instance<'tcx> {
|
||||||
impl<'tcx> Instance<'tcx> {
|
impl<'tcx> Instance<'tcx> {
|
||||||
pub fn new(def_id: DefId, substs: &'tcx Substs<'tcx>)
|
pub fn new(def_id: DefId, substs: &'tcx Substs<'tcx>)
|
||||||
-> Instance<'tcx> {
|
-> Instance<'tcx> {
|
||||||
assert!(substs.regions.iter().all(|&r| r == ty::ReErased));
|
assert!(substs.regions.as_full_slice().iter().all(|&r| r == ty::ReErased));
|
||||||
Instance { def: def_id, substs: substs }
|
Instance { def: def_id, substs: substs }
|
||||||
}
|
}
|
||||||
pub fn mono<'a>(scx: &SharedCrateContext<'a, 'tcx>, def_id: DefId) -> Instance<'tcx> {
|
pub fn mono<'a>(scx: &SharedCrateContext<'a, 'tcx>, def_id: DefId) -> Instance<'tcx> {
|
||||||
|
|
|
@ -570,7 +570,7 @@ fn push_type_params<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
output.push('<');
|
output.push('<');
|
||||||
|
|
||||||
for &type_parameter in types {
|
for &type_parameter in types.as_full_slice() {
|
||||||
push_unique_type_name(tcx, type_parameter, output);
|
push_unique_type_name(tcx, type_parameter, output);
|
||||||
output.push_str(", ");
|
output.push_str(", ");
|
||||||
}
|
}
|
||||||
|
|
|
@ -888,7 +888,8 @@ fn check_on_unimplemented<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||||
// `{Self}` is allowed
|
// `{Self}` is allowed
|
||||||
Position::ArgumentNamed(s) if s == "Self" => (),
|
Position::ArgumentNamed(s) if s == "Self" => (),
|
||||||
// So is `{A}` if A is a type parameter
|
// So is `{A}` if A is a type parameter
|
||||||
Position::ArgumentNamed(s) => match types.iter().find(|t| {
|
Position::ArgumentNamed(s) => match types.as_full_slice()
|
||||||
|
.iter().find(|t| {
|
||||||
t.name.as_str() == s
|
t.name.as_str() == s
|
||||||
}) {
|
}) {
|
||||||
Some(_) => (),
|
Some(_) => (),
|
||||||
|
@ -1895,7 +1896,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
/// Registers obligations that all types appearing in `substs` are well-formed.
|
/// Registers obligations that all types appearing in `substs` are well-formed.
|
||||||
pub fn add_wf_bounds(&self, substs: &Substs<'tcx>, expr: &hir::Expr)
|
pub fn add_wf_bounds(&self, substs: &Substs<'tcx>, expr: &hir::Expr)
|
||||||
{
|
{
|
||||||
for &ty in &substs.types {
|
for &ty in substs.types.as_full_slice() {
|
||||||
self.register_wf_obligation(ty, expr.span, traits::MiscObligation);
|
self.register_wf_obligation(ty, expr.span, traits::MiscObligation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1445,11 +1445,11 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
let origin = infer::ParameterInScope(origin, expr_span);
|
let origin = infer::ParameterInScope(origin, expr_span);
|
||||||
|
|
||||||
for ®ion in &substs.regions {
|
for ®ion in substs.regions.as_full_slice() {
|
||||||
self.sub_regions(origin.clone(), expr_region, region);
|
self.sub_regions(origin.clone(), expr_region, region);
|
||||||
}
|
}
|
||||||
|
|
||||||
for &ty in &substs.types {
|
for &ty in substs.types.as_full_slice() {
|
||||||
let ty = self.resolve_type(ty);
|
let ty = self.resolve_type(ty);
|
||||||
self.type_must_outlive(origin.clone(), ty, expr_region);
|
self.type_must_outlive(origin.clone(), ty, expr_region);
|
||||||
}
|
}
|
||||||
|
@ -1571,18 +1571,15 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
|
||||||
// the problem is to add `T: 'r`, which isn't true. So, if there are no
|
// the problem is to add `T: 'r`, which isn't true. So, if there are no
|
||||||
// inference variables, we use a verify constraint instead of adding
|
// inference variables, we use a verify constraint instead of adding
|
||||||
// edges, which winds up enforcing the same condition.
|
// edges, which winds up enforcing the same condition.
|
||||||
let needs_infer = {
|
let needs_infer = projection_ty.trait_ref.needs_infer();
|
||||||
projection_ty.trait_ref.substs.types.iter().any(|t| t.needs_infer()) ||
|
|
||||||
projection_ty.trait_ref.substs.regions.iter().any(|r| r.needs_infer())
|
|
||||||
};
|
|
||||||
if env_bounds.is_empty() && needs_infer {
|
if env_bounds.is_empty() && needs_infer {
|
||||||
debug!("projection_must_outlive: no declared bounds");
|
debug!("projection_must_outlive: no declared bounds");
|
||||||
|
|
||||||
for &component_ty in &projection_ty.trait_ref.substs.types {
|
for &component_ty in projection_ty.trait_ref.substs.types.as_full_slice() {
|
||||||
self.type_must_outlive(origin.clone(), component_ty, region);
|
self.type_must_outlive(origin.clone(), component_ty, region);
|
||||||
}
|
}
|
||||||
|
|
||||||
for &r in &projection_ty.trait_ref.substs.regions {
|
for &r in projection_ty.trait_ref.substs.regions.as_full_slice() {
|
||||||
self.sub_regions(origin.clone(), region, r);
|
self.sub_regions(origin.clone(), region, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1600,7 +1597,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
|
||||||
if !env_bounds.is_empty() && env_bounds[1..].iter().all(|b| *b == env_bounds[0]) {
|
if !env_bounds.is_empty() && env_bounds[1..].iter().all(|b| *b == env_bounds[0]) {
|
||||||
let unique_bound = env_bounds[0];
|
let unique_bound = env_bounds[0];
|
||||||
debug!("projection_must_outlive: unique declared bound = {:?}", unique_bound);
|
debug!("projection_must_outlive: unique declared bound = {:?}", unique_bound);
|
||||||
if projection_ty.trait_ref.substs.regions
|
if projection_ty.trait_ref.substs.regions.as_full_slice()
|
||||||
.iter()
|
.iter()
|
||||||
.any(|r| env_bounds.contains(r))
|
.any(|r| env_bounds.contains(r))
|
||||||
{
|
{
|
||||||
|
|
|
@ -621,7 +621,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
// Trait impl: take implied bounds from all types that
|
// Trait impl: take implied bounds from all types that
|
||||||
// appear in the trait reference.
|
// appear in the trait reference.
|
||||||
let trait_ref = self.instantiate_type_scheme(span, free_substs, trait_ref);
|
let trait_ref = self.instantiate_type_scheme(span, free_substs, trait_ref);
|
||||||
trait_ref.substs.types.as_slice().to_vec()
|
trait_ref.substs.types.as_full_slice().to_vec()
|
||||||
}
|
}
|
||||||
|
|
||||||
None => {
|
None => {
|
||||||
|
|
|
@ -1550,7 +1550,7 @@ fn convert_typed_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||||
// Debugging aid.
|
// Debugging aid.
|
||||||
if tcx.has_attr(ccx.tcx.map.local_def_id(it.id), "rustc_object_lifetime_default") {
|
if tcx.has_attr(ccx.tcx.map.local_def_id(it.id), "rustc_object_lifetime_default") {
|
||||||
let object_lifetime_default_reprs: String =
|
let object_lifetime_default_reprs: String =
|
||||||
scheme.generics.types.iter()
|
scheme.generics.types.as_full_slice().iter()
|
||||||
.map(|t| match t.object_lifetime_default {
|
.map(|t| match t.object_lifetime_default {
|
||||||
ty::ObjectLifetimeDefault::Specific(r) => r.to_string(),
|
ty::ObjectLifetimeDefault::Specific(r) => r.to_string(),
|
||||||
d => format!("{:?}", d),
|
d => format!("{:?}", d),
|
||||||
|
|
|
@ -302,8 +302,8 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
||||||
self.add_constraints_from_substs(
|
self.add_constraints_from_substs(
|
||||||
generics,
|
generics,
|
||||||
trait_ref.def_id,
|
trait_ref.def_id,
|
||||||
trait_def.generics.types.as_slice(),
|
trait_def.generics.types.as_full_slice(),
|
||||||
trait_def.generics.regions.as_slice(),
|
trait_def.generics.regions.as_full_slice(),
|
||||||
trait_ref.substs,
|
trait_ref.substs,
|
||||||
variance);
|
variance);
|
||||||
}
|
}
|
||||||
|
@ -388,8 +388,8 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
||||||
self.add_constraints_from_substs(
|
self.add_constraints_from_substs(
|
||||||
generics,
|
generics,
|
||||||
trait_ref.def_id,
|
trait_ref.def_id,
|
||||||
trait_def.generics.types.as_slice(),
|
trait_def.generics.types.as_full_slice(),
|
||||||
trait_def.generics.regions.as_slice(),
|
trait_def.generics.regions.as_full_slice(),
|
||||||
trait_ref.substs,
|
trait_ref.substs,
|
||||||
variance);
|
variance);
|
||||||
}
|
}
|
||||||
|
|
|
@ -788,8 +788,9 @@ impl<'tcx> Clean<TyParamBound> for ty::TraitRef<'tcx> {
|
||||||
impl<'tcx> Clean<Option<Vec<TyParamBound>>> for subst::Substs<'tcx> {
|
impl<'tcx> Clean<Option<Vec<TyParamBound>>> for subst::Substs<'tcx> {
|
||||||
fn clean(&self, cx: &DocContext) -> Option<Vec<TyParamBound>> {
|
fn clean(&self, cx: &DocContext) -> Option<Vec<TyParamBound>> {
|
||||||
let mut v = Vec::new();
|
let mut v = Vec::new();
|
||||||
v.extend(self.regions.iter().filter_map(|r| r.clean(cx)).map(RegionBound));
|
v.extend(self.regions.as_full_slice().iter().filter_map(|r| r.clean(cx))
|
||||||
v.extend(self.types.iter().map(|t| TraitBound(PolyTrait {
|
.map(RegionBound));
|
||||||
|
v.extend(self.types.as_full_slice().iter().map(|t| TraitBound(PolyTrait {
|
||||||
trait_: t.clean(cx),
|
trait_: t.clean(cx),
|
||||||
lifetimes: vec![]
|
lifetimes: vec![]
|
||||||
}, hir::TraitBoundModifier::None)));
|
}, hir::TraitBoundModifier::None)));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue