Skip to content

Commit 9b9ef44

Browse files
pcwaltonalexcrichton
authored andcommitted
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 03ec8e5 commit 9b9ef44

24 files changed

+176
-101
lines changed

src/librustc/middle/typeck/astconv.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
724724
.collect();
725725
ty::mk_tup(tcx, flds)
726726
}
727+
ast::TyParen(ref typ) => ast_ty_to_ty(this, rscope, &**typ),
727728
ast::TyBareFn(ref bf) => {
728729
if bf.decl.variadic && bf.abi != abi::C {
729730
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
@@ -1140,6 +1140,7 @@ impl<'a> Rebuilder<'a> {
11401140
}
11411141
ast::TyTup(new_tys)
11421142
}
1143+
ast::TyParen(ref typ) => ast::TyParen(build_to(*typ, to)),
11431144
ref other => other.clone()
11441145
};
11451146
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
@@ -60,7 +60,7 @@ impl<T: Clean<U>, U> Clean<VecPerParamSpace<U>> for VecPerParamSpace<T> {
6060
}
6161
}
6262

63-
impl<T: Clean<U>, U> Clean<U> for Gc<T> {
63+
impl<T: 'static + Clean<U>, U> Clean<U> for Gc<T> {
6464
fn clean(&self) -> U {
6565
(**self).clean()
6666
}
@@ -1198,6 +1198,7 @@ impl Clean<Type> for ast::Ty {
11981198
TyClosure(ref c, region) => Closure(box c.clean(), region.clean()),
11991199
TyProc(ref c) => Proc(box c.clean()),
12001200
TyBareFn(ref barefn) => BareFunction(box barefn.clean()),
1201+
TyParen(ref ty) => ty.clean(),
12011202
TyBot => Bottom,
12021203
ref x => fail!("Unimplemented type {:?}", x),
12031204
}

src/libsyntax/ast.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,8 @@ pub enum Ty_ {
784784
TyUnboxedFn(Gc<UnboxedFnTy>),
785785
TyTup(Vec<P<Ty>> ),
786786
TyPath(Path, Option<OwnedSlice<TyParamBound>>, NodeId), // for #7264; see above
787+
// No-op; kept solely so that we can pretty-print faithfully
788+
TyParen(P<Ty>),
787789
TyTypeof(Gc<Expr>),
788790
// TyInfer means the type should be inferred instead of it having been
789791
// 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)