Skip to content

Commit bbd3a5a

Browse files
committed
Auto merge of #141320 - matthiaskrgr:rollup-ag3vf3a, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #140981 (Add match guard let chain drop order and scoping tests) - #141042 (ci: split powerpc64le-linux job) - #141078 (ci: split dist-arm-linux job) - #141222 (Implement `ptr::try_cast_aligned` and `NonNull::try_cast_aligned`.) - #141308 (Do not call name() on rpitit assoc_item) - #141316 (Update books) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 87b4541 + 18f42dd commit bbd3a5a

File tree

23 files changed

+509
-84
lines changed

23 files changed

+509
-84
lines changed

compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,16 +2124,19 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
21242124
accessed through a specific `impl`",
21252125
self.tcx.def_kind_descr(assoc_item.as_def_kind(), item_def_id)
21262126
));
2127-
err.span_suggestion(
2128-
span,
2129-
"use the fully qualified path to an implementation",
2130-
format!(
2131-
"<Type as {}>::{}",
2132-
self.tcx.def_path_str(trait_ref),
2133-
assoc_item.name()
2134-
),
2135-
Applicability::HasPlaceholders,
2136-
);
2127+
2128+
if !assoc_item.is_impl_trait_in_trait() {
2129+
err.span_suggestion(
2130+
span,
2131+
"use the fully qualified path to an implementation",
2132+
format!(
2133+
"<Type as {}>::{}",
2134+
self.tcx.def_path_str(trait_ref),
2135+
assoc_item.name()
2136+
),
2137+
Applicability::HasPlaceholders,
2138+
);
2139+
}
21372140
}
21382141
}
21392142
}

library/core/src/ptr/const_ptr.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,34 @@ impl<T: ?Sized> *const T {
6666
self as _
6767
}
6868

69+
/// Try to cast to a pointer of another type by checking aligment.
70+
///
71+
/// If the pointer is properly aligned to the target type, it will be
72+
/// cast to the target type. Otherwise, `None` is returned.
73+
///
74+
/// # Examples
75+
///
76+
/// ```rust
77+
/// #![feature(pointer_try_cast_aligned)]
78+
///
79+
/// let aligned: *const u8 = 0x1000 as _;
80+
///
81+
/// // i32 has at most 4-byte alignment, so this will succeed
82+
/// assert!(aligned.try_cast_aligned::<i32>().is_some());
83+
///
84+
/// let unaligned: *const u8 = 0x1001 as _;
85+
///
86+
/// // i32 has at least 2-byte alignment, so this will fail
87+
/// assert!(unaligned.try_cast_aligned::<i32>().is_none());
88+
/// ```
89+
#[unstable(feature = "pointer_try_cast_aligned", issue = "141221")]
90+
#[must_use = "this returns the result of the operation, \
91+
without modifying the original"]
92+
#[inline]
93+
pub fn try_cast_aligned<U>(self) -> Option<*const U> {
94+
if self.is_aligned_to(align_of::<U>()) { Some(self.cast()) } else { None }
95+
}
96+
6997
/// Uses the address value in a new pointer of another type.
7098
///
7199
/// This operation will ignore the address part of its `meta` operand and discard existing

library/core/src/ptr/mut_ptr.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,34 @@ impl<T: ?Sized> *mut T {
4848
self as _
4949
}
5050

