Detect async visibility wrong order, async pub#76447
Conversation
|
(rust_highfive has picked a reviewer for you, use r? to override) |
|
niko is probably the wrong reviewer for this maybe r? @estebank |
estebank
left a comment
There was a problem hiding this comment.
I would prefer to make this change to parse_fn_front_matter:
rust/compiler/rustc_parse/src/parser/item.rs
Lines 1566 to 1594 in 0e2c128
That way the parser can recover more gracefully and you also have the spans for each element to work with more easily. You could also check for other permutations, like async const pub fn and unsafe async fn.
There was a problem hiding this comment.
This is weird, but at least users can know that visibility is duplicated. We could add a check but I probably don't want to do it in this patch.
|
What's left for another patch
Duplicate visibility (this one is obvious unlike the rest) |
2e9de38 to
2c6ae2d
Compare
tidy error: /checkout/src/test/ui/parser/default.rs:24: line longer than 100 chars
tidy error: /checkout/src/test/ui/parser/duplicate-visibility.rs:5: line longer than 100 charsI don't know how to fix this without using |
|
@estebank Do you know how should I fix this? |
|
I would add the |
|
@estebank Can you please help to review again? |
src/test/ui/parser/default.stderr
Outdated
There was a problem hiding this comment.
Only one nitpick: this suggestion is incorrect. The span should point at default pub and the suggestion content should be pub default.
There was a problem hiding this comment.
pub default? Can you show me an example output you mentioned? I don't think default pub should be there, it should be pub only right?
There was a problem hiding this comment.
Actually, it should be only default, as pub is implied, but yes the correct syntactic order is pub default fn foo().
There was a problem hiding this comment.
How should I check that? It doesn't seemed to be part of parse_fn_front_matter but rather in parse_fn_kind, I think it is related to
} else if self.check_fn_front_matter() {
// FUNCTION ITEM
let (ident, sig, generics, body) = self.parse_fn(attrs, req_name, lo)?;
(ident, ItemKind::Fn(def(), sig, generics, body))It feels weird that defaultness is not parsed as part of parse_fn_front_matter.
I feel lazy to do this, requires cleaning on other parts, @estebank do you want to do it?
There was a problem hiding this comment.
This should be fixed. I didn't know this is a regression created by the patch I made.
|
ping from triage: |
|
I haven't get myself to work on the last thing the reviewer mentioned. I think it may be a bit different from where I worked on this, it would be good if @estebank could point out where needs to be changed, I feel less motivated to work on the remaining parts either since this may need changes in other parts. If @estebank want to work on this then he can take this up, otherwise I can take a look at it this weekend. |
|
@pickfire can you resolve the conflict ? will be faster as we can get a review and then merge it quickly |
This comment has been minimized.
This comment has been minimized.
|
@Dylan-DPC done |
|
☔ The latest upstream changes (presumably #82517) made this pull request unmergeable. Please resolve the merge conflicts. |
|
triage: @pickfire unfortunately there's another merge conflict. |
|
@rustbot label: -S-waiting-on-review +S-waiting-on-author |
|
@JohnCSimon Do I have to keep on updating it? I am thinking of getting a review first before updating it, I have updated a few times in the past for merge conflict but still no review. |
|
@pickfire better to, makes it easier to merge if the review is green after that |
Redirects `const? async? unsafe? pub` to `pub const? async? unsafe?`. Fix rust-lang#76437
async-pub check created a regression for default
|
@pickfire my apologies. I believed I could get around this to point you towards an alternative way of doing this, but there's no reason not to merge this as is and potentially implement my idea later. So it isn't lost to the corners of my mind, my thinking here was to make the parser advance through tokens that can be part of the fn front matter ( @bors r+ |
|
📌 Commit 21c1574 has been approved by |
|
☀️ Test successful - checks-actions |
Ah, but it seems like something that we aren't going to need. Why would someone duplicate the header? I don't see any reason someone would do so. Order I can understand if they are wrong, but maybe duplicating them is too much I believe. Maybe I am wrong, if people copy pasted it could happen, but we may need extra care not to slow down the usual path. |
Partially address #76437.