Skip to content

Commit

Permalink
libsyntax: Allow + to separate trait bounds from objects.
Browse files Browse the repository at this point in the history
RFC rust-lang#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 rust-lang#12778.

[breaking-change]
  • Loading branch information
pcwalton authored and alexcrichton committed Jun 13, 2014
1 parent 03ec8e5 commit 9b9ef44
Show file tree
Hide file tree
Showing 24 changed files with 176 additions and 101 deletions.
1 change: 1 addition & 0 deletions src/librustc/middle/typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
.collect();
ty::mk_tup(tcx, flds)
}
ast::TyParen(ref typ) => ast_ty_to_ty(this, rscope, &**typ),
ast::TyBareFn(ref bf) => {
if bf.decl.variadic && bf.abi != abi::C {
tcx.sess.span_err(ast_ty.span,
Expand Down
1 change: 1 addition & 0 deletions src/librustc/middle/typeck/infer/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,7 @@ impl<'a> Rebuilder<'a> {
}
ast::TyTup(new_tys)
}
ast::TyParen(ref typ) => ast::TyParen(build_to(*typ, to)),
ref other => other.clone()
};
box(GC) ast::Ty { id: from.id, node: new_node, span: from.span }
Expand Down
3 changes: 2 additions & 1 deletion src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl<T: Clean<U>, U> Clean<VecPerParamSpace<U>> for VecPerParamSpace<T> {
}
}

impl<T: Clean<U>, U> Clean<U> for Gc<T> {
impl<T: 'static + Clean<U>, U> Clean<U> for Gc<T> {
fn clean(&self) -> U {
(**self).clean()
}
Expand Down Expand Up @@ -1198,6 +1198,7 @@ impl Clean<Type> for ast::Ty {
TyClosure(ref c, region) => Closure(box c.clean(), region.clean()),
TyProc(ref c) => Proc(box c.clean()),
TyBareFn(ref barefn) => BareFunction(box barefn.clean()),
TyParen(ref ty) => ty.clean(),
TyBot => Bottom,
ref x => fail!("Unimplemented type {:?}", x),
}
Expand Down
2 changes: 2 additions & 0 deletions src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,8 @@ pub enum Ty_ {
TyUnboxedFn(Gc<UnboxedFnTy>),
TyTup(Vec<P<Ty>> ),
TyPath(Path, Option<OwnedSlice<TyParamBound>>, NodeId), // for #7264; see above
// No-op; kept solely so that we can pretty-print faithfully
TyParen(P<Ty>),
TyTypeof(Gc<Expr>),
// TyInfer means the type should be inferred instead of it having been
// specified. This can appear anywhere in a type.
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/ast_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ pub fn get_inner_tys(ty: P<Ty>) -> Vec<P<Ty>> {
| ast::TyUniq(ty)
| ast::TyFixedLengthVec(ty, _) => vec!(ty),
ast::TyTup(ref tys) => tys.clone(),
ast::TyParen(ty) => get_inner_tys(ty),
_ => Vec::new()
}
}
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ pub trait Folder {
})
}
TyTup(ref tys) => TyTup(tys.iter().map(|&ty| self.fold_ty(ty)).collect()),
TyParen(ref ty) => TyParen(self.fold_ty(*ty)),
TyPath(ref path, ref bounds, id) => {
let id = self.new_id(id);
TyPath(self.fold_path(path),
Expand Down
Loading

0 comments on commit 9b9ef44

Please sign in to comment.