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

ices/91803.rs: fixed with errors #1209

Merged
merged 1 commit into from
Apr 6, 2022
Merged

ices/91803.rs: fixed with errors #1209

merged 1 commit into from
Apr 6, 2022

Conversation

github-actions[bot]
Copy link
Contributor

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

Issue: rust-lang/rust#91803

trait Foo<'a> {}

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

pub fn main() {}
=== stdout ===
=== stderr ===
warning: unreachable call
 --> /home/runner/work/glacier/glacier/ices/91803.rs:4:12
  |
4 |     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/91803.rs:3:43
  |
3 | fn or<'a>(first: &'static dyn Foo<'a>) -> dyn Foo<'a> {
  |                                           ^^^^^^^^^^^ 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 Foo<'a>` as the return type, as all return paths are of type `Box<_>`, which implements `Foo<'a>`
  |
3 | fn or<'a>(first: &'static dyn Foo<'a>) -> impl Foo<'a> {
  |                                           ~~~~~~~~~~~~

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/91803.rs:4:12
  |
4 |     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/91803.rs:3:43
  |
3 | fn or<'a>(first: &'static dyn Foo<'a>) -> dyn Foo<'a> {
  |                                           ^^^^^^^^^^^ 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 Foo<'a>` as the return type, as all return paths are of type `Box<_>`, which implements `Foo<'a>`
  |
3 | fn or<'a>(first: &'static dyn Foo<'a>) -> impl Foo<'a> {
  |                                           ~~~~~~~~~~~~

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0746`.
==============
@Alexendoo Alexendoo merged commit 608fa2b into master Apr 6, 2022
@Alexendoo Alexendoo deleted the autofix/ices/91803.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