From 0ab3bab25477b020b8cc98a9b7d71e20a38c8b7c Mon Sep 17 00:00:00 2001 From: Pete LeVasseur Date: Fri, 31 Jul 2026 19:36:43 +0900 Subject: [PATCH 1/3] docs(resolve): preserve leading qualifiers in use imports --- src/changelog.rst | 21 +++++++++++++++++ src/entities-and-resolution.rst | 40 ++++++++++++++++----------------- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/src/changelog.rst b/src/changelog.rst index 29f06aea..c8fcf111 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -238,6 +238,27 @@ Language changes in Rust 1.95.0 FLS maintenance --------------- +- Fix the construction of :t:`[import path prefix]es` to preserve leading :t:`[namespace qualifier]s`. + + Changed syntax: :s:`CommonPathPrefix` + + Changed paragraphs: + + - :p:`fls_sxo1jb25pl8a` + - :p:`fls_WAA4WmohGu6T` + - :p:`fls_IPYvldMqduf4` + - :p:`fls_MOXId37fcNPY` + - :p:`fls_2UyFcB6Our1v` + - :p:`fls_gAWsqibl4GLq` + - :p:`fls_irdKqoYzBM0M` + - :p:`fls_aam34hsRmKU2` + + New paragraphs: + + - :p:`fls_lfsIPXV0OTI5` + - :p:`fls_BMtRtjJ7gBKT` + - :p:`fls_UZHHtqJ0ekju` + - Replace the term "simple path prefix" with "common path prefix", to improve clarity. - Changed paragraphs: diff --git a/src/entities-and-resolution.rst b/src/entities-and-resolution.rst index 384f36f3..bff559e7 100644 --- a/src/entities-and-resolution.rst +++ b/src/entities-and-resolution.rst @@ -1005,7 +1005,8 @@ Use Imports SimplePath Renaming? CommonPathPrefix ::= - SimplePath? $$::$$ + SimplePath $$::$$ + | $$::$$ UseImportContentList ::= UseImportContent ($$,$$ UseImportContent)* $$,$$? @@ -1018,35 +1019,28 @@ A :t:`use import` brings :t:`entities ` :t:`in scope` within the :t:`use import` resides. :dp:`fls_sxo1jb25pl8a` -A :dt:`common path prefix` is the leading :t:`simple path` of a :t:`glob import` -or a :t:`nesting import`. +A :dt:`common path prefix` is the :t:`simple path` of a :s:`CommonPathPrefix` when one is present, and otherwise consists only of :t:`namespace qualifier` ``::``. :dp:`fls_WAA4WmohGu6T` -An :dt:`import path prefix` is the fully constructed :t:`path` prefix of a -:t:`use import`. An :t:`import path prefix` for a given -:t:`simple import` or :t:`glob import` is constructed as follows: +An :dt:`import path prefix` is the fully constructed sequence of :t:`[path segment]s` and :t:`[namespace qualifier]s` that precedes the selected :t:`entity` of a :t:`simple import` or the character asterisk ``*`` of a :t:`glob import`. The :t:`import path prefix` for a given :t:`simple import` or :t:`glob import` is constructed as follows: #. :dp:`fls_IPYvldMqduf4` - Start the :t:`import path prefix` as follows: + Make the given :t:`use import` the current :t:`use import`, and start the :t:`import path prefix` as follows: * :dp:`fls_MOXId37fcNPY` - If the :t:`use import` is a :t:`simple import` then start with the - :t:`[path segment]s` of the :t:`simple import`'s :t:`simple path` - :t:`path prefix`. + If the :t:`use import` is a :t:`simple import`, then start with the :t:`simple import`'s :t:`simple path` :t:`path prefix`, retaining any leading :t:`namespace qualifier` of the :t:`simple path`. * :dp:`fls_2UyFcB6Our1v` - If the :t:`use import` is a :t:`glob import` then start with the - :t:`[path segment]s` of the :t:`glob import`'s :t:`common path prefix`. + If the :t:`use import` is a :t:`glob import`, then start with the :t:`glob import`'s :t:`common path prefix`, or an empty sequence if the :t:`glob import` lacks a :t:`common path prefix`. + +#. :dp:`fls_gAWsqibl4GLq` + While the current :t:`use import` is the child of a :t:`nesting import`, repeat the following steps: * :dp:`fls_irdKqoYzBM0M` - If the :t:`use import` is a :t:`nesting import` then start with the - :t:`[path segment]s` of the :t:`nesting import`'s :t:`common path prefix`. + If the :t:`nesting import` has a :t:`common path prefix`, prepend the :t:`common path prefix` to the :t:`import path prefix`. If the :t:`common path prefix` contains a :t:`path segment` and the :t:`import path prefix` was not empty, place a :t:`namespace qualifier` ``::`` between them. -#. :dp:`fls_gAWsqibl4GLq` - Then if the current :t:`use import` is the child of a :t:`nesting import`, - prepend the :t:`nesting import`'s :t:`common path prefix` to the - :t:`import path prefix`. Repeat this step with the :t:`nesting import` as - the current :t:`use import`. + * :dp:`fls_lfsIPXV0OTI5` + Make the :t:`nesting import` the current :t:`use import`. :dp:`fls_2bkcn83smy2y` A :dt:`simple import` is a :t:`use import` that brings into :t:`scope` an :t:`entity` selected by its :t:`simple import path`, or by its :t:`import path prefix` when its :t:`simple path` ends in :t:`keyword` ``self`` and the :t:`simple path` appears in a :t:`nesting import`. @@ -1056,6 +1050,12 @@ A :t:`glob import` is a :t:`use import` that brings all :t:`entities ` exported by the :t:`module` or :t:`enum` its :t:`import path prefix` resolves to into :t:`scope`. +:dp:`fls_BMtRtjJ7gBKT` +Each :t:`namespace qualifier` of an :t:`import path prefix` shall either be the first element of the :t:`import path prefix` or appear between two :t:`[path segment]s`. + +:dp:`fls_UZHHtqJ0ekju` +An empty :t:`import path prefix` resolves to the current :t:`module`. + :dp:`fls_JHU0ersYB6eL` An :t:`import path prefix` shall resolve to a :t:`module` or :t:`enum`. @@ -1125,7 +1125,7 @@ A :t:`use import` with a single :t:`path segment` expressed as either :t:`keywor When a :t:`path segment` expressed as :t:`keyword` ``super`` is used to import a parent :t:`module`, the imported :t:`entity` shall be subject to a :t:`renaming`. :dp:`fls_aam34hsRmKU2` -A :t:`simple import` whose :t:`import path prefix` consists only of :t:`namespace qualifier` ``::`` and whose :t:`simple path` consists of a single :t:`path segment` expressed as :t:`keyword` ``self`` shall not be used. +An :t:`import path prefix` shall not consist only of :t:`namespace qualifier` ``::`` when it is the :t:`import path prefix` of a :t:`glob import` or selects the :t:`entity` of a :t:`simple import`. :dp:`fls_LV94x3HlpBWk` A :t:`simple import` shall not refer to :t:`[enum variant]s` through a :t:`type alias`. From a34105263483efd84b599bde181231f20fbd4e0a Mon Sep 17 00:00:00 2001 From: Pete LeVasseur Date: Fri, 31 Jul 2026 20:20:51 +0900 Subject: [PATCH 2/3] docs(resolve): reject empty glob import prefixes --- src/changelog.rst | 46 ++++++++++++++++++--------------- src/entities-and-resolution.rst | 12 ++++----- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/changelog.rst b/src/changelog.rst index c8fcf111..1e612ed8 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -19,6 +19,31 @@ with the change that has been applied due to it. just the language changes that had an impact to the FLS. See the `release notes`_ for a full list of changes. +FLS maintenance +--------------- + +- Fix the construction of :t:`[import path prefix]es` to preserve leading :t:`[namespace qualifier]s`. + + Changed syntax: :s:`CommonPathPrefix` + + Changed paragraphs: + + - :p:`fls_sxo1jb25pl8a` + - :p:`fls_WAA4WmohGu6T` + - :p:`fls_IPYvldMqduf4` + - :p:`fls_MOXId37fcNPY` + - :p:`fls_2UyFcB6Our1v` + - :p:`fls_gAWsqibl4GLq` + - :p:`fls_irdKqoYzBM0M` + - :p:`fls_JHU0ersYB6eL` + - :p:`fls_aam34hsRmKU2` + + New paragraphs: + + - :p:`fls_lfsIPXV0OTI5` + - :p:`fls_BMtRtjJ7gBKT` + - :p:`fls_UZHHtqJ0ekju` + Language changes in Rust 1.96.0 ------------------------------- @@ -238,27 +263,6 @@ Language changes in Rust 1.95.0 FLS maintenance --------------- -- Fix the construction of :t:`[import path prefix]es` to preserve leading :t:`[namespace qualifier]s`. - - Changed syntax: :s:`CommonPathPrefix` - - Changed paragraphs: - - - :p:`fls_sxo1jb25pl8a` - - :p:`fls_WAA4WmohGu6T` - - :p:`fls_IPYvldMqduf4` - - :p:`fls_MOXId37fcNPY` - - :p:`fls_2UyFcB6Our1v` - - :p:`fls_gAWsqibl4GLq` - - :p:`fls_irdKqoYzBM0M` - - :p:`fls_aam34hsRmKU2` - - New paragraphs: - - - :p:`fls_lfsIPXV0OTI5` - - :p:`fls_BMtRtjJ7gBKT` - - :p:`fls_UZHHtqJ0ekju` - - Replace the term "simple path prefix" with "common path prefix", to improve clarity. - Changed paragraphs: diff --git a/src/entities-and-resolution.rst b/src/entities-and-resolution.rst index bff559e7..ff5c67bd 100644 --- a/src/entities-and-resolution.rst +++ b/src/entities-and-resolution.rst @@ -1019,16 +1019,16 @@ A :t:`use import` brings :t:`entities ` :t:`in scope` within the :t:`use import` resides. :dp:`fls_sxo1jb25pl8a` -A :dt:`common path prefix` is the :t:`simple path` of a :s:`CommonPathPrefix` when one is present, and otherwise consists only of :t:`namespace qualifier` ``::``. +A :dt:`common path prefix` is the :t:`simple path` of a :s:`CommonPathPrefix` when the :s:`CommonPathPrefix` contains a :s:`SimplePath`, and otherwise consists only of :t:`namespace qualifier` ``::``. :dp:`fls_WAA4WmohGu6T` -An :dt:`import path prefix` is the fully constructed sequence of :t:`[path segment]s` and :t:`[namespace qualifier]s` that precedes the selected :t:`entity` of a :t:`simple import` or the character asterisk ``*`` of a :t:`glob import`. The :t:`import path prefix` for a given :t:`simple import` or :t:`glob import` is constructed as follows: +An :dt:`import path prefix` is a sequence of :t:`[path segment]s` and :t:`[namespace qualifier]s` associated with a :t:`simple import` or :t:`glob import`. The :t:`import path prefix` for a given :t:`simple import` or :t:`glob import` is constructed as follows: #. :dp:`fls_IPYvldMqduf4` Make the given :t:`use import` the current :t:`use import`, and start the :t:`import path prefix` as follows: * :dp:`fls_MOXId37fcNPY` - If the :t:`use import` is a :t:`simple import`, then start with the :t:`simple import`'s :t:`simple path` :t:`path prefix`, retaining any leading :t:`namespace qualifier` of the :t:`simple path`. + If the :t:`use import` is a :t:`simple import`, then start with the :t:`simple import`'s :t:`simple path` after removing its last :t:`path segment` and, if another :t:`path segment` precedes the last :t:`path segment`, the :t:`namespace qualifier` that separates them. * :dp:`fls_2UyFcB6Our1v` If the :t:`use import` is a :t:`glob import`, then start with the :t:`glob import`'s :t:`common path prefix`, or an empty sequence if the :t:`glob import` lacks a :t:`common path prefix`. @@ -1054,10 +1054,10 @@ into :t:`scope`. Each :t:`namespace qualifier` of an :t:`import path prefix` shall either be the first element of the :t:`import path prefix` or appear between two :t:`[path segment]s`. :dp:`fls_UZHHtqJ0ekju` -An empty :t:`import path prefix` resolves to the current :t:`module`. +An empty :t:`import path prefix` that selects the :t:`entity` of a :t:`simple import` resolves to the current :t:`module`. :dp:`fls_JHU0ersYB6eL` -An :t:`import path prefix` shall resolve to a :t:`module` or :t:`enum`. +An :t:`import path prefix` that contains a :t:`path segment` shall resolve to a :t:`module` or :t:`enum`. :dp:`fls_jlNKxkuhsvX4` A :t:`glob import` brings :t:`[name]s` into :t:`scope` as follows: @@ -1125,7 +1125,7 @@ A :t:`use import` with a single :t:`path segment` expressed as either :t:`keywor When a :t:`path segment` expressed as :t:`keyword` ``super`` is used to import a parent :t:`module`, the imported :t:`entity` shall be subject to a :t:`renaming`. :dp:`fls_aam34hsRmKU2` -An :t:`import path prefix` shall not consist only of :t:`namespace qualifier` ``::`` when it is the :t:`import path prefix` of a :t:`glob import` or selects the :t:`entity` of a :t:`simple import`. +The :t:`import path prefix` of a :t:`glob import` shall neither be empty nor consist only of :t:`namespace qualifier` ``::``. An :t:`import path prefix` that selects the :t:`entity` of a :t:`simple import` shall not consist only of :t:`namespace qualifier` ``::``. :dp:`fls_LV94x3HlpBWk` A :t:`simple import` shall not refer to :t:`[enum variant]s` through a :t:`type alias`. From 8e9c110f9933524c092b73c0402d61dcb109955e Mon Sep 17 00:00:00 2001 From: Pete LeVasseur Date: Fri, 31 Jul 2026 20:48:11 +0900 Subject: [PATCH 3/3] docs(resolve): centralize glob import restrictions --- src/changelog.rst | 1 + src/entities-and-resolution.rst | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/changelog.rst b/src/changelog.rst index 1e612ed8..9af6f13f 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -36,6 +36,7 @@ FLS maintenance - :p:`fls_gAWsqibl4GLq` - :p:`fls_irdKqoYzBM0M` - :p:`fls_JHU0ersYB6eL` + - :p:`fls_iNUBX5fJAI1N` - :p:`fls_aam34hsRmKU2` New paragraphs: diff --git a/src/entities-and-resolution.rst b/src/entities-and-resolution.rst index ff5c67bd..a3b74554 100644 --- a/src/entities-and-resolution.rst +++ b/src/entities-and-resolution.rst @@ -1103,8 +1103,7 @@ A :t:`nesting import` is a :t:`use import` that provides a common :t:`common path prefix` for its nested :t:`[use import]s`. :dp:`fls_iNUBX5fJAI1N` -A :t:`glob import` outside of a :t:`nesting import` without a :t:`common path -prefix` is rejected, but may still be consumed by :t:`[macro]s`. +A :t:`glob import` whose :t:`import path prefix` is empty or consists only of :t:`namespace qualifier` ``::`` is rejected, but may still be consumed by :t:`[macro]s`. :dp:`fls_wB3fVglLOqbZ` It is a static error if two :t:`[glob import]s` import the same :t:`name` in the @@ -1125,7 +1124,7 @@ A :t:`use import` with a single :t:`path segment` expressed as either :t:`keywor When a :t:`path segment` expressed as :t:`keyword` ``super`` is used to import a parent :t:`module`, the imported :t:`entity` shall be subject to a :t:`renaming`. :dp:`fls_aam34hsRmKU2` -The :t:`import path prefix` of a :t:`glob import` shall neither be empty nor consist only of :t:`namespace qualifier` ``::``. An :t:`import path prefix` that selects the :t:`entity` of a :t:`simple import` shall not consist only of :t:`namespace qualifier` ``::``. +An :t:`import path prefix` that selects the :t:`entity` of a :t:`simple import` shall not consist only of :t:`namespace qualifier` ``::``. :dp:`fls_LV94x3HlpBWk` A :t:`simple import` shall not refer to :t:`[enum variant]s` through a :t:`type alias`.