Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accurately portray raw identifiers in error messages #67010

Merged
merged 3 commits into from
Dec 6, 2019

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Dec 4, 2019

When refering to or suggesting raw identifiers, refer to them with r#.

Fix #65634.

When refering to or suggesting raw identifiers, refer to them with `r#`.

Fix rust-lang#65634.
@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 4, 2019
@Centril
Copy link
Contributor

Centril commented Dec 4, 2019

r? @Centril r=me rollup with ^-- fixed.

@Centril Centril assigned Centril and unassigned nikomatsakis Dec 4, 2019
@Centril Centril 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 Dec 4, 2019
@rust-highfive

This comment has been minimized.

@estebank
Copy link
Contributor Author

estebank commented Dec 4, 2019

@bors r=Centril rollup

@bors
Copy link
Contributor

bors commented Dec 4, 2019

📌 Commit 0103308 has been approved by Centril

@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 Dec 4, 2019
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Dec 5, 2019
Accurately portray raw identifiers in error messages

When refering to or suggesting raw identifiers, refer to them with `r#`.

Fix rust-lang#65634.
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Dec 5, 2019
Accurately portray raw identifiers in error messages

When refering to or suggesting raw identifiers, refer to them with `r#`.

Fix rust-lang#65634.
RalfJung added a commit to RalfJung/rust that referenced this pull request Dec 5, 2019
Accurately portray raw identifiers in error messages

When refering to or suggesting raw identifiers, refer to them with `r#`.

Fix rust-lang#65634.
bors added a commit that referenced this pull request Dec 5, 2019
Rollup of 13 pull requests

Successful merges:

 - #66405 (Tweak `ObligationForest` `NodeState`s)
 - #66730 (remove dependency from libhermit)
 - #66764 (Tweak wording of `collect()` on bad target type)
 - #66899 (Standard library support for riscv64gc-unknown-linux-gnu)
 - #66900 (Clean up error codes)
 - #66974 ([CI] fix the `! isCI` check in src/ci/run.sh)
 - #66979 (Add long error for E0631 and update ui tests.)
 - #67005 (capitalize Rust)
 - #67010 (Accurately portray raw identifiers in error messages)
 - #67011 (Include a span in more `expected...found` notes)
 - #67017 (cleanup long error explanations)
 - #67021 (Fix docs for formatting delegations)
 - #67041 (add ExitStatusExt into prelude)

Failed merges:

r? @ghost
Centril added a commit to Centril/rust that referenced this pull request Dec 5, 2019
Accurately portray raw identifiers in error messages

When refering to or suggesting raw identifiers, refer to them with `r#`.

Fix rust-lang#65634.
bors added a commit that referenced this pull request Dec 5, 2019
Rollup of 9 pull requests

Successful merges:

 - #66710 (weak-into-raw: Clarify some details in Safety)
 - #66863 (Check break target availability when checking breaks with values)
 - #67002 (Fix documentation of pattern for str::matches())
 - #67005 (capitalize Rust)
 - #67010 (Accurately portray raw identifiers in error messages)
 - #67011 (Include a span in more `expected...found` notes)
 - #67044 (E0023: handle expected != tuple pattern type)
 - #67045 (rustc_parser: cleanup imports)
 - #67055 (Make const-qualification look at more `const fn`s)

Failed merges:

r? @ghost
@bors bors merged commit 0103308 into rust-lang:master Dec 6, 2019
Copy link
Contributor

@olegnn olegnn left a comment

Choose a reason for hiding this comment

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

Some hints with raw identifiers are still incorrect.

|
LL | fn r#struct(&self) {
| ^^^^^^^^^^^^^^^^^^
= help: to disambiguate the method call, write `async::r#struct(r#fn {})` instead
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be r#async::r#struct(r#fn {}) instead of async::r#struct(r#fn {})

LL | r#fn {}.r#struct();
| ^^^^^^^^ multiple `r#struct` found
|
note: candidate #1 is defined in an impl of the trait `async` for the type `r#fn`
Copy link
Contributor

Choose a reason for hiding this comment

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

r#async

|
LL | fn r#struct(&self) {
| ^^^^^^^^^^^^^^^^^^
= help: to disambiguate the method call, write `await::r#struct(r#fn {})` instead
Copy link
Contributor

Choose a reason for hiding this comment

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

r#await::r#struct(r#fn {})

@estebank
Copy link
Contributor Author

estebank commented Dec 6, 2019

@olegnn it isn't clear from the test (but tested locally, just forgot to add the test file) that this is because the test is running as edition 2015, where await is not a keyword, so this is correct. If the test had a header with // edition:2018 the output would match what you expect.

@olegnn
Copy link
Contributor

olegnn commented Dec 6, 2019

Sorry, I didn't notice that it's edition 2015. But anyway, if item is declared with r# prefix, shouldn't it be mentioned the same way?

@estebank
Copy link
Contributor Author

estebank commented Dec 6, 2019

We don't keep track of whether an identifier was raw or not, we currently infer it from the fact that they couldn't be written any other way (if we have a struct called struct, it could only be a raw ident). I think this is fine, we only want to make people aware of raw idents if there's no other option. Only people writing ffi or macros should even need to care about these :)

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Feb 25, 2020
…crum

Deduplicate identifier printing a bit

rust-lang#67010 introduced a couple more subtly different ways to print an identifier.
This PR attempts to restore the order.

The most basic identifier printing interface is `Formatter`-based now, so `String`s are not allocated unless required.

r? @Mark-Simulacrum
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Feb 26, 2020
…crum

Deduplicate identifier printing a bit

rust-lang#67010 introduced a couple more subtly different ways to print an identifier.
This PR attempts to restore the order.

The most basic identifier printing interface is `Formatter`-based now, so `String`s are not allocated unless required.

r? @Mark-Simulacrum
@estebank estebank deleted the raw-idents branch November 9, 2023 05:17
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect compiler hints for traits with methods defined using raw identifiers
6 participants