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

macros in static-assertions crate no longer compile #94791

Closed
robjtede opened this issue Mar 10, 2022 · 4 comments
Closed

macros in static-assertions crate no longer compile #94791

robjtede opened this issue Mar 10, 2022 · 4 comments
Labels
C-bug Category: This is a bug. regression-from-stable-to-beta Performance or correctness regression from stable to beta.

Comments

@robjtede
Copy link
Contributor

robjtede commented Mar 10, 2022

Code

I tried this code:

This is a reduction of the macro output from assert_not_impl_any! macro of the static-assertions crate.

const _: fn() = || {
    trait AmbiguousIfImpl<A> {
        fn some_item() {}
    }
    impl<T: ?Sized> AmbiguousIfImpl<()> for T {}

    {
        #[allow(dead_code)]
        struct Invalid;

        impl<T: ?Sized + std::panic::UnwindSafe> AmbiguousIfImpl<Invalid> for T {}
    }
    
    let _ = <std::io::Error as AmbiguousIfImpl<_>>::some_item;
};

I expected to see this happen: Successful compilation.

Instead, this happened:

error[[E0282]](https://doc.rust-lang.org/beta/error-index.html#E0282): type annotations needed for `fn()`
  [--> src/main.rs:14:48
](https://play.rust-lang.org/?version=beta&mode=debug&edition=2021#)   |
14 |     let _ = <std::io::Error as AmbiguousIfImpl<_>>::some_item;
   |         -                                      ^ cannot infer type
   |         |
   |         consider giving this pattern the explicit type `fn()`, with the type parameters specified

error[[E0283]](https://doc.rust-lang.org/beta/error-index.html#E0283): type annotations needed for `fn()`
  [--> src/main.rs:14:13
](https://play.rust-lang.org/?version=beta&mode=debug&edition=2021#)   |
14 |     let _ = <std::io::Error as AmbiguousIfImpl<_>>::some_item;
   |         -   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
   |         |
   |         consider giving this pattern the explicit type `fn()`, with the type parameters specified
   |
note: multiple `impl`s satisfying `std::io::Error: AmbiguousIfImpl<_>` found
  [--> src/main.rs:5:5
](https://play.rust-lang.org/?version=beta&mode=debug&edition=2021#)   |
5  |     impl<T: ?Sized> AmbiguousIfImpl<()> for T {}
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
11 |         impl<T: ?Sized + std::panic::UnwindSafe> AmbiguousIfImpl<Invalid> for T {}
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Some errors have detailed explanations: E0282, E0283.
For more information about an error, try `rustc --explain E0282`.
error: could not compile `playground` due to 2 previous errors

Version it worked on

It most recently worked on: rustc 1.59.0 (9d1b2106e 2022-02-23)

Version with regression

rustc --version --verbose:

rustc 1.60.0-beta.3 (e5effbd0b 2022-03-07)
binary: rustc
commit-hash: e5effbd0b34c9ede216e21d3f60dcbad0b863676
commit-date: 2022-03-07
host: aarch64-apple-darwin
release: 1.60.0-beta.3
LLVM version: 14.0.0

References

@robjtede robjtede added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Mar 10, 2022
@rustbot rustbot added regression-from-stable-to-beta Performance or correctness regression from stable to beta. I-prioritize Issue: Indicates that prioritization has been requested for this issue. and removed regression-untriaged Untriaged performance or correctness regression. labels Mar 10, 2022
@compiler-errors
Copy link
Member

compiler-errors commented Mar 10, 2022

Lemme rustc-bisect this..

@robjtede
Copy link
Contributor Author

I'm on a tier 2 platform but here's my bisect:

searched nightlies: from nightly-2021-10-01 to nightly-2022-03-10
regressed nightly: nightly-2022-02-08
searched commit range: f624427...734368a
regressed commit: 734368a

bisected with cargo-bisect-rustc v0.6.1

Host triple: aarch64-apple-darwin
Reproduce with:

cargo bisect-rustc --start=2021-01-01

@compiler-errors
Copy link
Member

Nah you're likely right. My internet died during the bisect so sorry for leaving you hanging, haha. Thanks for doing the bisect.

So the issue seems to be that #87869 made std::io::Error implement UnwindSafe whereas that's not true on stable.

@robjtede
Copy link
Contributor Author

Okay, that's good then. Weird that there's no reference to it in the PR.

I suppose this is the tricky bit about negative impl testing auto traits.

robjtede added a commit to actix/actix-web that referenced this issue Mar 10, 2022
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. regression-from-stable-to-beta Performance or correctness regression from stable to beta.
Projects
None yet
Development

No branches or pull requests

4 participants