-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Description
get_attr
currently happily ignores any additional attributes in case there are more than one. While this is fine for attributes which don't care about duplicates or emit a warning/error in case there are more than one, this isn't currently checked in the compiler, potentially causing bugs.
rust/compiler/rustc_middle/src/ty/mod.rs
Lines 2282 to 2284 in a39bdb1
pub fn get_attr(self, did: DefId, attr: Symbol) -> Option<&'tcx ast::Attribute> { | |
self.get_attrs(did, attr).next() | |
} |
similar to the check in has_attr
we should check that the attr declaration in rustc_feature/builtin_attrs.rs
has an acceptable way of dealing with duplicates.
rust/compiler/rustc_middle/src/ty/mod.rs
Lines 2287 to 2290 in a39bdb1
pub fn has_attr(self, did: DefId, attr: Symbol) -> bool { | |
if cfg!(debug_assertions) && !did.is_local() && rustc_feature::is_builtin_only_local(attr) { | |
bug!("tried to access the `only_local` attribute `{}` from an extern crate", attr); | |
} else { |
in case there are any questions on how to implement this, feel free to open a thread on zulip and pinging me there.