Skip to content

Rollup of 6 pull requests #141320

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

Merged
merged 14 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2124,16 +2124,19 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
accessed through a specific `impl`",
self.tcx.def_kind_descr(assoc_item.as_def_kind(), item_def_id)
));
err.span_suggestion(
span,
"use the fully qualified path to an implementation",
format!(
"<Type as {}>::{}",
self.tcx.def_path_str(trait_ref),
assoc_item.name()
),
Applicability::HasPlaceholders,
);

if !assoc_item.is_impl_trait_in_trait() {
err.span_suggestion(
span,
"use the fully qualified path to an implementation",
format!(
"<Type as {}>::{}",
self.tcx.def_path_str(trait_ref),
assoc_item.name()
),
Applicability::HasPlaceholders,
);
}
}
}
}
Expand Down
28 changes: 28 additions & 0 deletions library/core/src/ptr/const_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,34 @@ impl<T: ?Sized> *const T {
self as _
}

/// Try to cast to a pointer of another type by checking aligment.
///
/// If the pointer is properly aligned to the target type, it will be
/// cast to the target type. Otherwise, `None` is returned.
///
/// # Examples
///
/// ```rust
/// #![feature(pointer_try_cast_aligned)]
///
/// let aligned: *const u8 = 0x1000 as _;
///
/// // i32 has at most 4-byte alignment, so this will succeed
/// assert!(aligned.try_cast_aligned::<i32>().is_some());
///
/// let unaligned: *const u8 = 0x1001 as _;
///
/// // i32 has at least 2-byte alignment, so this will fail
/// assert!(unaligned.try_cast_aligned::<i32>().is_none());
/// ```
#[unstable(feature = "pointer_try_cast_aligned", issue = "141221")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
pub fn try_cast_aligned<U>(self) -> Option<*const U> {
if self.is_aligned_to(align_of::<U>()) { Some(self.cast()) } else { None }
}

/// Uses the address value in a new pointer of another type.
///
/// This operation will ignore the address part of its `meta` operand and discard existing
Expand Down
28 changes: 28 additions & 0 deletions library/core/src/ptr/mut_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,34 @@ impl<T: ?Sized> *mut T {
self as _
}

/// Try to cast to a pointer of another type by checking aligment.
///
/// If the pointer is properly aligned to the target type, it will be
/// cast to the target type. Otherwise, `None` is returned.
///
/// # Examples
///
/// ```rust
/// #![feature(pointer_try_cast_aligned)]
///
/// let aligned: *mut u8 = 0x1000 as _;
///
/// // i32 has at most 4-byte alignment, so this will succeed
/// assert!(aligned.try_cast_aligned::<i32>().is_some());
///
/// let unaligned: *mut u8 = 0x1001 as _;
///
/// // i32 has at least 2-byte alignment, so this will fail
/// assert!(unaligned.try_cast_aligned::<i32>().is_none());
/// ```
#[unstable(feature = "pointer_try_cast_aligned", issue = "141221")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
pub fn try_cast_aligned<U>(self) -> Option<*mut U> {
if self.is_aligned_to(align_of::<U>()) { Some(self.cast()) } else { None }
}

/// Uses the address value in a new pointer of another type.
///
/// This operation will ignore the address part of its `meta` operand and discard existing
Expand Down
29 changes: 29 additions & 0 deletions library/core/src/ptr/non_null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,35 @@ impl<T: ?Sized> NonNull<T> {
unsafe { NonNull { pointer: self.as_ptr() as *mut U } }
}

/// Try to cast to a pointer of another type by checking aligment.
///
/// If the pointer is properly aligned to the target type, it will be
/// cast to the target type. Otherwise, `None` is returned.
///
/// # Examples
///
/// ```rust
/// #![feature(pointer_try_cast_aligned)]
/// use std::ptr::NonNull;
///
/// let aligned: NonNull<u8> = NonNull::new(0x1000 as _).unwrap();
///
/// // i32 has at most 4-byte alignment, so this will succeed
/// assert!(aligned.try_cast_aligned::<i32>().is_some());
///
/// let unaligned: NonNull<u8> = NonNull::new(0x1001 as _).unwrap();
///
/// // i32 has at least 2-byte alignment, so this will fail
/// assert!(unaligned.try_cast_aligned::<i32>().is_none());
/// ```
#[unstable(feature = "pointer_try_cast_aligned", issue = "141221")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
pub fn try_cast_aligned<U>(self) -> Option<NonNull<U>> {
if self.is_aligned_to(align_of::<U>()) { Some(self.cast()) } else { None }
}

