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 committed Jun 13, 2014
1 parent ceaeb66 commit 0272854
Show file tree
Hide file tree
Showing 25 changed files with 179 additions and 104 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 @@ -711,6 +711,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 @@ -1138,6 +1138,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 @@ -53,7 +53,7 @@ impl<T: Clean<U>, U> Clean<Vec<U>> for Vec<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 @@ -1171,6 +1171,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 @@ -792,6 +792,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

2 comments on commit 0272854

@pcwalton
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=alexcrichton

@alexcrichton
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors: retry

in case the rollup fails

Please sign in to comment.