Skip to content

Commit bbd3ab8

Browse files
authored
Rollup merge of #148600 - folkertdev:pass-indirectly-reuse-attrs, r=JonathanBrouwer
re-use `self.get_all_attrs` result for pass indirectly attribute Could be a fix for a potential performance regression reported here #144529 (comment). Apparently the regression later disappeared. Nevertheless, this seems like a decent refactor. r? ````@JonathanBrouwer```` (vaguely attribute-related, maybe there are other optimizations to that PR that we're missing)
2 parents f2beff6 + 1a9cc78 commit bbd3ab8

File tree

1 file changed

+3
-7
lines changed
  • compiler/rustc_middle/src/ty

1 file changed

+3
-7
lines changed

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,9 +1512,8 @@ impl<'tcx> TyCtxt<'tcx> {
15121512
field_shuffle_seed ^= user_seed;
15131513
}
15141514

1515-
if let Some(reprs) =
1516-
find_attr!(self.get_all_attrs(did), AttributeKind::Repr { reprs, .. } => reprs)
1517-
{
1515+
let attributes = self.get_all_attrs(did);
1516+
if let Some(reprs) = find_attr!(attributes, AttributeKind::Repr { reprs, .. } => reprs) {
15181517
for (r, _) in reprs {
15191518
flags.insert(match *r {
15201519
attr::ReprRust => ReprFlags::empty(),
@@ -1574,10 +1573,7 @@ impl<'tcx> TyCtxt<'tcx> {
15741573
}
15751574

15761575
// See `TyAndLayout::pass_indirectly_in_non_rustic_abis` for details.
1577-
if find_attr!(
1578-
self.get_all_attrs(did),
1579-
AttributeKind::RustcPassIndirectlyInNonRusticAbis(..)
1580-
) {
1576+
if find_attr!(attributes, AttributeKind::RustcPassIndirectlyInNonRusticAbis(..)) {
15811577
flags.insert(ReprFlags::PASS_INDIRECTLY_IN_NON_RUSTIC_ABIS);
15821578
}
15831579

0 commit comments

Comments
 (0)