Skip to content

Conversation

tgross35
Copy link
Contributor

Currently, this error emit a diagnostic with no context like:

error: `compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `<math::libm::support::hex_float::Hexf<i32> as core::fmt::LowerHex>::fmt` to `core::fmt::num::<impl core::fmt::LowerHex for i32>::fmt`

With this change, it at least usually points to the problematic function:

error: `compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `<math::libm::support::hex_float::Hexf<i32> as core::fmt::LowerHex>::fmt` to `core::fmt::num::<impl core::fmt::LowerHex for i32>::fmt`
   --> src/../libm/src/math/support/hex_float.rs:270:5
    |
270 |     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |

@rustbot
Copy link
Collaborator

rustbot commented Feb 24, 2025

r? @SparrowLii

rustbot has assigned @SparrowLii.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added 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. labels Feb 24, 2025
@rustbot
Copy link
Collaborator

rustbot commented Feb 24, 2025

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

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

r=me after fixing this commit (pls just amend it, don't push another one) and CI is green

@tgross35
Copy link
Contributor Author

tgross35 commented Feb 24, 2025

Hang on - sometimes this is giving a bad error where it points at two trait functions in core rather than whatever the problem in compiler-builtins is

error: `compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `core::fmt::num::<impl core::fmt::Debug for i128>::fmt` to `core::fmt::num::<impl core::fmt::LowerHex for i128>::fmt`
   --> /Users/tmgross/Documents/projects/rust/library/core/src/fmt/num.rs:516:1
    |
516 | / impl_Debug! {
517 | |     i8 i16 i32 i64 i128 isize
518 | |     u8 u16 u32 u64 u128 usize
519 | | }
    | |_^
    |
    = note: this error originates in the macro `impl_Debug` (in Nightly builds, run with -Z macro-backtrace for more info)

I'm not exactly sure what the code in this area is doing, but based on the results it looks like maybe:

  • compiler-builtins is calling i128::Debug somewhere, this is getting inlined
  • i128::Debug is calling i128::LowerHex, which is also getting lined
  • The error is getting raised because this call to LowerHex is (via inlining) within compiler-builtins, but it's showing up as a problem in core because fcx is for i128::Debug

@compiler-errors any idea if the span in compiler-builtins is readily available here?

(not the biggest deal since it's an internal error, but I haven't been very successful hunting these errors)

Currently, this error emit a diagnostic with no context like:

    error: `compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `<math::libm::support::hex_float::Hexf<i32> as core::fmt::LowerHex>::fmt` to `core::fmt::num::<impl core::fmt::LowerHex for i32>::fmt`

With this change, it at least usually points to the problematic
function:

    error: `compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `<math::libm::support::hex_float::Hexf<i32> as core::fmt::LowerHex>::fmt` to `core::fmt::num::<impl core::fmt::LowerHex for i32>::fmt`
       --> src/../libm/src/math/support/hex_float.rs:270:5
        |
    270 |     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
@tgross35 tgross35 force-pushed the builtins-cannot-call-error branch from c3e139f to 7a2db88 Compare February 24, 2025 03:33
@tgross35
Copy link
Contributor Author

@bors r=compiler-errors rollup

@bors
Copy link
Collaborator

bors commented Feb 24, 2025

📌 Commit 7a2db88 has been approved by compiler-errors

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 24, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 24, 2025
Rollup of 10 pull requests

Successful merges:

 - rust-lang#136610 (Allow `IndexSlice` to be indexed by ranges.)
 - rust-lang#136991 ([rustdoc] Add new setting to wrap source code lines when too long)
 - rust-lang#137061 (Unstable `gen_future` Feature Tracking  )
 - rust-lang#137393 (Stabilize `unbounded_shifts`)
 - rust-lang#137482 (Windows: use existing wrappers in `File::open_native`)
 - rust-lang#137484 (Fix documentation for unstable sort on slice)
 - rust-lang#137491 (Tighten `str-to-string-128690.rs``CHECK{,-NOT}`s to make it less likely to incorrectly fail with symbol name mangling)
 - rust-lang#137495 (Added into_value function to ControlFlow<T, T>)
 - rust-lang#137501 (Move `impl` blocks out of `rustc_middle/src/mir/syntax.rs`)
 - rust-lang#137505 (Add a span to `CompilerBuiltinsCannotCall`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 42014b4 into rust-lang:master Feb 24, 2025
6 checks passed
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 24, 2025
Rollup merge of rust-lang#137505 - tgross35:builtins-cannot-call-error, r=compiler-errors

Add a span to `CompilerBuiltinsCannotCall`

Currently, this error emit a diagnostic with no context like:

    error: `compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `<math::libm::support::hex_float::Hexf<i32> as core::fmt::LowerHex>::fmt` to `core::fmt::num::<impl core::fmt::LowerHex for i32>::fmt`

With this change, it at least usually points to the problematic function:

    error: `compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `<math::libm::support::hex_float::Hexf<i32> as core::fmt::LowerHex>::fmt` to `core::fmt::num::<impl core::fmt::LowerHex for i32>::fmt`
       --> src/../libm/src/math/support/hex_float.rs:270:5
        |
    270 |     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
@rustbot rustbot added this to the 1.87.0 milestone Feb 24, 2025
@tgross35 tgross35 deleted the builtins-cannot-call-error branch February 25, 2025 04:57
bjorn3 pushed a commit to bjorn3/rust that referenced this pull request Mar 25, 2025
…r, r=compiler-errors

Add a span to `CompilerBuiltinsCannotCall`

Currently, this error emit a diagnostic with no context like:

    error: `compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `<math::libm::support::hex_float::Hexf<i32> as core::fmt::LowerHex>::fmt` to `core::fmt::num::<impl core::fmt::LowerHex for i32>::fmt`

With this change, it at least usually points to the problematic function:

    error: `compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `<math::libm::support::hex_float::Hexf<i32> as core::fmt::LowerHex>::fmt` to `core::fmt::num::<impl core::fmt::LowerHex for i32>::fmt`
       --> src/../libm/src/math/support/hex_float.rs:270:5
        |
    270 |     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler 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