Add regression test for spurious const error with NLL

Fixes #55825
This commit is contained in:
Aaron Hill 2021-10-03 16:54:54 -05:00
parent 08759c691e
commit 5b6604825e
No known key found for this signature in database
GPG Key ID: B4087E510E98B164
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,8 @@
// Regression test for issue #55825
// Tests that we don't emit a spurious warning in NLL mode
#![feature(nll)]
const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } //~ ERROR const
fn main() { }

View File

@ -0,0 +1,12 @@
error[E0658]: trait objects in const fn are unstable
--> $DIR/issue-55825-const-fn.rs:6:32
|
LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.