Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

ices/63031.rs: fixed with no errors #920

Closed
wants to merge 1 commit into from

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#63031

trait Lf<'a> { type Type; }

struct F32;
impl<'a> Lf<'a> for F32 { type Type = f32; }

struct RefI32;
impl<'a> Lf<'a> for RefI32 { type Type = &'a i32; }

fn add_closure<T: for<'b> Lf<'b> + 'static>(v: &mut Vec<Box<for<'a> FnMut(<T as Lf<'a>>::Type)>>) {
    v.push(Box::new(move |_| {
    }));
}

fn main() {
    // bug? compiler can't seem to deduce <F32 as Lf<'a>>::Type == f32 nor <RefI32 as Lf<'a>>::Type == &'a i32
    let mut v1 = Vec::<Box<for<'a> FnMut(<F32 as Lf<'a>>::Type)>>::new();
    let mut v2 = Vec::<Box<for<'a> FnMut(<RefI32 as Lf<'a>>::Type)>>::new();
    add_closure::<F32>(&mut v1);
    add_closure::<RefI32>(&mut v2);
}
=== stdout ===
=== stderr ===
warning: trait objects without an explicit `dyn` are deprecated
 --> /home/runner/work/glacier/glacier/ices/63031.rs:9:61
  |
9 | fn add_closure<T: for<'b> Lf<'b> + 'static>(v: &mut Vec<Box<for<'a> FnMut(<T as Lf<'a>>::Type)>>) {
  |                                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn for<'a> FnMut(<T as Lf<'a>>::Type)`
  |
  = note: `#[warn(bare_trait_objects)]` on by default
  = warning: this is accepted in the current edition (Rust 2018) 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>

warning: trait objects without an explicit `dyn` are deprecated
  --> /home/runner/work/glacier/glacier/ices/63031.rs:16:28
   |
16 |     let mut v1 = Vec::<Box<for<'a> FnMut(<F32 as Lf<'a>>::Type)>>::new();
   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn for<'a> FnMut(<F32 as Lf<'a>>::Type)`
   |
   = warning: this is accepted in the current edition (Rust 2018) 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>

warning: trait objects without an explicit `dyn` are deprecated
  --> /home/runner/work/glacier/glacier/ices/63031.rs:17:28
   |
17 |     let mut v2 = Vec::<Box<for<'a> FnMut(<RefI32 as Lf<'a>>::Type)>>::new();
   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn for<'a> FnMut(<RefI32 as Lf<'a>>::Type)`
   |
   = warning: this is accepted in the current edition (Rust 2018) 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>

warning: 3 warnings emitted

==============

=== stdout ===
=== stderr ===
warning: trait objects without an explicit `dyn` are deprecated
 --> /home/runner/work/glacier/glacier/ices/63031.rs:9:61
  |
9 | fn add_closure<T: for<'b> Lf<'b> + 'static>(v: &mut Vec<Box<for<'a> FnMut(<T as Lf<'a>>::Type)>>) {
  |                                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn for<'a> FnMut(<T as Lf<'a>>::Type)`
  |
  = note: `#[warn(bare_trait_objects)]` on by default
  = warning: this is accepted in the current edition (Rust 2018) 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>

warning: trait objects without an explicit `dyn` are deprecated
  --> /home/runner/work/glacier/glacier/ices/63031.rs:16:28
   |
16 |     let mut v1 = Vec::<Box<for<'a> FnMut(<F32 as Lf<'a>>::Type)>>::new();
   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn for<'a> FnMut(<F32 as Lf<'a>>::Type)`
   |
   = warning: this is accepted in the current edition (Rust 2018) 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>

warning: trait objects without an explicit `dyn` are deprecated
  --> /home/runner/work/glacier/glacier/ices/63031.rs:17:28
   |
17 |     let mut v2 = Vec::<Box<for<'a> FnMut(<RefI32 as Lf<'a>>::Type)>>::new();
   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn for<'a> FnMut(<RefI32 as Lf<'a>>::Type)`
   |
   = warning: this is accepted in the current edition (Rust 2018) 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>

warning: 3 warnings emitted

==============
@Alexendoo Alexendoo closed this Aug 29, 2021
@Alexendoo Alexendoo deleted the autofix/ices/63031.rs branch August 29, 2021 12:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants