Skip to content

Commit c502b70

Browse files
committed
Auto merge of rust-lang#131867 - jhpratt:rollup-elgu3q7, r=jhpratt
Rollup of 5 pull requests Successful merges: - rust-lang#130136 (Partially stabilize const_pin) - rust-lang#131654 (Various fixes for Xous) - rust-lang#131743 (rustc_metadata: minor tidying) - rust-lang#131823 (Bump libc to 0.2.161) - rust-lang#131850 (Missing parenthesis) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d9c4b8d + 90ec770 commit c502b70

File tree

19 files changed

+587
-99
lines changed

19 files changed

+587
-99
lines changed

compiler/rustc_metadata/src/locator.rs

+49-42
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,11 @@ impl<'a> CrateLocator<'a> {
499499
dylibs: FxIndexMap<PathBuf, PathKind>,
500500
) -> Result<Option<(Svh, Library)>, CrateError> {
501501
let mut slot = None;
502-
// Order here matters, rmeta should come first. See comment in
503-
// `extract_one` below.
502+
// Order here matters, rmeta should come first.
503+
//
504+
// Make sure there's at most one rlib and at most one dylib.
505+
//
506+
// See comment in `extract_one` below.
504507
let source = CrateSource {
505508
rmeta: self.extract_one(rmetas, CrateFlavor::Rmeta, &mut slot)?,
506509
rlib: self.extract_one(rlibs, CrateFlavor::Rlib, &mut slot)?,
@@ -706,54 +709,58 @@ impl<'a> CrateLocator<'a> {
706709
let mut rmetas = FxIndexMap::default();
707710
let mut dylibs = FxIndexMap::default();
708711
for loc in &self.exact_paths {
709-
if !loc.canonicalized().exists() {
710-
return Err(CrateError::ExternLocationNotExist(
711-
self.crate_name,
712-
loc.original().clone(),
713-
));
712+
let loc_canon = loc.canonicalized();
713+
let loc_orig = loc.original();
714+
if !loc_canon.exists() {
715+
return Err(CrateError::ExternLocationNotExist(self.crate_name, loc_orig.clone()));
714716
}
715-
if !loc.original().is_file() {
716-
return Err(CrateError::ExternLocationNotFile(
717-
self.crate_name,
718-
loc.original().clone(),
719-
));
717+
if !loc_orig.is_file() {
718+
return Err(CrateError::ExternLocationNotFile(self.crate_name, loc_orig.clone()));
720719
}
721-
let Some(file) = loc.original().file_name().and_then(|s| s.to_str()) else {
722-
return Err(CrateError::ExternLocationNotFile(
723-
self.crate_name,
724-
loc.original().clone(),
725-
));
720+
// Note to take care and match against the non-canonicalized name:
721+
// some systems save build artifacts into content-addressed stores
722+
// that do not preserve extensions, and then link to them using
723+
// e.g. symbolic links. If we canonicalize too early, we resolve
724+
// the symlink, the file type is lost and we might treat rlibs and
725+
// rmetas as dylibs.
726+
let Some(file) = loc_orig.file_name().and_then(|s| s.to_str()) else {
727+
return Err(CrateError::ExternLocationNotFile(self.crate_name, loc_orig.clone()));
726728
};
727-
728-
if file.starts_with("lib") && (file.ends_with(".rlib") || file.ends_with(".rmeta"))
729-
|| file.starts_with(self.target.dll_prefix.as_ref())
730-
&& file.ends_with(self.target.dll_suffix.as_ref())
731-
{
732-
// Make sure there's at most one rlib and at most one dylib.
733-
// Note to take care and match against the non-canonicalized name:
734-
// some systems save build artifacts into content-addressed stores
735-
// that do not preserve extensions, and then link to them using
736-
// e.g. symbolic links. If we canonicalize too early, we resolve
737-
// the symlink, the file type is lost and we might treat rlibs and
738-
// rmetas as dylibs.
739-
let loc_canon = loc.canonicalized().clone();
740-
let loc = loc.original();
741-
if loc.file_name().unwrap().to_str().unwrap().ends_with(".rlib") {
742-
rlibs.insert(loc_canon, PathKind::ExternFlag);
743-
} else if loc.file_name().unwrap().to_str().unwrap().ends_with(".rmeta") {
744-
rmetas.insert(loc_canon, PathKind::ExternFlag);
745-
} else {
746-
dylibs.insert(loc_canon, PathKind::ExternFlag);
729+
// FnMut cannot return reference to captured value, so references
730+
// must be taken outside the closure.
731+
let rlibs = &mut rlibs;
732+
let rmetas = &mut rmetas;
733+
let dylibs = &mut dylibs;
734+
let type_via_filename = (|| {
735+
if file.starts_with("lib") {
736+
if file.ends_with(".rlib") {
737+
return Some(rlibs);
738+
}
739+
if file.ends_with(".rmeta") {
740+
return Some(rmetas);
741+
}
742+
}
743+
let dll_prefix = self.target.dll_prefix.as_ref();
744+
let dll_suffix = self.target.dll_suffix.as_ref();
745+
if file.starts_with(dll_prefix) && file.ends_with(dll_suffix) {
746+
return Some(dylibs);
747+
}
748+
None
749+
})();
750+
match type_via_filename {
751+
Some(type_via_filename) => {
752+
type_via_filename.insert(loc_canon.clone(), PathKind::ExternFlag);
753+
}
754+
None => {
755+
self.crate_rejections
756+
.via_filename
757+
.push(CrateMismatch { path: loc_orig.clone(), got: String::new() });
747758
}
748-
} else {
749-
self.crate_rejections
750-
.via_filename
751-
.push(CrateMismatch { path: loc.original().clone(), got: String::new() });
752759
}
753760
}
754761

755762
// Extract the dylib/rlib/rmeta triple.
756-
Ok(self.extract_lib(rlibs, rmetas, dylibs)?.map(|(_, lib)| lib))
763+
self.extract_lib(rlibs, rmetas, dylibs).map(|opt| opt.map(|(_, lib)| lib))
757764
}
758765

759766
pub(crate) fn into_error(self, root: Option<CratePaths>) -> CrateError {

library/Cargo.lock

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is automatically @generated by Cargo.
22
# It is not intended for manual editing.
3-
version = 3
3+
version = 4
44

55
[[package]]
66
name = "addr2line"
@@ -124,9 +124,9 @@ dependencies = [
124124

125125
[[package]]
126126
name = "gimli"
127-
version = "0.30.0"
127+
version = "0.31.1"
128128
source = "registry+https://github.com/rust-lang/crates.io-index"
129-
checksum = "e2e1d97fbe9722ba9bbd0c97051c2956e726562b61f86a25a4360398a40edfc9"
129+
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
130130
dependencies = [
131131
"compiler_builtins",
132132
"rustc-std-workspace-alloc",
@@ -158,9 +158,9 @@ dependencies = [
158158

159159
[[package]]
160160
name = "libc"
161-
version = "0.2.159"
161+
version = "0.2.161"
162162
source = "registry+https://github.com/rust-lang/crates.io-index"
163-
checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5"
163+
checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1"
164164
dependencies = [
165165
"rustc-std-workspace-core",
166166
]
@@ -406,12 +406,12 @@ dependencies = [
406406

407407
[[package]]
408408
name = "unwinding"
409-
version = "0.2.2"
409+
version = "0.2.3"
410410
source = "registry+https://github.com/rust-lang/crates.io-index"
411-
checksum = "dc55842d0db6329a669d55a623c674b02d677b16bfb2d24857d4089d41eba882"
411+
checksum = "637d511437df708cee34bdec7ba2f1548d256b7acf3ff20e0a1c559f9bf3a987"
412412
dependencies = [
413413
"compiler_builtins",
414-
"gimli 0.30.0",
414+
"gimli 0.31.1",
415415
"rustc-std-workspace-core",
416416
]
417417

library/alloc/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112
#![feature(const_eval_select)]
113113
#![feature(const_heap)]
114114
#![feature(const_maybe_uninit_write)]
115-
#![feature(const_pin)]
116115
#![feature(const_size_of_val)]
117116
#![feature(const_vec_string_slice)]
118117
#![feature(core_intrinsics)]

library/core/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
#![feature(const_nonnull_new)]
130130
#![feature(const_num_midpoint)]
131131
#![feature(const_option_ext)]
132-
#![feature(const_pin)]
132+
#![feature(const_pin_2)]
133133
#![feature(const_pointer_is_aligned)]
134134
#![feature(const_ptr_is_null)]
135135
#![feature(const_ptr_sub_ptr)]

library/core/src/macros/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1550,7 +1550,7 @@ pub(crate) mod builtin {
15501550
/// MODE is any of Forward, Reverse, ForwardFirst, ReverseFirst.
15511551
/// INPUT_ACTIVITIES consists of one valid activity for each input parameter.
15521552
/// OUTPUT_ACTIVITY must not be set if we implicitely return nothing (or explicitely return
1553-
/// `-> ()`. Otherwise it must be set to one of the allowed activities.
1553+
/// `-> ()`). Otherwise it must be set to one of the allowed activities.
15541554
#[unstable(feature = "autodiff", issue = "124509")]
15551555
#[allow_internal_unstable(rustc_attrs)]
15561556
#[rustc_builtin_macro]

library/core/src/pin.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ impl<Ptr: Deref<Target: Unpin>> Pin<Ptr> {
11861186
/// let mut pinned: Pin<&mut u8> = Pin::new(&mut val);
11871187
/// ```
11881188
#[inline(always)]
1189-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1189+
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
11901190
#[stable(feature = "pin", since = "1.33.0")]
11911191
pub const fn new(pointer: Ptr) -> Pin<Ptr> {
11921192
// SAFETY: the value pointed to is `Unpin`, and so has no requirements
@@ -1214,7 +1214,7 @@ impl<Ptr: Deref<Target: Unpin>> Pin<Ptr> {
12141214
/// assert_eq!(*r, 5);
12151215
/// ```
12161216
#[inline(always)]
1217-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1217+
#[rustc_const_unstable(feature = "const_pin_2", issue = "76654")]
12181218
#[stable(feature = "pin_into_inner", since = "1.39.0")]
12191219
pub const fn into_inner(pin: Pin<Ptr>) -> Ptr {
12201220
pin.__pointer
@@ -1351,7 +1351,7 @@ impl<Ptr: Deref> Pin<Ptr> {
13511351
/// [`pin` module docs]: self
13521352
#[lang = "new_unchecked"]
13531353
#[inline(always)]
1354-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1354+
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
13551355
#[stable(feature = "pin", since = "1.33.0")]
13561356
pub const unsafe fn new_unchecked(pointer: Ptr) -> Pin<Ptr> {
13571357
Pin { __pointer: pointer }
@@ -1503,7 +1503,7 @@ impl<Ptr: Deref> Pin<Ptr> {
15031503
/// If the underlying data is [`Unpin`], [`Pin::into_inner`] should be used
15041504
/// instead.
15051505
#[inline(always)]
1506-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1506+
#[rustc_const_unstable(feature = "const_pin_2", issue = "76654")]
15071507
#[stable(feature = "pin_into_inner", since = "1.39.0")]
15081508
pub const unsafe fn into_inner_unchecked(pin: Pin<Ptr>) -> Ptr {
15091509
pin.__pointer
@@ -1559,7 +1559,7 @@ impl<'a, T: ?Sized> Pin<&'a T> {
15591559
/// ["pinning projections"]: self#projections-and-structural-pinning
15601560
#[inline(always)]
15611561
#[must_use]
1562-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1562+
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
15631563
#[stable(feature = "pin", since = "1.33.0")]
15641564
pub const fn get_ref(self) -> &'a T {
15651565
self.__pointer
@@ -1570,7 +1570,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
15701570
/// Converts this `Pin<&mut T>` into a `Pin<&T>` with the same lifetime.
15711571
#[inline(always)]
15721572
#[must_use = "`self` will be dropped if the result is not used"]
1573-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1573+
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
15741574
#[stable(feature = "pin", since = "1.33.0")]
15751575
pub const fn into_ref(self) -> Pin<&'a T> {
15761576
Pin { __pointer: self.__pointer }
@@ -1588,7 +1588,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
15881588
#[inline(always)]
15891589
#[must_use = "`self` will be dropped if the result is not used"]
15901590
#[stable(feature = "pin", since = "1.33.0")]
1591-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1591+
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
15921592
pub const fn get_mut(self) -> &'a mut T
15931593
where
15941594
T: Unpin,
@@ -1609,7 +1609,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
16091609
#[inline(always)]
16101610
#[must_use = "`self` will be dropped if the result is not used"]
16111611
#[stable(feature = "pin", since = "1.33.0")]
1612-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1612+
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
16131613
pub const unsafe fn get_unchecked_mut(self) -> &'a mut T {
16141614
self.__pointer
16151615
}
@@ -1652,7 +1652,7 @@ impl<T: ?Sized> Pin<&'static T> {
16521652
/// This is safe because `T` is borrowed immutably for the `'static` lifetime, which
16531653
/// never ends.
16541654
#[stable(feature = "pin_static_ref", since = "1.61.0")]
1655-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1655+
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
16561656
pub const fn static_ref(r: &'static T) -> Pin<&'static T> {
16571657
// SAFETY: The 'static borrow guarantees the data will not be
16581658
// moved/invalidated until it gets dropped (which is never).
@@ -1666,7 +1666,7 @@ impl<T: ?Sized> Pin<&'static mut T> {
16661666
/// This is safe because `T` is borrowed for the `'static` lifetime, which
16671667
/// never ends.
16681668
#[stable(feature = "pin_static_ref", since = "1.61.0")]
1669-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1669+
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
16701670
pub const fn static_mut(r: &'static mut T) -> Pin<&'static mut T> {
16711671
// SAFETY: The 'static borrow guarantees the data will not be
16721672
// moved/invalidated until it gets dropped (which is never).

library/core/tests/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#![feature(const_likely)]
2222
#![feature(const_nonnull_new)]
2323
#![feature(const_option_ext)]
24-
#![feature(const_pin)]
24+
#![feature(const_pin_2)]
2525
#![feature(const_pointer_is_aligned)]
2626
#![feature(const_three_way_compare)]
2727
#![feature(const_trait_impl)]

library/core/tests/pin.rs

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ fn pin_const() {
1919
const REF: &'static usize = PINNED.get_ref();
2020
assert_eq!(REF, POINTER);
2121

22+
const INT: u8 = 42;
23+
const STATIC_REF: Pin<&'static u8> = Pin::static_ref(&INT);
24+
assert_eq!(*STATIC_REF, INT);
25+
2226
// Note: `pin_mut_const` tests that the methods of `Pin<&mut T>` are usable in a const context.
2327
// A const fn is used because `&mut` is not (yet) usable in constants.
2428
const fn pin_mut_const() {

library/std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ miniz_oxide = { version = "0.7.0", optional = true, default-features = false }
3939
addr2line = { version = "0.22.0", optional = true, default-features = false }
4040

4141
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]
42-
libc = { version = "0.2.159", default-features = false, features = [
42+
libc = { version = "0.2.161", default-features = false, features = [
4343
'rustc-dep-of-std',
4444
], public = true }
4545

library/std/src/os/xous/ffi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ pub(crate) fn thread_id() -> Result<ThreadId, Error> {
615615
/// An error is generated if the `knob` is not a valid limit, or if the call
616616
/// would not succeed.
617617
pub(crate) fn adjust_limit(knob: Limits, current: usize, new: usize) -> Result<usize, Error> {
618-
let mut a0 = Syscall::JoinThread as usize;
618+
let mut a0 = Syscall::AdjustProcessLimit as usize;
619619
let mut a1 = knob as usize;
620620
let a2 = current;
621621
let a3 = new;

library/std/src/sys/alloc/xous.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
2+
#![allow(static_mut_refs)]
3+
14
use crate::alloc::{GlobalAlloc, Layout, System};
25

36
#[cfg(not(test))]

library/std/src/sys/pal/xous/args.rs

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
use crate::ffi::OsString;
2+
use crate::sys::pal::xous::os::get_application_parameters;
3+
use crate::sys::pal::xous::os::params::ArgumentList;
4+
use crate::{fmt, vec};
5+
6+
pub struct Args {
7+
parsed_args_list: vec::IntoIter<OsString>,
8+
}
9+
10+
pub fn args() -> Args {
11+
let Some(params) = get_application_parameters() else {
12+
return Args { parsed_args_list: vec![].into_iter() };
13+
};
14+
15+
for param in params {
16+
if let Ok(args) = ArgumentList::try_from(&param) {
17+
let mut parsed_args = vec![];
18+
for arg in args {
19+
parsed_args.push(arg.into());
20+
}
21+
return Args { parsed_args_list: parsed_args.into_iter() };
22+
}
23+
}
24+
Args { parsed_args_list: vec![].into_iter() }
25+
}
26+
27+
impl fmt::Debug for Args {
28+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29+
self.parsed_args_list.as_slice().fmt(f)
30+
}
31+
}
32+
33+
impl Iterator for Args {
34+
type Item = OsString;
35+
fn next(&mut self) -> Option<OsString> {
36+
self.parsed_args_list.next()
37+
}
38+
fn size_hint(&self) -> (usize, Option<usize>) {
39+
self.parsed_args_list.size_hint()
40+
}
41+
}
42+
43+
impl DoubleEndedIterator for Args {
44+
fn next_back(&mut self) -> Option<OsString> {
45+
self.parsed_args_list.next_back()
46+
}
47+
}
48+
49+
impl ExactSizeIterator for Args {
50+
fn len(&self) -> usize {
51+
self.parsed_args_list.len()
52+
}
53+
}

library/std/src/sys/pal/xous/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![forbid(unsafe_op_in_unsafe_fn)]
22

3-
#[path = "../unsupported/args.rs"]
43
pub mod args;
54
#[path = "../unsupported/env.rs"]
65
pub mod env;

library/std/src/sys/pal/xous/net/dns.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::os::xous::ffi::lend_mut;
66
use crate::os::xous::services::{DnsLendMut, dns_server};
77

88
pub struct DnsError {
9+
#[allow(dead_code)]
910
pub code: u8,
1011
}
1112

0 commit comments

Comments
 (0)