-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Remove type ascription from parser and diagnostics #109128
Remove type ascription from parser and diagnostics #109128
Conversation
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
ping @Nilstrieb |
Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt |
3ecc00e
to
466fb66
Compare
This comment has been minimized.
This comment has been minimized.
466fb66
to
0ac6fae
Compare
This comment has been minimized.
This comment has been minimized.
0ac6fae
to
83bb0e0
Compare
This comment has been minimized.
This comment has been minimized.
a4f74c6
to
d0b2fc9
Compare
Have not had a chance to review in detail, but given the changes to expected output of formatting tests in d0b2fc96f919dd4a923ce5ea7538a82fec5e2bdc I want t-rustfmt to have an opportunity to review before merging to ensure the currently proposed changes in this PR do not contain something that would violate rustfmt's formatting stability guarantee |
sure, I checked the diff, and we can not support macro with ascription syntax now. |
Understood, and don't mean to imply there's any issues. Just leaving a note so that this doesn't get merged before we get an opportunity to review |
This comment has been minimized.
This comment has been minimized.
I don't have much experience with how to run the
I got this error: dyld[10473]: Library not loaded: @rpath/libstd-8c92ab8e515128e4.dylib
Referenced from: <2F10C189-2C7F-3447-943C-6509EEC9465A> /Users/yukang/rust/build/aarch64-apple-darwin/stage1-tools-bin/rustfmt
Reason: tried: '/Users/yukang/rust/build/aarch64-apple-darwin/stage1/lib/libstd-8c92ab8e515128e4.dylib' (no such file), .......
[1] 10473 abort ./build/aarch64-apple-darwin/stage1-tools-bin/rustfmt I found the file libstd-8c92ab8e515128e4.dylib located at: .//build/aarch64-apple-darwin/stage1-std/aarch64-apple-darwin/release/deps/libstd-8c92ab8e515128e4.dylib and I workaround it in this naive way: export DYLD_LIBRARY_PATH="$(rustc +dev --print sysroot)/lib"
cp .//build/aarch64-apple-darwin/stage1-std/aarch64-apple-darwin/release/deps/libstd-8c92ab8e515128e4.dylib /Users/yukang/rust/build/aarch64-apple-darwin/stage1/lib I guess there may be a right way for it? rustup component add rustfmt |
@chenyukang there's not a supported way to do this today: #102010 |
☔ The latest upstream changes (presumably #109010) made this pull request unmergeable. Please resolve the merge conflicts. |
0e8b6cd
to
dbf9825
Compare
Apologies for the late follow up but no concerns from my end wrt rustfmt changes. The diff looked odd at first blush but the reasoning became clear after refreshing my memory on part of the test contents that weren't part of the diff. |
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `:` | ||
--> $DIR/type-ascription-precedence.rs:27:7 | ||
| | ||
LL | &(S: &S); | ||
| ^ expected `&S`, found `S` | ||
LL | &S: &S; | ||
| ^ expected one of 8 possible tokens |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it makes sense to leave enough logic in the parser to detect at least ::
-> :
and ;
-> :
typos (the later is caught in the test below, but it isn't triggering here, maybe because it is in the same line?). We might also want to leave enough for type ascription parsing with a hard error saying "this used to be parsed but it no longer is" but that is much lower priority (so we can disregard my thought there).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can disregard this, the other positive tests are catching it, so we should be ok.
| | ||
= note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` | ||
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we soften the wording here with something like "if you meant to annotate an expression with a type, the type ascription syntax has been removed". Someone who encounters the note without knowing what it was might be left a bit baffled.
error: expected identifier, found `:` | ||
--> $DIR/type-ascription-instead-of-let.rs:5:13 | ||
| | ||
LL | temp: i32 = fun(5i32); | ||
| ^^^^ | ||
| | | ||
| not found in this scope | ||
| help: maybe you meant to write an assignment here: `let temp` | ||
| ^ expected identifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird that we don't suggest let
here :-/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current
help: maybe you meant to write an assignment here: `let temp`
is produced at here:
"maybe you meant to write an assignment here", |
but the function type_ascription_suggestion
is removed.
So it's a preexisting issue, now we only support this scenario:
4 | a = 1;
| ^
|
help: you might have meant to introduce a new binding
|
4 | let a = 1;
| +++
I think we should extend to the scenario of a: i32 = 1
, I will fix it in another PR.
@@ -29,5 +18,5 @@ LL - bar(baz: $rest) | |||
LL + bar(: $rest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preexisting, note to self: this suggestion is broken
This comment was marked as outdated.
This comment was marked as outdated.
@bors rollup=iffy aaaa... |
@bors r=estebank |
💡 This pull request was already approved, no need to approve it again.
|
☀️ Test successful - checks-actions |
Finished benchmarking commit (98c33e4): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 655.687s -> 656.873s (0.18%) |
@estebank can finally be in peace 😌 |
@rustbot label: +perf-regression-triaged |
…tion, r=estebank Remove type ascription from parser and diagnostics Mostly based on rust-lang#106826 Part of rust-lang#101728 r? `@estebank`
…ompiler-errors Suggest struct when we get colon in fileds in enum A follow-up fix for rust-lang#109128 From: rust-lang#109128 (comment) r? `@estebank`
…ilstrieb Suggest let for possible binding with ty Origin from rust-lang#109128 (comment) r? `@Nilstrieb`
…tion, r=estebank Remove type ascription from parser and diagnostics Mostly based on rust-lang#106826 Part of rust-lang#101728 r? `@estebank`
Mostly based on #106826
Part of #101728
r? @estebank