forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#114667 - compiler-errors:issue-114664, r=da…
…vidtwco Record binder for bare trait object in LifetimeCollectVisitor The `LifetimeCollectVisitor` had a bug where it was not recording the binder of bate trait objects. This was uncovered in rust-lang#114487, when I changed opaque type lowering to ICE if it encountered a captured fresh lifetime with no def-id to map back to: https://github.com/rust-lang/rust/pull/114487/files#diff-ad0c15bbde97a607d4758ec7eaf88248be5d6b8ae084dfc84127f81e3f7a9bb4R1585 Fixes rust-lang#114664
- Loading branch information
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 | ||
|