Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
5dd0500
Windows: Cache the pipe filesystem handle
ChrisDenton Apr 13, 2026
bb9788b
Add _mm512_permutexvar_epi64 shim
elichai Apr 14, 2026
c567332
Implemented PermissionsExt ACP on Windows, which provides functions/u…
asder8215 Apr 11, 2026
e1ef601
Adjust Documentation for `RawOsError`
bushrat011899 Apr 20, 2026
4cb72b3
Adjust Usage of `RawOsError`
bushrat011899 Apr 20, 2026
7653e5e
Move `RawOsError` to `core::io`
bushrat011899 Apr 20, 2026
a6ec294
Explicitly note that we're leaking a handle
ChrisDenton Apr 21, 2026
2f73eee
unnamed_socket: do not introduce artifical short reads/writes
RalfJung Apr 22, 2026
17aae34
rename unnamed_socket -> virtual_socket
RalfJung Apr 22, 2026
bb80f4e
Use windows-sys 0.61 in tests
bjorn3 Apr 23, 2026
c77b198
chore: disable short reads/writes for TCP sockets
WhySoBad Apr 23, 2026
83a157f
Merge pull request #4975 from RalfJung/internal_socket
RalfJung Apr 23, 2026
2d5f931
Merge pull request #4977 from WhySoBad/network-socket-disable-short-ops
RalfJung Apr 23, 2026
e55e812
Merge pull request #4976 from bjorn3/windows_sys_0_61
RalfJung Apr 23, 2026
d49039c
Use `AtomicUsize` instead of `AtomicBool` to test weak atomic
SpriteOvO Apr 23, 2026
b366dcd
Merge pull request #4971 from SpriteOvO/rv-weak-atomic-test
RalfJung Apr 23, 2026
e917fdc
add test
dianne Mar 5, 2026
b4e013b
fix cstr clone_into unsoundness
Manishearth Apr 23, 2026
c96d970
bump openssl-sys to support OpenSSL 4.0.x
heitbaum Apr 24, 2026
5276fcd
prevent deref coercions in `pin!`
dianne Mar 5, 2026
e509d19
Prepare for merging from rust-lang/rust
Apr 24, 2026
a19421c
Merge ref '9836b06b55f5' from rust-lang/rust
Apr 24, 2026
986eabe
Merge pull request #4979 from rust-lang/rustup-2026-04-24
oli-obk Apr 24, 2026
ffc86e7
Merge pull request #4978 from heitbaum/openssl-4.0.x
RalfJung Apr 24, 2026
d4ca795
Merge pull request #4962 from elichai/elichai/_mm512_permutexvar_epi64
RalfJung Apr 24, 2026
058a8b9
Support fstat on non-file-backed FDs
enthropy7 Mar 5, 2026
29d58f8
Utilize `if let` guards where aproppriate
Human9000-bit Apr 25, 2026
b6c6dd1
macro_metavar_expr_concat: explain why idents are invalid
mejrs Apr 25, 2026
f113540
Remove unnecessary uses of `AttributeExt`
JonathanBrouwer Apr 25, 2026
e3b0e9d
Remove `deprecation_note` from `AttributeExt`
JonathanBrouwer Apr 25, 2026
efaf460
Mention DEPRECATED_LLVM_INTRINSIC lint for internal use
shian15810 Apr 26, 2026
79e10fd
Remove the incomplete marker from `impl` restrictions
CoCo-Japan-pan Apr 26, 2026
2c16f9e
Suggest enclosing format string with `""` under special cases
cclfmht Apr 26, 2026
c91a363
merge fstat and metadata functions
RalfJung Apr 26, 2026
9ae47c9
Merge pull request #4812 from enthropy7/master
RalfJung Apr 26, 2026
f107bb8
Regression test for improper spans in inclusive-range suggestions
Zalathar Apr 26, 2026
9ceed25
Avoid improper spans when `...` or `..=` is recovered from non-ASCII
Zalathar Apr 26, 2026
48fe89f
add default field values to diagnostic FormatArgs
mejrs Apr 26, 2026
28c079a
Suggest `.iter()` for shared projections
qaijuang Apr 26, 2026
7c71f48
Rollup merge of #152995 - asder8215:windows_permissions_ext, r=Mark-S…
JonathanBrouwer Apr 26, 2026
691ab1b
Rollup merge of #153457 - dianne:no-coercing-in-pin-macro, r=Mark-Sim…
JonathanBrouwer Apr 26, 2026
eb779a1
Rollup merge of #155250 - ChrisDenton:pipe-fs, r=Mark-Simulacrum
JonathanBrouwer Apr 26, 2026
9170ff7
Rollup merge of #155574 - bushrat011899:core_io_raw_os_error, r=Mark-…
JonathanBrouwer Apr 26, 2026
382ec81
Rollup merge of #155757 - mejrs:ident_help, r=Kivooeo
JonathanBrouwer Apr 26, 2026
a722bc8
Rollup merge of #155823 - RalfJung:miri, r=RalfJung
JonathanBrouwer Apr 26, 2026
fa16f81
Rollup merge of #155693 - cclfmht:fix/issue-155508, r=ShoyuVanilla
JonathanBrouwer Apr 26, 2026
27aa1c5
Rollup merge of #155707 - Manishearth:cstring-vuln, r=Mark-Simulacrum
JonathanBrouwer Apr 26, 2026
59ca5ae
Rollup merge of #155719 - qaijuang:suggest-iter-for-shared-projection…
JonathanBrouwer Apr 26, 2026
ecdcd0e
Rollup merge of #155779 - Human9000-bit:ssa-range-prop-ref, r=Kivooeo
JonathanBrouwer Apr 26, 2026
37b53a9
Rollup merge of #155789 - JonathanBrouwer:attribute-ext, r=mejrs
JonathanBrouwer Apr 26, 2026
c96f7d2
Rollup merge of #155805 - shian15810:patch-1, r=mejrs
JonathanBrouwer Apr 26, 2026
b227d45
Rollup merge of #155806 - CoCo-Japan-pan:impl-restriction-mark-unstab…
JonathanBrouwer Apr 26, 2026
ae77516
Rollup merge of #155820 - Zalathar:range, r=Kivooeo
JonathanBrouwer Apr 26, 2026
139bcba
Rollup merge of #155822 - mejrs:default_fmt_args, r=JonathanBrouwer
JonathanBrouwer Apr 26, 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
69 changes: 32 additions & 37 deletions compiler/rustc_ast/src/attr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,34 +235,6 @@ impl AttributeExt for Attribute {
}
}

