Skip to content

Commit d5525a7

Browse files
committed
Auto merge of #149798 - matthiaskrgr:rollup-wjgs9x6, r=matthiaskrgr
Rollup of 11 pull requests Successful merges: - #147585 (Suppress the error for private fields with non_exhaustive attribute) - #149215 (Emit `check-cfg` lints during attribute parsing rather than evaluation) - #149652 (Add release notes for 1.92.0) - #149720 (rustdoc book: mention inner doc attribute) - #149730 (lint: emit proper diagnostic for unsafe binders in improper_ctypes instead of ICE) - #149754 (Retire `opt_str2` from compiletest cli parsing) - #149755 (bootstrap: Use a `CompiletestMode` enum instead of bare strings) - #149763 (Add inline attribute to generated delegation function if needed) - #149772 (test: Add a test for 146133) - #149779 (Fix typo "an" → "and") - #149782 (Remove `[no-mentions]` handler in the triagebot config) Failed merges: - #148491 ( Correctly provide suggestions when encountering `async fn` with a `dyn Trait` return type) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 018d269 + 288e970 commit d5525a7

File tree

45 files changed

+771
-217
lines changed

Some content is hidden

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

45 files changed

+771
-217
lines changed

RELEASES.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,88 @@
1+
Version 1.92.0 (2025-12-11)
2+
==========================
3+
4+
<a id="1.92.0-Language"></a>
5+
6+
Language
7+
--------
8+
- [Document `MaybeUninit` representation and validity](https://github.com/rust-lang/rust/pull/140463)
9+
- [Allow `&raw [mut | const]` for union field in safe code](https://github.com/rust-lang/rust/pull/141469)
10+
- [Prefer item bounds of associated types over where-bounds for auto-traits and `Sized`](https://github.com/rust-lang/rust/pull/144064)
11+
- [Do not materialize `X` in `[X; 0]` when `X` is unsizing a const](https://github.com/rust-lang/rust/pull/145277)
12+
- [Support combining `#[track_caller]` and `#[no_mangle]` (requires every declaration specifying `#[track_caller]` as well)](https://github.com/rust-lang/rust/pull/145724)
13+
- [Make never type lints `never_type_fallback_flowing_into_unsafe` and `dependency_on_unit_never_type_fallback` deny-by-default](https://github.com/rust-lang/rust/pull/146167)
14+
- [Allow specifying multiple bounds for same associated item, except in trait objects](https://github.com/rust-lang/rust/pull/146593)
15+
- [Slightly strengthen higher-ranked region handling in coherence](https://github.com/rust-lang/rust/pull/146725)
16+
- [The `unused_must_use` lint no longer warns on `Result<(), Uninhabited>` (for instance, `Result<(), !>`), or `ControlFlow<Uninhabited, ()>`](https://github.com/rust-lang/rust/pull/147382). This avoids having to check for an error that can never happen.
17+
18+
<a id="1.92.0-Compiler"></a>
19+
20+
Compiler
21+
--------
22+
- [Make `mips64el-unknown-linux-muslabi64` link dynamically](https://github.com/rust-lang/rust/pull/146858)
23+
- [Remove current code for embedding command-line args in PDB](https://github.com/rust-lang/rust/pull/147022)
24+
Command-line information is typically not needed by debugging tools, and the removed code
25+
was causing problems for incremental builds even on targets that don't use PDB debuginfo.
26+
27+
<a id="1.92.0-Libraries"></a>
28+
29+
Libraries
30+
---------
31+
- [Specialize `Iterator::eq{_by}` for `TrustedLen` iterators](https://github.com/rust-lang/rust/pull/137122)
32+
- [Simplify `Extend` for tuples](https://github.com/rust-lang/rust/pull/138799)
33+
- [Added details to `Debug` for `EncodeWide`](https://github.com/rust-lang/rust/pull/140153).
34+
- [`iter::Repeat::last`](https://github.com/rust-lang/rust/pull/147258) and [`count`](https://github.com/rust-lang/rust/pull/146410) will now panic, rather than looping infinitely.
35+
36+
<a id="1.92.0-Stabilized-APIs"></a>
37+
38+
Stabilized APIs
39+
---------------
40+
41+
- [`NonZero<u{N}>::div_ceil`](https://doc.rust-lang.org/stable/std/num/struct.NonZero.html#method.div_ceil)
42+
- [`Location::file_as_c_str`](https://doc.rust-lang.org/stable/std/panic/struct.Location.html#method.file_as_c_str)
43+
- [`RwLockWriteGuard::downgrade`](https://doc.rust-lang.org/stable/std/sync/struct.RwLockWriteGuard.html#method.downgrade)
44+
- [`Box::new_zeroed`](https://doc.rust-lang.org/stable/std/boxed/struct.Box.html#method.new_zeroed)
45+
- [`Box::new_zeroed_slice`](https://doc.rust-lang.org/stable/std/boxed/struct.Box.html#method.new_zeroed_slice)
46+
- [`Rc::new_zeroed`](https://doc.rust-lang.org/stable/std/rc/struct.Rc.html#method.new_zeroed)
47+
- [`Rc::new_zeroed_slice`](https://doc.rust-lang.org/stable/std/rc/struct.Rc.html#method.new_zeroed_slice)
48+
- [`Arc::new_zeroed`](https://doc.rust-lang.org/stable/std/sync/struct.Arc.html#method.new_zeroed)
49+
- [`Arc::new_zeroed_slice`](https://doc.rust-lang.org/stable/std/sync/struct.Arc.html#method.new_zeroed_slice)
50+
- [`btree_map::Entry::insert_entry`](https://doc.rust-lang.org/stable/std/collections/btree_map/enum.Entry.html#method.insert_entry)
51+
- [`btree_map::VacantEntry::insert_entry`](https://doc.rust-lang.org/stable/std/collections/btree_map/struct.VacantEntry.html#method.insert_entry)
52+
- [`impl Extend<proc_macro::Group> for proc_macro::TokenStream`](https://doc.rust-lang.org/stable/proc_macro/struct.TokenStream.html#impl-Extend%3CGroup%3E-for-TokenStream)
53+
- [`impl Extend<proc_macro::Literal> for proc_macro::TokenStream`](https://doc.rust-lang.org/stable/proc_macro/struct.TokenStream.html#impl-Extend%3CLiteral%3E-for-TokenStream)
54+
- [`impl Extend<proc_macro::Punct> for proc_macro::TokenStream`](https://doc.rust-lang.org/stable/proc_macro/struct.TokenStream.html#impl-Extend%3CPunct%3E-for-TokenStream)
55+
- [`impl Extend<proc_macro::Ident> for proc_macro::TokenStream`](https://doc.rust-lang.org/stable/proc_macro/struct.TokenStream.html#impl-Extend%3CIdent%3E-for-TokenStream)
56+
57+
These previously stable APIs are now stable in const contexts:
58+
59+
- [`<[_]>::rotate_left`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.rotate_left)
60+
- [`<[_]>::rotate_right`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.rotate_right)
61+
62+
<a id="1.92.0-Cargo"></a>
63+
64+
Cargo
65+
-----
66+
- [Added a new chapter](https://github.com/rust-lang/cargo/issues/16119) to the Cargo book, ["Optimizing Build Performance"](https://doc.rust-lang.org/stable/cargo/guide/build-performance.html).
67+
68+
<a id="1.92.0-Rustdoc"></a>
69+
70+
Rustdoc
71+
-----
72+
- [If a trait item appears in rustdoc search, hide the corresponding impl items](https://github.com/rust-lang/rust/pull/145898). Previously a search for "last" would show both `Iterator::last` as well as impl methods like `std::vec::IntoIter::last`. Now these impl methods will be hidden, freeing up space for inherent methods like `BTreeSet::last`.
73+
- [Relax rules for identifiers in search](https://github.com/rust-lang/rust/pull/147860). Previously you could only search for identifiers that were valid in rust code, now searches only need to be valid as part of an identifier. For example, you can now perform a search that starts with a digit.
74+
75+
<a id="1.92.0-Compatibility-Notes"></a>
76+
77+
Compatibility Notes
78+
-------------------
79+
* [Fix backtraces with `-C panic=abort` on Linux by generating unwind tables by default](https://github.com/rust-lang/rust/pull/143613). Build with `-C force-unwind-tables=no` to keep omitting unwind tables.
80+
- As part of the larger effort refactoring compiler built-in attributes and their diagnostics, [the future-compatibility lint `invalid_macro_export_arguments` is upgraded to deny-by-default and will be reported in dependencies too.](https://github.com/rust-lang/rust/pull/143857)
81+
- [Update the minimum external LLVM to 20](https://github.com/rust-lang/rust/pull/145071)
82+
- [Prevent downstream `impl DerefMut for Pin<LocalType>`](https://github.com/rust-lang/rust/pull/145608)
83+
- [Don't apply temporary lifetime extension rules to the arguments of non-extended `pin!` and formatting macros](https://github.com/rust-lang/rust/pull/145838)
84+
85+
186
Version 1.91.1 (2025-11-10)
287
===========================
388

compiler/rustc_ast_lowering/src/delegation.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ use hir::{BodyId, HirId};
4444
use rustc_abi::ExternAbi;
4545
use rustc_ast::*;
4646
use rustc_errors::ErrorGuaranteed;
47+
use rustc_hir::attrs::{AttributeKind, InlineAttr};
4748
use rustc_hir::def_id::DefId;
4849
use rustc_middle::span_bug;
4950
use rustc_middle::ty::{Asyncness, ResolverAstLowering};
@@ -87,6 +88,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
8788
let sig_id = self.get_delegation_sig_id(item_id, delegation.id, span, is_in_trait_impl);
8889
match sig_id {
8990
Ok(sig_id) => {
91+
self.add_inline_attribute_if_needed(span);
92+
9093
let is_method = self.is_method(sig_id, span);
9194
let (param_count, c_variadic) = self.param_count(sig_id);
9295
let decl = self.lower_delegation_decl(sig_id, param_count, c_variadic, span);
@@ -100,6 +103,31 @@ impl<'hir> LoweringContext<'_, 'hir> {
100103
}
101104
}
102105

106+
fn add_inline_attribute_if_needed(&mut self, span: Span) {
107+
const PARENT_ID: hir::ItemLocalId = hir::ItemLocalId::ZERO;
108+
let create_inline_attr_slice =
109+
|| [hir::Attribute::Parsed(AttributeKind::Inline(InlineAttr::Hint, span))];
110+
111+
let new_attributes = match self.attrs.get(&PARENT_ID) {
112+
Some(attrs) => {
113+
// Check if reuse already specifies any inline attribute, if so, do nothing
114+
if attrs
115+
.iter()
116+
.any(|a| matches!(a, hir::Attribute::Parsed(AttributeKind::Inline(..))))
117+
{
118+
return;
119+
}
120+
121+
self.arena.alloc_from_iter(
122+
attrs.into_iter().map(|a| a.clone()).chain(create_inline_attr_slice()),
123+
)
124+
}
125+
None => self.arena.alloc_from_iter(create_inline_attr_slice()),
126+
};
127+
128+
self.attrs.insert(PARENT_ID, new_attributes);
129+
}
130+
103131
fn get_delegation_sig_id(
104132
&self,
105133
item_id: NodeId,

compiler/rustc_attr_parsing/src/attributes/cfg.rs

Lines changed: 29 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ use std::convert::identity;
22

33
use rustc_ast::token::Delimiter;
44
use rustc_ast::tokenstream::DelimSpan;
5-
use rustc_ast::{AttrItem, Attribute, CRATE_NODE_ID, LitKind, NodeId, ast, token};
5+
use rustc_ast::{AttrItem, Attribute, CRATE_NODE_ID, LitKind, ast, token};
66
use rustc_errors::{Applicability, PResult};
77
use rustc_feature::{AttrSuggestionStyle, AttributeTemplate, Features, template};
88
use rustc_hir::attrs::CfgEntry;
9+
use rustc_hir::lints::AttributeLintKind;
910
use rustc_hir::{AttrPath, RustcVersion};
1011
use rustc_parse::parser::{ForceCollect, Parser};
1112
use rustc_parse::{exp, parse_in};
1213
use rustc_session::Session;
1314
use rustc_session::config::ExpectedValues;
14-
use rustc_session::lint::BuiltinLintDiag;
1515
use rustc_session::lint::builtin::UNEXPECTED_CFGS;
1616
use rustc_session::parse::{ParseSess, feature_err};
1717
use rustc_span::{ErrorGuaranteed, Span, Symbol, sym};
@@ -23,10 +23,7 @@ use crate::session_diagnostics::{
2323
AttributeParseError, AttributeParseErrorReason, CfgAttrBadDelim, MetaBadDelimSugg,
2424
ParsedDescription,
2525
};
26-
use crate::{
27-
AttributeParser, CfgMatchesLintEmitter, fluent_generated, parse_version, session_diagnostics,
28-
try_gate_cfg,
29-
};
26+
use crate::{AttributeParser, fluent_generated, parse_version, session_diagnostics, try_gate_cfg};
3027

3128
pub const CFG_TEMPLATE: AttributeTemplate = template!(
3229
List: &["predicate"],
@@ -195,43 +192,46 @@ fn parse_name_value<S: Stage>(
195192
}
196193
};
197194

198-
Ok(CfgEntry::NameValue { name, name_span, value, span })
195+
match cx.sess.psess.check_config.expecteds.get(&name) {
196+
Some(ExpectedValues::Some(values)) if !values.contains(&value.map(|(v, _)| v)) => cx
197+
.emit_lint(
198+
UNEXPECTED_CFGS,
199+
AttributeLintKind::UnexpectedCfgValue((name, name_span), value),
200+
span,
201+
),
202+
None if cx.sess.psess.check_config.exhaustive_names => cx.emit_lint(
203+
UNEXPECTED_CFGS,
204+
AttributeLintKind::UnexpectedCfgName((name, name_span), value),
205+
span,
206+
),
207+
_ => { /* not unexpected */ }
208+
}
209+
210+
Ok(CfgEntry::NameValue { name, value: value.map(|(v, _)| v), span })
199211
}
200212

201-
pub fn eval_config_entry(
202-
sess: &Session,
203-
cfg_entry: &CfgEntry,
204-
id: NodeId,
205-
emit_lints: ShouldEmit,
206-
) -> EvalConfigResult {
213+
pub fn eval_config_entry(sess: &Session, cfg_entry: &CfgEntry) -> EvalConfigResult {
207214
match cfg_entry {
208215
CfgEntry::All(subs, ..) => {
209-
let mut all = None;
210216
for sub in subs {
211-
let res = eval_config_entry(sess, sub, id, emit_lints);
212-
// We cannot short-circuit because `eval_config_entry` emits some lints
217+
let res = eval_config_entry(sess, sub);
213218
if !res.as_bool() {
214-
all.get_or_insert(res);
219+
return res;
215220
}
216221
}
217-
all.unwrap_or_else(|| EvalConfigResult::True)
222+
EvalConfigResult::True
218223
}
219224
CfgEntry::Any(subs, span) => {
220-
let mut any = None;
221225
for sub in subs {
222-
let res = eval_config_entry(sess, sub, id, emit_lints);
223-
// We cannot short-circuit because `eval_config_entry` emits some lints
226+
let res = eval_config_entry(sess, sub);
224227
if res.as_bool() {
225-
any.get_or_insert(res);
228+
return res;
226229
}
227230
}
228-
any.unwrap_or_else(|| EvalConfigResult::False {
229-
reason: cfg_entry.clone(),
230-
reason_span: *span,
231-
})
231+
EvalConfigResult::False { reason: cfg_entry.clone(), reason_span: *span }
232232
}
233233
CfgEntry::Not(sub, span) => {
234-
if eval_config_entry(sess, sub, id, emit_lints).as_bool() {
234+
if eval_config_entry(sess, sub).as_bool() {
235235
EvalConfigResult::False { reason: cfg_entry.clone(), reason_span: *span }
236236
} else {
237237
EvalConfigResult::True
@@ -244,32 +244,8 @@ pub fn eval_config_entry(
244244
EvalConfigResult::False { reason: cfg_entry.clone(), reason_span: *span }
245245
}
246246
}
247-
CfgEntry::NameValue { name, name_span, value, span } => {
248-
if let ShouldEmit::ErrorsAndLints = emit_lints {
249-
match sess.psess.check_config.expecteds.get(name) {
250-
Some(ExpectedValues::Some(values))
251-
if !values.contains(&value.map(|(v, _)| v)) =>
252-
{
253-
id.emit_span_lint(
254-
sess,
255-
UNEXPECTED_CFGS,
256-
*span,
257-
BuiltinLintDiag::UnexpectedCfgValue((*name, *name_span), *value),
258-
);
259-
}
260-
None if sess.psess.check_config.exhaustive_names => {
261-
id.emit_span_lint(
262-
sess,
263-
UNEXPECTED_CFGS,
264-
*span,
265-
BuiltinLintDiag::UnexpectedCfgName((*name, *name_span), *value),
266-
);
267-
}
268-
_ => { /* not unexpected */ }
269-
}
270-
}
271-
272-
if sess.psess.config.contains(&(*name, value.map(|(v, _)| v))) {
247+
CfgEntry::NameValue { name, value, span } => {
248+
if sess.psess.config.contains(&(*name, *value)) {
273249
EvalConfigResult::True
274250
} else {
275251
EvalConfigResult::False { reason: cfg_entry.clone(), reason_span: *span }

compiler/rustc_attr_parsing/src/attributes/cfg_old.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use rustc_ast::{LitKind, MetaItem, MetaItemInner, MetaItemKind, MetaItemLit, Nod
22
use rustc_ast_pretty::pprust;
33
use rustc_feature::{Features, GatedCfg, find_gated_cfg};
44
use rustc_hir::RustcVersion;
5+
use rustc_hir::lints::AttributeLintKind;
56
use rustc_session::Session;
67
use rustc_session::config::ExpectedValues;
78
use rustc_session::lint::builtin::UNEXPECTED_CFGS;
@@ -51,21 +52,21 @@ pub fn cfg_matches(
5152
sess,
5253
UNEXPECTED_CFGS,
5354
cfg.span,
54-
BuiltinLintDiag::UnexpectedCfgValue(
55+
BuiltinLintDiag::AttributeLint(AttributeLintKind::UnexpectedCfgValue(
5556
(cfg.name, cfg.name_span),
5657
cfg.value.map(|v| (v, cfg.value_span.unwrap())),
57-
),
58+
)),
5859
);
5960
}
6061
None if sess.psess.check_config.exhaustive_names => {
6162
lint_emitter.emit_span_lint(
6263
sess,
6364
UNEXPECTED_CFGS,
6465
cfg.span,
65-
BuiltinLintDiag::UnexpectedCfgName(
66+
BuiltinLintDiag::AttributeLint(AttributeLintKind::UnexpectedCfgName(
6667
(cfg.name, cfg.name_span),
6768
cfg.value.map(|v| (v, cfg.value_span.unwrap())),
68-
),
69+
)),
6970
);
7071
}
7172
_ => { /* not unexpected */ }

compiler/rustc_builtin_macros/src/cfg.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,7 @@ pub(crate) fn expand_cfg(
2626

2727
ExpandResult::Ready(match parse_cfg(cx, sp, tts) {
2828
Ok(cfg) => {
29-
let matches_cfg = attr::eval_config_entry(
30-
cx.sess,
31-
&cfg,
32-
cx.current_expansion.lint_node_id,
33-
ShouldEmit::ErrorsAndLints,
34-
)
35-
.as_bool();
29+
let matches_cfg = attr::eval_config_entry(cx.sess, &cfg).as_bool();
3630

3731
MacEager::expr(cx.expr_bool(sp, matches_cfg))
3832
}

compiler/rustc_builtin_macros/src/cfg_select.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_ast::tokenstream::TokenStream;
22
use rustc_attr_parsing as attr;
33
use rustc_attr_parsing::{
4-
CfgSelectBranches, CfgSelectPredicate, EvalConfigResult, ShouldEmit, parse_cfg_select,
4+
CfgSelectBranches, CfgSelectPredicate, EvalConfigResult, parse_cfg_select,
55
};
66
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult};
77
use rustc_span::{Ident, Span, sym};
@@ -10,21 +10,13 @@ use crate::errors::{CfgSelectNoMatches, CfgSelectUnreachable};
1010

1111
/// Selects the first arm whose predicate evaluates to true.
1212
fn select_arm(ecx: &ExtCtxt<'_>, branches: CfgSelectBranches) -> Option<(TokenStream, Span)> {
13-
let mut result = None;
1413
for (cfg, tt, arm_span) in branches.reachable {
15-
if let EvalConfigResult::True = attr::eval_config_entry(
16-
&ecx.sess,
17-
&cfg,
18-
ecx.current_expansion.lint_node_id,
19-
ShouldEmit::ErrorsAndLints,
20-
) {
21-
// FIXME(#149215) Ideally we should short-circuit here, but `eval_config_entry` currently emits lints so we cannot do this yet.
22-
result.get_or_insert((tt, arm_span));
14+
if let EvalConfigResult::True = attr::eval_config_entry(&ecx.sess, &cfg) {
15+
return Some((tt, arm_span));
2316
}
2417
}
2518

26-
let wildcard = branches.wildcard.map(|(_, tt, span)| (tt, span));
27-
result.or(wildcard)
19+
branches.wildcard.map(|(_, tt, span)| (tt, span))
2820
}
2921

3022
pub(super) fn expand_cfg_select<'cx>(

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ use find_msvc_tools;
1313
use itertools::Itertools;
1414
use regex::Regex;
1515
use rustc_arena::TypedArena;
16-
use rustc_ast::CRATE_NODE_ID;
17-
use rustc_attr_parsing::{ShouldEmit, eval_config_entry};
16+
use rustc_attr_parsing::eval_config_entry;
1817
use rustc_data_structures::fx::FxIndexSet;
1918
use rustc_data_structures::memmap::Mmap;
2019
use rustc_data_structures::temp_dir::MaybeTempDir;
@@ -3029,9 +3028,7 @@ fn add_dynamic_crate(cmd: &mut dyn Linker, sess: &Session, cratepath: &Path) {
30293028

30303029
fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool {
30313030
match lib.cfg {
3032-
Some(ref cfg) => {
3033-
eval_config_entry(sess, cfg, CRATE_NODE_ID, ShouldEmit::ErrorsAndLints).as_bool()
3034-
}
3031+
Some(ref cfg) => eval_config_entry(sess, cfg).as_bool(),
30353032
None => true,
30363033
}
30373034
}

0 commit comments

Comments
 (0)