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

Refactor dyn-compatibility error and suggestions #133372

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cramertj
Copy link
Member

This CL makes a number of small changes to dyn compatibility errors:

  • "object safety" has been renamed to "dyn-compatibility" throughout
  • "Convert to enum" suggestions are no longer generated when there exists a type-generic impl of the trait or an impl for dyn OtherTrait
  • Several error messages are reorganized for user readability

Additionally, the dyn compatibility error creation code has been split out into functions.

cc #132713
cc #133267

r? @compiler-errors

@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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 23, 2024
@rustbot
Copy link
Collaborator

rustbot commented Nov 23, 2024

HIR ty lowering was modified

cc @fmease


trait Child: Super {}

fn take_dyn(_: &dyn Child) {}
Copy link
Member Author

Choose a reason for hiding this comment

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

cc @compiler-errors

This duplication and mis-attribution is the original source of the AsyncFn issue. I haven't yet resolved it as part of this PR, but this one started to get quite large again, so I figured I'd save it. I'd be happy to poke around more or try things out if you have ideas!

This CL makes a number of small changes to dyn compatibility errors:
- "object safety" has been renamed to "dyn-compatibility" throughout
- "Convert to enum" suggestions are no longer generated when there
  exists a type-generic impl of the trait or an impl for `dyn OtherTrait`
- Several error messages are reorganized for user readability

Additionally, the dyn compatibility error creation code has been
split out into functions.

cc rust-lang#132713
cc rust-lang#133267
@rustbot
Copy link
Collaborator

rustbot commented Nov 23, 2024

Some changes occurred in src/tools/cargo

cc @ehuss

@fmease
Copy link
Member

fmease commented Nov 23, 2024

You've touched several git submodules. See https://rustc-dev-guide.rust-lang.org/git.html#i-changed-a-submodule-by-accident

@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
#17 exporting to docker image format
#17 sending tarball 27.8s done
#17 DONE 32.4s
##[endgroup]
Setting extra environment values for docker:  --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-18]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure: 
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-18', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-18/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
  Downloaded boml v0.3.1
   Compiling boml v0.3.1
   Compiling y v0.1.0 (/checkout/compiler/rustc_codegen_gcc/build_system)
    Finished `release` profile [optimized] target(s) in 3.98s
     Running `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-codegen/x86_64-unknown-linux-gnu/release/y test --use-system-gcc --use-backend gcc --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/cg_gcc --release --mini-tests --std-tests`
Using system GCC
[BUILD] example
[AOT] mini_core_hello_world
/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/cg_gcc/mini_core_hello_world
abc
---
   --> /checkout/library/stdarch/crates/std_detect/src/detect/macros.rs:9:16
    |
4   |   macro_rules! detect_feature {
    |   ---------------------------
    |   |
    |   in this expansion of `$crate::detect_feature!` (#2)
    |   in this expansion of `$crate::detect_feature!` (#3)
5   |       ($feature:tt, $feature_lit:tt) => {
6   |           $crate::detect_feature!($feature, $feature_lit : $feature_lit)
...
...
9   |           $(cfg!(target_feature = $target_feature_lit) ||)*
...
...
32  | /         macro_rules! $macro_name {
34  | |                 ($feature_lit) => {
34  | |                 ($feature_lit) => {
35  | |                     $crate::detect_feature!($feature, $feature_lit $(: $($target_feature_lit),*)?)
...   |
69  | |             };
70  | |         }
70  | |         }
    | |_________- in this expansion of `is_x86_feature_detected!` (#1)
   ::: std/tests/run-time-detect.rs:144:27
    |
    |
144 |       println!("mmx: {:?}", is_x86_feature_detected!("mmx"));
    |
    |
    = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, and `avx512vpopcntdq` and 251 more
    = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
             [lints.rust]
             [lints.rust]
             unexpected_cfgs = { level = "warn", check-cfg = ['cfg(target_feature, values("mmx"))'] }
    = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(target_feature, values(\"mmx\"))");` to the top of the `build.rs`
    = note: `-D unexpected-cfgs` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(unexpected_cfgs)]`

error: unexpected `cfg` condition value: `tsc`
error: unexpected `cfg` condition value: `tsc`
   --> /checkout/library/stdarch/crates/std_detect/src/detect/macros.rs:9:16
    |
4   |   macro_rules! detect_feature {
    |   ---------------------------
    |   |
    |   in this expansion of `$crate::detect_feature!` (#2)
    |   in this expansion of `$crate::detect_feature!` (#3)
5   |       ($feature:tt, $feature_lit:tt) => {
6   |           $crate::detect_feature!($feature, $feature_lit : $feature_lit)
...
...
9   |           $(cfg!(target_feature = $target_feature_lit) ||)*
...
...
32  | /         macro_rules! $macro_name {
34  | |                 ($feature_lit) => {
34  | |                 ($feature_lit) => {
35  | |                     $crate::detect_feature!($feature, $feature_lit $(: $($target_feature_lit),*)?)
...   |
69  | |             };
70  | |         }
70  | |         }
    | |_________- in this expansion of `is_x86_feature_detected!` (#1)
   ::: std/tests/run-time-detect.rs:145:27
    |
    |
145 |       println!("tsc: {:?}", is_x86_feature_detected!("tsc"));
    |
    |
    = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, and `avx512vpopcntdq` and 251 more
    = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
             [lints.rust]
             [lints.rust]
             unexpected_cfgs = { level = "warn", check-cfg = ['cfg(target_feature, values("tsc"))'] }
    = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(target_feature, values(\"tsc\"))");` to the top of the `build.rs`

error: could not compile `std` (test "run-time-detect") due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
Build completed unsuccessfully in 0:26:18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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-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.

5 participants