Skip to content

Fix leading qualifiers in use-import prefixes - #13

Draft
PLeVasseur wants to merge 45 commits into
mainfrom
fix-use-import-leading-namespace
Draft

PLeVasseur wants to merge 45 commits into
mainfrom
fix-use-import-leading-namespace

Conversation

@PLeVasseur

Copy link
Copy Markdown
Owner

Summary

  • Preserve leading namespace qualifiers when constructing import path prefixes.
  • Distinguish empty local prefixes, bare extern-prelude prefixes, and qualified global prefixes.
  • Retain qualifiers through nested use trees and reject invalid non-leading or duplicate qualifiers.
  • Centralize the empty and bare-:: glob-import restrictions.
  • Add the corresponding FLS maintenance accounting.

Tracks rust-lang#711.

Reference alignment

The FLS models brace grouping through explicit recursive prefix construction rather than the Reference's prose description. This is a structural difference with no intentional behavioral deviation.

The changes are limited to Rust 2021 semantics. The Rust 2015 interpretation of leading :: is excluded.

Glob-import restrictions are centralized in fls_iNUBX5fJAI1N; its macro-consumption allowance intentionally applies to both empty and bare-:: glob prefixes because macros may consume those token forms before import resolution rejects them.

Testing

  • ./make.py --clear
    • Passed with no warnings or errors.
  • ./make.py --check-links
    • Passed: 31 HTML files, 16,985 links checked, zero errors.
  • Rust 1.95.0 positive matrix under edition 2021
    • All six valid declarations accepted.
  • Rust 1.95.0 negative matrix under edition 2021
    • All six invalid declarations produced the expected diagnostics.
  • git diff --check upstream/main...HEAD
    • Passed.

tshepang and others added 30 commits July 24, 2026 14:26
Co-authored-by: Hristian Kirtchev <60669983+kirtchev-adacore@users.noreply.github.com>
…r-blockers

[Dev-Guide]: Dealing with PR blockers
Not clear what was intended there, but it does not look essential
"refutable pattern" and "irrefutable pattern" are already defined above
Also, unroll the sentence
This PR removes the term "indirection" and its derivatives from the FLS
as the Rust Project does not use this term. The preferred alternative is
"pointer", "pointer type", etc.

Closes: rust-lang#710
…irection

Remove term "indirection" and its derivatives
PLeVasseur and others added 15 commits September 5, 2026 09:11
…r-1.99

add changelog entries for Rust 1.99
Address the review of 2026-09-24 on the import path prefix construction:

- Fold the redundant "A sequence determined as follows" bullet into the
  "For each nesting import" step, which now enumerates only the nesting
  imports that contribute a common path prefix or a leading `::`.
- State the import's own contribution as flat cases with their own
  conditions; a glob import with no prefix of its own and a plain single
  segment simple import match no case and contribute nothing.
- Split the simple import case by multi segment and single segment path
  so the separating `::` is removed exactly and a leading `::` on a single
  segment path is kept.
- Phrase the glob and `self` prefix rules by what the import path prefix
  contains, matching the existing enum-or-module rule.
- Use "use import" as the subject of the nesting restriction.

The construction is unchanged in effect for every case in the review
matrix.
`fls_JHU0ersYB6eL` required every import path prefix that contains a
path segment to resolve to an enum or module. A simple import whose
simple path ends in keyword `self` brings the entity that its prefix
resolves to into scope, and `fls_oRdi3KXFbJcR` allows that entity to be
a trait, as does the Reference (items.use.self.module). So
`use m::Trait::{self as T};` was accepted by rustc and rejected by the
FLS text.

Exempt such imports from `fls_JHU0ersYB6eL`. Glob imports and simple
imports whose last path segment is not `self` are unchanged. Recorded as
its own changelog entry.
Preserve the import-prefix maintenance entries alongside the upstream trait-bound entry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants