Closed
Description
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