Skip to content

Commit

Permalink
Auto merge of rust-lang#131867 - jhpratt:rollup-elgu3q7, r=jhpratt
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Oct 18, 2024
2 parents d9c4b8d + 90ec770 commit c502b70
Show file tree
Hide file tree
Showing 19 changed files with 587 additions and 99 deletions.
91 changes: 49 additions & 42 deletions compiler/rustc_metadata/src/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,11 @@ impl<'a> CrateLocator<'a> {
dylibs: FxIndexMap<PathBuf, PathKind>,
) -> Result<Option<(Svh, Library)>, CrateError> {
let mut slot = None;
// Order here matters, rmeta should come first. See comment in
// `extract_one` below.
// Order here matters, rmeta should come first.
//
// Make sure there's at most one rlib and at most one dylib.
//
// See comment in `extract_one` below.
let source = CrateSource {
rmeta: self.extract_one(rmetas, CrateFlavor::Rmeta, &mut slot)?,
rlib: self.extract_one(rlibs, CrateFlavor::Rlib, &mut slot)?,
Expand Down Expand Up @@ -706,54 +709,58 @@ impl<'a> CrateLocator<'a> {
let mut rmetas = FxIndexMap::default();
let mut dylibs = FxIndexMap::default();
for loc in &self.exact_paths {
if !loc.canonicalized().exists() {
return Err(CrateError::ExternLocationNotExist(
self.crate_name,
loc.original().clone(),
));
let loc_canon = loc.canonicalized();
let loc_orig = loc.original();
if !loc_canon.exists() {
return Err(CrateError::ExternLocationNotExist(self.crate_name, loc_orig.clone()));
}
if !loc.original().is_file() {
return Err(CrateError::ExternLocationNotFile(
self.crate_name,
loc.original().clone(),
));
if !loc_orig.is_file() {
return Err(CrateError::ExternLocationNotFile(self.crate_name, loc_orig.clone()));
}
let Some(file) = loc.original().file_name().and_then(|s| s.to_str()) else {
return Err(CrateError::ExternLocationNotFile(
self.crate_name,
loc.original().clone(),
));
// Note to take care and match against the non-canonicalized name:
// some systems save build artifacts into content-addressed stores
// that do not preserve extensions, and then link to them using
// e.g. symbolic links. If we canonicalize too early, we resolve
// the symlink, the file type is lost and we might treat rlibs and
// rmetas as dylibs.
let Some(file) = loc_orig.file_name().and_then(|s| s.to_str()) else {
return Err(CrateError::ExternLocationNotFile(self.crate_name, loc_orig.clone()));
};

if file.starts_with("lib") && (file.ends_with(".rlib") || file.ends_with(".rmeta"))
|| file.starts_with(self.target.dll_prefix.as_ref())
&& file.ends_with(self.target.dll_suffix.as_ref())
{
// Make sure there's at most one rlib and at most one dylib.
// Note to take care and match against the non-canonicalized name:
// some systems save build artifacts into content-addressed stores
// that do not preserve extensions, and then link to them using
// e.g. symbolic links. If we canonicalize too early, we resolve
// the symlink, the file type is lost and we might treat rlibs and
// rmetas as dylibs.
let loc_canon = loc.canonicalized().clone();
let loc = loc.original();
if loc.file_name().unwrap().to_str().unwrap().ends_with(".rlib") {
rlibs.insert(loc_canon, PathKind::ExternFlag);
} else if loc.file_name().unwrap().to_str().unwrap().ends_with(".rmeta") {
rmetas.insert(loc_canon, PathKind::ExternFlag);
} else {
dylibs.insert(loc_canon, PathKind::ExternFlag);
// FnMut cannot return reference to captured value, so references
// must be taken outside the closure.
let rlibs = &mut rlibs;
let rmetas = &mut rmetas;
let dylibs = &mut dylibs;
let type_via_filename = (|| {
if file.starts_with("lib") {
if file.ends_with(".rlib") {
return Some(rlibs);
}
if file.ends_with(".rmeta") {
return Some(rmetas);
}
}
let dll_prefix = self.target.dll_prefix.as_ref();
let dll_suffix = self.target.dll_suffix.as_ref();
if file.starts_with(dll_prefix) && file.ends_with(dll_suffix) {
return Some(dylibs);
}
None
})();
match type_via_filename {
Some(type_via_filename) => {
type_via_filename.insert(loc_canon.clone(), PathKind::ExternFlag);
}
None => {
self.crate_rejections
.via_filename
.push(CrateMismatch { path: loc_orig.clone(), got: String::new() });
}
} else {
self.crate_rejections
.via_filename
.push(CrateMismatch { path: loc.original().clone(), got: String::new() });
}
}

// Extract the dylib/rlib/rmeta triple.
Ok(self.extract_lib(rlibs, rmetas, dylibs)?.map(|(_, lib)| lib))
self.extract_lib(rlibs, rmetas, dylibs).map(|opt| opt.map(|(_, lib)| lib))
}

pub(crate) fn into_error(self, root: Option<CratePaths>) -> CrateError {
Expand Down
16 changes: 8 additions & 8 deletions library/Cargo.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
version = 4

[[package]]
name = "addr2line"
Expand Down Expand Up @@ -124,9 +124,9 @@ dependencies = [

[[package]]
name = "gimli"
version = "0.30.0"
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2e1d97fbe9722ba9bbd0c97051c2956e726562b61f86a25a4360398a40edfc9"
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-alloc",
Expand Down Expand Up @@ -158,9 +158,9 @@ dependencies = [

[[package]]
name = "libc"
version = "0.2.159"
version = "0.2.161"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5"
checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down Expand Up @@ -406,12 +406,12 @@ dependencies = [

[[package]]
name = "unwinding"
version = "0.2.2"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc55842d0db6329a669d55a623c674b02d677b16bfb2d24857d4089d41eba882"
checksum = "637d511437df708cee34bdec7ba2f1548d256b7acf3ff20e0a1c559f9bf3a987"
dependencies = [
"compiler_builtins",
"gimli 0.30.0",
"gimli 0.31.1",
"rustc-std-workspace-core",
]

Expand Down
1 change: 0 additions & 1 deletion library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
#![feature(const_eval_select)]
#![feature(const_heap)]
#![feature(const_maybe_uninit_write)]
#![feature(const_pin)]
#![feature(const_size_of_val)]
#![feature(const_vec_string_slice)]
#![feature(core_intrinsics)]
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
#![feature(const_nonnull_new)]
#![feature(const_num_midpoint)]
#![feature(const_option_ext)]
#![feature(const_pin)]
#![feature(const_pin_2)]
#![feature(const_pointer_is_aligned)]
#![feature(const_ptr_is_null)]
#![feature(const_ptr_sub_ptr)]
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ pub(crate) mod builtin {
/// MODE is any of Forward, Reverse, ForwardFirst, ReverseFirst.
/// INPUT_ACTIVITIES consists of one valid activity for each input parameter.
/// OUTPUT_ACTIVITY must not be set if we implicitely return nothing (or explicitely return
/// `-> ()`. Otherwise it must be set to one of the allowed activities.
/// `-> ()`). Otherwise it must be set to one of the allowed activities.
#[unstable(feature = "autodiff", issue = "124509")]
#[allow_internal_unstable(rustc_attrs)]
#[rustc_builtin_macro]
Expand Down
20 changes: 10 additions & 10 deletions library/core/src/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ impl<Ptr: Deref<Target: Unpin>> Pin<Ptr> {
/// let mut pinned: Pin<&mut u8> = Pin::new(&mut val);
/// ```
#[inline(always)]
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
#[stable(feature = "pin", since = "1.33.0")]
pub const fn new(pointer: Ptr) -> Pin<Ptr> {
// SAFETY: the value pointed to is `Unpin`, and so has no requirements
Expand Down Expand Up @@ -1214,7 +1214,7 @@ impl<Ptr: Deref<Target: Unpin>> Pin<Ptr> {
/// assert_eq!(*r, 5);
/// ```
#[inline(always)]
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
#[rustc_const_unstable(feature = "const_pin_2", issue = "76654")]
#[stable(feature = "pin_into_inner", since = "1.39.0")]
pub const fn into_inner(pin: Pin<Ptr>) -> Ptr {
pin.__pointer
Expand Down Expand Up @@ -1351,7 +1351,7 @@ impl<Ptr: Deref> Pin<Ptr> {
/// [`pin` module docs]: self
#[lang = "new_unchecked"]
#[inline(always)]
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
#[stable(feature = "pin", since = "1.33.0")]
pub const unsafe fn new_unchecked(pointer: Ptr) -> Pin<Ptr> {
Pin { __pointer: pointer }
Expand Down Expand Up @@ -1503,7 +1503,7 @@ impl<Ptr: Deref> Pin<Ptr> {
/// If the underlying data is [`Unpin`], [`Pin::into_inner`] should be used
/// instead.
#[inline(always)]
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
#[rustc_const_unstable(feature = "const_pin_2", issue = "76654")]
#[stable(feature = "pin_into_inner", since = "1.39.0")]
pub const unsafe fn into_inner_unchecked(pin: Pin<Ptr>) -> Ptr {
pin.__pointer
Expand Down Expand Up @@ -1559,7 +1559,7 @@ impl<'a, T: ?Sized> Pin<&'a T> {
/// ["pinning projections"]: self#projections-and-structural-pinning
#[inline(always)]
#[must_use]
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
#[stable(feature = "pin", since = "1.33.0")]
pub const fn get_ref(self) -> &'a T {
self.__pointer
Expand All @@ -1570,7 +1570,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
/// Converts this `Pin<&mut T>` into a `Pin<&T>` with the same lifetime.
#[inline(always)]
#[must_use = "`self` will be dropped if the result is not used"]
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
#[stable(feature = "pin", since = "1.33.0")]
pub const fn into_ref(self) -> Pin<&'a T> {
Pin { __pointer: self.__pointer }
Expand All @@ -1588,7 +1588,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
#[inline(always)]
#[must_use = "`self` will be dropped if the result is not used"]
#[stable(feature = "pin", since = "1.33.0")]
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
pub const fn get_mut(self) -> &'a mut T
where
T: Unpin,
Expand All @@ -1609,7 +1609,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
#[inline(always)]
#[must_use = "`self` will be dropped if the result is not used"]
#[stable(feature = "pin", since = "1.33.0")]
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
pub const unsafe fn get_unchecked_mut(self) -> &'a mut T {
self.__pointer
}
Expand Down Expand Up @@ -1652,7 +1652,7 @@ impl<T: ?Sized> Pin<&'static T> {
/// This is safe because `T` is borrowed immutably for the `'static` lifetime, which
/// never ends.
#[stable(feature = "pin_static_ref", since = "1.61.0")]
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
pub const fn static_ref(r: &'static T) -> Pin<&'static T> {
// SAFETY: The 'static borrow guarantees the data will not be
// moved/invalidated until it gets dropped (which is never).
Expand All @@ -1666,7 +1666,7 @@ impl<T: ?Sized> Pin<&'static mut T> {
/// This is safe because `T` is borrowed for the `'static` lifetime, which
/// never ends.
#[stable(feature = "pin_static_ref", since = "1.61.0")]
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
pub const fn static_mut(r: &'static mut T) -> Pin<&'static mut T> {
// SAFETY: The 'static borrow guarantees the data will not be
// moved/invalidated until it gets dropped (which is never).
Expand Down
2 changes: 1 addition & 1 deletion library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#![feature(const_likely)]
#![feature(const_nonnull_new)]
#![feature(const_option_ext)]
#![feature(const_pin)]
#![feature(const_pin_2)]
#![feature(const_pointer_is_aligned)]
#![feature(const_three_way_compare)]
#![feature(const_trait_impl)]
Expand Down
4 changes: 4 additions & 0 deletions library/core/tests/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ fn pin_const() {
const REF: &'static usize = PINNED.get_ref();
assert_eq!(REF, POINTER);

const INT: u8 = 42;
const STATIC_REF: Pin<&'static u8> = Pin::static_ref(&INT);
assert_eq!(*STATIC_REF, INT);

// Note: `pin_mut_const` tests that the methods of `Pin<&mut T>` are usable in a const context.
// A const fn is used because `&mut` is not (yet) usable in constants.
const fn pin_mut_const() {
Expand Down
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ miniz_oxide = { version = "0.7.0", optional = true, default-features = false }
addr2line = { version = "0.22.0", optional = true, default-features = false }

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

Expand Down
2 changes: 1 addition & 1 deletion library/std/src/os/xous/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ pub(crate) fn thread_id() -> Result<ThreadId, Error> {
/// An error is generated if the `knob` is not a valid limit, or if the call
/// would not succeed.
pub(crate) fn adjust_limit(knob: Limits, current: usize, new: usize) -> Result<usize, Error> {
let mut a0 = Syscall::JoinThread as usize;
let mut a0 = Syscall::AdjustProcessLimit as usize;
let mut a1 = knob as usize;
let a2 = current;
let a3 = new;
Expand Down
3 changes: 3 additions & 0 deletions library/std/src/sys/alloc/xous.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
#![allow(static_mut_refs)]

use crate::alloc::{GlobalAlloc, Layout, System};

#[cfg(not(test))]
Expand Down
53 changes: 53 additions & 0 deletions library/std/src/sys/pal/xous/args.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
use crate::ffi::OsString;
use crate::sys::pal::xous::os::get_application_parameters;
use crate::sys::pal::xous::os::params::ArgumentList;
use crate::{fmt, vec};

pub struct Args {
parsed_args_list: vec::IntoIter<OsString>,
}

pub fn args() -> Args {
let Some(params) = get_application_parameters() else {
return Args { parsed_args_list: vec![].into_iter() };
};

for param in params {
if let Ok(args) = ArgumentList::try_from(&param) {
let mut parsed_args = vec![];
for arg in args {
parsed_args.push(arg.into());
}
return Args { parsed_args_list: parsed_args.into_iter() };
}
}
Args { parsed_args_list: vec![].into_iter() }
}

impl fmt::Debug for Args {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.parsed_args_list.as_slice().fmt(f)
}
}

impl Iterator for Args {
type Item = OsString;
fn next(&mut self) -> Option<OsString> {
self.parsed_args_list.next()
}
fn size_hint(&self) -> (usize, Option<usize>) {
self.parsed_args_list.size_hint()
}
}

impl DoubleEndedIterator for Args {
fn next_back(&mut self) -> Option<OsString> {
self.parsed_args_list.next_back()
}
}

impl ExactSizeIterator for Args {
fn len(&self) -> usize {
self.parsed_args_list.len()
}
}
1 change: 0 additions & 1 deletion library/std/src/sys/pal/xous/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![forbid(unsafe_op_in_unsafe_fn)]

#[path = "../unsupported/args.rs"]
pub mod args;
#[path = "../unsupported/env.rs"]
pub mod env;
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys/pal/xous/net/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::os::xous::ffi::lend_mut;
use crate::os::xous::services::{DnsLendMut, dns_server};

pub struct DnsError {
#[allow(dead_code)]
pub code: u8,
}

Expand Down
Loading

0 comments on commit c502b70

Please sign in to comment.