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

2024 dependency_on_unit_never_type_fallback doesn't display during 2024 edition migration #132930

Closed
ehuss opened this issue Nov 12, 2024 · 8 comments · Fixed by #132978
Closed
Labels
A-edition-2024 Area: The 2024 edition C-bug Category: This is a bug. D-edition Diagnostics: An error or lint that should account for edition differences. F-never_type `#![feature(never_type)]` L-dependency_on_unit_never_type_fallback Lint: dependency_on_unit_never_type_fallback

Comments

@ehuss
Copy link
Contributor

ehuss commented Nov 12, 2024

I'm not entirely certain what is wrong with this particular code, but it fails in the 2024 edition without generating any warnings.

[email protected]
https://crater-reports.s3.amazonaws.com/pr-132712/try%23da25749bf5e6ba5ed862ff361c19afff2a986b2d/reg/screenshots-0.8.10/log.txt

The error after updating to 2024 is:

error[E0277]: the trait bound `!: ReadAll` is not satisfied
   --> src/linux/wayland_screenshot.rs:70:11
    |
70  |     proxy.method_call(
    |           ^^^^^^^^^^^ the trait `ReadAll` is not implemented for `!`
    |
    = help: the following other types implement trait `ReadAll`:
              ()
              (A, B)
              (A, B, C)
              (A, B, C, D)
              (A, B, C, D, E)
              (A, B, C, D, E, F)
              (A, B, C, D, E, F, G)
              (A, B, C, D, E, F, G, H)
            and 28 others
    = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information)
    = help: did you intend to use the type `()` here instead?
note: required by a bound in `Proxy::<'a, C>::method_call`
   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/dbus-0.9.7/src/blocking.rs:396:35
    |
396 |     pub fn method_call<'i, 'm, R: ReadAll, A: AppendAll, I: Into<Interface<'i>>, M: Into<Member<'m>>>(&self, i: I, m: M, args: A) -> Result<R, Error> {
    |                                   ^^^^^^^ required by this bound in `Proxy::<'a, C>::method_call`

error[E0277]: the trait bound `!: ReadAll` is not satisfied
   --> src/linux/wayland_screenshot.rs:126:11
    |
126 |     proxy.method_call(
    |           ^^^^^^^^^^^ the trait `ReadAll` is not implemented for `!`
    |
    = help: the following other types implement trait `ReadAll`:
              ()
              (A, B)
              (A, B, C)
              (A, B, C, D)
              (A, B, C, D, E)
              (A, B, C, D, E, F)
              (A, B, C, D, E, F, G)
              (A, B, C, D, E, F, G, H)
            and 28 others
    = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information)
    = help: did you intend to use the type `()` here instead?
note: required by a bound in `Proxy::<'a, C>::method_call`
   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/dbus-0.9.7/src/blocking.rs:396:35
    |
396 |     pub fn method_call<'i, 'm, R: ReadAll, A: AppendAll, I: Into<Interface<'i>>, M: Into<Member<'m>>>(&self, i: I, m: M, args: A) -> Result<R, Error> {
    |                                   ^^^^^^^ required by this bound in `Proxy::<'a, C>::method_call`

The relevant types are from the dbus crate.

I would expect that if this is related to dependency_on_unit_never_type_fallback that it should generate a warning before migrating to 2024.

Meta

rustc --version --verbose:

rustc 1.84.0-nightly (143ce0920 2024-11-10)
binary: rustc
commit-hash: 143ce0920a2307b19831160a01f06f107610f1b2
commit-date: 2024-11-10
host: aarch64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.3
@ehuss ehuss added A-edition-2024 Area: The 2024 edition C-bug Category: This is a bug. D-edition Diagnostics: An error or lint that should account for edition differences. F-never_type `#![feature(never_type)]` L-dependency_on_unit_never_type_fallback Lint: dependency_on_unit_never_type_fallback labels Nov 12, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 12, 2024
@compiler-errors
Copy link
Member

the never type fallback lints are not marked as 2024 future compat, so they're not fixed in edition 2024 even though I implemented a machine applicable fix in #132383.

@compiler-errors
Copy link
Member

I'll fix that.

@WaffleLapkin
Copy link
Member

WaffleLapkin commented Nov 12, 2024

@ehuss the code does generate warnings:

warning: this function depends on never type fallback being `()`
  --> src/linux/wayland_capture.rs:47:1
   |
47 | / fn org_gnome_shell_screenshot(
48 | |     conn: &Connection,
49 | |     x: i32,
50 | |     y: i32,
51 | |     width: i32,
52 | |     height: i32,
53 | | ) -> XCapResult<RgbaImage> {
   | |__________________________^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
   = help: specify the types explicitly
note: in edition 2024, the requirement `!: ReadAll` will fail
  --> src/linux/wayland_capture.rs:71:11
   |
71 |     proxy.method_call(
   |           ^^^^^^^^^^^
   = note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
help: use `()` annotations to avoid fallback changes
   |
71 |     proxy.method_call::<_, _, (), _>(
   |                      +++++++++++++++

warning: this function depends on never type fallback being `()`
   --> src/linux/wayland_capture.rs:84:1
    |
84  | / fn org_freedesktop_portal_screenshot(
85  | |     conn: &Connection,
86  | |     x: i32,
87  | |     y: i32,
88  | |     width: i32,
89  | |     height: i32,
90  | | ) -> XCapResult<RgbaImage> {
    | |__________________________^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
    = help: specify the types explicitly
note: in edition 2024, the requirement `!: ReadAll` will fail
   --> src/linux/wayland_capture.rs:127:11
    |
127 |     proxy.method_call(
    |           ^^^^^^^^^^^
help: use `()` annotations to avoid fallback changes
    |
127 |     proxy.method_call::<_, _, (), _>(
    |                      +++++++++++++++

Not sure why they are not picked up with cargo fix --edition though 🤔 Upd: looks like @compiler-errors already figured it out.

@ehuss ehuss changed the title 2024 False negative on ! change 2024 dependency_on_unit_never_type_fallback doesn't display during 2024 edition migration Nov 12, 2024
@ehuss
Copy link
Contributor Author

ehuss commented Nov 12, 2024

Sorry, somehow I missed that the warnings were being generated on the previous edition. I'm not sure how. I thought I ran cargo check to verify.

If @compiler-errors wants to update it to be marked as the 2024 edition, I think that should be fine. It's not absolutely necessary since our policy is that the code should be warning-free before migrating.

@compiler-errors
Copy link
Member

🤔 yeah, but would cargo fix --edition also apply this lint unless it's attached to the edition? I guess not.

@ehuss
Copy link
Contributor Author

ehuss commented Nov 12, 2024

Correct, it will not apply the lint (and it is suppressed so it is not displayed at all) with running cargo fix --edition.

It would probably be best to mark it with the edition so at least the warning message tells you that it changes in 2024 instead of the nonspecific "in a future release!"

@ehuss
Copy link
Contributor Author

ehuss commented Nov 12, 2024

Oh, sorry, I just now read the conversation on #132931.

Given the comment in #132931 (review), then I would suggest we just close this.

Sorry for the confusion on my part.

@WaffleLapkin
Copy link
Member

@ehuss I think it still makes sense to mark it with the edition -- we just need to add an option to mark it as both edition and future release (i.e. #132931 (comment)). I'll work on it tomorrow.

@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 12, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 15, 2024
…kind, r=compiler-errors

Mention both release *and* edition breakage for never type lints

This PR makes ~~two changes~~ a change to the never type lints (`dependency_on_unit_never_type_fallback` and `never_type_fallback_flowing_into_unsafe`):
1.  Change the wording of the note to mention that the breaking change will be made in an edition _and_ in a future release
2. ~~Make these warnings be reported in deps (hopefully the lints are matured enough)~~

r? `@compiler-errors`
cc `@ehuss`
closes rust-lang#132930
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Nov 15, 2024
…kind, r=compiler-errors

Mention both release *and* edition breakage for never type lints

This PR makes ~~two changes~~ a change to the never type lints (`dependency_on_unit_never_type_fallback` and `never_type_fallback_flowing_into_unsafe`):
1.  Change the wording of the note to mention that the breaking change will be made in an edition _and_ in a future release
2. ~~Make these warnings be reported in deps (hopefully the lints are matured enough)~~

r? `@compiler-errors`
cc `@ehuss`
closes rust-lang#132930
@bors bors closed this as completed in b3e2981 Nov 16, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Nov 16, 2024
Rollup merge of rust-lang#132978 - WaffleLapkin:very-semantic-change-kind, r=compiler-errors

Mention both release *and* edition breakage for never type lints

This PR makes ~~two changes~~ a change to the never type lints (`dependency_on_unit_never_type_fallback` and `never_type_fallback_flowing_into_unsafe`):
1.  Change the wording of the note to mention that the breaking change will be made in an edition _and_ in a future release
2. ~~Make these warnings be reported in deps (hopefully the lints are matured enough)~~

r? ``@compiler-errors``
cc ``@ehuss``
closes rust-lang#132930
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edition-2024 Area: The 2024 edition C-bug Category: This is a bug. D-edition Diagnostics: An error or lint that should account for edition differences. F-never_type `#![feature(never_type)]` L-dependency_on_unit_never_type_fallback Lint: dependency_on_unit_never_type_fallback
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants