Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 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
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
c96d970
bump openssl-sys to support OpenSSL 4.0.x
heitbaum Apr 24, 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
4b5d544
Implement `core::arch::return_address` and tests
chorman0773 Apr 26, 2026
48fe89f
add default field values to diagnostic FormatArgs
mejrs Apr 26, 2026
df405e5
Rollup merge of #152995 - asder8215:windows_permissions_ext, r=Mark-S…
JonathanBrouwer Apr 26, 2026
7b3d81a
Rollup merge of #154972 - chorman0773:return_address, r=Mark-Simulacrum
JonathanBrouwer Apr 26, 2026
9cd6ef0
Rollup merge of #155250 - ChrisDenton:pipe-fs, r=Mark-Simulacrum
JonathanBrouwer Apr 26, 2026
4dd3997
Rollup merge of #155823 - RalfJung:miri, r=RalfJung
JonathanBrouwer Apr 26, 2026
52ab81c
Rollup merge of #155693 - cclfmht:fix/issue-155508, r=ShoyuVanilla
JonathanBrouwer Apr 26, 2026
fc49b29
Rollup merge of #155805 - shian15810:patch-1, r=mejrs
JonathanBrouwer Apr 26, 2026
48e67fa
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
6 changes: 6 additions & 0 deletions compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,12 @@ fn codegen_regular_intrinsic_call<'tcx>(
fx.bcx.set_cold_block(fx.bcx.current_block().unwrap());
}

sym::return_address => {
let val = fx.bcx.ins().get_return_address(fx.pointer_type);
let val = CValue::by_val(val, ret.layout());
ret.write_cvalue(fx, val);
}

// Unimplemented intrinsics must have a fallback body. The fallback body is obtained
// by converting the `InstanceKind::Intrinsic` to an `InstanceKind::Item`.
_ => {
Expand Down
16 changes: 16 additions & 0 deletions compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,22 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
}
}

sym::return_address => {
match self.sess().target.arch {
// Expand this list as needed
| Arch::Wasm32
| Arch::Wasm64 => {
let ty = self.type_ptr();
self.const_null(ty)
}
_ => {
let ty = self.type_ix(32);
let val = self.const_int(ty, 0);
self.call_intrinsic("llvm.returnaddress", &[], &[val])
}
}
}

_ => {
debug!("unknown intrinsic '{}' -- falling back to default body", name);
// Call the fallback body instead of generating the intrinsic code
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_ssa/src/mir/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
| sym::contract_checks
| sym::atomic_fence
| sym::atomic_singlethreadfence
| sym::caller_location => {}
| sym::caller_location
| sym::return_address => {}
_ => {
span_bug!(
span,
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
3 changes: 3 additions & 0 deletions compiler/rustc_hir_analysis/src/check/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -> hi
| sym::ptr_guaranteed_cmp
| sym::ptr_mask
| sym::ptr_metadata
| sym::return_address
| sym::rotate_left
| sym::rotate_right
| sym::round_ties_even_f16
Expand Down Expand Up @@ -803,6 +804,8 @@ pub(crate) fn check_intrinsic_type(
| sym::atomic_xor => (2, 1, vec![Ty::new_mut_ptr(tcx, param(0)), param(1)], param(0)),
sym::atomic_fence | sym::atomic_singlethreadfence => (0, 1, Vec::new(), tcx.types.unit),

sym::return_address => (0, 0, vec![], Ty::new_imm_ptr(tcx, tcx.types.unit)),

other => {
tcx.dcx().emit_err(UnrecognizedIntrinsicFunction { span, name: other });
return;
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
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
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1660,6 +1660,7 @@ symbols! {
residual,
result,
result_ffi_guarantees,
return_address,
return_position_impl_trait_in_trait,
return_type_notation,
riscv32,
Expand Down
27 changes: 27 additions & 0 deletions library/core/src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,30 @@ pub macro global_asm("assembly template", $(operands,)* $(options($(option),*))?
pub fn breakpoint() {
core::intrinsics::breakpoint();
}

/// The `core::arch::return_address!()` macro returns a pointer with an address that corresponds to the caller of the function that invoked the `return_address!()` macro.
/// The pointer has no provenance, as if created by `core::ptr::without_provenance`. It cannot be used to read memory (other than ZSTs).
///
/// The value returned by the macro depends highly on the architecture and compiler (including any options set).
/// In particular, it is allowed to be wrong (particularly if inlining is involved), or even contain a nonsense value.
/// The result of this macro must not be relied upon for soundness or correctness, only for debugging purposes.
///
/// As a best effort, if a useful value cannot be determined (for example, due to limitations on the current codegen),
/// this macro tries to return a null pointer instead of nonsense (this cannot be relied upon for correctness, however).
///
/// Formally, this function returns a pointer with a non-deterministic address and no provenance.
///
/// This is equivalent to the gcc `__builtin_return_address(0)` intrinsic (other forms of the intrinsic are not supported).
/// Because the operation can be always performed by the compiler without crashing or causing undefined behaviour, invoking the macro is a safe operation.
///
/// ## Example
/// ```
/// # #![cfg(not(miri))] // FIXME: Figure out how to make miri work before stabilizing this macro
/// #![feature(return_address)]
///
/// let addr = core::arch::return_address!();
/// println!("Caller is {addr:p}");
/// ```
#[unstable(feature = "return_address", issue = "154966")]
#[allow_internal_unstable(core_intrinsics)]
pub macro return_address() {{ core::intrinsics::return_address() }}
13 changes: 13 additions & 0 deletions library/core/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3589,3 +3589,16 @@ pub const fn va_copy<'f>(src: &VaList<'f>) -> VaList<'f> {
pub const unsafe fn va_end(ap: &mut VaList<'_>) {
/* deliberately does nothing */
}

/// Returns the return address of the caller function (after inlining) in a best-effort manner or a null pointer if it is not supported on the current backend.
/// Returning an accurate value is a quality-of-implementation concern, but no hard guarantees are
/// made about the return value: formally, the intrinsic non-deterministically returns
/// an arbitrary pointer without provenance.
///
/// Note that unlike most intrinsics, this is safe to call. This is because it only finds the return address of the immediate caller, which is guaranteed to be possible.
/// Other forms of the corresponding gcc or llvm intrinsic (which can have wildly unpredictable results or even crash at runtime) are not exposed.
#[rustc_intrinsic]
#[rustc_nounwind]
pub fn return_address() -> *const () {
core::ptr::null()
}
66 changes: 64 additions & 2 deletions library/std/src/os/windows/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

#![stable(feature = "rust1", since = "1.0.0")]

use crate::fs::{self, Metadata, OpenOptions};
use crate::fs::{self, Metadata, OpenOptions, Permissions};
use crate::io::BorrowedCursor;
use crate::path::Path;
use crate::sealed::Sealed;
use crate::sys::{AsInner, AsInnerMut, IntoInner};
use crate::sys::{AsInner, AsInnerMut, FromInner, IntoInner};
use crate::time::SystemTime;
use crate::{io, sys};

Expand Down Expand Up @@ -368,6 +368,68 @@ impl OpenOptionsExt2 for OpenOptions {
}
}

/// Windows-specific extensions to [`fs::Permissions`]. This extension trait
/// provides extra utilities to shows what Windows file attributes are enabled
/// in [`Permissions`] and to manually set file attributes on [`Permissions`].
///
/// See Microsoft's [`File Attribute Constants`] page to know what file
/// attribute metadata are defined and stored on Windows files.
///
/// [`Permissions`]: fs::Permissions
/// [`File Attribute Constants`]:
/// https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants
///
/// # Example
///
/// ```no_run
/// #![feature(windows_permissions_ext)]
/// use std::fs::Permissions;
/// use std::os::windows::fs::PermissionsExt;
///
/// const FILE_ATTRIBUTE_SYSTEM: u32 = 0x4;
/// const FILE_ATTRIBUTE_ARCHIVE: u32 = 0x20;
/// let my_file_attr = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE;
/// let mut permissions = Permissions::from_file_attributes(my_file_attr);
/// assert_eq!(permissions.file_attributes(), my_file_attr);
///
/// const FILE_ATTRIBUTE_HIDDEN: u32 = 0x2;
/// let new_file_attr = permissions.file_attributes() | FILE_ATTRIBUTE_HIDDEN;
/// permissions.set_file_attributes(new_file_attr);
/// assert_eq!(permissions.file_attributes(), new_file_attr);
/// ```
#[unstable(feature = "windows_permissions_ext", issue = "152956")]
pub trait PermissionsExt: Sealed {
/// Returns the file attribute bits.
#[unstable(feature = "windows_permissions_ext", issue = "152956")]
fn file_attributes(&self) -> u32;

/// Sets the file attribute bits.
#[unstable(feature = "windows_permissions_ext", issue = "152956")]
fn set_file_attributes(&mut self, mask: u32);

/// Creates a new instance from the given file attribute bits.
#[unstable(feature = "windows_permissions_ext", issue = "152956")]
fn from_file_attributes(mask: u32) -> Self;
}

#[unstable(feature = "windows_permissions_ext", issue = "152956")]
impl Sealed for fs::Permissions {}

#[unstable(feature = "windows_permissions_ext", issue = "152956")]
impl PermissionsExt for fs::Permissions {
fn file_attributes(&self) -> u32 {
self.as_inner().file_attributes()
}

fn set_file_attributes(&mut self, mask: u32) {
*self = Permissions::from_inner(FromInner::from_inner(mask));
}

fn from_file_attributes(mask: u32) -> Self {
Permissions::from_inner(FromInner::from_inner(mask))
}
}

/// Windows-specific extensions to [`fs::Metadata`].
///
/// The data members that this trait exposes correspond to the members
Expand Down
10 changes: 10 additions & 0 deletions library/std/src/sys/fs/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,16 @@ impl FilePermissions {
self.attrs &= !c::FILE_ATTRIBUTE_READONLY;
}
}

pub fn file_attributes(&self) -> u32 {
self.attrs as u32
}
}

impl FromInner<u32> for FilePermissions {
fn from_inner(attrs: u32) -> FilePermissions {
FilePermissions { attrs }
}
}

impl FileTimes {
Expand Down
Loading
Loading