Skip to content

Commit 47101ad

Browse files
committed
Auto merge of rust-lang#159316 - jhpratt:rollup-Ap3QBGh, r=jhpratt
Rollup of 15 pull requests Successful merges: - rust-lang#159311 (Add 1.97.1 release notes) - rust-lang#156220 (Implement `VecDeque::truncate_to_range`) - rust-lang#158608 (Implement `#[diagnostic::opaque]` attribute to hide backtraces of macros.) - rust-lang#159168 (Fix static_mut_refs lint check logic) - rust-lang#159242 (resolve: Inherit eager invocation parents) - rust-lang#159256 (Account for async closures when pointing at lifetime in return type) - rust-lang#159310 (cleanup: upstream dropped AMX-TF32) - rust-lang#158348 (Add documentation for the `inline` attribute) - rust-lang#159181 (add rustc_no_writable to mem::forget and structs it uses) - rust-lang#159191 (Mark `PrivateItems` with `std_internals` unstable feature.) - rust-lang#159194 (rustdoc: Fix auto trait normalization env) - rust-lang#159196 (OnceCell: Improve wording in module docs) - rust-lang#159289 (Fix Zulip backport command suggestion) - rust-lang#159294 (renovate: don't update PRs in the merge queue) - rust-lang#159305 (std: clarify available_parallelism docs for Windows 11 processor groups)
2 parents 470556c + b016514 commit 47101ad

70 files changed

Lines changed: 808 additions & 176 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.

