Skip to content

Ambiguity errors in 2018 uniform import paths are not technically necessary #56414

Closed
@petrochenkov

Description

@petrochenkov

Right now import resolution on 2018 edition fails with an ambiguity error if multiple candidates are found:

struct S; // Outer

fn main() {
    struct S; // Inner

    use S as Z; // ERROR `S` is ambiguous (name vs any other name during import resolution)

    let s = S; // OK, the Inner S is preferred
}

This is different from non-import paths in which resolutions from closer scopes are preferred without errors.

This restriction is technically unnecessary and exists because some people were uncomfortable with disambiguation happening in import paths specifically (see previous threads, ... many of them, #55618 being the latest one).

This restriction can be lifted fully or partially if it causes too much trouble in practice with ambiguity errors, or with addition of new names to libraries being backward-incompatible due to new ambiguities.

(By "partially" I mean e.g. "disambiguation is okay, unless one of the candidates is an extern crate" or something like that.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-needs-summaryStatus: It's hard to tell what's been done and what hasn't! Someone should do some investigation.T-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions