Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1ae22d8
Implement `Debug` for `EncodeWide`
thaliaarchi Apr 22, 2025
20d6246
the `#[track_caller]` shim should not inherit `#[no_mangle]`
folkertdev Aug 21, 2025
7d99979
use `codegen_instance_attrs` in some additional places
folkertdev Aug 21, 2025
9db7781
add indirect call example to `track-caller-ffi.rs`
folkertdev Aug 21, 2025
d52744e
iter repeat: panic on last
hkBst Oct 2, 2025
1dd0a01
Fix backtraces with -C panic=abort on qnx; emit unwind tables by default
Hoverbear Oct 7, 2025
1e6b444
library: fs: Factor out a `file_time_to_timespec` function in prepara…
joshtriplett Oct 7, 2025
1bf555c
library: fs: Factor out the Apple file time to attrlist code for reuse
joshtriplett Oct 7, 2025
7225454
Implement fs api set_times and set_times_nofollow
chenyukang Oct 8, 2025
3d40fa6
Update library/std/src/fs.rs
chenyukang Oct 9, 2025
6308e76
Update library/std/src/fs.rs
chenyukang Oct 9, 2025
1c5c8ca
use proper unsupported
chenyukang Oct 9, 2025
46c6f0a
rebase #147504
chenyukang Oct 9, 2025
2438df7
support fs::set_times for wasi
chenyukang Oct 9, 2025
1dd5641
add doc alias for set_times_nofollow
chenyukang Oct 9, 2025
6fd1c2b
add doc alias for set_times
chenyukang Oct 9, 2025
901366a
fix c_char error in Android
chenyukang Oct 9, 2025
f8118d8
unsupported: Use `unsupported()` for `set_times`
joshtriplett Oct 9, 2025
d2f590a
unsupported: Use `unsupported()` for `set_times_nofollow`
joshtriplett Oct 9, 2025
8182085
Fix compiling error for redox etc
chenyukang Oct 15, 2025
f1b180a
undo CopyForDeref assertion in const qualif
beepster4096 Oct 15, 2025
5ffbec8
add regression test
beepster4096 Oct 15, 2025
8492b24
use module_child index as disambiguator for external items
LorrensP-2158466 Oct 17, 2025
2e33760
docs: update Motor OS target docs
lasiotus Oct 17, 2025
b46db5c
Rollup merge of #140153 - thaliaarchi:encode-wide-debug, r=ChrisDenton
matthiaskrgr Oct 18, 2025
a5d38ed
Rollup merge of #145724 - folkertdev:track-caller-drop-no-mangle, r=f…
matthiaskrgr Oct 18, 2025
cb3c6ed
Rollup merge of #147258 - hkBst:panic-last-repeat, r=scottmcm
matthiaskrgr Oct 18, 2025
8527b54
Rollup merge of #147454 - ferrocene:hoverbear/panic-abort-uwtables-qn…
matthiaskrgr Oct 18, 2025
fc65029
Rollup merge of #147468 - chenyukang:yukang-api-set-times, r=joshtrip…
matthiaskrgr Oct 18, 2025
756d3a0
Rollup merge of #147764 - beepster4096:oopsies_sorry, r=saethlin
matthiaskrgr Oct 18, 2025
5695a88
Rollup merge of #147805 - LorrensP-2158466:extern-mod-disamb, r=petro…
matthiaskrgr Oct 18, 2025
706f5fb
Rollup merge of #147824 - moturus:motor-os-docs, r=Urgau
matthiaskrgr Oct 18, 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
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
true
} else {
instance.is_some_and(|inst| {
fx.tcx.codegen_fn_attrs(inst.def_id()).flags.contains(CodegenFnAttrFlags::COLD)
fx.tcx.codegen_instance_attrs(inst.def).flags.contains(CodegenFnAttrFlags::COLD)
})
};
if is_cold {
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_ssa/src/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,11 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
let fn_ty = bx.fn_decl_backend_type(fn_abi);

let fn_attrs = if bx.tcx().def_kind(fx.instance.def_id()).has_codegen_attrs() {
Some(bx.tcx().codegen_fn_attrs(fx.instance.def_id()))
Some(bx.tcx().codegen_instance_attrs(fx.instance.def))
} else {
None
};
let fn_attrs = fn_attrs.as_deref();

if !fn_abi.can_unwind {
unwind = mir::UnwindAction::Unreachable;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/check_consts/qualifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ where

Rvalue::Discriminant(place) => in_place::<Q, _>(cx, in_local, place.as_ref()),

Rvalue::CopyForDeref(_) => bug!("`CopyForDeref` in runtime MIR"),
Rvalue::CopyForDeref(place) => in_place::<Q, _>(cx, in_local, place.as_ref()),

Rvalue::Use(operand)
| Rvalue::Repeat(operand, _)
Expand Down
24 changes: 24 additions & 0 deletions compiler/rustc_middle/src/middle/codegen_fn_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ impl<'tcx> TyCtxt<'tcx> {
self,
instance_kind: InstanceKind<'_>,
) -> Cow<'tcx, CodegenFnAttrs> {
// NOTE: we try to not clone the `CodegenFnAttrs` when that is not needed.
// The `to_mut` method used below clones the inner value.
let mut attrs = Cow::Borrowed(self.codegen_fn_attrs(instance_kind.def_id()));

// Drop the `#[naked]` attribute on non-item `InstanceKind`s, like the shims that
Expand All @@ -23,6 +25,28 @@ impl<'tcx> TyCtxt<'tcx> {
}
}

// A shim created by `#[track_caller]` should not inherit any attributes
// that modify the symbol name. Failing to remove these attributes from
// the shim leads to errors like `symbol `foo` is already defined`.
//
// A `ClosureOnceShim` with the track_caller attribute does not have a symbol,
// and therefore can be skipped here.
if let InstanceKind::ReifyShim(_, _) = instance_kind
&& attrs.flags.contains(CodegenFnAttrFlags::TRACK_CALLER)
{
if attrs.flags.contains(CodegenFnAttrFlags::NO_MANGLE) {
attrs.to_mut().flags.remove(CodegenFnAttrFlags::NO_MANGLE);
}

if attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL) {
attrs.to_mut().flags.remove(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL);
}

if attrs.symbol_name.is_some() {
attrs.to_mut().symbol_name = None;
}
}

attrs
}
}
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_mir_transform/src/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl<'tcx> Inliner<'tcx> for ForceInliner<'tcx> {
fn on_inline_failure(&self, callsite: &CallSite<'tcx>, reason: &'static str) {
let tcx = self.tcx();
let InlineAttr::Force { attr_span, reason: justification } =
tcx.codegen_fn_attrs(callsite.callee.def_id()).inline
tcx.codegen_instance_attrs(callsite.callee.def).inline
else {
bug!("called on item without required inlining");
};
Expand Down Expand Up @@ -603,7 +603,8 @@ fn try_inlining<'tcx, I: Inliner<'tcx>>(
let tcx = inliner.tcx();
check_mir_is_available(inliner, caller_body, callsite.callee)?;

let callee_attrs = tcx.codegen_fn_attrs(callsite.callee.def_id());
let callee_attrs = tcx.codegen_instance_attrs(callsite.callee.def);
let callee_attrs = callee_attrs.as_ref();
check_inline::is_inline_valid_on_fn(tcx, callsite.callee.def_id())?;
check_codegen_attributes(inliner, callsite, callee_attrs)?;
inliner.check_codegen_attributes_extra(callee_attrs)?;
Expand Down
20 changes: 11 additions & 9 deletions compiler/rustc_resolve/src/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
parent: Module<'ra>,
ident: Ident,
ns: Namespace,
child_index: usize,
res: Res,
vis: Visibility<DefId>,
span: Span,
Expand All @@ -86,10 +87,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// Even if underscore names cannot be looked up, we still need to add them to modules,
// because they can be fetched by glob imports from those modules, and bring traits
// into scope both directly and through glob imports.
let key = BindingKey::new_disambiguated(ident, ns, || {
parent.underscore_disambiguator.update_unchecked(|d| d + 1);
parent.underscore_disambiguator.get()
});
let key =
BindingKey::new_disambiguated(ident, ns, || (child_index + 1).try_into().unwrap()); // 0 indicates no underscore
if self
.resolution_or_default(parent, key)
.borrow_mut_unchecked()
Expand Down Expand Up @@ -233,9 +232,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
}

pub(crate) fn build_reduced_graph_external(&self, module: Module<'ra>) {
for child in self.tcx.module_children(module.def_id()) {
for (i, child) in self.tcx.module_children(module.def_id()).into_iter().enumerate() {
let parent_scope = ParentScope::module(module, self.arenas);
self.build_reduced_graph_for_external_crate_res(child, parent_scope)
self.build_reduced_graph_for_external_crate_res(child, parent_scope, i)
}
}

Expand All @@ -244,6 +243,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
&self,
child: &ModChild,
parent_scope: ParentScope<'ra>,
child_index: usize,
) {
let parent = parent_scope.module;
let ModChild { ident, res, vis, ref reexport_chain } = *child;
Expand Down Expand Up @@ -272,7 +272,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
_,
)
| Res::PrimTy(..)
| Res::ToolMod => self.define_extern(parent, ident, TypeNS, res, vis, span, expansion),
| Res::ToolMod => {
self.define_extern(parent, ident, TypeNS, child_index, res, vis, span, expansion)
}
Res::Def(
DefKind::Fn
| DefKind::AssocFn
Expand All @@ -281,9 +283,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
| DefKind::AssocConst
| DefKind::Ctor(..),
_,
) => self.define_extern(parent, ident, ValueNS, res, vis, span, expansion),
) => self.define_extern(parent, ident, ValueNS, child_index, res, vis, span, expansion),
Res::Def(DefKind::Macro(..), _) | Res::NonMacroAttr(..) => {
self.define_extern(parent, ident, MacroNS, res, vis, span, expansion)
self.define_extern(parent, ident, MacroNS, child_index, res, vis, span, expansion)
}
Res::Def(
DefKind::TyParam
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_target/src/spec/base/nto_qnx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ pub(crate) fn opts() -> TargetOptions {
has_thread_local: false,
linker: Some("qcc".into()),
os: "nto".into(),
// We want backtraces to work by default and they rely on unwind tables
// (regardless of `-C panic` strategy).
default_uwtable: true,
position_independent_executables: true,
static_position_independent_executables: true,
relro_level: RelroLevel::Full,
Expand Down
11 changes: 11 additions & 0 deletions library/alloc/src/wtf8/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,17 @@ fn wtf8_encode_wide_size_hint() {
assert!(iter.next().is_none());
}

#[test]
fn wtf8_encode_wide_debug() {
let mut string = Wtf8Buf::from_str("aé ");
string.push(CodePoint::from_u32(0xD83D).unwrap());
string.push_char('💩');
assert_eq!(
format!("{:?}", string.encode_wide()),
r#"EncodeWide(['a', 'é', ' ', 0xD83D, 0xD83D, 0xDCA9])"#
);
}

#[test]
fn wtf8_clone_into() {
let mut string = Wtf8Buf::new();
Expand Down
3 changes: 2 additions & 1 deletion library/core/src/iter/sources/repeat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ impl<A: Clone> Iterator for Repeat<A> {
Some(self.element.clone())
}

#[track_caller]
fn last(self) -> Option<A> {
Some(self.element)
panic!("iterator is infinite");
}

#[track_caller]
Expand Down
29 changes: 25 additions & 4 deletions library/core/src/wtf8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,15 +562,36 @@ impl Iterator for EncodeWide<'_> {
}
}

#[stable(feature = "encode_wide_fused_iterator", since = "1.62.0")]
impl FusedIterator for EncodeWide<'_> {}

#[stable(feature = "encode_wide_debug", since = "CURRENT_RUSTC_VERSION")]
impl fmt::Debug for EncodeWide<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("EncodeWide").finish_non_exhaustive()
struct CodeUnit(u16);
impl fmt::Debug for CodeUnit {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// This output attempts to balance readability with precision.
// Render characters which take only one WTF-16 code unit using
// `char` syntax and everything else as code units with hex
// integer syntax (including paired and unpaired surrogate
// halves). Since Rust has no `char`-like type for WTF-16, this
// isn't perfect, so if this output isn't suitable, it is open
// to being changed (see #140153).
match char::from_u32(self.0 as u32) {
Some(c) => write!(f, "{c:?}"),
None => write!(f, "0x{:04X}", self.0),
}
}
}

write!(f, "EncodeWide(")?;
f.debug_list().entries(self.clone().map(CodeUnit)).finish()?;
write!(f, ")")?;
Ok(())
}
}

#[stable(feature = "encode_wide_fused_iterator", since = "1.62.0")]
impl FusedIterator for EncodeWide<'_> {}

impl Hash for CodePoint {
#[inline]
fn hash<H: Hasher>(&self, state: &mut H) {
Expand Down
1 change: 1 addition & 0 deletions library/coretests/tests/iter/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ fn test_repeat_count() {
}

#[test]
#[should_panic = "iterator is infinite"]
fn test_repeat_last() {
assert_eq!(repeat(42).last(), Some(42));
}
Expand Down
81 changes: 81 additions & 0 deletions library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,87 @@ pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> io::Result
inner(path.as_ref(), contents.as_ref())
}

/// Changes the timestamps of the file or directory at the specified path.
///
/// This function will attempt to set the access and modification times
/// to the times specified. If the path refers to a symbolic link, this function
/// will follow the link and change the timestamps of the target file.
///
/// # Platform-specific behavior
///
/// This function currently corresponds to the `utimensat` function on Unix platforms, the
/// `setattrlist` function on Apple platforms, and the `SetFileTime` function on Windows.
///
/// # Errors
///
/// This function will return an error if the user lacks permission to change timestamps on the
/// target file or symlink. It may also return an error if the OS does not support it.
///
/// # Examples
///
/// ```no_run
/// #![feature(fs_set_times)]
/// use std::fs::{self, FileTimes};
/// use std::time::SystemTime;
///
/// fn main() -> std::io::Result<()> {
/// let now = SystemTime::now();
/// let times = FileTimes::new()
/// .set_accessed(now)
/// .set_modified(now);
/// fs::set_times("foo.txt", times)?;
/// Ok(())
/// }
/// ```
#[unstable(feature = "fs_set_times", issue = "147455")]
#[doc(alias = "utimens")]
#[doc(alias = "utimes")]
#[doc(alias = "utime")]
pub fn set_times<P: AsRef<Path>>(path: P, times: FileTimes) -> io::Result<()> {
fs_imp::set_times(path.as_ref(), times.0)
}

/// Changes the timestamps of the file or symlink at the specified path.
///
/// This function will attempt to set the access and modification times
/// to the times specified. Differ from `set_times`, if the path refers to a symbolic link,
/// this function will change the timestamps of the symlink itself, not the target file.
///
/// # Platform-specific behavior
///
/// This function currently corresponds to the `utimensat` function with `AT_SYMLINK_NOFOLLOW` on
/// Unix platforms, the `setattrlist` function with `FSOPT_NOFOLLOW` on Apple platforms, and the
/// `SetFileTime` function on Windows.
///
/// # Errors
///
/// This function will return an error if the user lacks permission to change timestamps on the
/// target file or symlink. It may also return an error if the OS does not support it.
///
/// # Examples
///
/// ```no_run
/// #![feature(fs_set_times)]
/// use std::fs::{self, FileTimes};
/// use std::time::SystemTime;
///
/// fn main() -> std::io::Result<()> {
/// let now = SystemTime::now();
/// let times = FileTimes::new()
/// .set_accessed(now)
/// .set_modified(now);
/// fs::set_times_nofollow("symlink.txt", times)?;
/// Ok(())
/// }
/// ```
#[unstable(feature = "fs_set_times", issue = "147455")]
#[doc(alias = "utimensat")]
#[doc(alias = "lutimens")]
#[doc(alias = "lutimes")]
pub fn set_times_nofollow<P: AsRef<Path>>(path: P, times: FileTimes) -> io::Result<()> {
fs_imp::set_times_nofollow(path.as_ref(), times.0)
}

#[stable(feature = "file_lock", since = "1.89.0")]
impl error::Error for TryLockError {}

Expand Down
Loading
Loading