Skip to content

Have the alignment intrinsics return ptr::Alignment directly#152641

Draft
scottmcm wants to merge 2 commits intorust-lang:mainfrom
scottmcm:align-gives-alignment
Draft

Have the alignment intrinsics return ptr::Alignment directly#152641
scottmcm wants to merge 2 commits intorust-lang:mainfrom
scottmcm:align-gives-alignment

Conversation

@scottmcm
Copy link
Copy Markdown
Member

@scottmcm scottmcm commented Feb 15, 2026

View all comments

Follow-up to #152605

Notably, a common case of align_of_val is to put it in Layout for allocator calls, so might as well have it just be an Alignment already to avoid the extra transmute.

No changes to rustc_const_eval because that's already writing a Scalar into a place, which does what we need since ptr::Alignment is repr(transparent) to a repr(usize).

@rustbot rustbot added A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-core-stubs` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 15, 2026
Comment thread tests/mir-opt/alignment_checks.sized_ptr.CheckAlignment.panic-abort.diff Outdated
@rust-log-analyzer

This comment has been minimized.

@scottmcm scottmcm force-pushed the align-gives-alignment branch from 864bde0 to aa59f29 Compare February 15, 2026 08:37
Comment thread tests/mir-opt/pre-codegen/drop_boxed_slice.rs Outdated
@rust-log-analyzer

This comment has been minimized.

@scottmcm scottmcm force-pushed the align-gives-alignment branch from aa59f29 to 5c5e512 Compare February 15, 2026 09:50
@rust-log-analyzer

This comment has been minimized.

@scottmcm scottmcm force-pushed the align-gives-alignment branch from 5c5e512 to c071e30 Compare February 15, 2026 10:55
@rust-log-analyzer

This comment has been minimized.

@scottmcm scottmcm force-pushed the align-gives-alignment branch from c071e30 to 22ff442 Compare February 15, 2026 18:38
@scottmcm
Copy link
Copy Markdown
Member Author

I don't think anything in here should be more expensive, but in case...
@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Feb 15, 2026
Have the alignment intrinsics return `ptr::Alignment` directly
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 15, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Feb 15, 2026

☀️ Try build successful (CI)
Build commit: 7121e2d (7121e2d136c08d87b9a5f3717916d4bec53334bb, parent: 2219766af622ad1f051ca96ae40650106b1bd9bd)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (7121e2d): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
4.5% [0.2%, 16.2%] 4
Regressions ❌
(secondary)
0.6% [0.3%, 0.9%] 2
Improvements ✅
(primary)
-0.4% [-1.2%, -0.2%] 7
Improvements ✅
(secondary)
-1.0% [-3.3%, -0.1%] 22
All ❌✅ (primary) 1.4% [-1.2%, 16.2%] 11

Max RSS (memory usage)

Results (primary -3.9%, secondary 2.9%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
5.2% [1.3%, 9.0%] 2
Improvements ✅
(primary)
-3.9% [-5.4%, -1.6%] 5
Improvements ✅
(secondary)
-1.7% [-1.7%, -1.7%] 1
All ❌✅ (primary) -3.9% [-5.4%, -1.6%] 5

Cycles

Results (primary 11.9%, secondary -1.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
11.9% [11.9%, 11.9%] 1
Regressions ❌
(secondary)
4.0% [4.0%, 4.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.1% [-4.8%, -2.2%] 4
All ❌✅ (primary) 11.9% [11.9%, 11.9%] 1

Binary size

Results (primary 0.3%, secondary -0.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.6% [0.0%, 1.4%] 14
Regressions ❌
(secondary)
0.2% [0.0%, 0.4%] 8
Improvements ✅
(primary)
-0.5% [-0.7%, -0.1%] 4
Improvements ✅
(secondary)
-1.3% [-2.2%, -0.4%] 17
All ❌✅ (primary) 0.3% [-0.7%, 1.4%] 18

Bootstrap: 485.129s -> 482.811s (-0.48%)
Artifact size: 398.01 MiB -> 396.01 MiB (-0.50%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Feb 15, 2026
@scottmcm
Copy link
Copy Markdown
Member Author

scottmcm commented Feb 15, 2026

r? @cjgillot
@rustbot ready

Those perf results are, I think, overall good. They're mostly green, and include things like -28% on rustc_mir_build, which is impressively good.

The one big regression is one of the LTO sub-jobs just going nuts for some reason:
image

TBH I'm not sure how this could possibly cause that. It's not the kind of "oh, inlining reshuffled everything" that we normally see from MIR changes. None of the other variants of that code show any material impact, and it's just so different from the results on everything else.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 15, 2026
@scottmcm scottmcm marked this pull request as ready for review February 15, 2026 22:03
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Feb 15, 2026

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo, @GuillaumeGomez

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

This PR modifies tests/auxiliary/minicore.rs.

cc @jieyouxu

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

github-actions Bot pushed a commit to rust-lang/miri that referenced this pull request Feb 22, 2026
Add a mir-opt test for alignment check generation [zero changes outside tests]

I wrote this as part of rust-lang/rust#152641 which it looks like I'm going to just close, so submitting the new test separately since we didn't have any mir-opt testing of this pass that I could find (at least `x test tests/mir-opt` didn't fail when I broke them) so figured it's something that should exist.
github-actions Bot pushed a commit to rust-lang/miri that referenced this pull request Feb 22, 2026
…gillot

Simplify `size/align_of_val<T: Sized>` to `size/align_of<T>` instead

This is relevant to things like `Box<[u8; 1024]>` where the drop looks at the `size_of_val` (since obviously it might be DST in general) but where we don't actually need to do that since it's always that same value for the `Sized` type.

(Equivalent to rust-lang/rust#152681, but flipped in the rebase so it can land before rust-lang/rust#152641 instead of depending on it.)
github-actions Bot pushed a commit to rust-lang/rust-analyzer that referenced this pull request Feb 23, 2026
…gillot

Simplify `size/align_of_val<T: Sized>` to `size/align_of<T>` instead

This is relevant to things like `Box<[u8; 1024]>` where the drop looks at the `size_of_val` (since obviously it might be DST in general) but where we don't actually need to do that since it's always that same value for the `Sized` type.

(Equivalent to rust-lang/rust#152681, but flipped in the rebase so it can land before rust-lang/rust#152641 instead of depending on it.)
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Feb 23, 2026
…gillot

Simplify `size/align_of_val<T: Sized>` to `size/align_of<T>` instead

This is relevant to things like `Box<[u8; 1024]>` where the drop looks at the `size_of_val` (since obviously it might be DST in general) but where we don't actually need to do that since it's always that same value for the `Sized` type.

(Equivalent to rust-lang/rust#152681, but flipped in the rebase so it can land before rust-lang/rust#152641 instead of depending on it.)
github-actions Bot pushed a commit to rust-lang/stdarch that referenced this pull request Mar 9, 2026
Add a mir-opt test for alignment check generation [zero changes outside tests]

I wrote this as part of rust-lang/rust#152641 which it looks like I'm going to just close, so submitting the new test separately since we didn't have any mir-opt testing of this pass that I could find (at least `x test tests/mir-opt` didn't fail when I broke them) so figured it's something that should exist.
github-actions Bot pushed a commit to rust-lang/stdarch that referenced this pull request Mar 9, 2026
…gillot

Simplify `size/align_of_val<T: Sized>` to `size/align_of<T>` instead

This is relevant to things like `Box<[u8; 1024]>` where the drop looks at the `size_of_val` (since obviously it might be DST in general) but where we don't actually need to do that since it's always that same value for the `Sized` type.

(Equivalent to rust-lang/rust#152681, but flipped in the rebase so it can land before rust-lang/rust#152641 instead of depending on it.)
makai410 pushed a commit to makai410/rustc_public that referenced this pull request Mar 19, 2026
…gillot

Simplify `size/align_of_val<T: Sized>` to `size/align_of<T>` instead

This is relevant to things like `Box<[u8; 1024]>` where the drop looks at the `size_of_val` (since obviously it might be DST in general) but where we don't actually need to do that since it's always that same value for the `Sized` type.

(Equivalent to rust-lang/rust#152681, but flipped in the rebase so it can land before rust-lang/rust#152641 instead of depending on it.)
makai410 pushed a commit to makai410/rustc_public that referenced this pull request Mar 19, 2026
…gillot

Simplify `size/align_of_val<T: Sized>` to `size/align_of<T>` instead

This is relevant to things like `Box<[u8; 1024]>` where the drop looks at the `size_of_val` (since obviously it might be DST in general) but where we don't actually need to do that since it's always that same value for the `Sized` type.

(Equivalent to rust-lang/rust#152681, but flipped in the rebase so it can land before rust-lang/rust#152641 instead of depending on it.)
makai410 pushed a commit to makai410/rustc_public that referenced this pull request Mar 27, 2026
…gillot

Simplify `size/align_of_val<T: Sized>` to `size/align_of<T>` instead

This is relevant to things like `Box<[u8; 1024]>` where the drop looks at the `size_of_val` (since obviously it might be DST in general) but where we don't actually need to do that since it's always that same value for the `Sized` type.

(Equivalent to rust-lang/rust#152681, but flipped in the rebase so it can land before rust-lang/rust#152641 instead of depending on it.)
@scottmcm scottmcm reopened this May 9, 2026
@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label May 9, 2026
@scottmcm scottmcm force-pushed the align-gives-alignment branch from 22ff442 to ad4a3fc Compare May 9, 2026 07:06
@rust-log-analyzer

This comment has been minimized.

@scottmcm scottmcm force-pushed the align-gives-alignment branch from ad4a3fc to 0a9149f Compare May 9, 2026 07:16
@scottmcm
Copy link
Copy Markdown
Member Author

scottmcm commented May 9, 2026

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 9, 2026
rust-bors Bot pushed a commit that referenced this pull request May 9, 2026
Have the alignment intrinsics return `ptr::Alignment` directly
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 9, 2026

☀️ Try build successful (CI)
Build commit: a606286 (a60628660b41f808eeed74cac626bfc49b619ef6, parent: 4a997eeefbb8cf41617324bb6d08c72171c614e2)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (a606286): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
15.9% [15.9%, 15.9%] 1
Regressions ❌
(secondary)
0.2% [0.2%, 0.2%] 2
Improvements ✅
(primary)
-0.4% [-0.5%, -0.3%] 3
Improvements ✅
(secondary)
-1.3% [-3.9%, -0.2%] 17
All ❌✅ (primary) 3.7% [-0.5%, 15.9%] 4

Max RSS (memory usage)

Results (primary -0.0%, secondary -3.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.5% [2.3%, 2.7%] 3
Regressions ❌
(secondary)
0.9% [0.9%, 0.9%] 1
Improvements ✅
(primary)
-2.0% [-2.7%, -0.8%] 4
Improvements ✅
(secondary)
-4.9% [-9.3%, -2.6%] 3
All ❌✅ (primary) -0.0% [-2.7%, 2.7%] 7

Cycles

Results (primary 11.9%, secondary -3.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
11.9% [11.9%, 11.9%] 1
Regressions ❌
(secondary)
3.2% [3.2%, 3.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.0% [-5.1%, -2.4%] 7
All ❌✅ (primary) 11.9% [11.9%, 11.9%] 1

Binary size

Results (primary 0.2%, secondary -0.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.4% [0.0%, 1.4%] 26
Regressions ❌
(secondary)
0.2% [0.0%, 0.4%] 12
Improvements ✅
(primary)
-0.1% [-0.4%, -0.0%] 16
Improvements ✅
(secondary)
-1.0% [-2.6%, -0.0%] 18
All ❌✅ (primary) 0.2% [-0.4%, 1.4%] 42

Bootstrap: 497.359s -> 498.748s (0.28%)
Artifact size: 397.13 MiB -> 397.19 MiB (0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 9, 2026
@scottmcm scottmcm force-pushed the align-gives-alignment branch from 0a9149f to 8718f45 Compare May 9, 2026 14:25
@rust-log-analyzer

This comment has been minimized.

@scottmcm scottmcm force-pushed the align-gives-alignment branch from 8718f45 to 223c257 Compare May 9, 2026 18:57
@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

The job aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Executing "/scripts/stage_2_test_set1.sh"
+ /scripts/stage_2_test_set1.sh
PR_CI_JOB set; skipping tidy
+ '[' 1 == 1 ']'
+ echo 'PR_CI_JOB set; skipping tidy'
+ SKIP_TIDY='--skip tidy'
+ ../x.py --stage 2 test --skip tidy --skip compiler --skip src
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
downloading https://static.rust-lang.org/dist/2026-04-14/rustfmt-nightly-aarch64-unknown-linux-gnu.tar.xz
---
---- [ui] tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/consts/const-size_of_val-align_of_val-extern-type/const-size_of_val-align_of_val-extern-type.stderr`
diff of stderr:

+ warning: use of deprecated type alias `std::ptr::Alignment`: moved from `ptr` to `mem`
+   --> $DIR/const-size_of_val-align_of_val-extern-type.rs:6:15
+    |
+ LL | use std::ptr::Alignment;
+    |               ^^^^^^^^^
+    |
+    = note: `#[warn(deprecated)]` on by default
+ 
+ warning: use of deprecated type alias `std::ptr::Alignment`: moved from `ptr` to `mem`
+   --> $DIR/const-size_of_val-align_of_val-extern-type.rs:14:15
+    |
+ LL | const _ALIGN: Alignment = unsafe { align_of_val(&4 as *const i32 as *const Opaque) };
+    |               ^^^^^^^^^
+ 
1 error[E0277]: the size for values of type `Opaque` cannot be known
2   --> $DIR/const-size_of_val-align_of_val-extern-type.rs:12:43
3    |

34 LL | const _ALIGN: Alignment = unsafe { align_of_val(&mut (&4 as *const i32 as *const Opaque)) };
35    |                                                 ++++++                                 +
36 
- error: aborting due to 2 previous errors
+ error: aborting due to 2 previous errors; 2 warnings emitted
38 
39 For more information about this error, try `rustc --explain E0277`.
40 

Note: some mismatched output was normalized before being compared
-   --> /checkout/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs:6:15
-   --> /checkout/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs:14:15
+ warning: use of deprecated type alias `std::ptr::Alignment`: moved from `ptr` to `mem`
+   --> $DIR/const-size_of_val-align_of_val-extern-type.rs:6:15
+    |
+ LL | use std::ptr::Alignment;
+    |               ^^^^^^^^^
+    |
+    = note: `#[warn(deprecated)]` on by default
+ 
+ warning: use of deprecated type alias `std::ptr::Alignment`: moved from `ptr` to `mem`
+   --> $DIR/const-size_of_val-align_of_val-extern-type.rs:14:15
+    |
+ LL | const _ALIGN: Alignment = unsafe { align_of_val(&4 as *const i32 as *const Opaque) };
+    |               ^^^^^^^^^
+ 
+ error: aborting due to 2 previous errors; 2 warnings emitted


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args consts/const-size_of_val-align_of_val-extern-type.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/consts/const-size_of_val-align_of_val-extern-type" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
warning: use of deprecated type alias `std::ptr::Alignment`: moved from `ptr` to `mem`
##[warning]  --> /checkout/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs:6:15
   |
---

warning: use of deprecated type alias `std::ptr::Alignment`: moved from `ptr` to `mem`
##[warning]  --> /checkout/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs:14:15
   |
LL | const _ALIGN: Alignment = unsafe { align_of_val(&4 as *const i32 as *const Opaque) };
   |               ^^^^^^^^^

error[E0277]: the size for values of type `Opaque` cannot be known
##[error]  --> /checkout/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs:12:43
   |
LL | const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) };
   |                               ----------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MetaSized` is not implemented for `Opaque`
   |                               |
   |                               required by a bound introduced by this call
   |
   = note: the trait bound `Opaque: MetaSized` is not satisfied
note: required by a bound in `std::intrinsics::size_of_val`
  --> /rustc/FAKE_PREFIX/library/core/src/intrinsics/mod.rs:2861:0
help: consider borrowing here
   |
LL | const _SIZE: usize = unsafe { size_of_val(&(&4 as *const i32 as *const Opaque)) };
   |                                           ++                                 +
LL | const _SIZE: usize = unsafe { size_of_val(&mut (&4 as *const i32 as *const Opaque)) };
   |                                           ++++++                                 +

error[E0277]: the size for values of type `Opaque` cannot be known
##[error]  --> /checkout/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs:14:49
   |
LL | const _ALIGN: Alignment = unsafe { align_of_val(&4 as *const i32 as *const Opaque) };
   |                                    ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MetaSized` is not implemented for `Opaque`
   |                                    |
   |                                    required by a bound introduced by this call
   |
   = note: the trait bound `Opaque: MetaSized` is not satisfied
note: required by a bound in `std::intrinsics::align_of_val`
  --> /rustc/FAKE_PREFIX/library/core/src/intrinsics/mod.rs:2874:0
help: consider borrowing here
   |
LL | const _ALIGN: Alignment = unsafe { align_of_val(&(&4 as *const i32 as *const Opaque)) };
   |                                                 ++                                 +
LL | const _ALIGN: Alignment = unsafe { align_of_val(&mut (&4 as *const i32 as *const Opaque)) };
   |                                                 ++++++                                 +

error: aborting due to 2 previous errors; 2 warnings emitted

For more information about this error, try `rustc --explain E0277`.
---
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/consts/const-unstable-intrinsic/const-unstable-intrinsic.stderr`
diff of stderr:

18    = help: add `#![feature(unstable)]` to the crate attributes to enable
19    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
20 
+ warning: use of deprecated type alias `std::ptr::Alignment`: moved from `ptr` to `mem`
+   --> $DIR/const-unstable-intrinsic.rs:38:63
+    |
+ LL | pub const unsafe fn align_of_val<T>(x: *const T) -> std::ptr::Alignment;
+    |                                                               ^^^^^^^^^
+    |
+    = note: `#[warn(deprecated)]` on by default
+ 
21 error: `size_of_val` is not yet stable as a const intrinsic
22   --> $DIR/const-unstable-intrinsic.rs:17:9
23    |

84 LL |     const unsafe fn copy<T>(src: *const T, _dst: *mut T, _count: usize) {
85    |
86 
- error: aborting due to 8 previous errors
+ error: aborting due to 8 previous errors; 1 warning emitted
88 
89 For more information about this error, try `rustc --explain E0658`.
90 

Note: some mismatched output was normalized before being compared
-   --> /checkout/tests/ui/consts/const-unstable-intrinsic.rs:38:63
+ warning: use of deprecated type alias `std::ptr::Alignment`: moved from `ptr` to `mem`
+   --> $DIR/const-unstable-intrinsic.rs:38:63
+    |
+ LL | pub const unsafe fn align_of_val<T>(x: *const T) -> std::ptr::Alignment;
+    |                                                               ^^^^^^^^^
+    |
+    = note: `#[warn(deprecated)]` on by default
+ 
+ error: aborting due to 8 previous errors; 1 warning emitted
---
To only update this specific test, also pass `--test-args consts/const-unstable-intrinsic.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/consts/const-unstable-intrinsic.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/consts/const-unstable-intrinsic" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/consts/const-unstable-intrinsic/auxiliary"
stdout: none
--- stderr -------------------------------
error[E0658]: use of unstable library feature `unstable`
##[error]  --> /checkout/tests/ui/consts/const-unstable-intrinsic.rs:17:9
   |
LL |         unstable_intrinsic::size_of_val(&x);
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #42 <https://github.com/rust-lang/rust/issues/42> for more information
   = help: add `#![feature(unstable)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature `unstable`
##[error]  --> /checkout/tests/ui/consts/const-unstable-intrinsic.rs:20:9
   |
LL |         unstable_intrinsic::align_of_val(&x);
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #42 <https://github.com/rust-lang/rust/issues/42> for more information
   = help: add `#![feature(unstable)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

warning: use of deprecated type alias `std::ptr::Alignment`: moved from `ptr` to `mem`
##[warning]  --> /checkout/tests/ui/consts/const-unstable-intrinsic.rs:38:63
   |
LL | pub const unsafe fn align_of_val<T>(x: *const T) -> std::ptr::Alignment;
   |                                                               ^^^^^^^^^
   |
   = note: `#[warn(deprecated)]` on by default

error: `size_of_val` is not yet stable as a const intrinsic
---
   |
LL + #![feature(unstable)]
   |

error: const function that might be (indirectly) exposed to stable cannot use `#[feature(local)]`
##[error]  --> /checkout/tests/ui/consts/const-unstable-intrinsic.rs:24:9
   |
LL |         size_of_val(&x);
   |         ^^^^^^^^^^^^^^^
   |
help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]`
   |
LL + #[rustc_const_unstable(feature = "...", issue = "...")]
LL | const fn const_main() {
   |

error: const function that might be (indirectly) exposed to stable cannot use `#[feature(local)]`
##[error]  --> /checkout/tests/ui/consts/const-unstable-intrinsic.rs:26:9
   |
LL |         align_of_val(&x);
   |         ^^^^^^^^^^^^^^^^
   |
help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]`
   |
LL + #[rustc_const_unstable(feature = "...", issue = "...")]
LL | const fn const_main() {
   |

error: intrinsic `copy::copy` cannot be (indirectly) exposed to stable
##[error]  --> /checkout/tests/ui/consts/const-unstable-intrinsic.rs:48:14
   |
LL |     unsafe { copy(src, dst, count) }
   |              ^^^^^^^^^^^^^^^^^^^^^
   |
   = help: mark the caller as `#[rustc_const_unstable]`, or mark the intrinsic `#[rustc_intrinsic_const_stable_indirect]` (but this requires team approval)

error: const function that might be (indirectly) exposed to stable cannot use `#[feature(local)]`
##[error]  --> /checkout/tests/ui/consts/const-unstable-intrinsic.rs:56:9
   |
LL |         super::size_of_val(src);
   |         ^^^^^^^^^^^^^^^^^^^^^^^
   |
help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]`
   |
LL +     #[rustc_const_unstable(feature = "...", issue = "...")]
LL |     const unsafe fn copy<T>(src: *const T, _dst: *mut T, _count: usize) {
   |

error: aborting due to 8 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0658`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-core-stubs` perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants