Skip to content

Commit fc128b6

Browse files
committed
add check and don't encode #[inline]
1 parent b618cdb commit fc128b6

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
377377
ungated!(panic_handler, Normal, template!(Word), WarnFollowing), // RFC 2070
378378

379379
// Code generation:
380-
ungated!(inline, Normal, template!(Word, List: "always|never"), FutureWarnFollowing),
380+
ungated!(inline, Normal, template!(Word, List: "always|never"), FutureWarnFollowing, @only_local: true),
381381
ungated!(cold, Normal, template!(Word), WarnFollowing),
382382
ungated!(no_builtins, CrateLevel, template!(Word), WarnFollowing),
383383
ungated!(target_feature, Normal, template!(List: r#"enable = "name""#), DuplicatesOk),

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,6 +2201,9 @@ impl<'tcx> TyCtxt<'tcx> {
22012201

22022202
/// Determines whether an item is annotated with an attribute.
22032203
pub fn has_attr(self, did: DefId, attr: Symbol) -> bool {
2204+
if cfg!(debug_assertions) && !did.is_local() && rustc_feature::is_builtin_only_local(attr) {
2205+
bug!("tried to access the `only_local` attribute `{}` from an extern crate", attr);
2206+
}
22042207
self.sess.contains_name(&self.get_attrs(did), attr)
22052208
}
22062209

0 commit comments

Comments
 (0)