Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7f3569b
Implement diagnostic::opaque attribute
mejrs Jun 29, 2026
6a17b79
Remove `hide_backtrace`
mejrs Jun 29, 2026
106bb96
Remove `rustc_diagnostic_item` hack
mejrs Jul 5, 2026
ec8c18f
Un-copy-paste Dropper in VecDeque code
cammeresi May 3, 2026
ba313dd
Implement `VecDeque::retain_range`
cammeresi May 3, 2026
f371a62
Tidy up library/alloctests/tests/lib.rs
cammeresi May 13, 2026
a98d8ad
Fix static-mut-refs lint check logic
cclfmht Jul 12, 2026
cb055bc
Do not suggest interior mutable types for explicit borrows
cclfmht Jul 12, 2026
1e65341
Bless UI tests covered by `static_mut_refs` lint
cclfmht Jul 12, 2026
b5e580d
Mark `PrivateItems` with `std_internals` unstable feature.
obi1kenobi Jul 12, 2026
1592a06
Fix rustdoc auto trait normalization env
Dnreikronos Jul 12, 2026
45b58f3
OnceCell: Improve wording in module docs
Wilfred Jul 12, 2026
ab4b9bf
Add documentation for the `inline` attribute
valentynkit Jun 24, 2026
6866a94
Account for async closures when pointing at lifetime in return type
estebank Jul 13, 2026
38fa9b5
Inherit eager invocation parents
Dnreikronos Jul 14, 2026
c8fe362
Add eager glob delegation regression test
Dnreikronos Jul 14, 2026
52f8891
renovate: don't update PRs in the merge queue
marcoieni Jul 14, 2026
cbeec91
Fix Zulip backport command suggestion
apiraino Jul 14, 2026
5411bb0
std: clarify available_parallelism docs for Windows 11 processor groups
valentynkit Jul 14, 2026
c72a794
add rustc_no_writable to mem::forget and structs it uses
quiode Jul 14, 2026
1a56799
cleanup: upstream dropped AMX-TF32
krasimirgg Jul 9, 2026
a05a270
Add 1.97.1 release notes
Mark-Simulacrum Jul 14, 2026
1c70cd1
Rollup merge of #159311 - Mark-Simulacrum:relnotes-1.97.1, r=Mark-Sim…
jhpratt Jul 15, 2026
319376c
Rollup merge of #156220 - cammeresi:20260505-truncate-to-range, r=nia-e
jhpratt Jul 15, 2026
2d4ae66
Rollup merge of #158608 - mejrs:opaque, r=estebank
jhpratt Jul 15, 2026
c0a4d3f
Rollup merge of #159168 - cclfmht:fix/issue-158735, r=estebank
jhpratt Jul 15, 2026
58f1e26
Rollup merge of #159242 - Dnreikronos:resolver/eager_invocation_paren…
jhpratt Jul 15, 2026
c20383d
Rollup merge of #159256 - estebank:coroutine-ret-ty, r=workingjubilee
jhpratt Jul 15, 2026
bd86099
Rollup merge of #159310 - gmittert:RmAmxTf32, r=sayantn,workingjubilee
jhpratt Jul 15, 2026
812c630
Rollup merge of #158348 - valentynkit:docs-inline-attribute, r=Guilla…
jhpratt Jul 15, 2026
574e589
Rollup merge of #159181 - quiode:mem--forget-implicit-writes, r=RalfJung
jhpratt Jul 15, 2026
be2882d
Rollup merge of #159191 - obi1kenobi:pg/std-internals-feature-private…
jhpratt Jul 15, 2026
c9f7583
Rollup merge of #159194 - Dnreikronos:rustdoc/auto_trait_param_env, r…
jhpratt Jul 15, 2026
52867ef
Rollup merge of #159196 - Wilfred:patch-2, r=jhpratt
jhpratt Jul 15, 2026
9478e35
Rollup merge of #159289 - apiraino:fix-backport-msg-suggestion, r=Urgau
jhpratt Jul 15, 2026
9296225
Rollup merge of #159294 - marcoieni:renovate-stop-updating, r=Kobzol
jhpratt Jul 15, 2026
b016514
Rollup merge of #159305 - valentynkit:docs/available-parallelism-wind…
jhpratt Jul 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
],
// Require manual approval from the Dependency Dashboard before opening PRs
"dependencyDashboardApproval": true,
// Renovate shouldn't update a PR if it is in the bors merge queue.
"stopUpdatingLabel": "S-waiting-on-bors",
"packageRules": [
{
// No dashboard approval necessary for GitHub Actions updates
Expand Down
10 changes: 10 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Version 1.97.1 (2026-07-16)
==========================

<a id="1.97.1"></a>

- [rustc: Fix miscompilation in LLVM optimization](https://github.com/rust-lang/rust/issues/159035)
This backports an LLVM submodule bump to include the LLVM-side fix and a
revert of the rustc change that is one known trigger for the bug. The rustc
side revert should not be strictly necessary but is done out of abundance of caution.

Version 1.97.0 (2026-07-09)
==========================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub(crate) mod on_type_error;
pub(crate) mod on_unimplemented;
pub(crate) mod on_unknown;
pub(crate) mod on_unmatched_args;
pub(crate) mod opaque;

#[derive(Copy, Clone)]
pub(crate) enum Mode {
Expand Down
64 changes: 64 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/diagnostic/opaque.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
use rustc_feature::AttributeStability;
use rustc_hir::Target;
use rustc_hir::attrs::AttributeKind;
use rustc_session::lint::builtin::MALFORMED_DIAGNOSTIC_ATTRIBUTES;
use rustc_span::{Span, sym};

use crate::attributes::{AcceptMapping, AttributeParser};
use crate::context::{AcceptContext, FinalizeContext};
use crate::diagnostics::OpaqueDoesNotExpectArgs;
use crate::parser::ArgParser;
use crate::target_checking::AllowedTargets;
use crate::target_checking::Policy::Allow;
use crate::{template, unstable};

#[derive(Default)]
pub(crate) struct OpaqueParser {
attr_span: Option<Span>,
}

impl AttributeParser for OpaqueParser {
const ATTRIBUTES: AcceptMapping<Self> = &[
(
&[sym::diagnostic, sym::opaque],
template!(Word),
AttributeStability::Stable, // Unstable, stability checked manually in the parser
|this, cx, args| {
if !cx.features().diagnostic_opaque() {
return;
}
this.parse(cx, args);
},
),
(
// For use on exported macros, where using tool attributes is an error.
&[sym::rustc_diagnostic_opaque],
template!(Word),
unstable!(
rustc_attrs,
"see `#[diagnostic::opaque]` for the nightly equivalent of this attribute"
),
OpaqueParser::parse,
),
];
const ALLOWED_TARGETS: AllowedTargets<'_> =
AllowedTargets::AllowListWarnRest(&[Allow(Target::MacroDef)]);

fn finalize(self, _cx: &FinalizeContext<'_, '_>) -> Option<AttributeKind> {
if let Some(_) = self.attr_span { Some(AttributeKind::Opaque) } else { None }
}
}

impl OpaqueParser {
fn parse<'sess>(&mut self, cx: &mut AcceptContext<'_, 'sess>, args: &ArgParser) {
let attr_span = cx.attr_span;
if let Some(earlier_span) = self.attr_span {
cx.warn_unused_duplicate(earlier_span, attr_span);
}
self.attr_span = Some(attr_span);

if !matches!(args, ArgParser::NoArgs) {
cx.emit_lint(MALFORMED_DIAGNOSTIC_ATTRIBUTES, OpaqueDoesNotExpectArgs, attr_span);
}
}
}
2 changes: 2 additions & 0 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use crate::attributes::diagnostic::on_type_error::*;
use crate::attributes::diagnostic::on_unimplemented::*;
use crate::attributes::diagnostic::on_unknown::*;
use crate::attributes::diagnostic::on_unmatched_args::*;
use crate::attributes::diagnostic::opaque::*;
use crate::attributes::doc::*;
use crate::attributes::dummy::*;
use crate::attributes::inline::*;
Expand Down Expand Up @@ -151,6 +152,7 @@ attribute_parsers!(
OnUnimplementedParser,
OnUnknownParser,
OnUnmatchedArgsParser,
OpaqueParser,
RustcAlignParser,
RustcAlignStaticParser,
RustcCguTestAttributeParser,
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_attr_parsing/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ pub(crate) struct AttrCrateLevelOnly;
#[diag("`#[diagnostic::do_not_recommend]` does not expect any arguments")]
pub(crate) struct DoNotRecommendDoesNotExpectArgs;

#[derive(Diagnostic)]
#[diag("`#[diagnostic::opaque]` does not expect any arguments")]
pub(crate) struct OpaqueDoesNotExpectArgs;

#[derive(Diagnostic)]
#[diag("invalid `crate_type` value")]
pub(crate) struct UnknownCrateTypes {
Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_borrowck/src/diagnostics/region_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,12 +791,18 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
fn give_name_if_anonymous_region_appears_in_output(&self, fr: RegionVid) -> Option<RegionName> {
let tcx = self.infcx.tcx;

let return_ty = self.regioncx.universal_regions().unnormalized_output_ty;
let mut return_ty = self.regioncx.universal_regions().unnormalized_output_ty;
debug!("give_name_if_anonymous_region_appears_in_output: return_ty = {:?}", return_ty);
if !tcx.any_free_region_meets(&return_ty, |r| r.as_var() == fr) {
return None;
}

if let ty::Coroutine(_, args) = return_ty.kind() {
// When the return type is identified to be `{async closure body}`, we instead care
// about the actual return type of that coroutine.
return_ty = args.as_coroutine().return_ty();
}

let mir_hir_id = self.mir_hir_id();

let (return_span, mir_description, hir_ty) = match tcx.hir_node(mir_hir_id) {
Expand Down
16 changes: 11 additions & 5 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ pub trait Emitter {
ExpnKind::Desugaring(..) | ExpnKind::AstPass(..) => None,

ExpnKind::Macro(macro_kind, name) => {
Some((macro_kind, name, expn_data.hide_backtrace))
Some((macro_kind, name, expn_data.diagnostic_opaque))
}
}
})
Expand All @@ -188,8 +188,7 @@ pub trait Emitter {
self.render_multispans_macro_backtrace(span, children, backtrace);

if !backtrace {
// Skip builtin macros, as their expansion isn't relevant to the end user. This includes
// actual intrinsics, like `asm!`.
// Skip macros annotated with `#[diagnostic::opaque]`. Builtin macros are "opaque" too.
if let Some((macro_kind, name, _)) = has_macro_spans.first()
&& let Some((_, _, false)) = has_macro_spans.last()
{
Expand Down Expand Up @@ -334,18 +333,25 @@ pub trait Emitter {
// we move these spans from the external macros to their corresponding use site.
fn fix_multispan_in_extern_macros(&self, span: &mut MultiSpan) {
let Some(source_map) = self.source_map() else { return };
let should_hide = |span| {
source_map.is_imported(span) || {
let expn = span.data().ctxt.outer_expn_data();
expn.diagnostic_opaque && matches!(expn.kind, ExpnKind::Macro(MacroKind::Bang, _))
}
};

// First, find all the spans in external macros and point instead at their use site.
let replacements: Vec<(Span, Span)> = span
.primary_spans()
.iter()
.copied()
.chain(span.span_labels().iter().map(|sp_label| sp_label.span))
.filter_map(|sp| {
if !sp.is_dummy() && source_map.is_imported(sp) {
if !sp.is_dummy() && should_hide(sp) {
let mut span = sp;
while let Some(callsite) = span.parent_callsite() {
span = callsite;
if !source_map.is_imported(span) {
if !should_hide(span) {
return Some((sp, span));
}
}
Expand Down
21 changes: 8 additions & 13 deletions compiler/rustc_expand/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,9 +797,9 @@ pub struct SyntaxExtension {
/// Should debuginfo for the macro be collapsed to the outermost expansion site (in other
/// words, was the macro definition annotated with `#[collapse_debuginfo]`)?
pub collapse_debuginfo: bool,
/// Suppresses the "this error originates in the macro" note when a diagnostic points at this
/// macro.
pub hide_backtrace: bool,
/// Prevents diagnostics pointing into this macro and suppresses the "this error originates in
/// the macro" note when a diagnostic points at this macro.
pub diagnostic_opaque: bool,
}

impl SyntaxExtension {
Expand Down Expand Up @@ -833,7 +833,7 @@ impl SyntaxExtension {
allow_internal_unsafe: false,
local_inner_macros: false,
collapse_debuginfo: false,
hide_backtrace: false,
diagnostic_opaque: false,
}
}

Expand Down Expand Up @@ -863,12 +863,6 @@ impl SyntaxExtension {
collapse_table[flag as usize][attr as usize]
}

fn get_hide_backtrace(attrs: &[hir::Attribute]) -> bool {
// FIXME(estebank): instead of reusing `#[rustc_diagnostic_item]` as a proxy, introduce a
// new attribute purely for this under the `#[diagnostic]` namespace.
find_attr!(attrs, RustcDiagnosticItem(..))
}

/// Constructs a syntax extension with the given properties
/// and other properties converted from attributes.
pub fn new(
Expand Down Expand Up @@ -903,7 +897,8 @@ impl SyntaxExtension {
// Not a built-in macro
None => (None, helper_attrs),
};
let hide_backtrace = builtin_name.is_some() || Self::get_hide_backtrace(attrs);
let diagnostic_opaque = builtin_name.is_some()
|| (!sess.opts.unstable_opts.macro_backtrace && find_attr!(attrs, Opaque));

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

Expand Down Expand Up @@ -931,7 +926,7 @@ impl SyntaxExtension {
allow_internal_unsafe,
local_inner_macros,
collapse_debuginfo,
hide_backtrace,
diagnostic_opaque,
}
}

Expand Down Expand Up @@ -1017,7 +1012,7 @@ impl SyntaxExtension {
self.allow_internal_unsafe,
self.local_inner_macros,
self.collapse_debuginfo,
self.hide_backtrace,
self.diagnostic_opaque,
)
}
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ pub static BUILTIN_ATTRIBUTES: &[Symbol] = &[
// Used by the `rustc::bad_opt_access` lint on fields
// types (as well as any others in future).
sym::rustc_lint_opt_deny_field_access,
sym::rustc_diagnostic_opaque,

// ==========================================================================
// Internal attributes, Const related:
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,8 @@ declare_features! (
(unstable, diagnostic_on_unknown, "1.96.0", Some(152900)),
/// Allows macros to customize macro argument matcher diagnostics.
(unstable, diagnostic_on_unmatched_args, "1.97.0", Some(155642)),
// Used by macros to not show their bodies in error messages. No-op with `-Z macro-backtrace`.
(unstable, diagnostic_opaque, "CURRENT_RUSTC_VERSION", Some(158813)),
/// Allows `#[doc(cfg(...))]`.
(unstable, doc_cfg, "1.21.0", Some(43781)),
/// Allows `#[doc(masked)]`.
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_hir/src/attrs/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,9 @@ pub enum AttributeKind {
directive: Option<Box<Directive>>,
},

/// Represents `#[diagnostic::opaque]`.
Opaque,

/// Represents `#[optimize(size|speed)]`
Optimize(OptimizeAttr, Span),

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/attrs/encode_cross_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ impl AttributeKind {
OnUnimplemented { .. } => Yes,
OnUnknown { .. } => Yes,
OnUnmatchedArgs { .. } => Yes,
Opaque => Yes,
Optimize(..) => No,
PanicRuntime => No,
PatchableFunctionEntry { .. } => Yes,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2726,7 +2726,7 @@ pub(crate) enum MutRefSugg {

#[derive(Subdiagnostic)]
#[suggestion(
"this type already provides \"interior mutability\", so its binding doesn't need to be declared as mutable",
"this type already provides \"interior mutability\", so its binding doesn't need to be declared as mutable when borrowed with a shared reference",
style = "verbose",
applicability = "maybe-incorrect",
code = ""
Expand Down
10 changes: 8 additions & 2 deletions compiler/rustc_lint/src/static_mut_refs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ fn emit_static_mut_refs(
};

let (interior_mutability_help, interior_mutability_sugg) =
interior_mutability_suggestion(cx, def_id);
interior_mutability_suggestion(cx, def_id, mut_note, suggest_addr_of);

cx.emit_span_lint(
STATIC_MUT_REFS,
Expand All @@ -208,17 +208,23 @@ fn emit_static_mut_refs(
fn interior_mutability_suggestion(
cx: &LateContext<'_>,
def_id: DefId,
mut_ref: bool,
suggest_addr_of: bool,
) -> (bool, Option<StaticMutRefsInteriorMutabilitySugg>) {
let static_ty = cx.tcx.type_of(def_id).skip_binder();
let has_interior_mutability = !static_ty.is_freeze(cx.tcx, cx.typing_env());

if !has_interior_mutability {
return (!suggest_addr_of, None);
}

if mut_ref {
return (false, None);
}

let sugg =
static_mutability_span(cx, def_id).map(|span| StaticMutRefsInteriorMutabilitySugg { span });
(sugg.is_none(), sugg)
(false, sugg)
}

fn static_mutability_span(cx: &LateContext<'_>, def_id: DefId) -> Option<Span> {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
AttributeKind::NoStd { .. } => (),
AttributeKind::OnUnknown { .. } => (),
AttributeKind::OnUnmatchedArgs { .. } => (),
AttributeKind::Opaque => (),
AttributeKind::Optimize(..) => (),
AttributeKind::PanicRuntime => (),
AttributeKind::PatchableFunctionEntry { .. } => (),
Expand Down
Loading
Loading