-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent defining opaque types in nested items
- Loading branch information
Showing
6 changed files
with
129 additions
and
14 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
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,30 @@ | ||
#![feature(type_alias_impl_trait)] | ||
|
||
fn main() {} | ||
|
||
type Foo = impl std::fmt::Display; | ||
|
||
fn bar() { | ||
pub fn foo() -> Foo { | ||
"foo" | ||
//~^ ERROR: opaque type constrained in nested item | ||
} | ||
} | ||
|
||
fn baz() -> Foo { | ||
pub fn foo() -> Foo { | ||
"foo" | ||
//~^ ERROR: opaque type constrained in nested item | ||
} | ||
"baz" | ||
} | ||
|
||
struct Bak { | ||
x: [u8; { | ||
fn blob() -> Foo { | ||
"blob" | ||
//~^ ERROR: opaque type constrained in nested item | ||
} | ||
5 | ||
}], | ||
} |
26 changes: 26 additions & 0 deletions
26
tests/ui/type-alias-impl-trait/defining-use-item-child.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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
error: opaque type constrained in nested item | ||
--> $DIR/defining-use-item-child.rs:9:9 | ||
| | ||
LL | pub fn foo() -> Foo { | ||
| ------------------- this item is not a sibling of the opaque type | ||
LL | "foo" | ||
| ^^^^^ | ||
|
||
error: opaque type constrained in nested item | ||
--> $DIR/defining-use-item-child.rs:16:9 | ||
| | ||
LL | pub fn foo() -> Foo { | ||
| ------------------- this item is not a sibling of the opaque type | ||
LL | "foo" | ||
| ^^^^^ | ||
|
||
error: opaque type constrained in nested item | ||
--> $DIR/defining-use-item-child.rs:25:13 | ||
| | ||
LL | fn blob() -> Foo { | ||
| ---------------- this item is not a sibling of the opaque type | ||
LL | "blob" | ||
| ^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|