fn deprecation_note(&self) -> Option<Ident> {
match &self.kind {
AttrKind::Normal(normal) if normal.item.path == sym::deprecated => {
let meta = &normal.item;

// #[deprecated = "..."]
if let Some(s) = meta.value_str() {
return Some(Ident { name: s, span: meta.span() });
}

// #[deprecated(note = "...")]
if let Some(list) = meta.meta_item_list() {
for nested in list {
if let Some(mi) = nested.meta_item()
&& mi.path == sym::note
&& let Some(s) = mi.value_str()
{
return Some(Ident { name: s, span: mi.span });
}
}
}

None
}
_ => None,
}
}

fn doc_resolution_scope(&self) -> Option<AttrStyle> {
match &self.kind {
AttrKind::DocComment(..) => Some(self.style),
Expand Down Expand Up @@ -341,6 +313,34 @@ impl Attribute {
)],
}
}

pub fn deprecation_note(&self) -> Option<Ident> {
match &self.kind {
AttrKind::Normal(normal) if normal.item.path == sym::deprecated => {
let meta = &normal.item;

// #[deprecated = "..."]
if let Some(s) = meta.value_str() {
return Some(Ident { name: s, span: meta.span() });
}

// #[deprecated(note = "...")]
if let Some(list) = meta.meta_item_list() {
for nested in list {
if let Some(mi) = nested.meta_item()
&& mi.path == sym::note
&& let Some(s) = mi.value_str()
{
return Some(Ident { name: s, span: mi.span });
}
}
}

None
}
_ => None,
}
}
}

impl AttrItem {
Expand Down Expand Up @@ -824,19 +824,19 @@ pub fn mk_attr_name_value_str(
mk_attr(g, style, unsafety, path, args, span)
}

pub fn filter_by_name<A: AttributeExt>(attrs: &[A], name: Symbol) -> impl Iterator<Item = &A> {
pub fn filter_by_name(attrs: &[Attribute], name: Symbol) -> impl Iterator<Item = &Attribute> {
attrs.iter().filter(move |attr| attr.has_name(name))
}

pub fn find_by_name<A: AttributeExt>(attrs: &[A], name: Symbol) -> Option<&A> {
pub fn find_by_name(attrs: &[Attribute], name: Symbol) -> Option<&Attribute> {
filter_by_name(attrs, name).next()
}

pub fn first_attr_value_str_by_name(attrs: &[impl AttributeExt], name: Symbol) -> Option<Symbol> {
pub fn first_attr_value_str_by_name(attrs: &[Attribute], name: Symbol) -> Option<Symbol> {
find_by_name(attrs, name).and_then(|attr| attr.value_str())
}

pub fn contains_name(attrs: &[impl AttributeExt], name: Symbol) -> bool {
pub fn contains_name(attrs: &[Attribute], name: Symbol) -> bool {
find_by_name(attrs, name).is_some()
}

Expand Down Expand Up @@ -911,11 +911,6 @@ pub trait AttributeExt: Debug {
/// * `#[doc(...)]` returns `None`.
fn doc_str(&self) -> Option<Symbol>;

/// Returns the deprecation note if this is deprecation attribute.
/// * `#[deprecated = "note"]` returns `Some("note")`.
/// * `#[deprecated(note = "note", ...)]` returns `Some("note")`.
fn deprecation_note(&self) -> Option<Ident>;

/// Returns whether this attribute is any of the proc macro attributes.
/// i.e. `proc_macro`, `proc_macro_attribute` or `proc_macro_derive`.
fn is_proc_macro_attr(&self) -> bool {
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_attr_parsing/src/attributes/util.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::num::IntErrorKind;

use rustc_ast::LitKind;
use rustc_ast::attr::AttributeExt;
use rustc_ast::{LitKind, ast};
use rustc_feature::is_builtin_attr_name;
use rustc_hir::RustcVersion;
use rustc_hir::limit::Limit;
Expand All @@ -27,8 +26,8 @@ pub fn parse_version(s: Symbol) -> Option<RustcVersion> {
Some(RustcVersion { major, minor, patch })
}

pub fn is_builtin_attr(attr: &impl AttributeExt) -> bool {
attr.is_doc_comment().is_some() || attr.name().is_some_and(|name| is_builtin_attr_name(name))
pub fn is_builtin_attr(attr: &ast::Attribute) -> bool {
attr.is_doc_comment() || attr.name().is_some_and(|name| is_builtin_attr_name(name))
}

/// Parse a single integer.
Expand Down
9 changes: 1 addition & 8 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
.collect();
generic_args.push((kw::SelfUpper, this.clone()));

let args = FormatArgs {
this,
// Unused
this_sugared: String::new(),
// Unused
item_context: "",
generic_args,
};
let args = FormatArgs { this, generic_args, .. };
let CustomDiagnostic { message, label, notes, parent_label: _ } =
directive.eval(None, &args);

Expand Down
26 changes: 25 additions & 1 deletion compiler/rustc_builtin_macros/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ fn make_format_args(
style: fmt_style,
uncooked_symbol: uncooked_fmt_str,
} = {
// Extract snippet so that we can check cases `{}`, `{:?}` and `{:#?}` and emit help for
// them later.
let snippet = if let ExprKind::Block(b, None) = &efmt.kind
&& b.stmts.len() <= 1
{
Some(ecx.sess.source_map().span_to_snippet(unexpanded_fmt_span))
} else {
None
};

let ExpandResult::Ready(mac) = expr_to_spanned_string(ecx, efmt.clone(), msg) else {
return ExpandResult::Retry(());
};
Expand Down Expand Up @@ -222,12 +232,26 @@ fn make_format_args(
});
}
sugg_fmt = sugg_fmt.trim_end().to_string();
err.span_suggestion(
err.span_suggestion_verbose(
unexpanded_fmt_span.shrink_to_lo(),
"you might be missing a string literal to format with",
format!("\"{sugg_fmt}\", "),
Applicability::MaybeIncorrect,
);

if let Some(Ok(snippet)) = snippet.as_ref() {
match snippet.as_str() {
"{}" | "{:?}" | "{:#?}" => {
err.span_suggestion_verbose(
unexpanded_fmt_span,
format!("you might want to enclose `{snippet}` with `\"\"`"),
format!("\"{snippet}\""),
Applicability::MaybeIncorrect,
);
}
_ => {}
};
}
}
}
err.emit()
Expand Down
43 changes: 43 additions & 0 deletions compiler/rustc_expand/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,49 @@ mod metavar_exprs {
pub span: Span,
pub key: MacroRulesNormalizedIdent,
}

#[derive(Diagnostic)]
#[diag(r#"`${"{"}concat(..){"}"}` is not generating a valid identifier"#)]
pub(crate) struct ConcatInvalidIdent {
#[primary_span]
pub span: Span,
#[subdiagnostic]
pub reason: InvalidIdentReason,
}

#[derive(Subdiagnostic)]
pub(crate) enum InvalidIdentReason {
#[note(r#"this `${"{"}concat(..){"}"}` invocation generated an empty ident"#)]
Empty,
#[note(r#"this `${"{"}concat(..){"}"}` invocation generated `{$symbol}`, but {$start} is neither '_' nor XID_Start"#)]
#[note(
"see <https://doc.rust-lang.org/reference/identifiers.html> for the definition of valid identifiers"
)]
InvalidStart { symbol: Symbol, start: char },
#[note(r#"this `${"{"}concat(..){"}"}` invocation generated `{$symbol}`, but {$not_continue} is not XID_Continue"#)]
#[note(
"see <https://doc.rust-lang.org/reference/identifiers.html> for the definition of valid identifiers"
)]
InvalidContinue { symbol: Symbol, not_continue: char },
}

impl InvalidIdentReason {
pub(crate) fn new(symbol: Symbol) -> Self {
let mut chars = symbol.as_str().chars();
if let Some(start) = chars.next() {
if rustc_lexer::is_id_start(start) {
let not_continue = chars
.find(|c| !rustc_lexer::is_id_continue(*c))
.expect("InvalidIdentReason: cannot find invalid ident reason");
InvalidIdentReason::InvalidContinue { symbol, not_continue }
} else {
InvalidIdentReason::InvalidStart { symbol, start }
}
} else {
InvalidIdentReason::Empty
}
}
}
}

#[derive(Diagnostic)]
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_expand/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// tidy-alphabetical-start
#![allow(internal_features)]
#![feature(associated_type_defaults)]
#![feature(default_field_values)]
#![feature(macro_metavar_expr)]
#![feature(proc_macro_diagnostic)]
#![feature(proc_macro_internals)]
Expand Down
13 changes: 1 addition & 12 deletions compiler/rustc_expand/src/mbe/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,8 @@ pub(super) fn failed_to_match_macro(
let CustomDiagnostic {
message: custom_message, label: custom_label, notes: custom_notes, ..
} = {
let macro_name = name.to_string();
on_unmatch_args
.map(|directive| {
directive.eval(
None,
&FormatArgs {
this: macro_name.clone(),
this_sugared: macro_name,
item_context: "macro invocation",
generic_args: Vec::new(),
},
)
})
.map(|directive| directive.eval(None, &FormatArgs { this: name.to_string(), .. }))
.unwrap_or_default()
};

Expand Down
15 changes: 8 additions & 7 deletions compiler/rustc_expand/src/mbe/transcribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ use rustc_span::{
use smallvec::{SmallVec, smallvec};

use crate::errors::{
CountRepetitionMisplaced, MacroVarStillRepeating, MetaVarsDifSeqMatchers, MustRepeatOnce,
MveUnrecognizedVar, NoRepeatableVar, NoSyntaxVarsExprRepeat, VarNoTypo,
VarTypoSuggestionRepeatable, VarTypoSuggestionUnrepeatable, VarTypoSuggestionUnrepeatableLabel,
ConcatInvalidIdent, CountRepetitionMisplaced, InvalidIdentReason, MacroVarStillRepeating,
MetaVarsDifSeqMatchers, MustRepeatOnce, MveUnrecognizedVar, NoRepeatableVar,
NoSyntaxVarsExprRepeat, VarNoTypo, VarTypoSuggestionRepeatable, VarTypoSuggestionUnrepeatable,
VarTypoSuggestionUnrepeatableLabel,
};
use crate::mbe::macro_parser::NamedMatch;
use crate::mbe::macro_parser::NamedMatch::*;
Expand Down Expand Up @@ -656,10 +657,10 @@ fn metavar_expr_concat<'tx>(
let symbol = nfc_normalize(&concatenated);
let concatenated_span = tscx.visited_dspan(dspan);
if !rustc_lexer::is_ident(symbol.as_str()) {
return Err(dcx.struct_span_err(
concatenated_span,
"`${concat(..)}` is not generating a valid identifier",
));
return Err(dcx.create_err(ConcatInvalidIdent {
span: concatenated_span,
reason: InvalidIdentReason::new(symbol),
}));
}
tscx.psess.symbol_gallery.insert(symbol, concatenated_span);

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ declare_features! (
/// Target features on hexagon.
(unstable, hexagon_target_feature, "1.27.0", Some(150250)),
/// Allows `impl(crate) trait Foo` restrictions.
(incomplete, impl_restriction, "1.96.0", Some(105077)),
(unstable, impl_restriction, "CURRENT_RUSTC_VERSION", Some(105077)),
/// Allows `impl Trait` to be used inside associated types (RFC 2515).
(unstable, impl_trait_in_assoc_type, "1.70.0", Some(63063)),
/// Allows `impl Trait` in bindings (`let`).
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_hir/src/attrs/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,11 @@ impl FormatString {
/// ```
#[derive(Debug)]
pub struct FormatArgs {
/// The name of the item the attribute is on.
pub this: String,
pub this_sugared: String,
pub item_context: &'static str,
pub generic_args: Vec<(Symbol, String)>,
pub this_sugared: String = String::new(),
pub item_context: &'static str = "",
pub generic_args: Vec<(Symbol, String)> = Vec::new(),
}

#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1424,14 +1424,6 @@ impl AttributeExt for Attribute {
}
}

#[inline]
fn deprecation_note(&self) -> Option<Ident> {
match &self {
Attribute::Parsed(AttributeKind::Deprecated { deprecation, .. }) => deprecation.note,
_ => None,
}
}

fn is_automatically_derived_attr(&self) -> bool {
matches!(self, Attribute::Parsed(AttributeKind::AutomaticallyDerived(..)))
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#![feature(closure_track_caller)]
#![feature(const_default)]
#![feature(const_trait_impl)]
#![feature(default_field_values)]
#![feature(derive_const)]
#![feature(exhaustive_patterns)]
#![feature(never_type)]
Expand Down
26 changes: 25 additions & 1 deletion compiler/rustc_hir_typeck/src/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! normal visitor, which just walks the entire body in one shot, the
//! `ExprUseVisitor` determines how expressions are being used.
//!
//! In the compiler, this is only used for upvar inference, but there
//! In the compiler, this is only used for upvar inference and diagnostics, but there
//! are many uses within clippy.

use std::cell::{Ref, RefCell};
Expand Down Expand Up @@ -1855,3 +1855,27 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
}
}
}

struct ExprPlaceDelegate;

impl<'tcx> Delegate<'tcx> for ExprPlaceDelegate {
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}

fn use_cloned(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}

fn borrow(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind) {}

fn mutate(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}

fn fake_read(&mut self, _: &PlaceWithHirId<'tcx>, _: FakeReadCause, _: HirId) {}
}

/// Categorizes `expr` as a place for diagnostic suggestions.
///
/// This should be used for diagnostics purpose only.
pub(crate) fn expr_place<'tcx>(
fcx: &FnCtxt<'_, 'tcx>,
expr: &hir::Expr<'_>,
) -> Result<PlaceWithHirId<'tcx>, ErrorGuaranteed> {
ExprUseVisitor::new(fcx, ExprPlaceDelegate).cat_expr(expr)
}
Loading
Loading