51+
/// Try to cast to a pointer of another type by checking aligment.
52+
///
53+
/// If the pointer is properly aligned to the target type, it will be
54+
/// cast to the target type. Otherwise, `None` is returned.
55+
///
56+
/// # Examples
57+
///
58+
/// ```rust
59+
/// #![feature(pointer_try_cast_aligned)]
60+
///
61+
/// let aligned: *mut u8 = 0x1000 as _;
62+
///
63+
/// // i32 has at most 4-byte alignment, so this will succeed
64+
/// assert!(aligned.try_cast_aligned::<i32>().is_some());
65+
///
66+
/// let unaligned: *mut u8 = 0x1001 as _;
67+
///
68+
/// // i32 has at least 2-byte alignment, so this will fail
69+
/// assert!(unaligned.try_cast_aligned::<i32>().is_none());
70+
/// ```
71+
#[unstable(feature = "pointer_try_cast_aligned", issue = "141221")]
72+
#[must_use = "this returns the result of the operation, \
73+
without modifying the original"]
74+
#[inline]
75+
pub fn try_cast_aligned<U>(self) -> Option<*mut U> {
76+
if self.is_aligned_to(align_of::<U>()) { Some(self.cast()) } else { None }
77+
}
78+
5179
/// Uses the address value in a new pointer of another type.
5280
///
5381
/// This operation will ignore the address part of its `meta` operand and discard existing

library/core/src/ptr/non_null.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,35 @@ impl<T: ?Sized> NonNull<T> {
490490
unsafe { NonNull { pointer: self.as_ptr() as *mut U } }
491491
}
492492

493+
/// Try to cast to a pointer of another type by checking aligment.
494+
///
495+
/// If the pointer is properly aligned to the target type, it will be
496+
/// cast to the target type. Otherwise, `None` is returned.
497+
///
498+
/// # Examples
499+
///
500+
/// ```rust
501+
/// #![feature(pointer_try_cast_aligned)]
502+
/// use std::ptr::NonNull;
503+
///
504+
/// let aligned: NonNull<u8> = NonNull::new(0x1000 as _).unwrap();
505+
///
506+
/// // i32 has at most 4-byte alignment, so this will succeed
507+
/// assert!(aligned.try_cast_aligned::<i32>().is_some());
508+
///
509+
/// let unaligned: NonNull<u8> = NonNull::new(0x1001 as _).unwrap();
510+
///
511+
/// // i32 has at least 2-byte alignment, so this will fail
512+
/// assert!(unaligned.try_cast_aligned::<i32>().is_none());
513+
/// ```
514+
#[unstable(feature = "pointer_try_cast_aligned", issue = "141221")]
515+
#[must_use = "this returns the result of the operation, \
516+
without modifying the original"]
517+
#[inline]
518+
pub fn try_cast_aligned<U>(self) -> Option<NonNull<U>> {
519+
if self.is_aligned_to(align_of::<U>()) { Some(self.cast()) } else { None }
520+
}
521+
493522
/// Adds an offset to a pointer.
494523
///
495524
/// `count` is in units of T; e.g., a `count` of 3 represents a pointer
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
FROM ghcr.io/rust-lang/ubuntu:22.04
2+
3+
COPY scripts/cross-apt-packages.sh /scripts/
4+
RUN sh /scripts/cross-apt-packages.sh
5+
6+
COPY scripts/crosstool-ng.sh /scripts/
7+
RUN sh /scripts/crosstool-ng.sh
8+
9+
WORKDIR /build
10+
11+
COPY scripts/rustbuild-setup.sh /scripts/
12+
RUN sh /scripts/rustbuild-setup.sh
13+
WORKDIR /tmp
14+
15+
COPY scripts/crosstool-ng-build.sh /scripts/
16+
COPY host-x86_64/dist-arm-linux-gnueabi/arm-linux-gnueabi.defconfig /tmp/crosstool.defconfig
17+
RUN /scripts/crosstool-ng-build.sh
18+
19+
COPY scripts/sccache.sh /scripts/
20+
RUN sh /scripts/sccache.sh
21+
22+
ENV PATH=$PATH:/x-tools/arm-unknown-linux-gnueabi/bin
23+
24+
ENV CC_arm_unknown_linux_gnueabi=arm-unknown-linux-gnueabi-gcc \
25+
AR_arm_unknown_linux_gnueabi=arm-unknown-linux-gnueabi-ar \
26+
CXX_arm_unknown_linux_gnueabi=arm-unknown-linux-gnueabi-g++
27+
28+
ENV HOSTS=arm-unknown-linux-gnueabi
29+
30+
ENV RUST_CONFIGURE_ARGS \
31+
--enable-full-tools \
32+
--disable-docs \
33+
--enable-sanitizers \
34+
--enable-profiler
35+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

src/ci/docker/host-x86_64/dist-arm-linux/Dockerfile renamed to src/ci/docker/host-x86_64/dist-arm-linux-musl/Dockerfile

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,13 @@ RUN sh /scripts/rustbuild-setup.sh
1919
WORKDIR /tmp
2020

2121
COPY scripts/crosstool-ng-build.sh /scripts/
22-
COPY host-x86_64/dist-arm-linux/arm-linux-gnueabi.defconfig /tmp/crosstool.defconfig
22+
COPY host-x86_64/dist-arm-linux-musl/arm-linux-musl.defconfig /tmp/crosstool.defconfig
2323
RUN /scripts/crosstool-ng-build.sh
2424

2525
COPY scripts/sccache.sh /scripts/
2626
RUN sh /scripts/sccache.sh
2727

28-
ENV PATH=$PATH:/x-tools/arm-unknown-linux-gnueabi/bin
29-
30-
ENV CC_arm_unknown_linux_gnueabi=arm-unknown-linux-gnueabi-gcc \
31-
AR_arm_unknown_linux_gnueabi=arm-unknown-linux-gnueabi-ar \
32-
CXX_arm_unknown_linux_gnueabi=arm-unknown-linux-gnueabi-g++
33-
34-
ENV HOSTS=arm-unknown-linux-gnueabi,aarch64-unknown-linux-musl
28+
ENV HOSTS=aarch64-unknown-linux-musl
3529

3630
ENV RUST_CONFIGURE_ARGS \
3731
--enable-full-tools \
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CT_CONFIG_VERSION="4"
2+
CT_PREFIX_DIR="/x-tools/${CT_TARGET}"
3+
CT_USE_MIRROR=y
4+
CT_MIRROR_BASE_URL="https://ci-mirrors.rust-lang.org/rustc"
5+
CT_ARCH_ARM=y
6+
CT_ARCH_ARCH="armv6"
7+
CT_ARCH_FLOAT_SW=y
8+
CT_KERNEL_LINUX=y
9+
CT_LINUX_V_3_2=y
10+
CT_BINUTILS_V_2_32=y
11+
CT_GLIBC_V_2_17=y
12+
CT_GCC_V_8=y
13+
CT_CC_LANG_CXX=y
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
FROM ubuntu:22.04
2+
3+
COPY scripts/cross-apt-packages.sh /scripts/
4+
RUN sh /scripts/cross-apt-packages.sh
5+
6+
COPY scripts/crosstool-ng.sh /scripts/
7+
RUN sh /scripts/crosstool-ng.sh
8+
9+
COPY scripts/rustbuild-setup.sh /scripts/
10+
RUN sh /scripts/rustbuild-setup.sh
11+
12+
WORKDIR /tmp
13+
14+
COPY scripts/crosstool-ng-build.sh /scripts/
15+
COPY host-x86_64/dist-powerpc64le-linux-gnu/powerpc64le-unknown-linux-gnu.defconfig /tmp/crosstool.defconfig
16+
RUN /scripts/crosstool-ng-build.sh
17+
18+
WORKDIR /build
19+
20+
RUN apt-get install -y --no-install-recommends rpm2cpio cpio
21+
COPY scripts/shared.sh scripts/build-powerpc64le-toolchain.sh /build/
22+
RUN ./build-powerpc64le-toolchain.sh
23+
24+
COPY scripts/sccache.sh /scripts/
25+
RUN sh /scripts/sccache.sh
26+
27+
ENV \
28+
AR_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-ar \
29+
CC_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-gcc \
30+
CXX_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-g++
31+
32+
ENV HOSTS=powerpc64le-unknown-linux-gnu
33+
34+
ENV RUST_CONFIGURE_ARGS \
35+
--enable-extended \
36+
--enable-full-tools \
37+
--enable-profiler \
38+
--enable-sanitizers \
39+
--disable-docs
40+
41+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CT_CONFIG_VERSION="4"
2+
CT_EXPERIMENTAL=y
3+
CT_PREFIX_DIR="/x-tools/${CT_TARGET}"
4+
CT_USE_MIRROR=y
5+
CT_MIRROR_BASE_URL="https://ci-mirrors.rust-lang.org/rustc"
6+
CT_ARCH_POWERPC=y
7+
CT_ARCH_LE=y
8+
CT_ARCH_64=y
9+
# CT_DEMULTILIB is not set
10+
CT_ARCH_ARCH="powerpc64le"
11+
CT_KERNEL_LINUX=y
12+
CT_LINUX_V_4_19=y
13+
CT_CC_LANG_CXX=y
14+
CT_GETTEXT_NEEDED=y

src/ci/docker/host-x86_64/dist-powerpc64le-linux/Dockerfile renamed to src/ci/docker/host-x86_64/dist-powerpc64le-linux-musl/Dockerfile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ RUN sh /scripts/rustbuild-setup.sh
1212
WORKDIR /tmp
1313

1414
COPY scripts/crosstool-ng-build.sh /scripts/
15-
COPY host-x86_64/dist-powerpc64le-linux/powerpc64le-unknown-linux-musl.defconfig /tmp/crosstool.defconfig
15+
COPY host-x86_64/dist-powerpc64le-linux-musl/powerpc64le-unknown-linux-musl.defconfig /tmp/crosstool.defconfig
1616
RUN /scripts/crosstool-ng-build.sh
1717

1818
WORKDIR /build
1919

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

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

2929
ENV \
30-
AR_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-ar \
31-
CC_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-gcc \
32-
CXX_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-g++ \
3330
AR_powerpc64le_unknown_linux_musl=powerpc64le-unknown-linux-musl-ar \
3431
CC_powerpc64le_unknown_linux_musl=powerpc64le-unknown-linux-musl-gcc \
3532
CXX_powerpc64le_unknown_linux_musl=powerpc64le-unknown-linux-musl-g++
3633

37-
ENV HOSTS=powerpc64le-unknown-linux-gnu,powerpc64le-unknown-linux-musl
34+
ENV HOSTS=powerpc64le-unknown-linux-musl
3835

3936
ENV RUST_CONFIGURE_ARGS \
4037
--enable-extended \

src/ci/github-actions/jobs.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ runners:
1010
free_disk: true
1111
<<: *base-job
1212

13-
# Large runner used mainly for its bigger disk capacity
14-
- &job-linux-4c-largedisk
15-
os: ubuntu-24.04-4core-16gb
16-
<<: *base-job
17-
1813
- &job-linux-8c
1914
os: ubuntu-24.04-8core-32gb
2015
<<: *base-job
@@ -167,8 +162,11 @@ auto:
167162
- name: dist-android
168163
<<: *job-linux-4c
169164

170-
- name: dist-arm-linux
171-
<<: *job-linux-8c-codebuild
165+
- name: dist-arm-linux-gnueabi
166+
<<: *job-linux-4c
167+
168+
- name: dist-arm-linux-musl
169+
<<: *job-linux-4c
172170

173171
- name: dist-armhf-linux
174172
<<: *job-linux-4c
@@ -203,8 +201,11 @@ auto:
203201
- name: dist-powerpc64-linux
204202
<<: *job-linux-4c
205203

206-
- name: dist-powerpc64le-linux
207-
<<: *job-linux-4c-largedisk
204+
- name: dist-powerpc64le-linux-gnu
205+
<<: *job-linux-4c
206+
207+
- name: dist-powerpc64le-linux-musl
208+
<<: *job-linux-4c
208209

209210
- name: dist-riscv64-linux
210211
<<: *job-linux-4c

0 commit comments

Comments
 (0)