1
1
//! The `Visitor` responsible for actually checking a `mir::Body` for invalid operations.
2
2
3
- use rustc_errors:: { Applicability , Diagnostic , ErrorGuaranteed } ;
3
+ use rustc_errors:: { Diagnostic , ErrorGuaranteed } ;
4
4
use rustc_hir as hir;
5
5
use rustc_hir:: def_id:: DefId ;
6
6
use rustc_index:: bit_set:: BitSet ;
@@ -24,6 +24,7 @@ use super::qualifs::{self, CustomEq, HasMutInterior, NeedsDrop, NeedsNonConstDro
24
24
use super :: resolver:: FlowSensitiveAnalysis ;
25
25
use super :: { ConstCx , Qualif } ;
26
26
use crate :: const_eval:: is_unstable_const_fn;
27
+ use crate :: errors:: UnstableInStable ;
27
28
28
29
type QualifResults < ' mir , ' tcx , Q > =
29
30
rustc_mir_dataflow:: ResultsCursor < ' mir , ' tcx , FlowSensitiveAnalysis < ' mir , ' mir , ' tcx , Q > > ;
@@ -1026,23 +1027,5 @@ fn is_int_bool_or_char(ty: Ty<'_>) -> bool {
1026
1027
fn emit_unstable_in_stable_error ( ccx : & ConstCx < ' _ , ' _ > , span : Span , gate : Symbol ) {
1027
1028
let attr_span = ccx. tcx . def_span ( ccx. def_id ( ) ) . shrink_to_lo ( ) ;
1028
1029
1029
- ccx. tcx
1030
- . sess
1031
- . struct_span_err (
1032
- span,
1033
- & format ! ( "const-stable function cannot use `#[feature({})]`" , gate. as_str( ) ) ,
1034
- )
1035
- . span_suggestion (
1036
- attr_span,
1037
- "if it is not part of the public API, make this function unstably const" ,
1038
- concat ! ( r#"#[rustc_const_unstable(feature = "...", issue = "...")]"# , '\n' ) ,
1039
- Applicability :: HasPlaceholders ,
1040
- )
1041
- . span_suggestion (
1042
- attr_span,
1043
- "otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks" ,
1044
- format ! ( "#[rustc_allow_const_fn_unstable({})]\n " , gate) ,
1045
- Applicability :: MaybeIncorrect ,
1046
- )
1047
- . emit ( ) ;
1030
+ ccx. tcx . sess . emit_err ( UnstableInStable { gate : gate. to_string ( ) , span, attr_span } ) ;
1048
1031
}
0 commit comments