Skip to content

Commit

Permalink
Advice to use Box<T> not ~T
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowone committed May 18, 2014
1 parent 3da5a5c commit 2ee0ca5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/librustc/middle/typeck/astconv.rs
Expand Up @@ -653,7 +653,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
tcx.sess.span_err(
ast_ty.span,
format!("reference to trait `{name}` where a type is expected; \
try `~{name}` or `&{name}`", name=path_str));
try `Box<{name}>` or `&{name}`", name=path_str));
ty::mk_err()
}
ast::DefTy(did) | ast::DefStruct(did) => {
Expand Down
6 changes: 3 additions & 3 deletions src/test/compile-fail/issue-5883.rs
Expand Up @@ -11,15 +11,15 @@
trait A {}

struct Struct {
r: A //~ ERROR reference to trait `A` where a type is expected; try `~A` or `&A`
r: A //~ ERROR reference to trait `A` where a type is expected; try `Box<A>` or `&A`
}

fn new_struct(r: A) -> Struct {
//~^ ERROR reference to trait `A` where a type is expected; try `~A` or `&A`
//~^ ERROR reference to trait `A` where a type is expected; try `Box<A>` or `&A`
Struct { r: r }
}

trait Curve {}
enum E {X(Curve)}
//~^ ERROR reference to trait `Curve` where a type is expected; try `~Curve` or `&Curve`
//~^ ERROR reference to trait `Curve` where a type is expected; try `Box<Curve>` or `&Curve`
fn main() {}
2 changes: 1 addition & 1 deletion src/test/compile-fail/trait-bounds-not-on-bare-trait.rs
Expand Up @@ -14,7 +14,7 @@ trait Foo {
// This should emit the less confusing error, not the more confusing one.

fn foo(_x: Foo:Send) {
//~^ERROR reference to trait `Foo` where a type is expected; try `~Foo` or `&Foo`
//~^ERROR reference to trait `Foo` where a type is expected; try `Box<Foo>` or `&Foo`
}

fn main() { }

5 comments on commit 2ee0ca5

@bors
Copy link
Contributor

@bors bors commented on 2ee0ca5 May 18, 2014

Choose a reason for hiding this comment

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

saw approval from thestinger
at youknowone@2ee0ca5

@bors
Copy link
Contributor

@bors bors commented on 2ee0ca5 May 18, 2014

Choose a reason for hiding this comment

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

merging youknowone/rust/advice-tilt-to-box = 2ee0ca5 into auto

@bors
Copy link
Contributor

@bors bors commented on 2ee0ca5 May 18, 2014

Choose a reason for hiding this comment

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

youknowone/rust/advice-tilt-to-box = 2ee0ca5 merged ok, testing candidate = 63287ee

@bors
Copy link
Contributor

@bors bors commented on 2ee0ca5 May 18, 2014

@bors
Copy link
Contributor

@bors bors commented on 2ee0ca5 May 18, 2014

Choose a reason for hiding this comment

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

fast-forwarding master to auto = 63287ee

Please sign in to comment.