Skip to content

Commit f1dee43

Browse files
committed
Add link to book for Sized errors
1 parent 776544f commit f1dee43

File tree

11 files changed

+44
-1
lines changed

11 files changed

+44
-1
lines changed

src/libcore/marker.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ impl<T: ?Sized> !Send for *mut T { }
9393
#[lang = "sized"]
9494
#[rustc_on_unimplemented(
9595
message="`{Self}` does not have a constant size known at compile-time",
96-
label="`{Self}` does not have a constant size known at compile-time"
96+
label="`{Self}` does not have a constant size known at compile-time",
97+
note="to learn more, visit <https://doc.rust-lang.org/book/second-edition/\
98+
ch19-04-advanced-types.html#dynamically-sized-types--sized>",
9799
)]
98100
#[fundamental] // for Default, for example, which requires that `[T]: !Default` be evaluatable
99101
pub trait Sized {

src/test/ui/const-unsized.stderr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | const CONST_0: Debug+Sync = *(&0 as &(Debug+Sync));
55
| ^^^^^^^^^^^^^^^^^^^^^^ `std::fmt::Debug + std::marker::Sync + 'static` does not have a constant size known at compile-time
66
|
77
= help: the trait `std::marker::Sized` is not implemented for `std::fmt::Debug + std::marker::Sync + 'static`
8+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
89
= note: constant expressions must have a statically known size
910

1011
error[E0277]: `str` does not have a constant size known at compile-time
@@ -14,6 +15,7 @@ LL | const CONST_FOO: str = *"foo";
1415
| ^^^^^^ `str` does not have a constant size known at compile-time
1516
|
1617
= help: the trait `std::marker::Sized` is not implemented for `str`
18+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
1719
= note: constant expressions must have a statically known size
1820

1921
error[E0277]: `std::fmt::Debug + std::marker::Sync + 'static` does not have a constant size known at compile-time
@@ -23,6 +25,7 @@ LL | static STATIC_1: Debug+Sync = *(&1 as &(Debug+Sync));
2325
| ^^^^^^^^^^^^^^^^^^^^^^ `std::fmt::Debug + std::marker::Sync + 'static` does not have a constant size known at compile-time
2426
|
2527
= help: the trait `std::marker::Sized` is not implemented for `std::fmt::Debug + std::marker::Sync + 'static`
28+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
2629
= note: constant expressions must have a statically known size
2730

2831
error[E0277]: `str` does not have a constant size known at compile-time
@@ -32,6 +35,7 @@ LL | static STATIC_BAR: str = *"bar";
3235
| ^^^^^^ `str` does not have a constant size known at compile-time
3336
|
3437
= help: the trait `std::marker::Sized` is not implemented for `str`
38+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
3539
= note: constant expressions must have a statically known size
3640

3741
error: aborting due to 4 previous errors

src/test/ui/error-codes/E0277.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | fn f(p: Path) { }
55
| ^ `[u8]` does not have a constant size known at compile-time
66
|
77
= help: within `std::path::Path`, the trait `std::marker::Sized` is not implemented for `[u8]`
8+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
89
= note: required because it appears within the type `std::path::Path`
910
= note: all local variables must have a statically known size
1011

src/test/ui/feature-gate-trivial_bounds.stderr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ LL | struct TwoStrs(str, str) where str: Sized; //~ ERROR
9494
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `str` does not have a constant size known at compile-time
9595
|
9696
= help: the trait `std::marker::Sized` is not implemented for `str`
97+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
9798
= help: see issue #48214
9899
= help: add #![feature(trivial_bounds)] to the crate attributes to enable
99100

@@ -106,6 +107,7 @@ LL | | }
106107
| |_^ `A + 'static` does not have a constant size known at compile-time
107108
|
108109
= help: within `Dst<A + 'static>`, the trait `std::marker::Sized` is not implemented for `A + 'static`
110+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
109111
= note: required because it appears within the type `Dst<A + 'static>`
110112
= help: see issue #48214
111113
= help: add #![feature(trivial_bounds)] to the crate attributes to enable
@@ -119,6 +121,7 @@ LL | | }
119121
| |_^ `str` does not have a constant size known at compile-time
120122
|
121123
= help: the trait `std::marker::Sized` is not implemented for `str`
124+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
122125
= help: see issue #48214
123126
= help: add #![feature(trivial_bounds)] to the crate attributes to enable
124127

src/test/ui/generator/sized-yield.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ LL | | };
99
| |____^ `str` does not have a constant size known at compile-time
1010
|
1111
= help: the trait `std::marker::Sized` is not implemented for `str`
12+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
1213
= note: the yield type of a generator must have a statically known size
1314

