Skip to content

Commit c0b1bb9

Browse files
committed
Rote changes due to the fact that ast paths no longer carry this extraneous bounds.
1 parent d61422b commit c0b1bb9

File tree

17 files changed

+60
-75
lines changed

17 files changed

+60
-75
lines changed

src/librustc/lint/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
421421
impl<'a, 'tcx, 'v> Visitor<'v> for ImproperCTypesVisitor<'a, 'tcx> {
422422
fn visit_ty(&mut self, ty: &ast::Ty) {
423423
match ty.node {
424-
ast::TyPath(_, _, id) => self.check_def(ty.span, ty.id, id),
424+
ast::TyPath(_, id) => self.check_def(ty.span, ty.id, id),
425425
_ => (),
426426
}
427427
visit::walk_ty(self, ty);

src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,10 +1230,9 @@ fn encode_info_for_item(ecx: &EncodeContext,
12301230
encode_name(rbml_w, item.ident.name);
12311231
encode_attributes(rbml_w, item.attrs.as_slice());
12321232
match ty.node {
1233-
ast::TyPath(ref path, ref bounds, _) if path.segments
1233+
ast::TyPath(ref path, _) if path.segments
12341234
.len() == 1 => {
12351235
let ident = path.segments.last().unwrap().identifier;
1236-
assert!(bounds.is_none());
12371236
encode_impl_type_basename(rbml_w, ident);
12381237
}
12391238
_ => {}

src/librustc/middle/privacy.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
243243
// * Private trait impls for private types can be completely ignored
244244
ast::ItemImpl(_, _, ref ty, ref impl_items) => {
245245
let public_ty = match ty.node {
246-
ast::TyPath(_, _, id) => {
246+
ast::TyPath(_, id) => {
247247
match self.tcx.def_map.borrow()[id].clone() {
248248
def::DefPrimTy(..) => true,
249249
def => {
@@ -311,7 +311,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
311311

312312
ast::ItemTy(ref ty, _) if public_first => {
313313
match ty.node {
314-
ast::TyPath(_, _, id) => {
314+
ast::TyPath(_, id) => {
315315
match self.tcx.def_map.borrow()[id].clone() {
316316
def::DefPrimTy(..) | def::DefTyParam(..) => {},
317317
def => {
@@ -616,7 +616,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
616616
// was private.
617617
ast::ItemImpl(_, _, ref ty, _) => {
618618
let id = match ty.node {
619-
ast::TyPath(_, _, id) => id,
619+
ast::TyPath(_, id) => id,
620620
_ => return Some((err_span, err_msg, None)),
621621
};
622622
let def = self.tcx.def_map.borrow()[id].clone();
@@ -1292,7 +1292,7 @@ impl<'a, 'tcx> VisiblePrivateTypesVisitor<'a, 'tcx> {
12921292
impl<'a, 'b, 'tcx, 'v> Visitor<'v> for CheckTypeForPrivatenessVisitor<'a, 'b, 'tcx> {
12931293
fn visit_ty(&mut self, ty: &ast::Ty) {
12941294
match ty.node {
1295-
ast::TyPath(_, _, path_id) => {
1295+
ast::TyPath(_, path_id) => {
12961296
if self.inner.path_is_private_type(path_id) {
12971297
self.contains_private = true;
12981298
// found what we're looking for so let's stop
@@ -1493,7 +1493,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
14931493

14941494
fn visit_ty(&mut self, t: &ast::Ty) {
14951495
match t.node {
1496-
ast::TyPath(ref p, _, path_id) => {
1496+
ast::TyPath(ref p, path_id) => {
14971497
if !self.tcx.sess.features.borrow().visible_private_types &&
14981498
self.path_is_private_type(path_id) {
14991499
self.tcx.sess.span_err(p.span,

src/librustc/middle/resolve.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ use syntax::ast::{PolyTraitRef, PrimTy, Public, SelfExplicit, SelfStatic};
6363
use syntax::ast::{RegionTyParamBound, StmtDecl, StructField};
6464
use syntax::ast::{StructVariantKind, TraitRef, TraitTyParamBound};
6565
use syntax::ast::{TupleVariantKind, Ty, TyBool, TyChar, TyClosure, TyF32};
66-
use syntax::ast::{TyF64, TyFloat, TyI, TyI8, TyI16, TyI32, TyI64, TyInt};
66+
use syntax::ast::{TyF64, TyFloat, TyI, TyI8, TyI16, TyI32, TyI64, TyInt, TyObjectSum};
6767
use syntax::ast::{TyParam, TyParamBound, TyPath, TyPtr, TyPolyTraitRef, TyProc, TyQPath};
6868
use syntax::ast::{TyRptr, TyStr, TyU, TyU8, TyU16, TyU32, TyU64, TyUint};
6969
use syntax::ast::{TypeImplItem, UnnamedField};
@@ -4742,7 +4742,7 @@ impl<'a> Resolver<'a> {
47424742
// type, the result will be that the type name resolves to a module but not
47434743
// a type (shadowing any imported modules or types with this name), leading
47444744
// to weird user-visible bugs. So we ward this off here. See #15060.
4745-
TyPath(ref path, _, path_id) => {
4745+
TyPath(ref path, path_id) => {
47464746
match self.def_map.borrow().get(&path_id) {
47474747
// FIXME: should we catch other options and give more precise errors?
47484748
Some(&DefMod(_)) => {
@@ -4908,7 +4908,7 @@ impl<'a> Resolver<'a> {
49084908
// Like path expressions, the interpretation of path types depends
49094909
// on whether the path has multiple elements in it or not.
49104910

4911-
TyPath(ref path, ref bounds, path_id) => {
4911+
TyPath(ref path, path_id) => {
49124912
// This is a path in the type namespace. Walk through scopes
49134913
// looking for it.
49144914
let mut result_def = None;
@@ -4978,11 +4978,12 @@ impl<'a> Resolver<'a> {
49784978
self.resolve_error(ty.span, msg.as_slice());
49794979
}
49804980
}
4981+
}
49814982

4982-
bounds.as_ref().map(|bound_vec| {
4983-
self.resolve_type_parameter_bounds(ty.id, bound_vec,
4983+
TyObjectSum(ref ty, ref bound_vec) => {
4984+
self.resolve_type(&**ty);
4985+
self.resolve_type_parameter_bounds(ty.id, bound_vec,
49844986
TraitBoundingTypeParameter);
4985-
});
49864987
}
49874988

49884989
TyQPath(ref qpath) => {
@@ -5619,7 +5620,7 @@ impl<'a> Resolver<'a> {
56195620
fn extract_path_and_node_id(t: &Ty, allow: FallbackChecks)
56205621
-> Option<(Path, NodeId, FallbackChecks)> {
56215622
match t.node {
5622-
TyPath(ref path, _, node_id) => Some((path.clone(), node_id, allow)),
5623+
TyPath(ref path, node_id) => Some((path.clone(), node_id, allow)),
56235624
TyPtr(ref mut_ty) => extract_path_and_node_id(&*mut_ty.ty, OnlyTraitAndStatics),
56245625
TyRptr(_, ref mut_ty) => extract_path_and_node_id(&*mut_ty.ty, allow),
56255626
// This doesn't handle the remaining `Ty` variants as they are not

src/librustc/middle/resolve_lifetime.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,21 +162,14 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
162162
visit::walk_ty(this, ty);
163163
});
164164
}
165-
ast::TyPath(ref path, ref opt_bounds, id) => {
165+
ast::TyPath(ref path, id) => {
166166
// if this path references a trait, then this will resolve to
167167
// a trait ref, which introduces a binding scope.
168168
match self.def_map.borrow().get(&id) {
169169
Some(&def::DefTrait(..)) => {
170170
self.with(LateScope(&Vec::new(), self.scope), |this| {
171171
this.visit_path(path, id);
172172
});
173-
174-
match *opt_bounds {
175-
Some(ref bounds) => {
176-
visit::walk_ty_param_bounds_helper(self, bounds);
177-
}
178-
None => { }
179-
}
180173
}
181174
_ => {
182175
visit::walk_ty(self, ty);

src/librustc/middle/typeck/infer/error_reporting.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
12491249
}
12501250
ty_queue.push(&*mut_ty.ty);
12511251
}
1252-
ast::TyPath(ref path, ref bounds, id) => {
1252+
ast::TyPath(ref path, id) => {
12531253
let a_def = match self.tcx.def_map.borrow().get(&id) {
12541254
None => {
12551255
self.tcx
@@ -1296,7 +1296,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
12961296
let new_path = self.rebuild_path(rebuild_info, lifetime);
12971297
let to = ast::Ty {
12981298
id: cur_ty.id,
1299-
node: ast::TyPath(new_path, bounds.clone(), id),
1299+
node: ast::TyPath(new_path, id),
13001300
span: cur_ty.span
13011301
};
13021302
new_ty = self.rebuild_ty(new_ty, P(to));

src/librustc_trans/save/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
651651
typ: &ast::Ty,
652652
impl_items: &Vec<ast::ImplItem>) {
653653
match typ.node {
654-
ast::TyPath(ref path, _, id) => {
654+
ast::TyPath(ref path, id) => {
655655
match self.lookup_type_ref(id) {
656656
Some(id) => {
657657
let sub_span = self.span.sub_span_for_type_name(path.span);
@@ -1256,7 +1256,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
12561256
}
12571257

12581258
match t.node {
1259-
ast::TyPath(ref path, _, id) => {
1259+
ast::TyPath(ref path, id) => {
12601260
match self.lookup_type_ref(id) {
12611261
Some(id) => {
12621262
let sub_span = self.span.sub_span_for_type_name(t.span);

src/libsyntax/ast_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ impl<'a, 'v, O: IdVisitingOperation> Visitor<'v> for IdVisitor<'a, O> {
454454
fn visit_ty(&mut self, typ: &Ty) {
455455
self.operation.visit_id(typ.id);
456456
match typ.node {
457-
TyPath(_, _, id) => self.operation.visit_id(id),
457+
TyPath(_, id) => self.operation.visit_id(id),
458458
_ => {}
459459
}
460460
visit::walk_ty(self, typ)

src/libsyntax/ext/build.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ pub trait AstBuilder {
4444
fn ty_mt(&self, ty: P<ast::Ty>, mutbl: ast::Mutability) -> ast::MutTy;
4545

4646
fn ty(&self, span: Span, ty: ast::Ty_) -> P<ast::Ty>;
47-
fn ty_path(&self, ast::Path, Option<OwnedSlice<ast::TyParamBound>>) -> P<ast::Ty>;
47+
fn ty_path(&self, ast::Path) -> P<ast::Ty>;
48+
fn ty_sum(&self, ast::Path, OwnedSlice<ast::TyParamBound>) -> P<ast::Ty>;
4849
fn ty_ident(&self, span: Span, idents: ast::Ident) -> P<ast::Ty>;
4950

5051
fn ty_rptr(&self, span: Span,
@@ -344,17 +345,21 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
344345
})
345346
}
346347

347-
fn ty_path(&self, path: ast::Path, bounds: Option<OwnedSlice<ast::TyParamBound>>)
348-
-> P<ast::Ty> {
348+
fn ty_path(&self, path: ast::Path) -> P<ast::Ty> {
349+
self.ty(path.span, ast::TyPath(path, ast::DUMMY_NODE_ID))
350+
}
351+
352+
fn ty_sum(&self, path: ast::Path, bounds: OwnedSlice<ast::TyParamBound>) -> P<ast::Ty> {
349353
self.ty(path.span,
350-
ast::TyPath(path, bounds, ast::DUMMY_NODE_ID))
354+
ast::TyObjectSum(self.ty_path(path),
355+
bounds))
351356
}
352357

353358
// Might need to take bounds as an argument in the future, if you ever want
354359
// to generate a bounded existential trait type.
355360
fn ty_ident(&self, span: Span, ident: ast::Ident)
356361
-> P<ast::Ty> {
357-
self.ty_path(self.path_ident(span, ident), None)
362+
self.ty_path(self.path_ident(span, ident))
358363
}
359364

360365
fn ty_rptr(&self,
@@ -386,7 +391,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
386391
self.ident_of("Option")
387392
),
388393
Vec::new(),
389-
vec!( ty )), None)
394+
vec!( ty )))
390395
}
391396

392397
fn ty_field_imm(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> ast::TypeField {
@@ -425,8 +430,10 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
425430
}
426431

427432
fn ty_vars_global(&self, ty_params: &OwnedSlice<ast::TyParam>) -> Vec<P<ast::Ty>> {
428-
ty_params.iter().map(|p| self.ty_path(
429-
self.path_global(DUMMY_SP, vec!(p.ident)), None)).collect()
433+
ty_params
434+
.iter()
435+
.map(|p| self.ty_path(self.path_global(DUMMY_SP, vec!(p.ident))))
436+
.collect()
430437
}
431438

432439
fn trait_ref(&self, path: ast::Path) -> ast::TraitRef {

src/libsyntax/ext/deriving/generic/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ impl<'a> TraitDef<'a> {
444444
// Create the type of `self`.
445445
let self_type = cx.ty_path(
446446
cx.path_all(self.span, false, vec!( type_ident ), self_lifetimes,
447-
self_ty_params.into_vec()), None);
447+
self_ty_params.into_vec()));
448448

449449
let attr = cx.attribute(
450450
self.span,

src/libsyntax/ext/deriving/generic/ty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl<'a> Path<'a> {
7070
self_ty: Ident,
7171
self_generics: &Generics)
7272
-> P<ast::Ty> {
73-
cx.ty_path(self.to_path(cx, span, self_ty, self_generics), None)
73+
cx.ty_path(self.to_path(cx, span, self_ty, self_generics))
7474
}
7575
pub fn to_path(&self,
7676
cx: &ExtCtxt,
@@ -152,7 +152,7 @@ impl<'a> Ty<'a> {
152152
}
153153
Literal(ref p) => { p.to_ty(cx, span, self_ty, self_generics) }
154154
Self => {
155-
cx.ty_path(self.to_path(cx, span, self_ty, self_generics), None)
155+
cx.ty_path(self.to_path(cx, span, self_ty, self_generics))
156156
}
157157
Tuple(ref fields) => {
158158
let ty = ast::TyTup(fields.iter()

src/libsyntax/ext/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ impl<'a, 'b> Context<'a, 'b> {
531531
true, Context::rtpath(self.ecx, "Argument"),
532532
vec![static_lifetime],
533533
vec![]
534-
), None);
534+
));
535535
lets.push(Context::item_static_array(self.ecx,
536536
static_args_name,
537537
piece_ty,

src/libsyntax/ext/tt/macro_parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ pub fn parse_nt(p: &mut Parser, name: &str) -> Nonterminal {
514514
"stmt" => token::NtStmt(p.parse_stmt(Vec::new())),
515515
"pat" => token::NtPat(p.parse_pat()),
516516
"expr" => token::NtExpr(p.parse_expr()),
517-
"ty" => token::NtTy(p.parse_ty(false /* no need to disambiguate*/)),
517+
"ty" => token::NtTy(p.parse_ty()),
518518
// this could be handled like a token, since it is one
519519
"ident" => match p.token {
520520
token::Ident(sn,b) => { p.bump(); token::NtIdent(box sn,b) }
@@ -525,7 +525,7 @@ pub fn parse_nt(p: &mut Parser, name: &str) -> Nonterminal {
525525
}
526526
},
527527
"path" => {
528-
token::NtPath(box p.parse_path(LifetimeAndTypesWithoutColons).path)
528+
token::NtPath(box p.parse_path(LifetimeAndTypesWithoutColons))
529529
}
530530
"meta" => token::NtMeta(p.parse_meta_item()),
531531
"tt" => {

src/libsyntax/fold.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,11 +433,13 @@ pub fn noop_fold_ty<T: Folder>(t: P<Ty>, fld: &mut T) -> P<Ty> {
433433
}
434434
TyTup(tys) => TyTup(tys.move_map(|ty| fld.fold_ty(ty))),
435435
TyParen(ty) => TyParen(fld.fold_ty(ty)),
436-
TyPath(path, bounds, id) => {
436+
TyPath(path, id) => {
437437
let id = fld.new_id(id);
438-
TyPath(fld.fold_path(path),
439-
fld.fold_opt_bounds(bounds),
440-
id)
438+
TyPath(fld.fold_path(path), id)
439+
}
440+
TyObjectSum(ty, bounds) => {
441+
TyObjectSum(fld.fold_ty(ty),
442+
fld.fold_bounds(bounds))
441443
}
442444
TyQPath(qpath) => {
443445
TyQPath(fld.fold_qpath(qpath))

src/libsyntax/print/pprust.rs

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,11 +1916,11 @@ impl<'a> State<'a> {
19161916
self.print_expr(coll)
19171917
}
19181918

1919-
fn print_path_(&mut self,
1920-
path: &ast::Path,
1921-
colons_before_params: bool,
1922-
opt_bounds: &Option<OwnedSlice<ast::TyParamBound>>)
1923-
-> IoResult<()> {
1919+
fn print_path(&mut self,
1920+
path: &ast::Path,
1921+
colons_before_params: bool)
1922+
-> IoResult<()>
1923+
{
19241924
try!(self.maybe_print_comment(path.span.lo));
19251925
if path.global {
19261926
try!(word(&mut self.s, "::"));
@@ -1939,10 +1939,7 @@ impl<'a> State<'a> {
19391939
try!(self.print_path_parameters(&segment.parameters, colons_before_params));
19401940
}
19411941

1942-
match *opt_bounds {
1943-
None => Ok(()),
1944-
Some(ref bounds) => self.print_bounds("+", bounds)
1945-
}
1942+
Ok(())
19461943
}
19471944

19481945
fn print_path_parameters(&mut self,
@@ -2005,17 +2002,6 @@ impl<'a> State<'a> {
20052002
Ok(())
20062003
}
20072004

2008-
fn print_path(&mut self, path: &ast::Path,
2009-
colons_before_params: bool) -> IoResult<()> {
2010-
self.print_path_(path, colons_before_params, &None)
2011-
}
2012-
2013-
fn print_bounded_path(&mut self, path: &ast::Path,
2014-
bounds: &Option<OwnedSlice<ast::TyParamBound>>)
2015-
-> IoResult<()> {
2016-
self.print_path_(path, false, bounds)
2017-
}
2018-
20192005
pub fn print_pat(&mut self, pat: &ast::Pat) -> IoResult<()> {
20202006
try!(self.maybe_print_comment(pat.span.lo));
20212007
try!(self.ann.pre(self, NodePat(pat)));

src/libsyntax/test.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,7 @@ fn mk_tests(cx: &TestCtxt) -> P<ast::Item> {
482482
let ecx = &cx.ext_cx;
483483
let struct_type = ecx.ty_path(ecx.path(sp, vec![ecx.ident_of("self"),
484484
ecx.ident_of("test"),
485-
ecx.ident_of("TestDescAndFn")]),
486-
None);
485+
ecx.ident_of("TestDescAndFn")]));
487486
let static_lt = ecx.lifetime(sp, token::special_idents::static_lifetime.name);
488487
// &'static [self::test::TestDescAndFn]
489488
let static_type = ecx.ty_rptr(sp,

src/libsyntax/visit.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -404,14 +404,12 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
404404
walk_fn_ret_ty(visitor, &function_declaration.decl.output);
405405
walk_lifetime_decls_helper(visitor, &function_declaration.lifetimes);
406406
}
407-
TyPath(ref path, ref opt_bounds, id) => {
407+
TyPath(ref path, id) => {
408408
visitor.visit_path(path, id);
409-
match *opt_bounds {
410-
Some(ref bounds) => {
411-
walk_ty_param_bounds_helper(visitor, bounds);
412-
}
413-
None => { }
414-
}
409+
}
410+
TyObjectSum(ref ty, ref bounds) => {
411+
visitor.visit_ty(&**ty);
412+
walk_ty_param_bounds_helper(visitor, bounds);
415413
}
416414
TyQPath(ref qpath) => {
417415
visitor.visit_ty(&*qpath.self_type);

0 commit comments

Comments
 (0)