Fix "unstable in stable" error

The "otherwise" note is printed before the suggestion currently.
This commit is contained in:
Dylan MacKenzie 2020-09-29 13:18:43 -07:00
parent 782a595d7c
commit ce50939952
4 changed files with 18 additions and 4 deletions

View File

@ -33,7 +33,12 @@ pub fn non_const<O: NonConstOp>(ccx: &ConstCx<'_, '_>, op: O, span: Span) -> boo
concat!(r#"#[rustc_const_unstable(feature = "...", issue = "...")]"#, '\n').to_owned(),
Applicability::HasPlaceholders,
)
.note("otherwise `#[allow_internal_unstable]` can be used to bypass stability checks")
.span_suggestion(
ccx.body.span,
"otherwise `#[allow_internal_unstable]` can be used to bypass stability checks",
format!("#[allow_internal_unstable({})]", gate),
Applicability:: MaybeIncorrect,
)
.emit();
}

View File

@ -4,11 +4,14 @@ error: const-stable function cannot use `#[feature(const_fn_fn_ptr_basics)]`
LL | const fn error(_: fn()) {}
| ^
|
= note: otherwise `#[allow_internal_unstable]` can be used to bypass stability checks
help: if it is not part of the public API, make this function unstably const
|
LL | #[rustc_const_unstable(feature = "...", issue = "...")]
|
help: otherwise `#[allow_internal_unstable]` can be used to bypass stability checks
|
LL | #[allow_internal_unstable(const_fn_fn_ptr_basics)]
|
error: aborting due to previous error

View File

@ -20,11 +20,14 @@ error: const-stable function cannot use `#[feature(const_fn_floating_point_arith
LL | const fn bar3() -> u32 { (5f32 + 6f32) as u32 }
| ^^^^^^^^^^^^^
|
= note: otherwise `#[allow_internal_unstable]` can be used to bypass stability checks
help: if it is not part of the public API, make this function unstably const
|
LL | #[rustc_const_unstable(feature = "...", issue = "...")]
|
help: otherwise `#[allow_internal_unstable]` can be used to bypass stability checks
|
LL | #[allow_internal_unstable(const_fn_floating_point_arithmetic)]
|
error: `foo2_gated` is not yet stable as a const fn
--> $DIR/min_const_fn_libstd_stability.rs:39:32

View File

@ -20,11 +20,14 @@ error: const-stable function cannot use `#[feature(const_fn_floating_point_arith
LL | const unsafe fn bar3() -> u32 { (5f32 + 6f32) as u32 }
| ^^^^^^^^^^^^^
|
= note: otherwise `#[allow_internal_unstable]` can be used to bypass stability checks
help: if it is not part of the public API, make this function unstably const
|
LL | #[rustc_const_unstable(feature = "...", issue = "...")]
|
help: otherwise `#[allow_internal_unstable]` can be used to bypass stability checks
|
LL | #[allow_internal_unstable(const_fn_floating_point_arithmetic)]
|
error: `foo2_gated` is not yet stable as a const fn
--> $DIR/min_const_unsafe_fn_libstd_stability.rs:39:48