diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-02-26 00:46:28 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-26 00:46:28 +0100 |
| commit | 65eecc6b59f69bac45ddce8081f5edd23e74b17e (patch) | |
| tree | 6a9ca8103320369dbf52834f7e2a1c720eb70fd1 /compiler/rustc_error_codes/src | |
| parent | 9631f4b5c9167bc93ea890736e22d97bfd0941b7 (diff) | |
| parent | 3b51e9fde8e86e6a082922bc7db2f673ed981836 (diff) | |
| download | rust-65eecc6b59f69bac45ddce8081f5edd23e74b17e.tar.gz rust-65eecc6b59f69bac45ddce8081f5edd23e74b17e.zip | |
Rollup merge of #108444 - Ezrashaw:add-test+docs-for-e0476, r=GuillaumeGomez
docs/test: add UI test and docs for `E0476` Final undocumented error code. Not entirely sure about wording in the docs. Part of https://github.com/rust-lang/rust/issues/61137. r? ```@compiler-errors``` cc ```@compiler-errors```
Diffstat (limited to 'compiler/rustc_error_codes/src')
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0476.md | 21 |
2 files changed, 22 insertions, 1 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index 800f3c52177..97201219cdf 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -253,6 +253,7 @@ E0466: include_str!("./error_codes/E0466.md"), E0468: include_str!("./error_codes/E0468.md"), E0469: include_str!("./error_codes/E0469.md"), E0472: include_str!("./error_codes/E0472.md"), +E0476: include_str!("./error_codes/E0476.md"), E0477: include_str!("./error_codes/E0477.md"), E0478: include_str!("./error_codes/E0478.md"), E0482: include_str!("./error_codes/E0482.md"), @@ -611,7 +612,6 @@ E0793: include_str!("./error_codes/E0793.md"), // E0473, // dereference of reference outside its lifetime // E0474, // captured variable `..` does not outlive the enclosing closure // E0475, // index of slice outside its lifetime - E0476, // lifetime of the source pointer does not outlive lifetime bound... // E0479, // the type `..` (provided as the value of a type parameter) is... // E0480, // lifetime of method receiver does not outlive the method call // E0481, // lifetime of function argument does not outlive the function call diff --git a/compiler/rustc_error_codes/src/error_codes/E0476.md b/compiler/rustc_error_codes/src/error_codes/E0476.md new file mode 100644 index 00000000000..fc141ba77f5 --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0476.md @@ -0,0 +1,21 @@ +The coerced type does not outlive the value being coerced to. + +Example of erroneous code: + +```compile_fail,E0476 +#![feature(coerce_unsized)] +#![feature(unsize)] + +use std::marker::Unsize; +use std::ops::CoerceUnsized; + +// error: lifetime of the source pointer does not outlive lifetime bound of the +// object type +impl<'a, 'b, T, S> CoerceUnsized<&'a T> for &'b S where S: Unsize<T> {} +``` + +During a coercion, the "source pointer" (the coerced type) did not outlive the +"object type" (value being coerced to). In the above example, `'b` is not a +subtype of `'a`. This error can currently only be encountered with the unstable +`CoerceUnsized` trait which allows custom coercions of unsized types behind a +smart pointer to be implemented. |
