diff options
| author | bors <bors@rust-lang.org> | 2017-01-22 14:38:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-01-22 14:38:04 +0000 |
| commit | 9f705575452e04ce2d8cb88e5f5accdc4d54e650 (patch) | |
| tree | 869ec14f574e51de474e3fd2b84ac4a75acd4064 /src | |
| parent | 3ddc27025229c01bd1aeab9da3ebe34e3046da58 (diff) | |
| parent | ac28aba886c92ff3b81347425c7b09cdfaf88ec8 (diff) | |
| download | rust-9f705575452e04ce2d8cb88e5f5accdc4d54e650.tar.gz rust-9f705575452e04ce2d8cb88e5f5accdc4d54e650.zip | |
Auto merge of #38108 - linclark:32777-E0328, r=GuillaumeGomez
Add error explanation for E0328.
This PR adds an explanation for an error in the list in #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
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_typeck/diagnostics.rs | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 3617b1f0a7d..6d943f3ca2e 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -3038,6 +3038,42 @@ impl Foo for Bar { ``` "##, +E0328: r##" +The Unsize trait should not be implemented directly. All implementations of +Unsize are provided automatically by the compiler. + +Erroneous code example: + +```compile_fail,E0328 +#![feature(unsize)] + +use std::marker::Unsize; + +pub struct MyType; + +impl<T> Unsize<T> for MyType {} +``` + +If you are defining your own smart pointer type and would like to enable +conversion from a sized to an unsized type with the [DST coercion system] +(https://github.com/rust-lang/rfcs/blob/master/text/0982-dst-coercion.md), use +[`CoerceUnsized`](https://doc.rust-lang.org/std/ops/trait.CoerceUnsized.html) +instead. + +``` +#![feature(coerce_unsized)] + +use std::ops::CoerceUnsized; + +pub struct MyType<T: ?Sized> { + field_with_unsized_type: T, +} + +impl<T, U> CoerceUnsized<MyType<U>> for MyType<T> + where T: CoerceUnsized<U> {} +``` +"##, + E0329: r##" An attempt was made to access an associated constant through either a generic type parameter or `Self`. This is not supported yet. An example causing this @@ -4147,7 +4183,6 @@ register_diagnostics! { // E0249, // E0319, // trait impls for defaulted traits allowed just for structs/enums E0320, // recursive overflow during dropck - E0328, // cannot implement Unsize explicitly // E0372, // coherence not object safe E0377, // the trait `CoerceUnsized` may only be implemented for a coercion // between structures with the same definition |
