Skip to content

Method lookup fails for operator #21922

Closed
@sellibitze

Description

@sellibitze

libcore/ops.rs provides all kinds of operator implementations for “value” and “reference type” combinations. But one thing does not seem to work like it should:

use std::ops::Add;
fn show(z: i32) {
    println!("{}", z)
}
fn main() {
    let x = 23;
    let y = 42;
    show(Add::add( x,  y));
    show(Add::add( x, &y));
    show(Add::add(&x,  y));
    show(Add::add(&x, &y));
    show( x +  y);
    show( x + &y);  // <-- everything but this works
    show(&x +  y);
    show(&x + &y);
}

I think there is a problem with how these methods are looked up because the UFCS apparently works. This issue currently kind of blocks the libcoretest/ops.rs tests I was planning to add.

cc @aturon

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyP-mediumMedium priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions