forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#106945 - matthiaskrgr:rollup-c5or8z3, r=matth…
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#105954 (Update instrument-coverage.md) - rust-lang#106835 (new trait solver: rebase impl substs for gats correctly) - rust-lang#106912 (check -Z query-dep-graph is enabled if -Z dump-dep-graph (rust-lang#106736)) - rust-lang#106940 (Improve a TAIT error and add an error code plus documentation) - rust-lang#106942 (Update books) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
31 changed files
with
166 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
A type alias impl trait can only have its hidden type assigned | ||
when used fully generically (and within their defining scope). | ||
This means | ||
|
||
```compile_fail,E0792 | ||
#![feature(type_alias_impl_trait)] | ||
type Foo<T> = impl std::fmt::Debug; | ||
fn foo() -> Foo<u32> { | ||
5u32 | ||
} | ||
``` | ||
|
||
is not accepted. If it were accepted, one could create unsound situations like | ||
|
||
```compile_fail,E0792 | ||
#![feature(type_alias_impl_trait)] | ||
type Foo<T> = impl Default; | ||
fn foo() -> Foo<u32> { | ||
5u32 | ||
} | ||
fn main() { | ||
let x = Foo::<&'static mut String>::default(); | ||
} | ||
``` | ||
|
||
|
||
Instead you need to make the function generic: | ||
|
||
``` | ||
#![feature(type_alias_impl_trait)] | ||
type Foo<T> = impl std::fmt::Debug; | ||
fn foo<U>() -> Foo<U> { | ||
5u32 | ||
} | ||
``` | ||
|
||
This means that no matter the generic parameter to `foo`, | ||
the hidden type will always be `u32`. | ||
If you want to link the generic parameter to the hidden type, | ||
you can do that, too: | ||
|
||
|
||
``` | ||
#![feature(type_alias_impl_trait)] | ||
use std::fmt::Debug; | ||
type Foo<T: Debug> = impl Debug; | ||
fn foo<U: Debug>() -> Foo<U> { | ||
Vec::<U>::new() | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule reference
updated
7 files
+1 −1 | src/const_eval.md | |
+7 −2 | src/destructors.md | |
+1 −1 | src/expressions/field-expr.md | |
+8 −1 | src/expressions/operator-expr.md | |
+150 −20 | src/items/enumerations.md | |
+1 −1 | src/type-layout.md | |
+2 −0 | triagebot.toml |
Submodule rust-by-example
updated
2 files
+3 −3 | src/error/option_unwrap/defaults.md | |
+6 −3 | src/hello/print.md |
Submodule rustc-dev-guide
updated
31 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Test dump-dep-graph requires query-dep-graph enabled | ||
|
||
// incremental | ||
// compile-flags: -Z dump-dep-graph | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
error: can't dump dependency graph without `-Z query-dep-graph` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
error: non-defining opaque type use in defining scope | ||
error[E0792]: expected generic type parameter, found `<T as TraitWithAssoc>::Assoc` | ||
--> $DIR/bound_reduction2.rs:16:5 | ||
| | ||
LL | type Foo<V> = impl Trait<V>; | ||
| - this generic parameter must be used with a generic type parameter | ||
... | ||
LL | () | ||
| ^^ | ||
| | ||
note: used non-generic type `<T as TraitWithAssoc>::Assoc` for generic parameter | ||
--> $DIR/bound_reduction2.rs:9:10 | ||
| | ||
LL | type Foo<V> = impl Trait<V>; | ||
| ^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0792`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 12 additions & 17 deletions
29
tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,30 @@ | ||
error: non-defining opaque type use in defining scope | ||
--> $DIR/generic_nondefining_use.rs:17:5 | ||
error[E0792]: expected generic type parameter, found `u32` | ||
--> $DIR/generic_nondefining_use.rs:16:5 | ||
| | ||
LL | type OneTy<T> = impl Debug; | ||
| - this generic parameter must be used with a generic type parameter | ||
... | ||
LL | 5u32 | ||
| ^^^^ | ||
| | ||
note: used non-generic type `u32` for generic parameter | ||
--> $DIR/generic_nondefining_use.rs:7:12 | ||
| | ||
LL | type OneTy<T> = impl Debug; | ||
| ^ | ||
|
||
error: non-defining opaque type use in defining scope | ||
--> $DIR/generic_nondefining_use.rs:22:5 | ||
--> $DIR/generic_nondefining_use.rs:21:5 | ||
| | ||
LL | type OneLifetime<'a> = impl Debug; | ||
| -- cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type | ||
... | ||
LL | 6u32 | ||
| ^^^^ | ||
|
||
error: non-defining opaque type use in defining scope | ||
--> $DIR/generic_nondefining_use.rs:27:5 | ||
error[E0792]: expected generic constant parameter, found `123` | ||
--> $DIR/generic_nondefining_use.rs:26:5 | ||
| | ||
LL | type OneConst<const X: usize> = impl Debug; | ||
| -------------- this generic parameter must be used with a generic constant parameter | ||
... | ||
LL | 7u32 | ||
| ^^^^ | ||
| | ||
note: used non-generic constant `123` for generic parameter | ||
--> $DIR/generic_nondefining_use.rs:11:15 | ||
| | ||
LL | type OneConst<const X: usize> = impl Debug; | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0792`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
error: non-defining opaque type use in defining scope | ||
error[E0792]: expected generic type parameter, found `u8` | ||
--> $DIR/issue-60564.rs:20:9 | ||
| | ||
LL | type IterBitsIter<T, E, I> = impl std::iter::Iterator<Item = I>; | ||
| - this generic parameter must be used with a generic type parameter | ||
... | ||
LL | (0u8..n).rev().map(move |shift| ((self >> T::from(shift)) & T::from(1)).try_into().unwrap()) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: used non-generic type `u8` for generic parameter | ||
--> $DIR/issue-60564.rs:8:25 | ||
| | ||
LL | type IterBitsIter<T, E, I> = impl std::iter::Iterator<Item = I>; | ||
| ^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0792`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.