chain: drop redundant check - #7095
Conversation
52e60e9 to
44c2cc3
Compare
44c2cc3 to
2746838
Compare
|
@matthewhughes934 Not a huge deal, but since we've added the LLM disclosure checkboxes to our PR template it would be nice to see them checked on all PRs going forward. |
|
Also, when referencing issues or PRs for this repo in commit messages it's probably best to use |
Hm, triagebot has a detection/message for that. EDIT: #7098, we just didn't enable it on this repo. |
In the code: `chain_item` is a _child_ in the chain, and not the root, e.g. `1.foo.bar` in `root.1.foo.bar`. So the question is, can a `try!(..)` expression appear there, e.g. `root.try!(something).0`? My conclusion is that it cannot: firstly note `try!` is not a valid identifier (because of the `!`), so working through the possible chain types (see `pop_expr_chain`): * `MethodCallExpression → Expression . PathExprSegment ( CallParams? )` (e.g. `root.some_method()`): `PathExprSegment` starts with a `PathIdentSegment`, starts with a `IDENTIFIER`: `try!` doesn't match * `FieldExpression → Expression . IDENTIFIER` (e.g. `root.sub`): `try!` doesn't match * `TupleIndexingExpression → Expression . TUPLE_INDEX` (e.g. `root.0`): tuple index is repeated decimal digits: `try!` doesn't match * keywords:`.await`, `.use`, `.yield`: `try!` doesn't match Of course a: `try!` can be the _root_ of a chain `try!(foo).bar` is perfectly valid. This fixes an issue: as previously, if the `use_try_shorthand` config was set we would skip over any comments in any children of the chain, so they would be dropped. The added test case covers this situation. Fixes: rust-lang#6121
2746838 to
d4a22f4
Compare
👍 restored that. I have some muscle memory from keeping the PR description in sync with commits where I'll just
If the commit can potentially end up in rust-lang/rust (this is what the repo syncing does I think?). Then I think I should make an effort to disambiguate it there too, but I've update the description/commit for both those things |
| // FIXME: Figure out the way to get a correct span when converting `try!` to `?`. | ||
| let handle_comment = | ||
| !(context.config.use_try_shorthand() || is_tries(comment_snippet.trim())); | ||
| let handle_comment = !is_tries(comment_snippet.trim()); |
There was a problem hiding this comment.
The PR description didn't fully help me understand why this is a redundant check. Can you try to explain it differently?
Also, is it fine to just remove the FIXME comment?
In the code:
chain_itemis a child in the chain, and not the root,e.g.
1.foo.barinroot.1.foo.bar. So the question is, can atry!(..)expression appear there, e.g.root.try!(something).0? Myconclusion is that it cannot: firstly note
try!is not a valididentifier (because of the
!), so working through the possible chaintypes (see
pop_expr_chain):MethodCallExpression → Expression . PathExprSegment ( CallParams? )(e.g.
root.some_method()):PathExprSegmentstarts with aPathIdentSegment, starts with aIDENTIFIER:try!doesn't matchFieldExpression → Expression . IDENTIFIER(e.g.root.sub):try!doesn't match
TupleIndexingExpression → Expression . TUPLE_INDEX(e.g.root.0):tuple index is repeated decimal digits:
try!doesn't match.await,.use,.yield:try!doesn'tmatch
Of course a:
try!can be the root of a chaintry!(foo).barisperfectly valid.
This fixes an issue: as previously, if the
use_try_shorthandconfigwas set we would skip over any comments in any children of the chain,
so they would be dropped. The added test case covers this situation.
Fixes: #6121