Skip to content

permit crate in absolute paths #45477

Closed
Closed
@nikomatsakis

Description

@nikomatsakis

As part of #44660, we plan to support absolute paths that begin with crate. The RFC was actually a bit vague about how crate::foo paths work outside of use items. I'm going to go with the interpretation described by @rpjohnst, that one would write ::crate::foo to reference the item foo from outside of a use statement.

This means we want to support use statements like this:

use crate::foo::bar; // equivalent to `use foo::bar` today.

and "absolute" code references like this:

fn baz() {
    ::crate::foo::bar() // equivalent to `::foo::bar` today
}

This version also avoids a parsing ambiguity around tuple structs and the crate visibility modifier:

struct Foo(crate ::crate::Bar)

Metadata

Metadata

Assignees

Labels

T-compilerRelevant to the compiler 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