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

ices/91801-1.rs: fixed with errors #1208

Merged
merged 1 commit into from
Apr 6, 2022
Merged

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Apr 6, 2022

Issue: rust-lang/rust#91801

fn or<'a>(first: &'static (dyn Fn(&'a i32))) -> dyn 'a + Fn(&'a i32) {
   return Box::new(panic!());
}

fn main() {}
=== stdout ===
=== stderr ===
warning: unreachable call
 --> /home/runner/work/glacier/glacier/ices/91801-1.rs:2:11
  |
2 |    return Box::new(panic!());
  |           ^^^^^^^^ -------- any code following this expression is unreachable
  |           |
  |           unreachable call
  |
  = note: `#[warn(unreachable_code)]` on by default

error[E0746]: return type cannot have an unboxed trait object
 --> /home/runner/work/glacier/glacier/ices/91801-1.rs:1:49
  |
1 | fn or<'a>(first: &'static (dyn Fn(&'a i32))) -> dyn 'a + Fn(&'a i32) {
  |                                                 ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
  |
  = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
help: use `impl 'a + Fn(&'a i32)` as the return type, as all return paths are of type `Box<_>`, which implements `'a + Fn(&'a i32)`
  |
1 | fn or<'a>(first: &'static (dyn Fn(&'a i32))) -> impl 'a + Fn(&'a i32) {
  |                                                 ~~~~~~~~~~~~~~~~~~~~~

error: aborting due to previous error; 1 warning emitted

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

=== stdout ===
=== stderr ===
warning: unreachable call
 --> /home/runner/work/glacier/glacier/ices/91801-1.rs:2:11
  |
2 |    return Box::new(panic!());
  |           ^^^^^^^^ -------- any code following this expression is unreachable
  |           |
  |           unreachable call
  |
  = note: `#[warn(unreachable_code)]` on by default

error[E0746]: return type cannot have an unboxed trait object
 --> /home/runner/work/glacier/glacier/ices/91801-1.rs:1:49
  |
1 | fn or<'a>(first: &'static (dyn Fn(&'a i32))) -> dyn 'a + Fn(&'a i32) {
  |                                                 ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
  |
  = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
help: use `impl 'a + Fn(&'a i32)` as the return type, as all return paths are of type `Box<_>`, which implements `'a + Fn(&'a i32)`
  |
1 | fn or<'a>(first: &'static (dyn Fn(&'a i32))) -> impl 'a + Fn(&'a i32) {
  |                                                 ~~~~~~~~~~~~~~~~~~~~~

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0746`.
==============
@Alexendoo Alexendoo merged commit 9a0ed99 into master Apr 6, 2022
@Alexendoo Alexendoo deleted the autofix/ices/91801-1.rs branch April 6, 2022 16:05
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