Skip to content

Commit 9f70557

Browse files
committed
Auto merge of rust-lang#38108 - linclark:32777-E0328, r=GuillaumeGomez
Add error explanation for E0328. This PR adds an explanation for an error in the list in rust-lang#32777. I haven't used this feature myself, so I was piecing it together from the docs. Please let me know if any changes in wording should be made. One problem: When I followed the instructions in CONTRIBUTING.md, it said to run `make check-stage1` before posting the PR. This reported failures, but they seemed to be intermittent. I got different numbers of failures on each run. Here's the output for the last run ``` failures: ---- [run-make] run-make/rustc-macro-dep-files stdout ---- error: make failed status: exit code: 2 command: "make" stdout: ------------------------------------------ DYLD_LIBRARY_PATH="/Users/lclark/Repos/rust/x86_64-apple-darwin/test/run-make/rustc-macro-dep-files.stage1-x86_64-apple-darwin:/Users/lclark/Repos/rust/x86_64-apple-darwin/stage1/lib:" '/Users/lclark/Repos/rust/x86_64-apple-darwin/stage1/bin/rustc' --out-dir /Users/lclark/Repos/rust/x86_64-apple-darwin/test/run-make/rustc-macro-dep-files.stage1-x86_64-apple-darwin -L /Users/lclark/Repos/rust/x86_64-apple-darwin/test/run-make/rustc-macro-dep-files.stage1-x86_64-apple-darwin foo.rs DYLD_LIBRARY_PATH="/Users/lclark/Repos/rust/x86_64-apple-darwin/test/run-make/rustc-macro-dep-files.stage1-x86_64-apple-darwin:/Users/lclark/Repos/rust/x86_64-apple-darwin/stage1/lib:" '/Users/lclark/Repos/rust/x86_64-apple-darwin/stage1/bin/rustc' --out-dir /Users/lclark/Repos/rust/x86_64-apple-darwin/test/run-make/rustc-macro-dep-files.stage1-x86_64-apple-darwin -L /Users/lclark/Repos/rust/x86_64-apple-darwin/test/run-make/rustc-macro-dep-files.stage1-x86_64-apple-darwin bar.rs --emit dep-info ------------------------------------------ stderr: ------------------------------------------ dyld: lazy symbol binding failed: Symbol not found: __ZN4core3fmt5write17h2f7663117dd4fb40E Referenced from: /Users/lclark/Repos/rust/x86_64-apple-darwin/test/run-make/rustc-macro-dep-files.stage1-x86_64-apple-darwin/libfoo.dylib Expected in: /Users/lclark/Repos/rust/x86_64-apple-darwin/stage1/lib/libstd-fdb5dc8c.dylib dyld: Symbol not found: __ZN4core3fmt5write17h2f7663117dd4fb40E Referenced from: /Users/lclark/Repos/rust/x86_64-apple-darwin/test/run-make/rustc-macro-dep-files.stage1-x86_64-apple-darwin/libfoo.dylib Expected in: /Users/lclark/Repos/rust/x86_64-apple-darwin/stage1/lib/libstd-fdb5dc8c.dylib make[1]: *** [all] Trace/BPT trap: 5 ------------------------------------------ thread '[run-make] run-make/rustc-macro-dep-files' panicked at 'explicit panic', /Users/lclark/Repos/rust/src/tools/compiletest/src/runtest.rs:2407 note: Run with `RUST_BACKTRACE=1` for a backtrace. failures: [run-make] run-make/rustc-macro-dep-files test result: FAILED. 136 passed; 1 failed; 0 ignored; 0 measured thread 'main' panicked at 'Some tests failed', /Users/lclark/Repos/rust/src/tools/compiletest/src/main.rs:302 make: *** [tmp/check-stage1-T-x86_64-apple-darwin-H-x86_64-apple-darwin-rmake.ok] Error 101 ``` r? @GuillaumeGomez
2 parents 3ddc270 + ac28aba commit 9f70557

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

src/librustc_typeck/diagnostics.rs

+36-1
Original file line numberDiff line numberDiff line change
@@ -3038,6 +3038,42 @@ impl Foo for Bar {
30383038
```
30393039
"##,
30403040

3041+
E0328: r##"
3042+
The Unsize trait should not be implemented directly. All implementations of
3043+
Unsize are provided automatically by the compiler.
3044+
3045+
Erroneous code example:
3046+
3047+
```compile_fail,E0328
3048+
#![feature(unsize)]
3049+
3050+
use std::marker::Unsize;
3051+
3052+
pub struct MyType;
3053+
3054+
impl<T> Unsize<T> for MyType {}
3055+
```
3056+
3057+
If you are defining your own smart pointer type and would like to enable
3058+
conversion from a sized to an unsized type with the [DST coercion system]
3059+
(https://github.com/rust-lang/rfcs/blob/master/text/0982-dst-coercion.md), use
3060+
[`CoerceUnsized`](https://doc.rust-lang.org/std/ops/trait.CoerceUnsized.html)
3061+
instead.
3062+
3063+
```
3064+
#![feature(coerce_unsized)]
3065+
3066+
use std::ops::CoerceUnsized;
3067+
3068+
pub struct MyType<T: ?Sized> {
3069+
field_with_unsized_type: T,
3070+
}
3071+
3072+
impl<T, U> CoerceUnsized<MyType<U>> for MyType<T>
3073+
where T: CoerceUnsized<U> {}
3074+
```
3075+
"##,
3076+
30413077
E0329: r##"
30423078
An attempt was made to access an associated constant through either a generic
30433079
type parameter or `Self`. This is not supported yet. An example causing this
@@ -4147,7 +4183,6 @@ register_diagnostics! {
41474183
// E0249,
41484184
// E0319, // trait impls for defaulted traits allowed just for structs/enums
41494185
E0320, // recursive overflow during dropck
4150-
E0328, // cannot implement Unsize explicitly
41514186
// E0372, // coherence not object safe
41524187
E0377, // the trait `CoerceUnsized` may only be implemented for a coercion
41534188
// between structures with the same definition

0 commit comments

Comments
 (0)