Skip to content

missing_const_for_fn does not work with TAIT #13009

Closed
@matthiaskrgr

Description

@matthiaskrgr

Summary

#![feature(type_alias_impl_trait)]
type Foo4 = impl Debug;

fn define4(_: Foo4) {
    let y: Foo4 = 42;
}

=>

warning: this could be a `const fn`
  --> a.rs:28:1
   |
28 | / fn define4(_: Foo4) {
29 | |     let y: Foo4 = 42;
30 | | }
   | |_^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_const_for_fn
help: make the function `const`
   |
28 | const fn define4(_: Foo4) {
   | +++++

=>

error[E0493]: destructor of `Foo4` cannot be evaluated at compile-time
  --> a.rs:28:18
   |
28 | const fn define4(_: Foo4) {
   |                  ^ the destructor for this type cannot be evaluated in constant functions
29 |     let y: Foo4 = 42;
30 | }
   | - value is dropped here

error: aborting due to 1 previous error; 3 warnings emitted

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions