Skip to content

Rollup of 8 pull requests #141710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 61 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
7a65911
Optimize `Seek::stream_len` impl for `File`
tbu- May 13, 2024
cbe64ce
Clarify description of `Seek::stream_len`
tbu- Jan 9, 2025
06da7b3
fixes: ide-assists, generate_new indent loses
A4-Tacks May 12, 2025
6a35b51
fix: ide-assists, generate mut trait impl indent
A4-Tacks May 14, 2025
687eeea
Change import prefix default to be by crate
Veykril May 19, 2025
31b4808
Fix cache problems with lints level
ChayimFriedman2 May 19, 2025
226db31
Correctly set the span of the proc_macro crate's Group delimiters
ChayimFriedman2 May 21, 2025
8acb1b5
internal: fix `integrated_benchmarks` to make actual edits
davidbarsky May 21, 2025
0cb50cd
Merge pull request #19840 from rust-lang/davidbarsky/fix-integrated-b…
ChayimFriedman2 May 21, 2025
2580d83
Merge pull request #19839 from ChayimFriedman2/inlay-hints-attr
Veykril May 21, 2025
1c58418
Merge pull request #19824 from ChayimFriedman2/lints-again
Veykril May 22, 2025
24a416c
Support `transmute_unchecked` intrinsic for mir-eval
Veykril May 22, 2025
b64a934
Merge pull request #19842 from Veykril/push-zunlmrzpnrzk
Veykril May 22, 2025
fb181cf
Remove rust-analyzer.vs from other editors
oli-obk May 22, 2025
11afee4
Merge pull request #19843 from oli-obk/rust-analyzer.vs
Veykril May 22, 2025
f0096ae
Normalize when checking for uninhabited types for pattern exhaustiven…
ChayimFriedman2 May 22, 2025
69ba323
Bump salsa
Veykril May 23, 2025
9d61d8a
Merge pull request #19853 from Veykril/push-ovpvzkxmpsuk
Veykril May 23, 2025
947be5f
add CStr::display
tamird Apr 17, 2025
a3bd12b
Path::with_extension: improve examples
tshepang May 24, 2025
248f4b2
reduce clutter... too many imports
tshepang May 24, 2025
396c5ca
clean up old rintf leftovers
RalfJung May 25, 2025
fe18087
Fix IDE resolution of item macros
ChayimFriedman2 May 25, 2025
753c62c
Properly implement `might_be_inside_macro_call()` using semantic info…
ChayimFriedman2 May 25, 2025
a493526
Merge pull request #19864 from ChayimFriedman2/is-in-macro
Veykril May 26, 2025
6b49172
Merge pull request #19851 from ChayimFriedman2/normalize-exhaustiveness
Veykril May 26, 2025
3d67336
Merge pull request #19785 from A4-Tacks/fix-generate-new-indent
Veykril May 26, 2025
376edac
Merge pull request #19819 from Veykril/push-utvzwvwuuvlm
Veykril May 26, 2025
94c624e
Merge pull request #19792 from A4-Tacks/fix-generate-mut-trait-impl-i…
Veykril May 26, 2025
2e9c2ce
Merge pull request #19862 from ChayimFriedman2/item-resolve-macro-hir
ChayimFriedman2 May 26, 2025
7baa85d
Fix inference of `AsyncFnX` return type
ChayimFriedman2 May 27, 2025
68ff7f2
Make `Semantics<'db, DB>` support `Semantics<'db, dyn HirDatabase>`, …
regexident May 26, 2025
5b6ca80
Merge pull request #19850 from regexident/dyn-semantics
ChayimFriedman2 May 27, 2025
a55a370
fix: Skip pattern analysis on type mismatches
ShoyuVanilla May 27, 2025
2c5d840
Merge pull request #19875 from ShoyuVanilla/issue-19844
ChayimFriedman2 May 27, 2025
9f94b13
chore: Remove support for `concat_idents!`
tgross35 May 28, 2025
f67ee9c
Merge pull request #19877 from tgross35/remove-concat-idents
Veykril May 28, 2025
cfe488c
fix: Fix IDE layer not resolving some macro calls
Veykril May 28, 2025
711546a
Drop unnecessay code
Veykril May 28, 2025
7ec351e
Back out "Fix IDE resolution of item macros"
Veykril May 28, 2025
636495c
feat: Render padding information when hovering on structs
ShoyuVanilla May 28, 2025
7840bc0
Merge pull request #19879 from Veykril/push-mqykxnqtktuw
Veykril May 28, 2025
fa22119
Merge pull request #19876 from ShoyuVanilla/layout-padding
Veykril May 28, 2025
457e84f
fix: Handle included files better in IDE layer
Veykril May 28, 2025
035cf40
Merge pull request #19872 from ChayimFriedman2/async-fn-output
Veykril May 28, 2025
c205ef7
Merge pull request #19880 from Veykril/push-xmpxumsrkymk
Veykril May 28, 2025
8231d88
feat: Desugar assist for `let pat = expr?;` -> `let else`
Veykril May 28, 2025
d08ab51
Merge pull request #19881 from Veykril/push-wsrmttkymyps
Veykril May 28, 2025
2e99a88
Add diagnostic items to sys::Mutex
Patrick-6 May 28, 2025
149b5b2
Make pthread Mutex internals less public
Patrick-6 May 28, 2025
467eeab
Stabilise `repr128`
beetrees Mar 9, 2025
8237107
Add comments to diagnostic items
Patrick-6 May 28, 2025
9f2ee0f
Add eholk to compiler reviewer rotation
eholk May 28, 2025
085f835
Rollup merge of #125087 - tbu-:pr_file_stream_len, r=ChrisDenton
tgross35 May 28, 2025
e72ae09
Rollup merge of #138285 - beetrees:repr128-stable, r=traviscross,bjorn3
tgross35 May 28, 2025
6fb8687
Rollup merge of #139994 - tamird:cstr-display, r=Amanieu
tgross35 May 28, 2025
8fef103
Rollup merge of #141477 - tshepang:patch-1, r=ChrisDenton
tgross35 May 28, 2025
7726b94
Rollup merge of #141533 - RalfJung:rintf, r=bjorn3
tgross35 May 28, 2025
61cff5b
Rollup merge of #141690 - Patrick-6:intercept-mutex, r=m-ou-se
tgross35 May 28, 2025
e87b557
Rollup merge of #141693 - lnicola:sync-from-ra, r=lnicola
tgross35 May 28, 2025
9d394b9
Rollup merge of #141702 - eholk:eholk-reviewers, r=aDotInTheVoid
tgross35 May 28, 2025
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
12 changes: 3 additions & 9 deletions compiler/rustc_error_codes/src/error_codes/E0658.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ An unstable feature was used.
Erroneous code example:

```compile_fail,E0658
#[repr(u128)] // error: use of unstable library feature 'repr128'
enum Foo {
Bar(u64),
}
use std::intrinsics; // error: use of unstable library feature `core_intrinsics`
```

If you're using a stable or a beta version of rustc, you won't be able to use
Expand All @@ -17,12 +14,9 @@ If you're using a nightly version of rustc, just add the corresponding feature
to be able to use it:

```
#![feature(repr128)]
#![feature(core_intrinsics)]

#[repr(u128)] // ok!
enum Foo {
Bar(u64),
}
use std::intrinsics; // ok!
```

[rustup]: https://rust-lang.github.io/rustup/concepts/channels.html
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ declare_features! (
(accepted, relaxed_adts, "1.19.0", Some(35626)),
/// Lessens the requirements for structs to implement `Unsize`.
(accepted, relaxed_struct_unsize, "1.58.0", Some(81793)),
/// Allows the `#[repr(i128)]` attribute for enums.
(accepted, repr128, "CURRENT_RUSTC_VERSION", Some(56071)),
/// Allows `repr(align(16))` struct attribute (RFC 1358).
(accepted, repr_align, "1.25.0", Some(33626)),
/// Allows using `#[repr(align(X))]` on enums with equivalent semantics
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,6 @@ declare_features! (
(incomplete, ref_pat_eat_one_layer_2024_structural, "1.81.0", Some(123076)),
/// Allows using the `#[register_tool]` attribute.
(unstable, register_tool, "1.41.0", Some(66079)),
/// Allows the `#[repr(i128)]` attribute for enums.
(incomplete, repr128, "1.16.0", Some(56071)),
/// Allows `repr(simd)` and importing the various simd intrinsics.
(unstable, repr_simd, "1.4.0", Some(27731)),
/// Allows bounding the return type of AFIT/RPITIT.
Expand Down
15 changes: 1 addition & 14 deletions compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use rustc_middle::middle::resolve_bound_vars::ResolvedArg;
use rustc_middle::middle::stability::EvalResult;
use rustc_middle::ty::error::TypeErrorToStringExt;
use rustc_middle::ty::layout::{LayoutError, MAX_SIMD_LANES};
use rustc_middle::ty::util::{Discr, IntTypeExt};
use rustc_middle::ty::util::Discr;
use rustc_middle::ty::{
AdtDef, BottomUpFolder, GenericArgKind, RegionKind, TypeFoldable, TypeSuperVisitable,
TypeVisitable, TypeVisitableExt, fold_regions,
Expand Down Expand Up @@ -1385,19 +1385,6 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) {
);
}

let repr_type_ty = def.repr().discr_type().to_ty(tcx);
if repr_type_ty == tcx.types.i128 || repr_type_ty == tcx.types.u128 {
if !tcx.features().repr128() {
feature_err(
&tcx.sess,
sym::repr128,
tcx.def_span(def_id),
"repr with 128-bit type is unstable",
)
.emit();
}
}

for v in def.variants() {
if let ty::VariantDiscr::Explicit(discr_def_id) = v.discr {
tcx.ensure_ok().typeck(discr_def_id.expect_local());
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2074,6 +2074,9 @@ symbols! {
sym,
sync,
synthetic,
sys_mutex_lock,
sys_mutex_try_lock,
sys_mutex_unlock,
t32,
target,
target_abi,
Expand Down
24 changes: 24 additions & 0 deletions library/core/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,30 @@ impl CStr {
// instead of doing it afterwards.
str::from_utf8(self.to_bytes())
}

/// Returns an object that implements [`Display`] for safely printing a [`CStr`] that may
/// contain non-Unicode data.
///
/// Behaves as if `self` were first lossily converted to a `str`, with invalid UTF-8 presented
/// as the Unicode replacement character: �.
///
/// [`Display`]: fmt::Display
///
/// # Examples
///
/// ```
/// #![feature(cstr_display)]
///
/// let cstr = c"Hello, world!";
/// println!("{}", cstr.display());
/// ```
#[unstable(feature = "cstr_display", issue = "139984")]
#[must_use = "this does not display the `CStr`; \
it returns an object that can be displayed"]
#[inline]
pub fn display(&self) -> impl fmt::Display {
crate::bstr::ByteStr::from_bytes(self.to_bytes())
}
}

// `.to_bytes()` representations are compared instead of the inner `[c_char]`s,
Expand Down
12 changes: 0 additions & 12 deletions library/core/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2285,12 +2285,6 @@ pub fn round_ties_even_f16(x: f16) -> f16;
#[rustc_nounwind]
pub fn round_ties_even_f32(x: f32) -> f32;

/// Provided for compatibility with stdarch. DO NOT USE.
#[inline(always)]
pub unsafe fn rintf32(x: f32) -> f32 {
round_ties_even_f32(x)
}

/// Returns the nearest integer to an `f64`. Rounds half-way cases to the number with an even
/// least significant digit.
///
Expand All @@ -2300,12 +2294,6 @@ pub unsafe fn rintf32(x: f32) -> f32 {
#[rustc_nounwind]
pub fn round_ties_even_f64(x: f64) -> f64;

/// Provided for compatibility with stdarch. DO NOT USE.
#[inline(always)]
pub unsafe fn rintf64(x: f64) -> f64 {
round_ties_even_f64(x)
}

/// Returns the nearest integer to an `f128`. Rounds half-way cases to the number with an even
/// least significant digit.
///
Expand Down
6 changes: 6 additions & 0 deletions library/coretests/tests/ffi/cstr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ fn debug() {
let s = c"abc\x01\x02\n\xE2\x80\xA6\xFF";
assert_eq!(format!("{s:?}"), r#""abc\x01\x02\n\xe2\x80\xa6\xff""#);
}

#[test]
fn display() {
let s = c"\xf0\x28\x8c\xbc";
assert_eq!(format!("{}", s.display()), "�(��");
}
1 change: 1 addition & 0 deletions library/coretests/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#![feature(core_io_borrowed_buf)]
#![feature(core_private_bignum)]
#![feature(core_private_diy_float)]
#![feature(cstr_display)]
#![feature(dec2flt)]
#![feature(duration_constants)]
#![feature(duration_constructors)]
Expand Down
36 changes: 36 additions & 0 deletions library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1311,9 +1311,39 @@ impl Write for &File {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl Seek for &File {
/// Seek to an offset, in bytes in a file.
///
/// See [`Seek::seek`] docs for more info.
///
/// # Platform-specific behavior
///
/// This function currently corresponds to the `lseek64` function on Unix
/// and the `SetFilePointerEx` function on Windows. Note that this [may
/// change in the future][changes].
///
/// [changes]: io#platform-specific-behavior
fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
self.inner.seek(pos)
}

/// Returns the length of this file (in bytes).
///
/// See [`Seek::stream_len`] docs for more info.
///
/// # Platform-specific behavior
///
/// This function currently corresponds to the `statx` function on Linux
/// (with fallbacks) and the `GetFileSizeEx` function on Windows. Note that
/// this [may change in the future][changes].
///
/// [changes]: io#platform-specific-behavior
fn stream_len(&mut self) -> io::Result<u64> {
if let Some(result) = self.inner.size() {
return result;
}
io::stream_len_default(self)
}

fn stream_position(&mut self) -> io::Result<u64> {
self.inner.tell()
}
Expand Down Expand Up @@ -1363,6 +1393,9 @@ impl Seek for File {
fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
(&*self).seek(pos)
}
fn stream_len(&mut self) -> io::Result<u64> {
(&*self).stream_len()
}
fn stream_position(&mut self) -> io::Result<u64> {
(&*self).stream_position()
}
Expand Down Expand Up @@ -1412,6 +1445,9 @@ impl Seek for Arc<File> {
fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
(&**self).seek(pos)
}
fn stream_len(&mut self) -> io::Result<u64> {
(&**self).stream_len()
}
fn stream_position(&mut self) -> io::Result<u64> {
(&**self).stream_position()
}
Expand Down
26 changes: 15 additions & 11 deletions library/std/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,7 @@ pub trait Seek {

/// Returns the length of this stream (in bytes).
///
/// This method is implemented using up to three seek operations. If this
/// The default implementation uses up to three seek operations. If this
/// method returns successfully, the seek position is unchanged (i.e. the
/// position before calling this method is the same as afterwards).
/// However, if this method returns an error, the seek position is
Expand Down Expand Up @@ -2062,16 +2062,7 @@ pub trait Seek {
/// ```
#[unstable(feature = "seek_stream_len", issue = "59359")]
fn stream_len(&mut self) -> Result<u64> {
let old_pos = self.stream_position()?;
let len = self.seek(SeekFrom::End(0))?;

// Avoid seeking a third time when we were already at the end of the
// stream. The branch is usually way cheaper than a seek operation.
if old_pos != len {
self.seek(SeekFrom::Start(old_pos))?;
}

Ok(len)
stream_len_default(self)
}

/// Returns the current seek position from the start of the stream.
Expand Down Expand Up @@ -2132,6 +2123,19 @@ pub trait Seek {
}
}

pub(crate) fn stream_len_default<T: Seek + ?Sized>(self_: &mut T) -> Result<u64> {
let old_pos = self_.stream_position()?;
let len = self_.seek(SeekFrom::End(0))?;

// Avoid seeking a third time when we were already at the end of the
// stream. The branch is usually way cheaper than a seek operation.
if old_pos != len {
self_.seek(SeekFrom::Start(old_pos))?;
}

Ok(len)
}

/// Enumeration of possible methods to seek within an I/O object.
///
/// It is used by the [`Seek`] trait.
Expand Down
25 changes: 20 additions & 5 deletions library/std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2746,15 +2746,30 @@ impl Path {
/// # Examples
///
/// ```
/// use std::path::{Path, PathBuf};
/// use std::path::Path;
///
/// let path = Path::new("foo.rs");
/// assert_eq!(path.with_extension("txt"), PathBuf::from("foo.txt"));
/// assert_eq!(path.with_extension("txt"), Path::new("foo.txt"));
/// assert_eq!(path.with_extension(""), Path::new("foo"));
/// ```
///
/// Handling multiple extensions:
///
/// ```
/// use std::path::Path;
///
/// let path = Path::new("foo.tar.gz");
/// assert_eq!(path.with_extension(""), PathBuf::from("foo.tar"));
/// assert_eq!(path.with_extension("xz"), PathBuf::from("foo.tar.xz"));
/// assert_eq!(path.with_extension("").with_extension("txt"), PathBuf::from("foo.txt"));
/// assert_eq!(path.with_extension("xz"), Path::new("foo.tar.xz"));
/// assert_eq!(path.with_extension("").with_extension("txt"), Path::new("foo.txt"));
/// ```
///
/// Adding an extension where one did not exist:
///
/// ```
/// use std::path::Path;
///
/// let path = Path::new("foo");
/// assert_eq!(path.with_extension("rs"), Path::new("foo.rs"));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn with_extension<S: AsRef<OsStr>>(&self, extension: S) -> PathBuf {
Expand Down
4 changes: 4 additions & 0 deletions library/std/src/sys/fs/hermit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,10 @@ impl File {
self.0.seek(pos)
}

pub fn size(&self) -> Option<io::Result<u64>> {
None
}

pub fn tell(&self) -> io::Result<u64> {
self.0.tell()
}
Expand Down
4 changes: 4 additions & 0 deletions library/std/src/sys/fs/solid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,10 @@ impl File {
self.tell()
}

pub fn size(&self) -> Option<io::Result<u64>> {
None
}

pub fn tell(&self) -> io::Result<u64> {
unsafe {
let mut out_offset = MaybeUninit::uninit();
Expand Down
9 changes: 9 additions & 0 deletions library/std/src/sys/fs/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,15 @@ impl File {
Ok(n as u64)
}

pub fn size(&self) -> Option<io::Result<u64>> {
match self.file_attr().map(|attr| attr.size()) {
// Fall back to default implementation if the returned size is 0,
// we might be in a proc mount.
Ok(0) => None,
result => Some(result),
}
}

pub fn tell(&self) -> io::Result<u64> {
self.seek(SeekFrom::Current(0))
}
Expand Down
4 changes: 4 additions & 0 deletions library/std/src/sys/fs/unsupported.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ impl File {
self.0
}

pub fn size(&self) -> Option<io::Result<u64>> {
self.0
}

pub fn tell(&self) -> io::Result<u64> {
self.0
}
Expand Down
4 changes: 4 additions & 0 deletions library/std/src/sys/fs/wasi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,10 @@ impl File {
self.fd.seek(pos)
}

pub fn size(&self) -> Option<io::Result<u64>> {
None
}

pub fn tell(&self) -> io::Result<u64> {
self.fd.tell()
}
Expand Down
8 changes: 8 additions & 0 deletions library/std/src/sys/fs/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,14 @@ impl File {
Ok(newpos as u64)
}

pub fn size(&self) -> Option<io::Result<u64>> {
let mut result = 0;
Some(
cvt(unsafe { c::GetFileSizeEx(self.handle.as_raw_handle(), &mut result) })
.map(|_| result as u64),
)
}

pub fn tell(&self) -> io::Result<u64> {
self.seek(SeekFrom::Current(0))
}
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys/pal/windows/c/bindings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2156,6 +2156,7 @@ GetExitCodeProcess
GetFileAttributesW
GetFileInformationByHandle
GetFileInformationByHandleEx
GetFileSizeEx
GetFileType
GETFINALPATHNAMEBYHANDLE_FLAGS
GetFinalPathNameByHandleW
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys/pal/windows/c/windows_sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ windows_targets::link!("kernel32.dll" "system" fn GetExitCodeProcess(hprocess :
windows_targets::link!("kernel32.dll" "system" fn GetFileAttributesW(lpfilename : PCWSTR) -> u32);
windows_targets::link!("kernel32.dll" "system" fn GetFileInformationByHandle(hfile : HANDLE, lpfileinformation : *mut BY_HANDLE_FILE_INFORMATION) -> BOOL);
windows_targets::link!("kernel32.dll" "system" fn GetFileInformationByHandleEx(hfile : HANDLE, fileinformationclass : FILE_INFO_BY_HANDLE_CLASS, lpfileinformation : *mut core::ffi::c_void, dwbuffersize : u32) -> BOOL);
windows_targets::link!("kernel32.dll" "system" fn GetFileSizeEx(hfile : HANDLE, lpfilesize : *mut i64) -> BOOL);
windows_targets::link!("kernel32.dll" "system" fn GetFileType(hfile : HANDLE) -> FILE_TYPE);
windows_targets::link!("kernel32.dll" "system" fn GetFinalPathNameByHandleW(hfile : HANDLE, lpszfilepath : PWSTR, cchfilepath : u32, dwflags : GETFINALPATHNAMEBYHANDLE_FLAGS) -> u32);
windows_targets::link!("kernel32.dll" "system" fn GetFullPathNameW(lpfilename : PCWSTR, nbufferlength : u32, lpbuffer : PWSTR, lpfilepart : *mut PWSTR) -> u32);
Expand Down
Loading
Loading