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

Rollup of 6 pull requests #121013

Closed
wants to merge 26 commits into from
Closed

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Feb 13, 2024

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

reitermarkus and others added 26 commits February 8, 2024 21:57
but right now all of them have zero const generic params
Turn `is_val_statically_known` into such an intrinsic to demonstrate. It is perfectly safe to call after all.
The check within changed from `delay_span_bug` to `delay_good_path_bug`
in rust-lang#110476, and removing the check altogether was considered. It's a
very weak sanity check and gets in the way of removing good path delayed
bugs altogether, so this PR just removes it.
It's only has a single remaining purpose: to ensure that a diagnostic is
printed when `trimmed_def_paths` is used. It's an annoying mechanism:
weak, with odd semantics, badly named, and gets in the way of other
changes.

This commit replaces it with a simpler `must_produce_diag` mechanism,
getting rid of a diagnostic `Level` along the way.
…r=dtolnay

Use generic `NonZero` internally.

Tracking issue: rust-lang#120257
Implement intrinsics with fallback bodies

fixes rust-lang#93145 (though we can port many more intrinsics)
cc rust-lang#63585

The way this works is that the backend logic for generating custom code for intrinsics has been made fallible. The only failure path is "this intrinsic is unknown". The `Instance` (that was `InstanceDef::Intrinsic`) then gets converted to `InstanceDef::Item`, which represents the fallback body. A regular function call to that body is then codegenned. This is currently implemented for

* codegen_ssa (so llvm and gcc)
* codegen_cranelift

other backends will need to adjust, but they can just keep doing what they were doing if they prefer (though adding new intrinsics to the compiler will then require them to implement them, instead of getting the fallback body).

cc ``@scottmcm`` ``@WaffleLapkin``

### todo

* [ ] miri support
* [x] default intrinsic name to name of function instead of requiring it to be specified in attribute
* [x] make sure that the bodies are always available (must be collected for metadata)
…rors

Be less confident when `dyn` suggestion is not checked for object safety

rust-lang#120275 no longer checks bare traits for object safety when making a `dyn` suggestion on Rust < 2021. In this case, qualify the suggestion with a note that the trait must be object safe, to prevent user confusion as seen in rust-lang#116434

r? ``@fmease``
…r=dtolnay

Make `NonZero::get` generic.

Tracking issue: rust-lang#120257

Depends on rust-lang#120521.

r? ``@dtolnay``
…errors

Continue compilation after check_mod_type_wf errors

The ICEs fixed here were probably reachable through const eval gymnastics before, but now they are easily reachable without that, too.

The new errors are often bugfixes, where useful errors were missing, because they were reported after the early abort. In other cases sometimes they are just duplication of already emitted errors, which won't be user-visible due to deduplication.

fixes rust-lang#120860
Remove good path delayed bugs

Because they're not that useful, and kind of annoying. Details in the individual commits.

r? ``@compiler-errors``
@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic O-hermit Operating System: Hermit O-SGX Target: SGX labels Feb 13, 2024
@rustbot rustbot added O-unix Operating system: Unix-like O-wasi Operating system: Wasi, Webassembly System Interface O-wasm Target: WASM (WebAssembly), http://webassembly.org/ O-windows Operating system: Windows S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Feb 13, 2024
@oli-obk
Copy link
Contributor Author

oli-obk commented Feb 13, 2024

@bors r+ p=6

@bors
Copy link
Contributor

bors commented Feb 13, 2024

📌 Commit 56f78e0 has been approved by oli-obk

It is now in the queue for this repository.

@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 Feb 13, 2024
@bors
Copy link
Contributor

bors commented Feb 13, 2024

⌛ Testing commit 56f78e0 with merge 4272bb8...

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 13, 2024
Rollup of 6 pull requests

Successful merges:

 - rust-lang#120486 (Use generic `NonZero` internally.)
 - rust-lang#120500 (Implement intrinsics with fallback bodies)
 - rust-lang#120530 (Be less confident when `dyn` suggestion is not checked for object safety)
 - rust-lang#120563 (Make `NonZero::get` generic.)
 - rust-lang#120847 (Continue compilation after check_mod_type_wf errors)
 - rust-lang#120959 (Remove good path delayed bugs)

r? `@ghost`
`@rustbot` modify labels: rollup
@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)

---- [ui] tests/ui/const-generics/issues/issue-72352.rs#full stdout ----
diff of stderr:

4 LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
6 
- error: aborting due to 1 previous error
+ error[E0308]: mismatched types
+   --> $DIR/issue-72352.rs:9:22
+   --> $DIR/issue-72352.rs:9:22
+    |
+ LL |     F(CStr::from_ptr(ptr))
+    |       -------------- ^^^ expected `*const u8`, found `*const i8`
+    |       arguments to this function are incorrect
+    |
+    |
+    = note: expected raw pointer `*const u8`
+               found raw pointer `*const i8`
+ note: associated function defined here
+   --> $SRC_DIR/core/src/ffi/c_str.rs:LL:COL
- For more information about this error, try `rustc --explain E0741`.
+ error[E0308]: mismatched types
+   --> $DIR/issue-72352.rs:20:54
+    |
+    |
+ LL |         unsafely_do_the_thing::<safely_do_the_thing>(ptr)
+    |         -------------------------------------------- ^^^ expected `*const i8`, found `*const u8`
+    |         arguments to this function are incorrect
+    |
+    |
+    = note: expected raw pointer `*const i8`
+               found raw pointer `*const u8`
+ note: function defined here
+    |
+    |
+ LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
+ 
+ error: aborting due to 3 previous errors
+ 
+ Some errors have detailed explanations: E0308, E0741.
+ Some errors have detailed explanations: E0308, E0741.
+ For more information about an error, try `rustc --explain E0308`.
10 


The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/const-generics/issues/issue-72352.full/issue-72352.full.stderr
To only update this specific test, also pass `--test-args const-generics/issues/issue-72352.rs`


error in revision `full`: 1 errors occurred comparing output.
status: exit status: 1
command: RUSTC_ICE="0" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/const-generics/issues/issue-72352.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" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--cfg" "full" "--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/const-generics/issues/issue-72352.full" "-A" "unused" "-A" "internal_features" "-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/const-generics/issues/issue-72352.full/auxiliary"
--- stderr -------------------------------
error[E0741]: using function pointers as const generic parameters is forbidden
##[error]  --> /checkout/tests/ui/const-generics/issues/issue-72352.rs:7:42
   |
   |
LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/const-generics/issues/issue-72352.rs:9:22
   |
   |
LL |     F(CStr::from_ptr(ptr))
   |       -------------- ^^^ expected `*const u8`, found `*const i8`
   |       arguments to this function are incorrect
   |
   |
   = note: expected raw pointer `*const u8`
              found raw pointer `*const i8`
  --> /rustc/FAKE_PREFIX/library/core/src/ffi/c_str.rs:263:25

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/const-generics/issues/issue-72352.rs:20:54
##[error]  --> /checkout/tests/ui/const-generics/issues/issue-72352.rs:20:54
   |
LL |         unsafely_do_the_thing::<safely_do_the_thing>(ptr)
   |         -------------------------------------------- ^^^ expected `*const i8`, found `*const u8`
   |         arguments to this function are incorrect
   |
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`
  --> /checkout/tests/ui/const-generics/issues/issue-72352.rs:7:11
   |
   |
LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0308, E0741.
---
---- [ui] tests/ui/const-generics/issues/issue-72352.rs#min stdout ----
diff of stderr:

6    |
7    = note: the only supported types are integers, `bool` and `char`
- error: aborting due to 1 previous error
+ error[E0308]: mismatched types
+   --> $DIR/issue-72352.rs:9:22
+    |
+    |
+ LL |     F(CStr::from_ptr(ptr))
+    |       -------------- ^^^ expected `*const u8`, found `*const i8`
+    |       arguments to this function are incorrect
+    |
+    |
+    = note: expected raw pointer `*const u8`
+               found raw pointer `*const i8`
+ note: associated function defined here
+   --> $SRC_DIR/core/src/ffi/c_str.rs:LL:COL
+ error[E0308]: mismatched types
+   --> $DIR/issue-72352.rs:20:54
+    |
+    |
+ LL |         unsafely_do_the_thing::<safely_do_the_thing>(ptr)
+    |         -------------------------------------------- ^^^ expected `*const i8`, found `*const u8`
+    |         arguments to this function are incorrect
+    |
+    |
+    = note: expected raw pointer `*const i8`
+               found raw pointer `*const u8`
+ note: function defined here
+    |
+    |
+ LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
+ 
+ error: aborting due to 3 previous errors
+ 
+ For more information about this error, try `rustc --explain E0308`.
+ For more information about this error, try `rustc --explain E0308`.
11 


The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/const-generics/issues/issue-72352.min/issue-72352.min.stderr
To only update this specific test, also pass `--test-args const-generics/issues/issue-72352.rs`

error in revision `min`: 1 errors occurred comparing output.
status: exit status: 1
status: exit status: 1
command: RUSTC_ICE="0" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/const-generics/issues/issue-72352.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" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--cfg" "min" "--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/const-generics/issues/issue-72352.min" "-A" "unused" "-A" "internal_features" "-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/const-generics/issues/issue-72352.min/auxiliary"
--- stderr -------------------------------
error: using function pointers as const generic parameters is forbidden
##[error]  --> /checkout/tests/ui/const-generics/issues/issue-72352.rs:7:42
   |
   |
LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
   |
   |
   = note: the only supported types are integers, `bool` and `char`
error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/const-generics/issues/issue-72352.rs:9:22
   |
LL |     F(CStr::from_ptr(ptr))
LL |     F(CStr::from_ptr(ptr))
   |       -------------- ^^^ expected `*const u8`, found `*const i8`
   |       arguments to this function are incorrect
   |
   |
   = note: expected raw pointer `*const u8`
              found raw pointer `*const i8`
  --> /rustc/FAKE_PREFIX/library/core/src/ffi/c_str.rs:263:25

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/const-generics/issues/issue-72352.rs:20:54
##[error]  --> /checkout/tests/ui/const-generics/issues/issue-72352.rs:20:54
   |
LL |         unsafely_do_the_thing::<safely_do_the_thing>(ptr)
   |         -------------------------------------------- ^^^ expected `*const i8`, found `*const u8`
   |         arguments to this function are incorrect
   |
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`
  --> /checkout/tests/ui/const-generics/issues/issue-72352.rs:7:11
   |
   |
LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {

error: aborting due to 3 previous errors

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

@bors
Copy link
Contributor

bors commented Feb 13, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 13, 2024
@oli-obk oli-obk closed this Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic O-hermit Operating System: Hermit O-SGX Target: SGX O-unix Operating system: Unix-like O-wasi Operating system: Wasi, Webassembly System Interface O-wasm Target: WASM (WebAssembly), http://webassembly.org/ O-windows Operating system: Windows rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants