Skip to content

Conversation

fpdotmonkey
Copy link
Contributor

No description provided.

@rustbot
Copy link
Collaborator

rustbot commented Jun 18, 2025

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 18, 2025
@fpdotmonkey fpdotmonkey force-pushed the doc/as-fully-qualified-syntax branch from 7cfd0dd to a2d247b Compare June 18, 2025 13:32
/// _fully qualified path_, a means of clarifying ambiguous method calls, constants, and types.
/// If you have a type which implements two traits with identical method names (e.g.
/// `Into<u32>::into` and `Into<u64>::into`), you can clarify which method you'll use with
/// `<MyThing as Into<u32>>::into(my_thing)`. This is quite verbose, but fortunately, Rust's type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any other std traits where this is commonly needed? A small downside with this example is that this is something that should just be written u32::from(my_thing) 🙂

Copy link
Contributor Author

@fpdotmonkey fpdotmonkey Jun 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be a thing with Debug vs Display::fmt. That said, <Self as fmt::Debug>::fmt(self, f) is semantically identical, longer, and weirder than fmt::Debug::fmt(self, f). io::Write::write_fmt and fmt::Write::write_fmt have the same problem.

Into<T> is nice since it's reasonably likely that users will encounter a message from rustc that they should use the fully-qualified path as in these docs (though by all rights, it should suggest that you should use T::from(self)).

An other option would be to make a contrived exampled like is done in the Rust book. E.g.,

struct Person;

trait MetalHead {
    fn head_bang();
}
trait SalaryWorker {
    fn head_bang();
}
impl MetalHead for Person { ... }
impl SalaryWorker for Person { ... }

// 9 to 5
<Person as SalaryWorker>::head_bang();
// 5 to 9
<Person as MetalHead>::head_bang();

But of course coming up with a more useful example is hard since associated items don't usually overlap and there's usually sufficient type information to remove the ambiguity this doc is trying to highlight. The optimal example would be either a pair of trait methods that return a generic type like Into::<T>::into, or a pair of static trait methods. Short of what's here already, I can't find anything like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed it so there's a footnote saying that it'd be better to use T::from(my_thing) and that the example is imperfect.

Comment on lines 28 to 29
/// _fully qualified path_, a means of clarifying ambiguous method calls, constants, and types.
/// If you have a type which implements two traits with identical method names (e.g.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small nit.

Suggested change
/// _fully qualified path_, a means of clarifying ambiguous method calls, constants, and types.
/// If you have a type which implements two traits with identical method names (e.g.
/// _fully qualified path_, a means of clarifying ambiguous associated items. For example,
/// if you have a type which implements two traits with identical method names (e.g.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to make this change, but isn't this a bit less useful? As it was, it tells you exactly which syntactic objects this syntax can be used with, whereas the change demands that you know about the associated item abstraction. Realistically, if I'm someone who's reading the keyword docs, I'm probably a rust beginner and probably not familiar with this abstraction.

Perhaps "a means of clarifying ambiguous associated items, i.e. methods, constants, and types. For example," would be a good compromise?

Copy link
Member

@fmease fmease Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'm not the primary reviewer) if you end up listing the three kinds of associated item, please substitute method with function or with function (includes methods). Methods are only a subset of associated functions.

@ibraheemdev
Copy link
Member

r=me after the nit.

@ibraheemdev ibraheemdev added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 25, 2025
@fpdotmonkey fpdotmonkey force-pushed the doc/as-fully-qualified-syntax branch 2 times, most recently from 054ee36 to 15f73ab Compare June 27, 2025 10:52
@ibraheemdev
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jun 27, 2025

📌 Commit 15f73ab has been approved by ibraheemdev

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 27, 2025
@fmease
Copy link
Member

fmease commented Jun 27, 2025

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 27, 2025
@fpdotmonkey fpdotmonkey force-pushed the doc/as-fully-qualified-syntax branch 2 times, most recently from c7fd35f to 0de43e0 Compare July 1, 2025 12:40
@ibraheemdev
Copy link
Member

r? fmease

@rustbot
Copy link
Collaborator

rustbot commented Jul 1, 2025

fmease is currently at their maximum review capacity.
They may take a while to respond.

@fmease fmease added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 17, 2025
@fpdotmonkey fpdotmonkey force-pushed the doc/as-fully-qualified-syntax branch from 0de43e0 to 6ccea07 Compare October 3, 2025 14:26
@rustbot

This comment has been minimized.

@fpdotmonkey fpdotmonkey force-pushed the doc/as-fully-qualified-syntax branch from 6ccea07 to 1485e78 Compare October 3, 2025 14:36
@rustbot
Copy link
Collaborator

rustbot commented Oct 3, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@fmease
Copy link
Member

fmease commented Oct 3, 2025

@bors r=ibraheemdev,fmease

@bors
Copy link
Collaborator

bors commented Oct 3, 2025

📌 Commit 1485e78 has been approved by ibraheemdev,fmease

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 3, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Oct 4, 2025
…-syntax, r=ibraheemdev,fmease

Document fully-qualified syntax in `as`' keyword doc
bors added a commit that referenced this pull request Oct 4, 2025
Rollup of 14 pull requests

Successful merges:

 - #142670 (Document fully-qualified syntax in `as`' keyword doc)
 - #144908 (Fix doctest output json)
 - #145685 (add CloneFromCell and Cell::get_cloned)
 - #146330 (Bump unicode_data and printables to version 17.0.0)
 - #146451 (Fix atan2 inaccuracy in documentation)
 - #146479 (add mem::conjure_zst)
 - #147190 (std: `sys::net` cleanups)
 - #147245 (only replace the intended comma in pattern suggestions)
 - #147251 (Do not assert that a change in global cache only happens when concurrent)
 - #147269 (Add regression test for 123953)
 - #147277 (Extract common logic for iterating over features)
 - #147280 (Return to needs-llvm-components being info-only)
 - #147292 (Respect `-Z` unstable options in `rustdoc --test`)
 - #147300 (Add xtensa arch to object file creation)

r? `@ghost`
`@rustbot` modify labels: rollup
Zalathar added a commit to Zalathar/rust that referenced this pull request Oct 4, 2025
…-syntax, r=ibraheemdev,fmease

Document fully-qualified syntax in `as`' keyword doc
Zalathar added a commit to Zalathar/rust that referenced this pull request Oct 4, 2025
…-syntax, r=ibraheemdev,fmease

Document fully-qualified syntax in `as`' keyword doc
Zalathar added a commit to Zalathar/rust that referenced this pull request Oct 4, 2025
…-syntax, r=ibraheemdev,fmease

Document fully-qualified syntax in `as`' keyword doc
Zalathar added a commit to Zalathar/rust that referenced this pull request Oct 4, 2025
…-syntax, r=ibraheemdev,fmease

Document fully-qualified syntax in `as`' keyword doc
bors added a commit that referenced this pull request Oct 4, 2025
Rollup of 14 pull requests

Successful merges:

 - #142670 (Document fully-qualified syntax in `as`' keyword doc)
 - #145685 (add CloneFromCell and Cell::get_cloned)
 - #146330 (Bump unicode_data and printables to version 17.0.0)
 - #146451 (Fix atan2 inaccuracy in documentation)
 - #146479 (add mem::conjure_zst)
 - #146874 (compiler: Hint at multiple crate versions if trait impl is for wrong ADT )
 - #147117 (interpret `#[used]` as `#[used(compiler)]` on illumos)
 - #147190 (std: `sys::net` cleanups)
 - #147251 (Do not assert that a change in global cache only happens when concurrent)
 - #147280 (Return to needs-llvm-components being info-only)
 - #147288 (compiletest: Make `DirectiveLine` responsible for name/value splitting)
 - #147309 (Add documentation about unwinding to wasm targets)
 - #147315 (bless autodiff batching test)
 - #147323 (Fix top level ui tests check in tidy)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 4, 2025
…-syntax, r=ibraheemdev,fmease

Document fully-qualified syntax in `as`' keyword doc
bors added a commit that referenced this pull request Oct 4, 2025
Rollup of 11 pull requests

Successful merges:

 - #142670 (Document fully-qualified syntax in `as`' keyword doc)
 - #145685 (add CloneFromCell and Cell::get_cloned)
 - #146330 (Bump unicode_data and printables to version 17.0.0)
 - #146451 (Fix atan2 inaccuracy in documentation)
 - #146479 (add mem::conjure_zst)
 - #147117 (interpret `#[used]` as `#[used(compiler)]` on illumos)
 - #147190 (std: `sys::net` cleanups)
 - #147251 (Do not assert that a change in global cache only happens when concurrent)
 - #147280 (Return to needs-llvm-components being info-only)
 - #147288 (compiletest: Make `DirectiveLine` responsible for name/value splitting)
 - #147315 (bless autodiff batching test)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 4, 2025
…-syntax, r=ibraheemdev,fmease

Document fully-qualified syntax in `as`' keyword doc
bors added a commit that referenced this pull request Oct 4, 2025
Rollup of 10 pull requests

Successful merges:

 - #142670 (Document fully-qualified syntax in `as`' keyword doc)
 - #145685 (add CloneFromCell and Cell::get_cloned)
 - #146330 (Bump unicode_data and printables to version 17.0.0)
 - #146451 (Fix atan2 inaccuracy in documentation)
 - #146479 (add mem::conjure_zst)
 - #147117 (interpret `#[used]` as `#[used(compiler)]` on illumos)
 - #147190 (std: `sys::net` cleanups)
 - #147251 (Do not assert that a change in global cache only happens when concurrent)
 - #147280 (Return to needs-llvm-components being info-only)
 - #147315 (bless autodiff batching test)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f837cfe into rust-lang:master Oct 4, 2025
10 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Oct 4, 2025
rust-timer added a commit that referenced this pull request Oct 4, 2025
Rollup merge of #142670 - fpdotmonkey:doc/as-fully-qualified-syntax, r=ibraheemdev,fmease

Document fully-qualified syntax in `as`' keyword doc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants