Skip to content

Commit 0272854

Browse files
committed
libsyntax: Allow + to separate trait bounds from objects.
RFC #27. After a snapshot, the old syntax will be removed. This can break some code that looked like `foo as &Trait:Send`. Now you will need to write `foo as (&Trait+Send)`. Closes #12778. [breaking-change]
1 parent ceaeb66 commit 0272854

25 files changed

+179
-104
lines changed

src/librustc/middle/typeck/astconv.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
711711
.collect();
712712
ty::mk_tup(tcx, flds)
713713
}
714+
ast::TyParen(ref typ) => ast_ty_to_ty(this, rscope, &**typ),
714715
ast::TyBareFn(ref bf) => {
715716
if bf.decl.variadic && bf.abi != abi::C {
716717
tcx.sess.span_err(ast_ty.span,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,7 @@ impl<'a> Rebuilder<'a> {
11381138
}
11391139
ast::TyTup(new_tys)
11401140
}
1141+
ast::TyParen(ref typ) => ast::TyParen(build_to(*typ, to)),
11411142
ref other => other.clone()
11421143
};
11431144
box(GC) ast::Ty { id: from.id, node: new_node, span: from.span }

src/librustdoc/clean/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<T: Clean<U>, U> Clean<Vec<U>> for Vec<T> {
5353
}
5454
}
5555

56-
impl<T: Clean<U>, U> Clean<U> for Gc<T> {
56+
impl<T: 'static + Clean<U>, U> Clean<U> for Gc<T> {
5757
fn clean(&self) -> U {
5858
(**self).clean()
5959
}
@@ -1171,6 +1171,7 @@ impl Clean<Type> for ast::Ty {
11711171
TyClosure(ref c, region) => Closure(box c.clean(), region.clean()),
11721172
TyProc(ref c) => Proc(box c.clean()),
11731173
TyBareFn(ref barefn) => BareFunction(box barefn.clean()),
1174+
TyParen(ref ty) => ty.clean(),
11741175
TyBot => Bottom,
11751176
ref x => fail!("Unimplemented type {:?}", x),
11761177
}

src/libsyntax/ast.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,8 @@ pub enum Ty_ {
792792
TyUnboxedFn(Gc<UnboxedFnTy>),
793793
TyTup(Vec<P<Ty>> ),
794794
TyPath(Path, Option<OwnedSlice<TyParamBound>>, NodeId), // for #7264; see above
795+
// No-op; kept solely so that we can pretty-print faithfully
796+
TyParen(P<Ty>),
795797
TyTypeof(Gc<Expr>),
796798
// TyInfer means the type should be inferred instead of it having been
797799
// specified. This can appear anywhere in a type.

src/libsyntax/ast_util.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ pub fn get_inner_tys(ty: P<Ty>) -> Vec<P<Ty>> {
737737
| ast::TyUniq(ty)
738738
| ast::TyFixedLengthVec(ty, _) => vec!(ty),
739739
ast::TyTup(ref tys) => tys.clone(),
740+
ast::TyParen(ty) => get_inner_tys(ty),
740741
_ => Vec::new()
741742
}
742743
}

src/libsyntax/fold.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ pub trait Folder {
192192
})
193193
}
194194
TyTup(ref tys) => TyTup(tys.iter().map(|&ty| self.fold_ty(ty)).collect()),
195+
TyParen(ref ty) => TyParen(self.fold_ty(*ty)),
195196
TyPath(ref path, ref bounds, id) => {
196197
let id = self.new_id(id);
197198
TyPath(self.fold_path(path),

0 commit comments

Comments
 (0)