Problem
The FLS use-import model constructs an import path prefix primarily from path segments. A leading ::, however, is a namespace qualifier rather than a path segment, so the construction in fls_WAA4WmohGu6T does not clearly retain it.
The grammar permits a use-import prefix consisting only of ::, while the related prefix definition and construction describe prefixes in terms of a leading simple path or its path segments. This leaves the FLS unable to rigorously distinguish these Rust 2021 cases:
use {self as this_module}; // Valid: empty local prefix.
use ::{self as root}; // Invalid: imports the bare extern-prelude root.
use ::std::{self as std_alias}; // Valid: global path through the extern prelude.
In particular:
- An empty prefix with no leading
:: should resolve from the current module.
- A bare
:: prefix denotes the extern-prelude root and cannot be imported.
- A prefix such as
::std must retain ::; otherwise it can become indistinguishable from locally resolved std.
- Prefix construction through nested use trees must retain
:: while ensuring it remains at the start of the fully combined path.
This problem predates #694. That PR exposes it by adding a restriction that refers directly to an import path prefix consisting only of ::.
Expected result
The FLS should model the complete use-import prefix, including any leading namespace qualifier, and align the grammar, prefix definitions, construction rules, and legality rules.
The resulting model should account for:
// Valid.
use {self as this_module};
use ::std::{self as std_alias};
use {::{std::mem as m}};
// Invalid.
use ::{self as root};
use ::*;
use ::{*};
use std::{::{std::mem as m}};
use ::{::{std::mem as m}};
This issue is limited to the inherited leading-::/import-prefix model. The keyword-import restrictions added by #694 and unrelated self wording cleanups do not need to be reopened here.
References
Problem
The FLS use-import model constructs an
import path prefixprimarily from path segments. A leading::, however, is a namespace qualifier rather than a path segment, so the construction infls_WAA4WmohGu6Tdoes not clearly retain it.The grammar permits a use-import prefix consisting only of
::, while the related prefix definition and construction describe prefixes in terms of a leading simple path or its path segments. This leaves the FLS unable to rigorously distinguish these Rust 2021 cases:In particular:
::should resolve from the current module.::prefix denotes the extern-prelude root and cannot be imported.::stdmust retain::; otherwise it can become indistinguishable from locally resolvedstd.::while ensuring it remains at the start of the fully combined path.This problem predates #694. That PR exposes it by adding a restriction that refers directly to an import path prefix consisting only of
::.Expected result
The FLS should model the complete use-import prefix, including any leading namespace qualifier, and align the grammar, prefix definitions, construction rules, and legality rules.
The resulting model should account for:
This issue is limited to the inherited leading-
::/import-prefix model. The keyword-import restrictions added by #694 and unrelatedselfwording cleanups do not need to be reopened here.References