Repository navigation
Tracking Issue for "More Qualified Paths" #86935
Copy link
Copy link
Open
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-more_qualified_paths`#![feature(more_qualified_paths)]``#![feature(more_qualified_paths)]`S-tracking-ready-to-stabilizeStatus: This is ready to stabilize; it may need a stabilization report and a PRStatus: This is ready to stabilize; it may need a stabilization report and a PRT-langRelevant to the language teamRelevant to the language team
Description
This is a tracking issue for the "more qualified paths" feature. This feature originally grew out of a bug report #79658 where structs with qualified paths could not be constructed or used in patterns.
For instance:
fn main() {
let <Foo as MyTrait>::Assoc { a } = <Foo as MyTrait>::Assoc { a: 2 };
// The above would previously not parse.
assert!(a == 2);
}
struct StructStruct {
a: i8,
}
trait MyTrait {
type Assoc;
}
struct Foo;
impl MyTrait for Foo {
type Assoc = StructStruct;
}See the implementation PR #80080 for more detailed discussion.
The feature gate for the issue is #![feature(more_qualified_paths)].
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
- Implement the feature Allow qualified paths in struct construction (both expressions and patterns) #80080
- Adjust documentation (see instructions on rustc-dev-guide)
- Stabilization PR (see instructions on rustc-dev-guide)
Unresolved Questions
Implementation history
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-more_qualified_paths`#![feature(more_qualified_paths)]``#![feature(more_qualified_paths)]`S-tracking-ready-to-stabilizeStatus: This is ready to stabilize; it may need a stabilization report and a PRStatus: This is ready to stabilize; it may need a stabilization report and a PRT-langRelevant to the language teamRelevant to the language team
Activity
Rollup merge of rust-lang#86937 - rylev:tracking-more-qualified-paths…
Aaron1011 commentedon Mar 6, 2022
cc @petrochenkov: It looks like this might interact with my higher-ranked closure RFC: rust-lang/rfcs#3216 (comment)
Since only lifetimes can be specified within a
for<>binder (which I doubt will ever change, since lifetimes are the only generic 'kind' that we can erase), I think we can still disambiguate between the two cases by checking for'token immediately following thefor <- a qualified path cannot start with a', and afor<>binder can only start with a'.Does that sound correct to you?
comex commentedon Mar 7, 2022
Personally I'm really hoping to someday see closures with generic type parameters in Rust, similar to what exists in C++. There's no need to erase the type parameter; you "just" desugar to a generic
Fn*impl, so, e.g.,would be like
Though, this is of limited use unless you also have higher-ranked trait bounds, like
But that too is something I would like to see someday.
petrochenkov commentedon Mar 7, 2022
@Aaron1011
This ambiguity already exists in the language in a few places, like
impl <T> :: A {}and some others, and we have some disambiguation rules for this case.I think we need to reuse the same rules for the
for<...>closure case too, without introducing more special cases.rodrimati1992 commentedon Jun 4, 2022
Lack of stable support for this can be worked around with a simple type alias
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=92460c3c1d0931dc9fac47d8e9877a51
jhpratt commentedon Jul 25, 2022
Where is this actually wanted? It seems extremely convoluted. Surely if you know the names of the fields, you know the name of the type? I was amazed to see this is already possible via the trivial workaround, and think this should absolutely not be encouraged.
Aaron1011 commentedon Jul 25, 2022
The main use-case would be macros (for example, if you want to assert a type built from a user-provided type). However, I don't know if there are currently any macros in the wild that would benefit from this.
tyranron commentedon Jul 25, 2022
The situation where we name a concrete type via an associative type is quite regular in macros, yes.
At least,
#[cucumber::when]does.joshtriplett commentedon Jul 27, 2022
This seems like it may be ready to stabilize. Could we get a stabilization report and documentation PR?
jhpratt commentedon Jul 27, 2022
Why is the proc macro unable to know the name of the concrete type?
15 remaining items
Implement client-side trait methods for action messages
Action message support (#417)
Action message support (#417)
Action message support (#417)
Action message support (#417)
Action message support (#417)
Action message support (#417)
Action message support (#417)
Action message support (#417)
Action message support (#417)
Action message support (#417)
joshlf commentedon Apr 8, 2025
Are there any blockers? I'd be happy to put up a stabilization PR.
Implement client-side trait methods for action messages
victorteokw commentedon Jul 24, 2025
ChayimFriedman2 commentedon Mar 31, 2026
Just FYI this feature was merged into r-a right now.