Skip to content

UFCS inconsistencies #21122

Closed
Closed
@bluss

Description

@bluss

Methods on Vec are not available even if Vec is in the prelude;

let v: Vec<i32> = Vec::new();
Vec::len(&v);  // (a) -> error: unresolved name `Vec::len`
std::vec::Vec::len(&v);  // (b) -> OK!

fix: use std::vec::Vec; and both lines (a) and (b) compile!

BitvSet is just weird and doesn't ever cooperate:

use std::collections::BitvSet;
let bs = BitvSet::new();
BitvSet::len(&bs); // error: unresolved name `BitvSet::len`

use was fine with Vec -- but not this time.

And this is weirder:

extern crate collections;

use std::collections::BitvSet;

fn main() {
    let bs = BitvSet::new();
    BitvSet::len(&bs); // error: unresolved name `BitvSet::len`
    std::collections::BitvSet::len(&bs); // error: unresolved name `std::collections::BitvSet::len`
    collections::bitv_set::BitvSet::len(&bs); // error: unresolved name `collections::bitv_set::BitvSet::len`
    collections::bit::BitvSet::len(&bs);  // error: function `len` is private
}

UFCS tracking issue: #16293

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions