Skip to content
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

Stability oddity with const intrinsics #80707

Merged
merged 3 commits into from
Jan 19, 2021

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jan 4, 2021

cc @RalfJung

In #80699 (comment) @usbalbin realized we accepted some intrinsics as const without a #[rustc_const_(un)stable] attribute. I did some digging, and that example works because intrinsics inherit their stability from their parents... including #[rustc_const_(un)stable] attributes. While we may want to fix that (not sure, wasn't there just a MCPed PR that caused this on purpose?), we definitely want tests for it, thus this PR adding tests and some fun tracing statements.

@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 4, 2021
@oli-obk oli-obk force-pushed the stability_hole_const_intrinsics branch from 0626088 to 7da07bf Compare January 4, 2021 23:40
@petrochenkov
Copy link
Contributor

r? @RalfJung

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-9 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
.................................................................................................... 9000/11246
.................................................................................................... 9100/11246
.................................................................................................... 9200/11246
...........................................i.....i.................................................. 9300/11246
.................................................................................iiiiii..iiiiii.i... 9400/11246
.................................................................................................... 9600/11246
.................................................................................................... 9700/11246
.................................................................................................... 9800/11246
.................................................................................................... 9900/11246
---
.....................................i.............................................................. 11200/11246
..............................................
failures:

---- [ui] ui/consts/intrinsic_without_const_stab_fail.rs stdout ----


1 error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
-   --> $DIR/intrinsic_without_const_stab_fail.rs:15:14
+   --> $DIR/intrinsic_without_const_stab_fail.rs:12:14
3    |
4 LL |     unsafe { copy(src, dst, count) }


The actual stderr differed from the expected stderr.
The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/intrinsic_without_const_stab_fail/intrinsic_without_const_stab_fail.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args consts/intrinsic_without_const_stab_fail.rs`
error: 1 errors occurred comparing output.
status: exit code: 1
status: exit code: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/consts/intrinsic_without_const_stab_fail.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zemit-future-incompat-report" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/intrinsic_without_const_stab_fail" "-A" "unused" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/intrinsic_without_const_stab_fail/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
  --> /checkout/src/test/ui/consts/intrinsic_without_const_stab_fail.rs:12:14
   |
LL |     unsafe { copy(src, dst, count) } //~ ERROR calls in constant functions are limited

error: aborting due to previous error

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

Some tests failed in compiletest suite=ui mode=ui host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu


command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--suite" "ui" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-9/bin/FileCheck" "--nodejs" "/usr/bin/node" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "9.0.0" "--llvm-components" "aarch64 aarch64asmparser aarch64codegen aarch64desc aarch64disassembler aarch64info aarch64utils aggressiveinstcombine all all-targets amdgpu amdgpuasmparser amdgpucodegen amdgpudesc amdgpudisassembler amdgpuinfo amdgpuutils analysis arm armasmparser armcodegen armdesc armdisassembler arminfo armutils asmparser asmprinter avr avrasmparser avrcodegen avrdesc avrdisassembler avrinfo binaryformat bitreader bitstreamreader bitwriter bpf bpfasmparser bpfcodegen bpfdesc bpfdisassembler bpfinfo codegen core coroutines coverage debuginfocodeview debuginfodwarf debuginfogsym debuginfomsf debuginfopdb demangle dlltooldriver engine executionengine fuzzmutate globalisel hexagon hexagonasmparser hexagoncodegen hexagondesc hexagondisassembler hexagoninfo instcombine instrumentation interpreter ipo irreader jitlink lanai lanaiasmparser lanaicodegen lanaidesc lanaidisassembler lanaiinfo libdriver lineeditor linker lto mc mca mcdisassembler mcjit mcparser mips mipsasmparser mipscodegen mipsdesc mipsdisassembler mipsinfo mirparser msp430 msp430asmparser msp430codegen msp430desc msp430disassembler msp430info native nativecodegen nvptx nvptxcodegen nvptxdesc nvptxinfo objcarcopts object objectyaml option orcjit passes perfjitevents powerpc powerpcasmparser powerpccodegen powerpcdesc powerpcdisassembler powerpcinfo profiledata remarks riscv riscvasmparser riscvcodegen riscvdesc riscvdisassembler riscvinfo riscvutils runtimedyld scalaropts selectiondag sparc sparcasmparser sparccodegen sparcdesc sparcdisassembler sparcinfo support symbolize systemz systemzasmparser systemzcodegen systemzdesc systemzdisassembler systemzinfo tablegen target textapi transformutils vectorize webassembly webassemblyasmparser webassemblycodegen webassemblydesc webassemblydisassembler webassemblyinfo windowsmanifest x86 x86asmparser x86codegen x86desc x86disassembler x86info x86utils xcore xcorecodegen xcoredesc xcoredisassembler xcoreinfo xray" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"


failed to run: /checkout/obj/build/bootstrap/debug/bootstrap --stage 2 test --exclude src/tools/tidy
Build completed unsuccessfully in 0:16:03

@oli-obk oli-obk force-pushed the stability_hole_const_intrinsics branch from 14e2c38 to 074a69b Compare January 5, 2021 15:46
@RalfJung
Copy link
Member

RalfJung commented Jan 6, 2021

hat example works because intrinsics inherit their stability from their parents

Oh, that's interesting. For normal intrinsics this makes sense (when declared inside a fn they anyway cannot be used from the outside), but since const stability has this extra property of being recursive (stable things may not call unstable things), IMO this makes less sense.

@oli-obk
Copy link
Contributor Author

oli-obk commented Jan 11, 2021

since const stability has this extra property of being recursive (stable things may not call unstable things), IMO this makes less sense.

So... should I try to fix it in this PR?

@RalfJung
Copy link
Member

I think it should be fixed... and that makes the tests added in this PR a bit odd since they test behavior that I consider buggy. But I'd also be okay with opening an issue and having a comment in the test saying that this is testing buggy behavior and should be adjusted once there's a fix.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@@ -1849,6 +1849,7 @@ pub(crate) fn is_nonoverlapping<T>(src: *const T, dst: *const T, count: usize) -
#[inline]
pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
extern "rust-intrinsic" {
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "none")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we have another case of this a few lines down, around line 1940, according to CI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, I had to rebase first ^^

@RalfJung
Copy link
Member

r=me with CI fixed and the commits squashed a bit.

@oli-obk oli-obk force-pushed the stability_hole_const_intrinsics branch from 84e414c to 2a412ae Compare January 17, 2021 13:40
@rust-log-analyzer

This comment has been minimized.

@oli-obk oli-obk force-pushed the stability_hole_const_intrinsics branch from 2a412ae to 5bac1c9 Compare January 18, 2021 11:07
@oli-obk
Copy link
Contributor Author

oli-obk commented Jan 18, 2021

@bors r=RalfJung

@bors
Copy link
Contributor

bors commented Jan 18, 2021

📌 Commit 5bac1c9 has been approved by RalfJung

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 18, 2021
m-ou-se added a commit to m-ou-se/rust that referenced this pull request Jan 18, 2021
…sics, r=RalfJung

Stability oddity with const intrinsics

cc `@RalfJung`

In rust-lang#80699 (comment) `@usbalbin` realized we accepted some intrinsics as `const` without a `#[rustc_const_(un)stable]` attribute. I did some digging, and that example works because intrinsics inherit their stability from their parents... including `#[rustc_const_(un)stable]` attributes. While we may want to fix that (not sure, wasn't there just a MCPed PR that caused this on purpose?), we definitely want tests for it, thus this PR adding tests and some fun tracing statements.
@bors
Copy link
Contributor

bors commented Jan 18, 2021

⌛ Testing commit 5bac1c9 with merge d98d2f5...

@bors
Copy link
Contributor

bors commented Jan 19, 2021

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing d98d2f5 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 19, 2021
@bors bors merged commit d98d2f5 into rust-lang:master Jan 19, 2021
@rustbot rustbot added this to the 1.51.0 milestone Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants