@@ -14,7 +14,7 @@ use rustc_target::asm::{
1414use rustc_trait_selection:: infer:: InferCtxtExt ;
1515
1616use crate :: FnCtxt ;
17- use crate :: errors:: RegisterTypeUnstable ;
17+ use crate :: errors:: { AsmConstPtrUnstable , RegisterTypeUnstable } ;
1818
1919pub ( crate ) struct InlineAsmCtxt < ' a , ' tcx > {
2020 target_features : & ' tcx FxIndexSet < Symbol > ,
@@ -522,15 +522,46 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
522522 match ty. kind ( ) {
523523 ty:: Error ( _) => { }
524524 _ if ty. is_integral ( ) => { }
525+ ty:: FnPtr ( ..) => {
526+ if !self . tcx ( ) . features ( ) . asm_const_ptr ( ) {
527+ self . tcx ( )
528+ . sess
529+ . create_feature_err (
530+ AsmConstPtrUnstable { span : op_sp } ,
531+ sym:: asm_const_ptr,
532+ )
533+ . emit ( ) ;
534+ }
535+ }
536+ ty:: RawPtr ( pointee, _) | ty:: Ref ( _, pointee, _)
537+ if self . is_thin_ptr_ty ( op_sp, * pointee) =>
538+ {
539+ if !self . tcx ( ) . features ( ) . asm_const_ptr ( ) {
540+ self . tcx ( )
541+ . sess
542+ . create_feature_err (
543+ AsmConstPtrUnstable { span : op_sp } ,
544+ sym:: asm_const_ptr,
545+ )
546+ . emit ( ) ;
547+ }
548+ }
525549 _ => {
550+ let const_possible_ty = if !self . tcx ( ) . features ( ) . asm_const_ptr ( ) {
551+ "integer"
552+ } else {
553+ "integer or thin pointer"
554+ } ;
526555 self . fcx
527556 . dcx ( )
528557 . struct_span_err ( op_sp, "invalid type for `const` operand" )
529558 . with_span_label (
530559 self . tcx ( ) . def_span ( anon_const. def_id ) ,
531560 format ! ( "is {} `{}`" , ty. kind( ) . article( ) , ty) ,
532561 )
533- . with_help ( "`const` operands must be of an integer type" )
562+ . with_help ( format ! (
563+ "`const` operands must be of an {const_possible_ty} type"
564+ ) )
534565 . emit ( ) ;
535566 }
536567 }
0 commit comments