Skip to content

Commit

Permalink
Update message for !Sized types
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Jun 20, 2018
1 parent 76a4952 commit d4bfae1
Show file tree
Hide file tree
Showing 64 changed files with 209 additions and 207 deletions.
4 changes: 2 additions & 2 deletions src/libcore/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ impl<T: ?Sized> !Send for *mut T { }
#[stable(feature = "rust1", since = "1.0.0")]
#[lang = "sized"]
#[rustc_on_unimplemented(
message="`{Self}` does not have a constant size known at compile-time",
label="`{Self}` does not have a constant size known at compile-time",
message="the size for value values of type `{Self}` cannot be known at compilation time",
label="doesn't have a size known at compile-time",
note="to learn more, visit <https://doc.rust-lang.org/book/second-edition/\
ch19-04-advanced-types.html#dynamically-sized-types--sized>",
)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/associated-types-unsized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait Get {
}

fn foo<T:Get>(t: T) {
let x = t.get(); //~ ERROR `<T as Get>::Value` does not have a constant size known at
let x = t.get(); //~ ERROR the size for value values of type
}

fn main() {
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/bad-sized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ trait Trait {}
pub fn main() {
let x: Vec<Trait + Sized> = Vec::new();
//~^ ERROR only auto traits can be used as additional traits in a trait object
//~| ERROR `Trait` does not have a constant size known at compile-time
//~| ERROR `Trait` does not have a constant size known at compile-time
//~| ERROR the size for value values of type
//~| ERROR the size for value values of type
}
3 changes: 2 additions & 1 deletion src/test/compile-fail/dst-bad-assign-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ pub fn main() {
let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} };
let z: Box<ToBar> = Box::new(Bar1 {f: 36});
f5.ptr = *z;
//~^ ERROR `ToBar` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type

}
2 changes: 1 addition & 1 deletion src/test/compile-fail/dst-bad-assign-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ pub fn main() {
//~| expected type `ToBar`
//~| found type `Bar1`
//~| expected trait ToBar, found struct `Bar1`
//~| ERROR `ToBar` does not have a constant size known at compile-time
//~| ERROR the size for value values of type
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/dst-bad-assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ pub fn main() {
//~| expected type `ToBar`
//~| found type `Bar1`
//~| expected trait ToBar, found struct `Bar1`
//~| ERROR `ToBar` does not have a constant size known at compile-time
//~| ERROR the size for value values of type
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/dst-bad-deep-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ pub fn main() {
let f: ([isize; 3],) = ([5, 6, 7],);
let g: &([isize],) = &f;
let h: &(([isize],),) = &(*g,);
//~^ ERROR `[isize]` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/dst-bad-deep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ pub fn main() {
let f: Fat<[isize; 3]> = Fat { ptr: [5, 6, 7] };
let g: &Fat<[isize]> = &f;
let h: &Fat<Fat<[isize]>> = &Fat { ptr: *g };
//~^ ERROR `[isize]` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
}
8 changes: 4 additions & 4 deletions src/test/compile-fail/dst-object-from-unsized-type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ impl Foo for [u8] {}

fn test1<T: ?Sized + Foo>(t: &T) {
let u: &Foo = t;
//~^ ERROR `T` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
}

fn test2<T: ?Sized + Foo>(t: &T) {
let v: &Foo = t as &Foo;
//~^ ERROR `T` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
}

fn test3() {
let _: &[&Foo] = &["hi"];
//~^ ERROR `str` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
}

fn test4(x: &[u8]) {
let _: &Foo = x as &Foo;
//~^ ERROR `[u8]` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
}

fn main() { }
4 changes: 2 additions & 2 deletions src/test/compile-fail/dst-sized-trait-param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
trait Foo<T> : Sized { fn take(self, x: &T) { } } // Note: T is sized

impl Foo<[isize]> for usize { }
//~^ ERROR `[isize]` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type

impl Foo<isize> for [usize] { }
//~^ ERROR `[usize]` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type

pub fn main() { }
8 changes: 4 additions & 4 deletions src/test/compile-fail/extern-types-unsized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ fn assert_sized<T>() { }

fn main() {
assert_sized::<A>();
//~^ ERROR `A` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type

assert_sized::<Foo>();
//~^ ERROR `A` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type

assert_sized::<Bar<A>>();
//~^ ERROR `A` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type

assert_sized::<Bar<Bar<A>>>();
//~^ ERROR `A` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-14366.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@

fn main() {
let _x = "test" as &::std::any::Any;
//~^ ERROR `str` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-15756.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn dft_iter<'a, T>(arg1: Chunks<'a,T>, arg2: ChunksMut<'a,T>)
{
for
&mut something
//~^ ERROR `[T]` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
in arg2
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-17651.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@

fn main() {
(|| Box::new(*(&[0][..])))();
//~^ ERROR `[{integer}]` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-18107.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub trait AbstractRenderer {}

fn _create_render(_: &()) ->
AbstractRenderer
//~^ ERROR: `AbstractRenderer + 'static` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
{
match 0 {
_ => unimplemented!()
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-18919.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
type FuncType<'f> = Fn(&isize) -> isize + 'f;

fn ho_func(f: Option<FuncType>) {
//~^ ERROR: `for<'r> std::ops::Fn(&'r isize) -> isize` does not have a constant size known at
//~^ ERROR the size for value values of type
}

fn main() {}
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-20005.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ trait From<Src> {
}

trait To {
fn to<Dst>( //~ ERROR `Self` does not have a constant size known at compile-time
fn to<Dst>( //~ ERROR the size for value values of type
self
) -> <Dst as From<Self>>::Result where Dst: From<Self> {
From::from(self)
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-20433.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ struct The;

impl The {
fn iceman(c: Vec<[i32]>) {}
//~^ ERROR `[i32]` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-20605.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

fn changer<'a>(mut things: Box<Iterator<Item=&'a mut u8>>) {
for item in *things { *item = 0 }
//~^ ERROR `std::iter::Iterator<Item=&mut u8>` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
}

fn main() {}
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-22874.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

struct Table {
rows: [[String]],
//~^ ERROR `[std::string::String]` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
}

fn f(table: &Table) -> &[String] {
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-23281.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct Struct;

impl Struct {
pub fn function(funs: Vec<Fn() -> ()>) {}
//~^ ERROR `std::ops::Fn() + 'static` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
}

fn main() {}
4 changes: 2 additions & 2 deletions src/test/compile-fail/issue-24446.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

fn main() {
static foo: Fn() -> u32 = || -> u32 {
//~^ ERROR: mismatched types
//~| ERROR: `std::ops::Fn() -> u32 + 'static` does not have a constant size known at
//~^ ERROR mismatched types
//~| ERROR the size for value values of type
0
};
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-27060-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#[repr(packed)]
pub struct Bad<T: ?Sized> {
data: T, //~ ERROR `T` does not have a constant size known at compile-time
data: T, //~ ERROR the size for value values of type
}

fn main() {}
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-27078.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
trait Foo {
const BAR: i32;
fn foo(self) -> &'static i32 {
//~^ ERROR `Self` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
&<Self>::BAR
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-35988.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

enum E {
V([Box<E>]),
//~^ ERROR `[std::boxed::Box<E>]` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
}

fn main() {}
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-38954.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
// except according to those terms.

fn _test(ref _p: str) {}
//~^ ERROR `str` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type

fn main() { }
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-41229-ref-str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
// except according to those terms.

pub fn example(ref s: str) {}
//~^ ERROR `str` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type

fn main() {}
4 changes: 2 additions & 2 deletions src/test/compile-fail/issue-42312.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use std::ops::Deref;

pub trait Foo {
fn baz(_: Self::Target) where Self: Deref {}
//~^ ERROR `<Self as std::ops::Deref>::Target` does not have a constant size known at
//~^ ERROR the size for value values of type
}

pub fn f(_: ToString) {}
//~^ ERROR `std::string::ToString + 'static` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type

fn main() { }
4 changes: 2 additions & 2 deletions src/test/compile-fail/issue-5883.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ struct Struct {
}

fn new_struct(r: A+'static)
-> Struct { //~^ ERROR `A + 'static` does not have a constant size known at compile-time
//~^ ERROR `A + 'static` does not have a constant size known at compile-time
-> Struct { //~^ ERROR the size for value values of type
//~^ ERROR the size for value values of type
Struct { r: r }
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/range-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ pub fn main() {
// Unsized type.
let arr: &[_] = &[1, 2, 3];
let range = *arr..;
//~^ ERROR `[{integer}]` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
}
4 changes: 2 additions & 2 deletions src/test/compile-fail/str-mut-idx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ fn bot<T>() -> T { loop {} }

fn mutate(s: &mut str) {
s[1..2] = bot();
//~^ ERROR `str` does not have a constant size known at compile-time
//~| ERROR `str` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
//~| ERROR the size for value values of type
s[1usize] = bot();
//~^ ERROR the type `str` cannot be mutably indexed by `usize`
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/substs-ppaux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ fn foo<'z>() where &'z (): Sized {
//[normal]~| found type `fn() {foo::<'static>}`

<str as Foo<u8>>::bar;
//[verbose]~^ ERROR `str` does not have a constant size known at compile-time
//[normal]~^^ ERROR `str` does not have a constant size known at compile-time
//[verbose]~^ ERROR the size for value values of type
//[normal]~^^ ERROR the size for value values of type
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/trait-bounds-not-on-bare-trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ trait Foo {
// This should emit the less confusing error, not the more confusing one.

fn foo(_x: Foo + Send) {
//~^ ERROR `Foo + std::marker::Send + 'static` does not have a constant size known at
//~^ ERROR the size for value values of type
}

fn main() { }
5 changes: 3 additions & 2 deletions src/test/compile-fail/union/union-unsized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@

union U {
a: str,
//~^ ERROR `str` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type

b: u8,
}

union W {
a: u8,
b: str,
//~^ ERROR `str` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
}

fn main() {}
2 changes: 1 addition & 1 deletion src/test/compile-fail/unsized-bare-typaram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@

fn bar<T: Sized>() { }
fn foo<T: ?Sized>() { bar::<T>() }
//~^ ERROR `T` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
fn main() { }
2 changes: 1 addition & 1 deletion src/test/compile-fail/unsized-enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn not_sized<T: ?Sized>() { }
enum Foo<U> { FooSome(U), FooNone }
fn foo1<T>() { not_sized::<Foo<T>>() } // Hunky dory.
fn foo2<T: ?Sized>() { not_sized::<Foo<T>>() }
//~^ ERROR `T` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
//
// Not OK: `T` is not sized.

Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/unsized-inherent-impl-self-type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
struct S5<Y>(Y);

impl<X: ?Sized> S5<X> {
//~^ ERROR `X` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
}

fn main() { }
4 changes: 2 additions & 2 deletions src/test/compile-fail/unsized-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ fn not_sized<T: ?Sized>() { }
struct Foo<T> { data: T }
fn foo1<T>() { not_sized::<Foo<T>>() } // Hunky dory.
fn foo2<T: ?Sized>() { not_sized::<Foo<T>>() }
//~^ ERROR `T` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
//
// Not OK: `T` is not sized.

struct Bar<T: ?Sized> { data: T }
fn bar1<T: ?Sized>() { not_sized::<Bar<T>>() }
fn bar2<T: ?Sized>() { is_sized::<Bar<T>>() }
//~^ ERROR `T` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
//
// Not OK: `Bar<T>` is not sized, but it should be.

Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/unsized-trait-impl-self-type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait T3<Z: ?Sized> {
struct S5<Y>(Y);

impl<X: ?Sized> T3<X> for S5<X> {
//~^ ERROR `X` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
}

fn main() { }
2 changes: 1 addition & 1 deletion src/test/compile-fail/unsized-trait-impl-trait-arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ trait T2<Z> {
}
struct S4<Y: ?Sized>(Box<Y>);
impl<X: ?Sized> T2<X> for S4<X> {
//~^ ERROR `X` does not have a constant size known at compile-time
//~^ ERROR the size for value values of type
}

fn main() { }
Loading

0 comments on commit d4bfae1

Please sign in to comment.