.github/renovate.json5

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
],
1414
// Require manual approval from the Dependency Dashboard before opening PRs
1515
"dependencyDashboardApproval": true,
16+
// Renovate shouldn't update a PR if it is in the bors merge queue.
17+
"stopUpdatingLabel": "S-waiting-on-bors",
1618
"packageRules": [
1719
{
1820
// No dashboard approval necessary for GitHub Actions updates

RELEASES.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Version 1.97.1 (2026-07-16)
2+
==========================
3+
4+
<a id="1.97.1"></a>
5+
6+
- [rustc: Fix miscompilation in LLVM optimization](https://github.com/rust-lang/rust/issues/159035)
7+
This backports an LLVM submodule bump to include the LLVM-side fix and a
8+
revert of the rustc change that is one known trigger for the bug. The rustc
9+
side revert should not be strictly necessary but is done out of abundance of caution.
10+
111
Version 1.97.0 (2026-07-09)
212
==========================
313

compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub(crate) mod on_type_error;
2828
pub(crate) mod on_unimplemented;
2929
pub(crate) mod on_unknown;
3030
pub(crate) mod on_unmatched_args;
31+
pub(crate) mod opaque;
3132

3233
#[derive(Copy, Clone)]
3334
pub(crate) enum Mode {
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
use rustc_feature::AttributeStability;
2+
use rustc_hir::Target;
3+
use rustc_hir::attrs::AttributeKind;
4+
use rustc_session::lint::builtin::MALFORMED_DIAGNOSTIC_ATTRIBUTES;
5+
use rustc_span::{Span, sym};
6+
7+
use crate::attributes::{AcceptMapping, AttributeParser};
8+
use crate::context::{AcceptContext, FinalizeContext};
9+
use crate::diagnostics::OpaqueDoesNotExpectArgs;
10+
use crate::parser::ArgParser;
11+
use crate::target_checking::AllowedTargets;
12+
use crate::target_checking::Policy::Allow;
13+
use crate::{template, unstable};
14+
15+
#[derive(Default)]
16+
pub(crate) struct OpaqueParser {
17+
attr_span: Option<Span>,
18+
}
19+
20+
impl AttributeParser for OpaqueParser {
21+
const ATTRIBUTES: AcceptMapping<Self> = &[
22+
(
23+
&[sym::diagnostic, sym::opaque],
24+
template!(Word),
25+
AttributeStability::Stable, // Unstable, stability checked manually in the parser
26+
|this, cx, args| {
27+
if !cx.features().diagnostic_opaque() {
28+
return;
29+
}
30+
this.parse(cx, args);
31+
},
32+
),
33+
(
34+
// For use on exported macros, where using tool attributes is an error.
35+
&[sym::rustc_diagnostic_opaque],
36+
template!(Word),
37+
unstable!(
38+
rustc_attrs,
39+
"see `#[diagnostic::opaque]` for the nightly equivalent of this attribute"
40+
),
41+
OpaqueParser::parse,
42+
),
43+
];
44+
const ALLOWED_TARGETS: AllowedTargets<'_> =
45+
AllowedTargets::AllowListWarnRest(&[Allow(Target::MacroDef)]);
46+
47+
fn finalize(self, _cx: &FinalizeContext<'_, '_>) -> Option<AttributeKind> {
48+
if let Some(_) = self.attr_span { Some(AttributeKind::Opaque) } else { None }
49+
}
50+
}
51+
52+
impl OpaqueParser {
53+
fn parse<'sess>(&mut self, cx: &mut AcceptContext<'_, 'sess>, args: &ArgParser) {
54+
let attr_span = cx.attr_span;
55+
if let Some(earlier_span) = self.attr_span {
56+
cx.warn_unused_duplicate(earlier_span, attr_span);
57+
}
58+
self.attr_span = Some(attr_span);
59+
60+
if !matches!(args, ArgParser::NoArgs) {
61+
cx.emit_lint(MALFORMED_DIAGNOSTIC_ATTRIBUTES, OpaqueDoesNotExpectArgs, attr_span);
62+
}
63+
}
64+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use crate::attributes::diagnostic::on_type_error::*;
3636
use crate::attributes::diagnostic::on_unimplemented::*;
3737
use crate::attributes::diagnostic::on_unknown::*;
3838
use crate::attributes::diagnostic::on_unmatched_args::*;
39+
use crate::attributes::diagnostic::opaque::*;
3940
use crate::attributes::doc::*;
4041
use crate::attributes::dummy::*;
4142
use crate::attributes::inline::*;
@@ -151,6 +152,7 @@ attribute_parsers!(
151152
OnUnimplementedParser,
152153
OnUnknownParser,
153154
OnUnmatchedArgsParser,
155+
OpaqueParser,
154156
RustcAlignParser,
155157
RustcAlignStaticParser,
156158
RustcCguTestAttributeParser,

compiler/rustc_attr_parsing/src/diagnostics.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ pub(crate) struct AttrCrateLevelOnly;
279279
#[diag("`#[diagnostic::do_not_recommend]` does not expect any arguments")]
280280
pub(crate) struct DoNotRecommendDoesNotExpectArgs;
281281

282+
#[derive(Diagnostic)]
283+
#[diag("`#[diagnostic::opaque]` does not expect any arguments")]
284+
pub(crate) struct OpaqueDoesNotExpectArgs;
285+
282286
#[derive(Diagnostic)]
283287
#[diag("invalid `crate_type` value")]
284288
pub(crate) struct UnknownCrateTypes {

compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,12 +791,18 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
791791
fn give_name_if_anonymous_region_appears_in_output(&self, fr: RegionVid) -> Option<RegionName> {
792792
let tcx = self.infcx.tcx;
793793

794-
let return_ty = self.regioncx.universal_regions().unnormalized_output_ty;
794+
let mut return_ty = self.regioncx.universal_regions().unnormalized_output_ty;
795795
debug!("give_name_if_anonymous_region_appears_in_output: return_ty = {:?}", return_ty);
796796
if !tcx.any_free_region_meets(&return_ty, |r| r.as_var() == fr) {
797797
return None;
798798
}
799799

800+
if let ty::Coroutine(_, args) = return_ty.kind() {
801+
// When the return type is identified to be `{async closure body}`, we instead care
802+
// about the actual return type of that coroutine.
803+
return_ty = args.as_coroutine().return_ty();
804+
}
805+
800806
let mir_hir_id = self.mir_hir_id();
801807

802808
let (return_span, mir_description, hir_ty) = match tcx.hir_node(mir_hir_id) {

compiler/rustc_errors/src/emitter.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ pub trait Emitter {
175175
ExpnKind::Desugaring(..) | ExpnKind::AstPass(..) => None,
176176

177177
ExpnKind::Macro(macro_kind, name) => {
178-
Some((macro_kind, name, expn_data.hide_backtrace))
178+
Some((macro_kind, name, expn_data.diagnostic_opaque))
179179
}
180180
}
181181
})
@@ -188,8 +188,7 @@ pub trait Emitter {
188188
self.render_multispans_macro_backtrace(span, children, backtrace);
189189

190190
if !backtrace {
191-
// Skip builtin macros, as their expansion isn't relevant to the end user. This includes
192-
// actual intrinsics, like `asm!`.
191+
// Skip macros annotated with `#[diagnostic::opaque]`. Builtin macros are "opaque" too.
193192
if let Some((macro_kind, name, _)) = has_macro_spans.first()
194193
&& let Some((_, _, false)) = has_macro_spans.last()
195194
{
@@ -334,18 +333,25 @@ pub trait Emitter {
334333
// we move these spans from the external macros to their corresponding use site.
335334
fn fix_multispan_in_extern_macros(&self, span: &mut MultiSpan) {
336335
let Some(source_map) = self.source_map() else { return };
336+
let should_hide = |span| {
337+
source_map.is_imported(span) || {
338+
let expn = span.data().ctxt.outer_expn_data();
339+
expn.diagnostic_opaque && matches!(expn.kind, ExpnKind::Macro(MacroKind::Bang, _))
340+
}
341+
};
342+
337343
// First, find all the spans in external macros and point instead at their use site.
338344
let replacements: Vec<(Span, Span)> = span
339345
.primary_spans()
340346
.iter()
341347
.copied()
342348
.chain(span.span_labels().iter().map(|sp_label| sp_label.span))
343349
.filter_map(|sp| {
344-
if !sp.is_dummy() && source_map.is_imported(sp) {
350+
if !sp.is_dummy() && should_hide(sp) {
345351
let mut span = sp;
346352
while let Some(callsite) = span.parent_callsite() {
347353
span = callsite;
348-
if !source_map.is_imported(span) {
354+
if !should_hide(span) {
349355
return Some((sp, span));
350356
}
351357
}

compiler/rustc_expand/src/base.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -797,9 +797,9 @@ pub struct SyntaxExtension {
797797
/// Should debuginfo for the macro be collapsed to the outermost expansion site (in other
798798
/// words, was the macro definition annotated with `#[collapse_debuginfo]`)?
799799
pub collapse_debuginfo: bool,
800-
/// Suppresses the "this error originates in the macro" note when a diagnostic points at this
801-
/// macro.
802-
pub hide_backtrace: bool,
800+
/// Prevents diagnostics pointing into this macro and suppresses the "this error originates in
801+
/// the macro" note when a diagnostic points at this macro.
802+
pub diagnostic_opaque: bool,
803803
}
804804

805805
impl SyntaxExtension {
@@ -833,7 +833,7 @@ impl SyntaxExtension {
833833
allow_internal_unsafe: false,
834834
local_inner_macros: false,
835835
collapse_debuginfo: false,
836-
hide_backtrace: false,
836+
diagnostic_opaque: false,
837837
}
838838
}
839839

@@ -863,12 +863,6 @@ impl SyntaxExtension {
863863
collapse_table[flag as usize][attr as usize]
864864
}
865865

866-
fn get_hide_backtrace(attrs: &[hir::Attribute]) -> bool {
867-
// FIXME(estebank): instead of reusing `#[rustc_diagnostic_item]` as a proxy, introduce a
868-
// new attribute purely for this under the `#[diagnostic]` namespace.
869-
find_attr!(attrs, RustcDiagnosticItem(..))
870-
}
871-
872866
/// Constructs a syntax extension with the given properties
873867
/// and other properties converted from attributes.
874868
pub fn new(
@@ -903,7 +897,8 @@ impl SyntaxExtension {
903897
// Not a built-in macro
904898
None => (None, helper_attrs),
905899
};
906-
let hide_backtrace = builtin_name.is_some() || Self::get_hide_backtrace(attrs);
900+
let diagnostic_opaque = builtin_name.is_some()
901+
|| (!sess.opts.unstable_opts.macro_backtrace && find_attr!(attrs, Opaque));
907902

908903
let stability = find_attr!(attrs, Stability { stability, .. } => *stability);
909904

@@ -931,7 +926,7 @@ impl SyntaxExtension {
931926
allow_internal_unsafe,
932927
local_inner_macros,
933928
collapse_debuginfo,
934-
hide_backtrace,
929+
diagnostic_opaque,
935930
}
936931
}
937932

@@ -1017,7 +1012,7 @@ impl SyntaxExtension {
10171012
self.allow_internal_unsafe,
10181013
self.local_inner_macros,
10191014
self.collapse_debuginfo,
1020-
self.hide_backtrace,
1015+
self.diagnostic_opaque,
10211016
)
10221017
}
10231018
}

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ pub static BUILTIN_ATTRIBUTES: &[Symbol] = &[
321321
// Used by the `rustc::bad_opt_access` lint on fields
322322
// types (as well as any others in future).
323323
sym::rustc_lint_opt_deny_field_access,
324+
sym::rustc_diagnostic_opaque,
324325

325326
// ==========================================================================
326327
// Internal attributes, Const related:

0 commit comments

Comments
 (0)