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

ices/58355.rs: fixed with errors #1425

Merged
merged 1 commit into from
Sep 22, 2022
Merged

ices/58355.rs: fixed with errors #1425

merged 1 commit into from
Sep 22, 2022

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#58355

#![crate_type = "lib"]

pub fn foo(callback: fn() -> ToString) {
    let mut x: Option<Box<Fn() -> ToString>> = None;
    x = Some(Box::new(callback));
}
=== stdout ===
=== stderr ===
warning: trait objects without an explicit `dyn` are deprecated
 --> /home/runner/work/glacier/glacier/ices/58355.rs:3:30
  |
3 | pub fn foo(callback: fn() -> ToString) {
  |                              ^^^^^^^^
  |
  = 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>
help: use `dyn`
  |
3 | pub fn foo(callback: fn() -> dyn ToString) {
  |                              +++

warning: trait objects without an explicit `dyn` are deprecated
 --> /home/runner/work/glacier/glacier/ices/58355.rs:4:27
  |
4 |     let mut x: Option<Box<Fn() -> ToString>> = None;
  |                           ^^^^^^^^^^^^^^^^
  |
  = 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>
help: use `dyn`
  |
4 |     let mut x: Option<Box<dyn Fn() -> ToString>> = None;
  |                           +++

warning: trait objects without an explicit `dyn` are deprecated
 --> /home/runner/work/glacier/glacier/ices/58355.rs:4:35
  |
4 |     let mut x: Option<Box<Fn() -> ToString>> = None;
  |                                   ^^^^^^^^
  |
  = 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>
help: use `dyn`
  |
4 |     let mut x: Option<Box<Fn() -> dyn ToString>> = None;
  |                                   +++

error[E0277]: the size for values of type `dyn ToString` cannot be known at compilation time
 --> /home/runner/work/glacier/glacier/ices/58355.rs:5:14
  |
5 |     x = Some(Box::new(callback));
  |              ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
  |
  = help: within `fn() -> dyn ToString`, the trait `Sized` is not implemented for `dyn ToString`
  = note: required because it appears within the type `fn() -> dyn ToString`
  = note: required for the cast from `fn() -> dyn ToString` to the object type `dyn Fn() -> (dyn ToString + 'static)`

error: aborting due to previous error; 3 warnings emitted

For more information about this error, try `rustc --explain E0277`.
==============

=== stdout ===
=== stderr ===
warning: trait objects without an explicit `dyn` are deprecated
 --> /home/runner/work/glacier/glacier/ices/58355.rs:3:30
  |
3 | pub fn foo(callback: fn() -> ToString) {
  |                              ^^^^^^^^
  |
  = 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>
help: use `dyn`
  |
3 | pub fn foo(callback: fn() -> dyn ToString) {
  |                              +++

warning: trait objects without an explicit `dyn` are deprecated
 --> /home/runner/work/glacier/glacier/ices/58355.rs:4:27
  |
4 |     let mut x: Option<Box<Fn() -> ToString>> = None;
  |                           ^^^^^^^^^^^^^^^^
  |
  = 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>
help: use `dyn`
  |
4 |     let mut x: Option<Box<dyn Fn() -> ToString>> = None;
  |                           +++

warning: trait objects without an explicit `dyn` are deprecated
 --> /home/runner/work/glacier/glacier/ices/58355.rs:4:35
  |
4 |     let mut x: Option<Box<Fn() -> ToString>> = None;
  |                                   ^^^^^^^^
  |
  = 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>
help: use `dyn`
  |
4 |     let mut x: Option<Box<Fn() -> dyn ToString>> = None;
  |                                   +++

error[E0277]: the size for values of type `dyn ToString` cannot be known at compilation time
 --> /home/runner/work/glacier/glacier/ices/58355.rs:5:14
  |
5 |     x = Some(Box::new(callback));
  |              ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
  |
  = help: within `fn() -> dyn ToString`, the trait `Sized` is not implemented for `dyn ToString`
  = note: required because it appears within the type `fn() -> dyn ToString`
  = note: required for the cast from `fn() -> dyn ToString` to the object type `dyn Fn() -> (dyn ToString + 'static)`

error: aborting due to previous error; 3 warnings emitted

For more information about this error, try `rustc --explain E0277`.
==============
@JohnTitor JohnTitor merged commit 6d544e5 into master Sep 22, 2022
@JohnTitor JohnTitor deleted the autofix/ices/58355.rs branch September 22, 2022 10:50
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