-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
regression 1.49: problem with autoderef and trait method #80816
Comments
searched nightlies: from nightly-2020-10-01 to nightly-2020-11-14 bisected with cargo-bisect-rustc v0.6.0Host triple: x86_64-unknown-linux-gnu cargo bisect-rustc --preserve --start=2020-10-01 --end=2020-11-14 -- check |
Assigning |
use std::marker::PhantomData;
use std::ops::Deref;
use std::sync::Arc;
pub struct Guard<T> {
_phantom: PhantomData<T>,
}
impl<T> Deref for Guard<T> {
type Target = T;
fn deref(&self) -> &T {
unimplemented!()
}
}
pub struct DirectDeref<T>(T);
impl<T> Deref for DirectDeref<Arc<T>> {
type Target = T;
fn deref(&self) -> &T {
unimplemented!()
}
}
pub trait Access<T> {
type Guard: Deref<Target = T>;
fn load(&self) -> Self::Guard {
unimplemented!()
}
}
impl<T, A: Access<T>, P: Deref<Target = A>> Access<T> for P {
type Guard = A::Guard;
}
impl<T> Access<T> for ArcSwapAny<T> {
type Guard = Guard<T>;
}
impl<T> Access<T> for ArcSwapAny<Arc<T>> {
type Guard = DirectDeref<Arc<T>>;
}
pub struct ArcSwapAny<T> {
_phantom_arc: PhantomData<T>,
}
pub fn foo() {
let s: Arc<ArcSwapAny<Arc<usize>>> = unimplemented!();
let guard: Guard<Arc<usize>> = s.load();
} |
The examples now print actionable feedback for the user, in the form of errors complaining about multiple applicable impl's. For example, the code from the description now prints:
So I think this might just need a regression test. @rustbot label: E-needs-test |
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#105835 (Refactor post borrowck cleanup passes) - rust-lang#105930 (Disable `NormalizeArrayLen`) - rust-lang#105938 (Update coerce_unsized tracking issue from rust-lang#27732 to rust-lang#18598) - rust-lang#105939 (Improve description of struct-fields GUI test) - rust-lang#105943 (Add regression test for rust-lang#102206) - rust-lang#105944 (Add regression test for rust-lang#80816) - rust-lang#105945 (Add regression test for rust-lang#57404) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
A code attached below used to compile with rustc 1.48 (stable) and stopped to work with 1.49 (stable). Two thing help to make the code compile:
use arc_swap::access::Access;
(*s).load()
.To compile code below one need to add
arc-swap = "1.2"
to Cargo.toml dependencies. Maybe this is due to some conflict between ArcSwap instance method and Access load method?Code
I tried this code:
I expected to see this happen: It should compile properly (it worked with rustc version 1.48 and earlier versions as well).
Instead, this happened: I got compilation error
Version it worked on
It most recently worked on: Rust 1.48
Version with regression
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: