Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 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
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
efaf460
Mention DEPRECATED_LLVM_INTRINSIC lint for internal use
shian15810 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
c96d342
Rollup merge of #152995 - asder8215:windows_permissions_ext, r=Mark-S…
JonathanBrouwer Apr 26, 2026
c025050
Rollup merge of #153457 - dianne:no-coercing-in-pin-macro, r=Mark-Sim…
JonathanBrouwer Apr 26, 2026
874eb55
Rollup merge of #155250 - ChrisDenton:pipe-fs, r=Mark-Simulacrum
JonathanBrouwer Apr 26, 2026
0a548e4
Rollup merge of #155574 - bushrat011899:core_io_raw_os_error, r=Mark-…
JonathanBrouwer Apr 26, 2026
1902d1a
Rollup merge of #155823 - RalfJung:miri, r=RalfJung
JonathanBrouwer Apr 26, 2026
68ba646
Rollup merge of #155693 - cclfmht:fix/issue-155508, r=ShoyuVanilla
JonathanBrouwer Apr 26, 2026
3b76a4d
Rollup merge of #155719 - qaijuang:suggest-iter-for-shared-projection…
JonathanBrouwer Apr 26, 2026
cfa3c97
Rollup merge of #155805 - shian15810:patch-1, r=mejrs
JonathanBrouwer Apr 26, 2026
67e408c
Rollup merge of #155820 - Zalathar:range, r=Kivooeo
JonathanBrouwer Apr 26, 2026
f8e1380
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
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
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
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
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)
}
73 changes: 70 additions & 3 deletions compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ use tracing::{debug, info, instrument};
use super::probe::{AutorefOrPtrAdjustment, IsSuggestion, Mode, ProbeScope};
use super::{CandidateSource, MethodError, NoMatchData};
use crate::errors::{self, CandidateTraitNote, NoAssociatedItem};
use crate::expr_use_visitor::expr_place;
use crate::method::probe::UnsatisfiedPredicates;
use crate::{Expectation, FnCtxt};

Expand Down Expand Up @@ -189,6 +190,70 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
false
}

// Pick the iterator method to suggest: `.into_iter()` by default, and
// `.iter()`/`.iter_mut()` for projections through references.
fn preferred_iterator_method(
&self,
source: SelfSource<'tcx>,
rcvr_ty: Ty<'tcx>,
) -> Option<Symbol> {
let SelfSource::MethodCall(rcvr_expr) = source else {
return Some(sym::into_iter);
};

let rcvr_expr = rcvr_expr.peel_drop_temps().peel_blocks();
let Ok(place_with_id) = expr_place(self, rcvr_expr) else {
return None;
};

let mut projection_mutability = None;
for pointer_ty in place_with_id.place.deref_tys() {
match self.structurally_resolve_type(rcvr_expr.span, pointer_ty).kind() {
ty::Ref(.., Mutability::Not) => {
projection_mutability = Some(Mutability::Not);
break;
}
ty::Ref(.., Mutability::Mut) => {
projection_mutability.get_or_insert(Mutability::Mut);
}
ty::RawPtr(..) => return None,
_ => {}
}
}

// Keep `.into_iter()` for receivers like `&Vec<_>`; only projections that
// dereference a reference need to switch to `iter`/`iter_mut`.
let Some(projection_mutability) = projection_mutability else {
return Some(sym::into_iter);
};

let call_expr = self.tcx.hir_expect_expr(self.tcx.parent_hir_id(rcvr_expr.hir_id));
// `IntoIterator` does not imply inherent `iter`/`iter_mut` methods.
let has_method = |method_name| {
self.lookup_probe_for_diagnostic(
Ident::with_dummy_span(method_name),
rcvr_ty,
call_expr,
ProbeScope::TraitsInScope,
None,
)
.is_ok()
};

match projection_mutability {
Mutability::Not => has_method(sym::iter).then_some(sym::iter),
Mutability::Mut => {
if has_method(sym::iter_mut) {
Some(sym::iter_mut)
} else if has_method(sym::iter) {
Some(sym::iter)
} else {
None
}
}
}
}

#[instrument(level = "debug", skip(self))]
pub(crate) fn report_method_error(
&self,
Expand Down Expand Up @@ -855,10 +920,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else if self.impl_into_iterator_should_be_iterator(rcvr_ty, span, unsatisfied_predicates)
{
err.span_label(span, format!("`{rcvr_ty}` is not an iterator"));
if !span.in_external_macro(self.tcx.sess.source_map()) {
if !span.in_external_macro(self.tcx.sess.source_map())
&& let Some(method_name) = self.preferred_iterator_method(source, rcvr_ty)
{
err.multipart_suggestion(
"call `.into_iter()` first",
vec![(span.shrink_to_lo(), format!("into_iter()."))],
format!("call `.{method_name}()` first"),
vec![(span.shrink_to_lo(), format!("{method_name}()."))],
Applicability::MaybeIncorrect,
);
}
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5639,7 +5639,12 @@ declare_lint! {
/// LLVM periodically updates its list of intrinsics. Deprecated intrinsics are unlikely
/// to be removed, but they may optimize less well than their new versions, so it's
/// best to use the new version. Also, some deprecated intrinsics might have buggy
/// behavior
/// behavior.
///
/// This `link_llvm_intrinsics` lint is intended to be used internally only, and requires the
/// `#![feature(link_llvm_intrinsics)]` internal feature gate. For more information, see [its chapter in
/// the Unstable Book](https://doc.rust-lang.org/unstable-book/language-features/link-llvm-intrinsics.html)
/// and [its tracking issue](https://github.com/rust-lang/rust/issues/29602).
pub DEPRECATED_LLVM_INTRINSIC,
Allow,
"detects uses of deprecated LLVM intrinsics",
Expand Down
10 changes: 4 additions & 6 deletions compiler/rustc_parse/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1140,29 +1140,27 @@ pub(crate) struct InclusiveRangeMatchArrow {
#[primary_span]
pub arrow: Span,
#[label("this is parsed as an inclusive range `..=`")]
pub span: Span,
#[suggestion(
"add a space between the pattern and `=>`",
style = "verbose",
code = " ",
code = ".. =",
applicability = "machine-applicable"
)]
pub after_pat: Span,
pub span: Span,
}

#[derive(Diagnostic)]
#[diag("inclusive range with no end", code = E0586)]
#[note("inclusive ranges must be bounded at the end (`..=b` or `a..=b`)")]
pub(crate) struct InclusiveRangeNoEnd {
#[primary_span]
pub span: Span,
#[suggestion(
"use `..` instead",
code = "",
code = "..",
applicability = "machine-applicable",
style = "verbose"
)]
pub suggestion: Span,
pub span: Span,
}

#[derive(Subdiagnostic)]
Expand Down
12 changes: 4 additions & 8 deletions compiler/rustc_parse/src/parser/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ impl<'a> Parser<'a> {
pub(super) fn inclusive_range_with_incorrect_end(&mut self) -> ErrorGuaranteed {
let tok = &self.token;
let span = self.prev_token.span;
// If the user typed "..==" instead of "..=", we want to give them
// If the user typed "..==" or "...=" instead of "..=", we want to give them
// a specific error message telling them to use "..=".
// If they typed "..=>", suggest they use ".. =>".
// Otherwise, we assume that they meant to type a half open exclusive
Expand All @@ -1243,14 +1243,10 @@ impl<'a> Parser<'a> {

self.dcx().emit_err(InclusiveRangeExtraEquals { span: span_with_eq })
}
token::Gt if no_space => {
let after_pat = span.with_hi(span.hi() - BytePos(1)).shrink_to_hi();
self.dcx().emit_err(InclusiveRangeMatchArrow { span, arrow: tok.span, after_pat })
token::Gt if self.prev_token.kind == token::DotDotEq && no_space => {
self.dcx().emit_err(InclusiveRangeMatchArrow { span, arrow: tok.span })
}
_ => self.dcx().emit_err(InclusiveRangeNoEnd {
span,
suggestion: span.with_lo(span.hi() - BytePos(1)),
}),
_ => self.dcx().emit_err(InclusiveRangeNoEnd { span }),
}
}

Expand Down
7 changes: 1 addition & 6 deletions compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -886,12 +886,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {

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

Expand Down
14 changes: 14 additions & 0 deletions library/core/src/io/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

use crate::fmt;

/// The type of raw OS error codes.
///
/// This is an [`i32`] on all currently supported platforms, but platforms
/// added in the future (such as UEFI) may use a different primitive type like
/// [`usize`]. Use `as` or [`into`] conversions where applicable to ensure maximum
/// portability.
///
/// [`into`]: Into::into
#[unstable(feature = "raw_os_error_ty", issue = "107792")]
pub type RawOsError = cfg_select! {
target_os = "uefi" => usize,
_ => i32,
};

/// A list specifying general categories of I/O error.
///
/// This list is intended to grow over time and it is not recommended to
Expand Down
2 changes: 2 additions & 0 deletions library/core/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ mod error;
pub use self::borrowed_buf::{BorrowedBuf, BorrowedCursor};
#[unstable(feature = "core_io", issue = "154046")]
pub use self::error::ErrorKind;
#[unstable(feature = "raw_os_error_ty", issue = "107792")]
pub use self::error::RawOsError;
1 change: 1 addition & 0 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
#![feature(no_core)]
#![feature(optimize_attribute)]
#![feature(pattern_types)]
#![feature(pin_macro_internals)]
#![feature(prelude_import)]
#![feature(repr_simd)]
#![feature(rustc_attrs)]
Expand Down
Loading
Loading