@@ -29,6 +29,7 @@ use rustc_errors::DiagCtxtHandle;
29
29
use rustc_feature:: Features ;
30
30
use rustc_parse:: validate_attr;
31
31
use rustc_session:: Session ;
32
+ use rustc_session:: config:: SymbolManglingVersion ;
32
33
use rustc_session:: lint:: builtin:: {
33
34
DEPRECATED_WHERE_CLAUSE_LOCATION , MISSING_ABI , MISSING_UNSAFE_ON_EXTERN ,
34
35
PATTERNS_IN_FNS_WITHOUT_BODY ,
@@ -82,6 +83,8 @@ struct AstValidator<'a> {
82
83
/// Used to ban explicit safety on foreign items when the extern block is not marked as unsafe.
83
84
extern_mod_safety : Option < Safety > ,
84
85
86
+ is_interface : bool ,
87
+
85
88
lint_buffer : & ' a mut LintBuffer ,
86
89
}
87
90
@@ -922,7 +925,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
922
925
923
926
let is_intrinsic =
924
927
item. attrs . iter ( ) . any ( |a| a. name_or_empty ( ) == sym:: rustc_intrinsic) ;
925
- if body. is_none ( ) && !is_intrinsic {
928
+ if body. is_none ( ) && !is_intrinsic && ! self . is_interface {
926
929
self . dcx ( ) . emit_err ( errors:: FnWithoutBody {
927
930
span : item. span ,
928
931
replace_span : self . ending_semi_or_hi ( item. span ) ,
@@ -1110,6 +1113,12 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1110
1113
} ) ;
1111
1114
}
1112
1115
}
1116
+ ItemKind :: ExternDynCrate ( _) => {
1117
+ if self . sess . opts . get_symbol_mangling_version ( ) != SymbolManglingVersion :: V0 {
1118
+ self . dcx ( )
1119
+ . emit_err ( errors:: WrongManglingSchemeForExternDyn { span : item. span } ) ;
1120
+ }
1121
+ }
1113
1122
_ => { }
1114
1123
}
1115
1124
@@ -1419,7 +1428,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1419
1428
} ) ;
1420
1429
}
1421
1430
AssocItemKind :: Fn ( box Fn { body, .. } ) => {
1422
- if body. is_none ( ) {
1431
+ if body. is_none ( ) && ! self . is_interface {
1423
1432
self . dcx ( ) . emit_err ( errors:: AssocFnWithoutBody {
1424
1433
span : item. span ,
1425
1434
replace_span : self . ending_semi_or_hi ( item. span ) ,
@@ -1669,6 +1678,7 @@ pub fn check_crate(
1669
1678
sess : & Session ,
1670
1679
features : & Features ,
1671
1680
krate : & Crate ,
1681
+ is_interface : bool ,
1672
1682
lints : & mut LintBuffer ,
1673
1683
) -> bool {
1674
1684
let mut validator = AstValidator {
@@ -1680,6 +1690,7 @@ pub fn check_crate(
1680
1690
outer_impl_trait : None ,
1681
1691
disallow_tilde_const : Some ( TildeConstReason :: Item ) ,
1682
1692
extern_mod_safety : None ,
1693
+ is_interface,
1683
1694
lint_buffer : lints,
1684
1695
} ;
1685
1696
visit:: walk_crate ( & mut validator, krate) ;
0 commit comments