Skip to content

Commit

Permalink
Rollup merge of #39877 - estebank:remove-params, r=petrochenkov
Browse files Browse the repository at this point in the history
Remove noop method `Substs::params()`

Re: 48b3dd1 & 7a8d482
  • Loading branch information
GuillaumeGomez authored Feb 16, 2017
2 parents a80192f + a7f63d1 commit c51e2be
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/librustc/traits/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2547,7 +2547,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
// TyError and ensure they do not affect any other fields.
// This could be checked after type collection for any struct
// with a potentially unsized trailing field.
let params = substs_a.params().iter().enumerate().map(|(i, &k)| {
let params = substs_a.iter().enumerate().map(|(i, &k)| {
if ty_params.contains(i) {
Kind::from(tcx.types.err)
} else {
Expand All @@ -2567,7 +2567,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {

// Check that the source structure with the target's
// type parameters is a subtype of the target.
let params = substs_a.params().iter().enumerate().map(|(i, &k)| {
let params = substs_a.iter().enumerate().map(|(i, &k)| {
if ty_params.contains(i) {
Kind::from(substs_b.type_at(i))
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/relate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ pub fn relate_substs<'a, 'gcx, 'tcx, R>(relation: &mut R,
{
let tcx = relation.tcx();

let params = a_subst.params().iter().zip(b_subst.params()).enumerate().map(|(i, (a, b))| {
let params = a_subst.iter().zip(b_subst).enumerate().map(|(i, (a, b))| {
let variance = variances.map_or(ty::Invariant, |v| v[i]);
if let (Some(a_ty), Some(b_ty)) = (a.as_type(), b.as_type()) {
Ok(Kind::from(relation.relate_with_variance(variance, &a_ty, &b_ty)?))
Expand Down
6 changes: 0 additions & 6 deletions src/librustc/ty/subst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,6 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
self.is_empty()
}

#[inline]
pub fn params(&self) -> &[Kind<'tcx>] {
// FIXME (dikaiosune) this should be removed, and corresponding compilation errors fixed
self
}

#[inline]
pub fn types(&'a self) -> impl DoubleEndedIterator<Item=Ty<'tcx>> + 'a {
self.iter().filter_map(|k| k.as_type())
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_typeck/check/method/confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,17 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
// parameters from the type and those from the method.
//
// FIXME -- permit users to manually specify lifetimes
let supplied_start = substs.params().len() + method_generics.regions.len();
let supplied_start = substs.len() + method_generics.regions.len();
Substs::for_item(self.tcx, pick.item.def_id, |def, _| {
let i = def.index as usize;
if i < substs.params().len() {
if i < substs.len() {
substs.region_at(i)
} else {
self.region_var_for_def(self.span, def)
}
}, |def, cur_substs| {
let i = def.index as usize;
if i < substs.params().len() {
if i < substs.len() {
substs.type_at(i)
} else if supplied_method_types.is_empty() {
self.type_var_for_def(self.span, def, cur_substs)
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/check/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
} else {
let substs = Substs::for_item(self.tcx, method, |def, _| {
let i = def.index as usize;
if i < substs.params().len() {
if i < substs.len() {
substs.region_at(i)
} else {
// In general, during probe we erase regions. See
Expand All @@ -1335,7 +1335,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
}
}, |def, cur_substs| {
let i = def.index as usize;
if i < substs.params().len() {
if i < substs.len() {
substs.type_at(i)
} else {
self.type_var_for_def(self.span, def, cur_substs)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {

let gcx = fcx.tcx.global_tcx();
let free_substs = fcx.parameter_environment.free_substs;
for (i, k) in free_substs.params().iter().enumerate() {
for (i, k) in free_substs.iter().enumerate() {
let r = if let Some(r) = k.as_region() {
r
} else {
Expand Down

0 comments on commit c51e2be

Please sign in to comment.