diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-09-06 16:34:41 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-06 16:34:41 +0530 |
| commit | 3f220200064dbd1a20a8327cb0dd577c53a9e16e (patch) | |
| tree | 35b56ce0a4e0396649db5dea1f42ec6dbaed7d50 /compiler/rustc_middle | |
| parent | 098cf8802271eacdc463fa66c35da377926d4c4e (diff) | |
| parent | 00b10a5552c575e884a40de808a3cb64a647a442 (diff) | |
| download | rust-3f220200064dbd1a20a8327cb0dd577c53a9e16e.tar.gz rust-3f220200064dbd1a20a8327cb0dd577c53a9e16e.zip | |
Rollup merge of #100658 - chenyukang:100631-check-get-attr, r=lcnr
TyCtxt::get_attr should check that no duplicates are allowed Fixes #100631
Diffstat (limited to 'compiler/rustc_middle')
| -rw-r--r-- | compiler/rustc_middle/src/ty/mod.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 8235a05fb53..1312a146796 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -2269,7 +2269,11 @@ impl<'tcx> TyCtxt<'tcx> { } pub fn get_attr(self, did: DefId, attr: Symbol) -> Option<&'tcx ast::Attribute> { - self.get_attrs(did, attr).next() + if cfg!(debug_assertions) && !rustc_feature::is_valid_for_get_attr(attr) { + bug!("get_attr: unexpected called with DefId `{:?}`, attr `{:?}`", did, attr); + } else { + self.get_attrs(did, attr).next() + } } /// Determines whether an item is annotated with an attribute. |
