Skip to content

Commit b3b06c1

Browse files
committed
Auto merge of #158753 - jhpratt:rollup-nhJHVUD, r=<try>
Rollup of 18 pull requests try-job: dist-various-1 try-job: test-various try-job: x86_64-gnu-aux try-job: x86_64-gnu-llvm-21-3 try-job: x86_64-msvc-1 try-job: aarch64-apple try-job: x86_64-mingw-1 try-job: i686-msvc-2
2 parents c397dae + 2e45131 commit b3b06c1

85 files changed

Lines changed: 1716 additions & 1138 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎RELEASES.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
Version 1.96.1 (2026-06-30)
2+
===========================
3+
4+
<a id="1.96.1"></a>
5+
6+
- [Cargo: fix timeout/retry behavior](https://github.com/rust-lang/cargo/pull/17131)
7+
- [Cargo: apply patches for CVE-2025-15661, CVE-2026-55199, and CVE-2026-55200 to libssh2](https://github.com/rust-lang/cargo/pull/17140)
8+
- [rustc: fix miscompilation in MIR optimization](https://github.com/rust-lang/rust/pull/158214)
9+
110
Version 1.96.0 (2026-05-28)
211
==========================
312

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
use rustc_hir::attrs::{AttributeKind, InlineAttr};
2+
use rustc_hir::{self as hir};
3+
use rustc_span::Span;
4+
use rustc_span::def_id::DefId;
5+
6+
use crate::LoweringContext;
7+
use crate::delegation::DelegationResolution;
8+
9+
struct AdditionInfo {
10+
pub equals: fn(&hir::Attribute) -> bool,
11+
pub kind: AdditionKind,
12+
}
13+
14+
enum AdditionKind {
15+
Default { factory: fn(Span) -> hir::Attribute },
16+
Inherit { factory: fn(Span, &hir::Attribute) -> hir::Attribute },
17+
}
18+
19+
static ADDITIONS: &[AdditionInfo] = &[
20+
AdditionInfo {
21+
equals: |a| matches!(a, hir::Attribute::Parsed(AttributeKind::MustUse { .. })),
22+
kind: AdditionKind::Inherit {
23+
factory: |span, original_attr| {
24+
let reason = match original_attr {
25+
hir::Attribute::Parsed(AttributeKind::MustUse { reason, .. }) => *reason,
26+
_ => None,
27+
};
28+
29+
hir::Attribute::Parsed(AttributeKind::MustUse { span, reason })
30+
},
31+
},
32+
},
33+
AdditionInfo {
34+
equals: |a| matches!(a, hir::Attribute::Parsed(AttributeKind::Inline(..))),
35+
kind: AdditionKind::Default {
36+
factory: |span| hir::Attribute::Parsed(AttributeKind::Inline(InlineAttr::Hint, span)),
37+
},
38+
},
39+
];
40+
41+
impl<'hir> LoweringContext<'_, 'hir> {
42+
pub(super) fn add_attrs_if_needed(&mut self, resolution: &DelegationResolution) {
43+
let &DelegationResolution { span, sig_id, .. } = resolution;
44+
45+
const PARENT_ID: hir::ItemLocalId = hir::ItemLocalId::ZERO;
46+
let new_attrs = self.create_new_attrs(span, sig_id, self.attrs.get(&PARENT_ID));
47+
48+
if !new_attrs.is_empty() {
49+
let new_attrs = match self.attrs.get(&PARENT_ID) {
50+
Some(existing_attrs) => self.arena.alloc_from_iter(
51+
existing_attrs.iter().map(|a| a.clone()).chain(new_attrs.into_iter()),
52+
),
53+
None => self.arena.alloc_from_iter(new_attrs.into_iter()),
54+
};
55+
56+
self.attrs.insert(PARENT_ID, new_attrs);
57+
}
58+
}
59+
60+
fn create_new_attrs(
61+
&self,
62+
span: Span,
63+
sig_id: DefId,
64+
existing: Option<&&[hir::Attribute]>,
65+
) -> Vec<hir::Attribute> {
66+
ADDITIONS
67+
.iter()
68+
.filter_map(|addition| {
69+
existing
70+
.is_none_or(|attrs| !attrs.iter().any(|a| (addition.equals)(a)))
71+
.then(|| match addition.kind {
72+
AdditionKind::Default { factory } => Some(factory(span)),
73+
AdditionKind::Inherit { factory, .. } =>
74+
{
75+
#[allow(deprecated)]
76+
self.tcx
77+
.get_all_attrs(sig_id)
78+
.iter()
79+
.find_map(|a| (addition.equals)(a).then(|| factory(span, a)))
80+
}
81+
})
82+
.flatten()
83+
})
84+
.collect::<Vec<_>>()
85+
}
86+
}

0 commit comments

Comments
 (0)