-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Record binder for bare trait object in LifetimeCollectVisitor
- Loading branch information
1 parent
a9b2c6a
commit bbe7a96
Showing
3 changed files
with
79 additions
and
2 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
22 changes: 22 additions & 0 deletions
22
tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.rs
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,22 @@ | ||
// edition:2015 | ||
// check-pass | ||
// issue: 114664 | ||
|
||
fn ice() -> impl AsRef<Fn(&())> { | ||
//~^ WARN trait objects without an explicit `dyn` are deprecated | ||
//~| WARN trait objects without an explicit `dyn` are deprecated | ||
//~| WARN trait objects without an explicit `dyn` are deprecated | ||
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! | ||
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! | ||
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! | ||
Foo | ||
} | ||
|
||
struct Foo; | ||
impl AsRef<dyn Fn(&())> for Foo { | ||
fn as_ref(&self) -> &(dyn for<'a> Fn(&'a ()) + 'static) { | ||
todo!() | ||
} | ||
} | ||
|
||
pub fn main() {} |
42 changes: 42 additions & 0 deletions
42
tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.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,42 @@ | ||
warning: trait objects without an explicit `dyn` are deprecated | ||
--> $DIR/fresh-lifetime-from-bare-trait-obj-114664.rs:5:24 | ||
| | ||
LL | fn ice() -> impl AsRef<Fn(&())> { | ||
| ^^^^^^^ | ||
| | ||
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! | ||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> | ||
= note: `#[warn(bare_trait_objects)]` on by default | ||
help: use `dyn` | ||
| | ||
LL | fn ice() -> impl AsRef<dyn Fn(&())> { | ||
| +++ | ||
|
||
warning: trait objects without an explicit `dyn` are deprecated | ||
--> $DIR/fresh-lifetime-from-bare-trait-obj-114664.rs:5:24 | ||
| | ||
LL | fn ice() -> impl AsRef<Fn(&())> { | ||
| ^^^^^^^ | ||
| | ||
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! | ||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> | ||
help: use `dyn` | ||
| | ||
LL | fn ice() -> impl AsRef<dyn Fn(&())> { | ||
| +++ | ||
|
||
warning: trait objects without an explicit `dyn` are deprecated | ||
--> $DIR/fresh-lifetime-from-bare-trait-obj-114664.rs:5:24 | ||
| | ||
LL | fn ice() -> impl AsRef<Fn(&())> { | ||
| ^^^^^^^ | ||
| | ||
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! | ||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> | ||
help: use `dyn` | ||
| | ||
LL | fn ice() -> impl AsRef<dyn Fn(&())> { | ||
| +++ | ||
|
||
warning: 3 warnings emitted | ||
|