Skip to content

Commit a83733f

Browse files
committed
Flatten some occurrences of [P<T>] to [T]
1 parent 19f5e5e commit a83733f

File tree

4 files changed

+30
-21
lines changed

4 files changed

+30
-21
lines changed

src/librustc/hir/lowering.rs

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,11 @@ impl<'a> LoweringContext<'a> {
10491049
}
10501050
}
10511051

1052-
fn lower_ty(&mut self, t: &Ty, mut itctx: ImplTraitContext) -> P<hir::Ty> {
1052+
fn lower_ty(&mut self, t: &Ty, itctx: ImplTraitContext) -> P<hir::Ty> {
1053+
P(self.lower_ty_direct(t, itctx))
1054+
}
1055+
1056+
fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext) -> hir::Ty {
10531057
let kind = match t.node {
10541058
TyKind::Infer => hir::TyInfer,
10551059
TyKind::Err => hir::TyErr,
@@ -1086,10 +1090,15 @@ impl<'a> LoweringContext<'a> {
10861090
),
10871091
TyKind::Never => hir::TyNever,
10881092
TyKind::Tup(ref tys) => {
1089-
hir::TyTup(tys.iter().map(|ty| self.lower_ty(ty, itctx.reborrow())).collect())
1093+
hir::TyTup(
1094+
tys
1095+
.iter()
1096+
.map(|ty| self.lower_ty_direct(ty, itctx.reborrow()))
1097+
.collect()
1098+
)
10901099
}
10911100
TyKind::Paren(ref ty) => {
1092-
return self.lower_ty(ty, itctx);
1101+
return self.lower_ty_direct(ty, itctx);
10931102
}
10941103
TyKind::Path(ref qself, ref path) => {
10951104
let id = self.lower_node_id(t.id);
@@ -1270,12 +1279,12 @@ impl<'a> LoweringContext<'a> {
12701279
};
12711280

12721281
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(t.id);
1273-
P(hir::Ty {
1282+
hir::Ty {
12741283
id: node_id,
12751284
node: kind,
12761285
span: t.span,
12771286
hir_id,
1278-
})
1287+
}
12791288
}
12801289

12811290
fn generics_from_impl_trait_bounds(
@@ -1596,7 +1605,7 @@ impl<'a> LoweringContext<'a> {
15961605
// e.g. `Vec` in `Vec::new` or `<I as Iterator>::Item` in
15971606
// `<I as Iterator>::Item::default`.
15981607
let new_id = self.next_id();
1599-
self.ty_path(new_id, p.span, hir::QPath::Resolved(qself, path))
1608+
P(self.ty_path(new_id, p.span, hir::QPath::Resolved(qself, path)))
16001609
};
16011610

16021611
// Anything after the base path are associated "extensions",
@@ -1627,7 +1636,7 @@ impl<'a> LoweringContext<'a> {
16271636

16281637
// Wrap the associated extension in another type node.
16291638
let new_id = self.next_id();
1630-
ty = self.ty_path(new_id, p.span, qpath);
1639+
ty = P(self.ty_path(new_id, p.span, qpath));
16311640
}
16321641

16331642
// Should've returned in the for loop above.
@@ -1762,10 +1771,10 @@ impl<'a> LoweringContext<'a> {
17621771
|this| {
17631772
const DISALLOWED: ImplTraitContext = ImplTraitContext::Disallowed;
17641773
let &ParenthesisedArgs { ref inputs, ref output, span } = data;
1765-
let inputs = inputs.iter().map(|ty| this.lower_ty(ty, DISALLOWED)).collect();
1774+
let inputs = inputs.iter().map(|ty| this.lower_ty_direct(ty, DISALLOWED)).collect();
17661775
let mk_tup = |this: &mut Self, tys, span| {
17671776
let LoweredNodeId { node_id, hir_id } = this.next_id();
1768-
P(hir::Ty { node: hir::TyTup(tys), id: node_id, hir_id, span })
1777+
hir::Ty { node: hir::TyTup(tys), id: node_id, hir_id, span }
17691778
};
17701779

17711780
(
@@ -1778,7 +1787,7 @@ impl<'a> LoweringContext<'a> {
17781787
ty: output
17791788
.as_ref()
17801789
.map(|ty| this.lower_ty(&ty, DISALLOWED))
1781-
.unwrap_or_else(|| mk_tup(this, hir::HirVec::new(), span)),
1790+
.unwrap_or_else(|| P(mk_tup(this, hir::HirVec::new(), span))),
17821791
span: output.as_ref().map_or(span, |ty| ty.span),
17831792
}
17841793
],
@@ -1850,9 +1859,9 @@ impl<'a> LoweringContext<'a> {
18501859
.iter()
18511860
.map(|arg| {
18521861
if let Some((def_id, ibty, _)) = in_band_ty_params.as_mut() {
1853-
self.lower_ty(&arg.ty, ImplTraitContext::Universal(*def_id, ibty))
1862+
self.lower_ty_direct(&arg.ty, ImplTraitContext::Universal(*def_id, ibty))
18541863
} else {
1855-
self.lower_ty(&arg.ty, ImplTraitContext::Disallowed)
1864+
self.lower_ty_direct(&arg.ty, ImplTraitContext::Disallowed)
18561865
}
18571866
})
18581867
.collect(),
@@ -3302,7 +3311,7 @@ impl<'a> LoweringContext<'a> {
33023311
let e1 = self.lower_expr(e1);
33033312
let e2 = self.lower_expr(e2);
33043313
let ty_path = P(self.std_path(span, &["ops", "RangeInclusive"], false));
3305-
let ty = self.ty_path(id, span, hir::QPath::Resolved(None, ty_path));
3314+
let ty = P(self.ty_path(id, span, hir::QPath::Resolved(None, ty_path)));
33063315
let new_seg = P(hir::PathSegment::from_name(Symbol::intern("new")));
33073316
let new_path = hir::QPath::TypeRelative(ty, new_seg);
33083317
let new = P(self.expr(span, hir::ExprPath(new_path), ThinVec::new()));
@@ -4180,7 +4189,7 @@ impl<'a> LoweringContext<'a> {
41804189
.resolve_str_path(span, self.crate_root, components, is_value)
41814190
}
41824191

4183-
fn ty_path(&mut self, id: LoweredNodeId, span: Span, qpath: hir::QPath) -> P<hir::Ty> {
4192+
fn ty_path(&mut self, id: LoweredNodeId, span: Span, qpath: hir::QPath) -> hir::Ty {
41844193
let mut id = id;
41854194
let node = match qpath {
41864195
hir::QPath::Resolved(None, path) => {
@@ -4205,12 +4214,12 @@ impl<'a> LoweringContext<'a> {
42054214
}
42064215
_ => hir::TyPath(qpath),
42074216
};
4208-
P(hir::Ty {
4217+
hir::Ty {
42094218
id: id.node_id,
42104219
hir_id: id.hir_id,
42114220
node,
42124221
span,
4213-
})
4222+
}
42144223
}
42154224

42164225
/// Invoked to create the lifetime argument for a type `&T`

src/librustc/hir/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ impl GenericArgs {
412412
self.args.is_empty() && self.bindings.is_empty() && !self.parenthesized
413413
}
414414

415-
pub fn inputs(&self) -> &[P<Ty>] {
415+
pub fn inputs(&self) -> &[Ty] {
416416
if self.parenthesized {
417417
for arg in &self.args {
418418
match arg {
@@ -1660,7 +1660,7 @@ pub enum Ty_ {
16601660
/// The never type (`!`)
16611661
TyNever,
16621662
/// A tuple (`(A, B, C, D,...)`)
1663-
TyTup(HirVec<P<Ty>>),
1663+
TyTup(HirVec<Ty>),
16641664
/// A path to a type definition (`module::module::...::Type`), or an
16651665
/// associated type, e.g. `<Vec<T> as Trait>::Type` or `<T>::Target`.
16661666
///
@@ -1721,7 +1721,7 @@ pub struct Arg {
17211721
/// Represents the header (not the body) of a function declaration
17221722
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
17231723
pub struct FnDecl {
1724-
pub inputs: HirVec<P<Ty>>,
1724+
pub inputs: HirVec<Ty>,
17251725
pub output: FunctionRetTy,
17261726
pub variadic: bool,
17271727
/// True if this function has an `self`, `&self` or `&mut self` receiver

src/librustc/middle/resolve_lifetime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1789,7 +1789,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
17891789

17901790
fn visit_fn_like_elision(
17911791
&mut self,
1792-
inputs: &'tcx [P<hir::Ty>],
1792+
inputs: &'tcx [hir::Ty],
17931793
output: Option<&'tcx P<hir::Ty>>,
17941794
) {
17951795
debug!("visit_fn_like_elision: enter");

src/librustc/traits/error_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
964964
..
965965
}) => {
966966
(self.tcx.sess.codemap().def_span(span), decl.inputs.iter()
967-
.map(|arg| match arg.clone().into_inner().node {
967+
.map(|arg| match arg.clone().node {
968968
hir::TyTup(ref tys) => ArgKind::Tuple(
969969
Some(arg.span),
970970
tys.iter()

0 commit comments

Comments
 (0)