1415
error[E0277]: `str` does not have a constant size known at compile-time
@@ -18,6 +19,7 @@ LL | unsafe { gen.resume(); }
1819
| ^^^^^^ `str` does not have a constant size known at compile-time
1920
|
2021
= help: the trait `std::marker::Sized` is not implemented for `str`
22+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
2123

2224
error: aborting due to 2 previous errors
2325

src/test/ui/mismatched_types/cast-rfc0401.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ LL | let _ = fat_v as *const Foo; //~ ERROR `[u8]` does not have a constant
223223
| ^^^^^ `[u8]` does not have a constant size known at compile-time
224224
|
225225
= help: the trait `std::marker::Sized` is not implemented for `[u8]`
226+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
226227
= note: required for the cast to the object type `Foo`
227228

228229
error[E0277]: `str` does not have a constant size known at compile-time
@@ -232,6 +233,7 @@ LL | let _ = a as *const Foo; //~ ERROR `str` does not have a constant size
232233
| ^ `str` does not have a constant size known at compile-time
233234
|
234235
= help: the trait `std::marker::Sized` is not implemented for `str`
236+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
235237
= note: required for the cast to the object type `Foo`
236238

237239
error[E0606]: casting `&{float}` as `f32` is invalid

src/test/ui/resolve/issue-5035-2.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | fn foo(_x: K) {}
55
| ^^ `I + 'static` does not have a constant size known at compile-time
66
|
77
= help: the trait `std::marker::Sized` is not implemented for `I + 'static`
8+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
89
= note: all local variables must have a statically known size
910

1011
error: aborting due to previous error

src/test/ui/suggestions/str-array-assignment.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ LL | let v = s[..2];
2828
| `str` does not have a constant size known at compile-time
2929
|
3030
= help: the trait `std::marker::Sized` is not implemented for `str`
31+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
3132
= note: all local variables must have a statically known size
3233

3334
error[E0308]: mismatched types

src/test/ui/trait-suggest-where-clause.stderr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | mem::size_of::<U>();
55
| ^^^^^^^^^^^^^^^^^ `U` does not have a constant size known at compile-time
66
|
77
= help: the trait `std::marker::Sized` is not implemented for `U`
8+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
89
= help: consider adding a `where U: std::marker::Sized` bound
910
= note: required by `std::mem::size_of`
1011

@@ -15,6 +16,7 @@ LL | mem::size_of::<Misc<U>>();
1516
| ^^^^^^^^^^^^^^^^^^^^^^^ `U` does not have a constant size known at compile-time
1617
|
1718
= help: within `Misc<U>`, the trait `std::marker::Sized` is not implemented for `U`
19+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
1820
= help: consider adding a `where U: std::marker::Sized` bound
1921
= note: required because it appears within the type `Misc<U>`
2022
= note: required by `std::mem::size_of`
@@ -52,6 +54,7 @@ LL | mem::size_of::<[T]>();
5254
| ^^^^^^^^^^^^^^^^^^^ `[T]` does not have a constant size known at compile-time
5355
|
5456
= help: the trait `std::marker::Sized` is not implemented for `[T]`
57+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
5558
= note: required by `std::mem::size_of`
5659

5760
error[E0277]: `[&U]` does not have a constant size known at compile-time
@@ -61,6 +64,7 @@ LL | mem::size_of::<[&U]>();
6164
| ^^^^^^^^^^^^^^^^^^^^ `[&U]` does not have a constant size known at compile-time
6265
|
6366
= help: the trait `std::marker::Sized` is not implemented for `[&U]`
67+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
6468
= note: required by `std::mem::size_of`
6569

6670
error: aborting due to 7 previous errors

src/test/ui/union/union-sized-field.stderr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | value: T,
55
| ^^^^^^^^ `T` does not have a constant size known at compile-time
66
|
77
= help: the trait `std::marker::Sized` is not implemented for `T`
8+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
89
= help: consider adding a `where T: std::marker::Sized` bound
910
= note: no field of a union may have a dynamically sized type
1011

@@ -15,6 +16,7 @@ LL | value: T,
1516
| ^^^^^^^^ `T` does not have a constant size known at compile-time
1617
|
1718
= help: the trait `std::marker::Sized` is not implemented for `T`
19+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
1820
= help: consider adding a `where T: std::marker::Sized` bound
1921
= note: only the last field of a struct may have a dynamically sized type
2022

@@ -25,6 +27,7 @@ LL | Value(T),
2527
| ^ `T` does not have a constant size known at compile-time
2628
|
2729
= help: the trait `std::marker::Sized` is not implemented for `T`
30+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
2831
= help: consider adding a `where T: std::marker::Sized` bound
2932
= note: no field of an enum variant may have a dynamically sized type
3033

0 commit comments

Comments
 (0)