It's unintuitive that this doesn't compile: ```rust struct Foo; const fn bar() -> Foo { Foo } // doesn't compile fn foo() -> &'static Foo { &bar() } // this compiles fn foo2() -> &'static Foo { const FOO: &'static Foo = &bar(); FOO } // this compiles fn foo3() -> &'static Foo { const FOO: Foo = bar(); &FOO } ``` https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=3b50f81085d7e51908ce0378ae865d0f **rustc should just generate a `const` (or `static`) behind the scenes and typecheck the code as if the user had written that.**
Activity
jonas-schievink commentedon Jul 17, 2020
This is intended behavior according to rust-lang/const-eval#19