/// Adds an offset to a pointer.
///
/// `count` is in units of T; e.g., a `count` of 3 represents a pointer
Expand Down
35 changes: 35 additions & 0 deletions src/ci/docker/host-x86_64/dist-arm-linux-gnueabi/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM ghcr.io/rust-lang/ubuntu:22.04

COPY scripts/cross-apt-packages.sh /scripts/
RUN sh /scripts/cross-apt-packages.sh

COPY scripts/crosstool-ng.sh /scripts/
RUN sh /scripts/crosstool-ng.sh

WORKDIR /build

COPY scripts/rustbuild-setup.sh /scripts/
RUN sh /scripts/rustbuild-setup.sh
WORKDIR /tmp

COPY scripts/crosstool-ng-build.sh /scripts/
COPY host-x86_64/dist-arm-linux-gnueabi/arm-linux-gnueabi.defconfig /tmp/crosstool.defconfig
RUN /scripts/crosstool-ng-build.sh

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

ENV PATH=$PATH:/x-tools/arm-unknown-linux-gnueabi/bin

ENV CC_arm_unknown_linux_gnueabi=arm-unknown-linux-gnueabi-gcc \
AR_arm_unknown_linux_gnueabi=arm-unknown-linux-gnueabi-ar \
CXX_arm_unknown_linux_gnueabi=arm-unknown-linux-gnueabi-g++

ENV HOSTS=arm-unknown-linux-gnueabi

ENV RUST_CONFIGURE_ARGS \
--enable-full-tools \
--disable-docs \
--enable-sanitizers \
--enable-profiler
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,13 @@ RUN sh /scripts/rustbuild-setup.sh
WORKDIR /tmp

COPY scripts/crosstool-ng-build.sh /scripts/
COPY host-x86_64/dist-arm-linux/arm-linux-gnueabi.defconfig /tmp/crosstool.defconfig
COPY host-x86_64/dist-arm-linux-musl/arm-linux-musl.defconfig /tmp/crosstool.defconfig
RUN /scripts/crosstool-ng-build.sh

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

ENV PATH=$PATH:/x-tools/arm-unknown-linux-gnueabi/bin

ENV CC_arm_unknown_linux_gnueabi=arm-unknown-linux-gnueabi-gcc \
AR_arm_unknown_linux_gnueabi=arm-unknown-linux-gnueabi-ar \
CXX_arm_unknown_linux_gnueabi=arm-unknown-linux-gnueabi-g++

ENV HOSTS=arm-unknown-linux-gnueabi,aarch64-unknown-linux-musl
ENV HOSTS=aarch64-unknown-linux-musl

ENV RUST_CONFIGURE_ARGS \
--enable-full-tools \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CT_CONFIG_VERSION="4"
CT_PREFIX_DIR="/x-tools/${CT_TARGET}"
CT_USE_MIRROR=y
CT_MIRROR_BASE_URL="https://ci-mirrors.rust-lang.org/rustc"
CT_ARCH_ARM=y
CT_ARCH_ARCH="armv6"
CT_ARCH_FLOAT_SW=y
CT_KERNEL_LINUX=y
CT_LINUX_V_3_2=y
CT_BINUTILS_V_2_32=y
CT_GLIBC_V_2_17=y
CT_GCC_V_8=y
CT_CC_LANG_CXX=y
41 changes: 41 additions & 0 deletions src/ci/docker/host-x86_64/dist-powerpc64le-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM ubuntu:22.04

COPY scripts/cross-apt-packages.sh /scripts/
RUN sh /scripts/cross-apt-packages.sh

COPY scripts/crosstool-ng.sh /scripts/
RUN sh /scripts/crosstool-ng.sh

COPY scripts/rustbuild-setup.sh /scripts/
RUN sh /scripts/rustbuild-setup.sh

WORKDIR /tmp

COPY scripts/crosstool-ng-build.sh /scripts/
COPY host-x86_64/dist-powerpc64le-linux-gnu/powerpc64le-unknown-linux-gnu.defconfig /tmp/crosstool.defconfig
RUN /scripts/crosstool-ng-build.sh

WORKDIR /build

RUN apt-get install -y --no-install-recommends rpm2cpio cpio
COPY scripts/shared.sh scripts/build-powerpc64le-toolchain.sh /build/
RUN ./build-powerpc64le-toolchain.sh

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

ENV \
AR_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-ar \
CC_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-gcc \
CXX_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-g++

ENV HOSTS=powerpc64le-unknown-linux-gnu

ENV RUST_CONFIGURE_ARGS \
--enable-extended \
--enable-full-tools \
--enable-profiler \
--enable-sanitizers \
--disable-docs

ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CT_CONFIG_VERSION="4"
CT_EXPERIMENTAL=y
CT_PREFIX_DIR="/x-tools/${CT_TARGET}"
CT_USE_MIRROR=y
CT_MIRROR_BASE_URL="https://ci-mirrors.rust-lang.org/rustc"
CT_ARCH_POWERPC=y
CT_ARCH_LE=y
CT_ARCH_64=y
# CT_DEMULTILIB is not set
CT_ARCH_ARCH="powerpc64le"
CT_KERNEL_LINUX=y
CT_LINUX_V_4_19=y
CT_CC_LANG_CXX=y
CT_GETTEXT_NEEDED=y
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ RUN sh /scripts/rustbuild-setup.sh
WORKDIR /tmp

COPY scripts/crosstool-ng-build.sh /scripts/
COPY host-x86_64/dist-powerpc64le-linux/powerpc64le-unknown-linux-musl.defconfig /tmp/crosstool.defconfig
COPY host-x86_64/dist-powerpc64le-linux-musl/powerpc64le-unknown-linux-musl.defconfig /tmp/crosstool.defconfig
RUN /scripts/crosstool-ng-build.sh

WORKDIR /build

RUN apt-get install -y --no-install-recommends rpm2cpio cpio
COPY scripts/shared.sh host-x86_64/dist-powerpc64le-linux/build-powerpc64le-toolchain.sh /build/
COPY scripts/shared.sh scripts/build-powerpc64le-toolchain.sh /build/
RUN ./build-powerpc64le-toolchain.sh

COPY scripts/sccache.sh /scripts/
Expand All @@ -27,14 +27,11 @@ RUN sh /scripts/sccache.sh
ENV PATH=$PATH:/x-tools/powerpc64le-unknown-linux-musl/bin

ENV \
AR_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-ar \
CC_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-gcc \
CXX_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-g++ \
AR_powerpc64le_unknown_linux_musl=powerpc64le-unknown-linux-musl-ar \
CC_powerpc64le_unknown_linux_musl=powerpc64le-unknown-linux-musl-gcc \
CXX_powerpc64le_unknown_linux_musl=powerpc64le-unknown-linux-musl-g++

ENV HOSTS=powerpc64le-unknown-linux-gnu,powerpc64le-unknown-linux-musl
ENV HOSTS=powerpc64le-unknown-linux-musl

ENV RUST_CONFIGURE_ARGS \
--enable-extended \
Expand Down
19 changes: 10 additions & 9 deletions src/ci/github-actions/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ runners:
free_disk: true
<<: *base-job

# Large runner used mainly for its bigger disk capacity
- &job-linux-4c-largedisk
os: ubuntu-24.04-4core-16gb
<<: *base-job

- &job-linux-8c
os: ubuntu-24.04-8core-32gb
<<: *base-job
Expand Down Expand Up @@ -167,8 +162,11 @@ auto:
- name: dist-android
<<: *job-linux-4c

- name: dist-arm-linux
<<: *job-linux-8c-codebuild
- name: dist-arm-linux-gnueabi
<<: *job-linux-4c

- name: dist-arm-linux-musl
<<: *job-linux-4c

- name: dist-armhf-linux
<<: *job-linux-4c
Expand Down Expand Up @@ -203,8 +201,11 @@ auto:
- name: dist-powerpc64-linux
<<: *job-linux-4c

- name: dist-powerpc64le-linux
<<: *job-linux-4c-largedisk
- name: dist-powerpc64le-linux-gnu
<<: *job-linux-4c

- name: dist-powerpc64le-linux-musl
<<: *job-linux-4c

- name: dist-riscv64-linux
<<: *job-linux-4c
Expand Down
2 changes: 1 addition & 1 deletion src/doc/edition-guide
2 changes: 1 addition & 1 deletion src/doc/reference
Loading
Loading