Skip to content

Regression in method resolution through Deref #17594

Closed
@sfackler

Description

@sfackler

This should compile but no longer does:

use std::cell::RefCell;

trait Foo {
    fn foo(&self) {}
}

impl<T> Foo for T where T: Clone {}

struct Bar;

impl Bar {
    fn foo(&self) {}
}

fn main() {
    let b = RefCell::new(Bar);
    b.borrow().foo()
}
test.rs:17:5: 17:21 error: the trait `core::clone::Clone` is not implemented for the type `core::cell::Ref<'_,Bar>`
test.rs:17     b.borrow().foo()
               ^~~~~~~~~~~~~~~~

Note that calling Bar.foo() directly works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions