Skip to content

Conversation

m4rch3n1ng
Copy link
Contributor

fixes: #234. i have two notes for this:

one: i had to use a prec(1, to resolve conflicts with _type. i could have also just used a _type instead of the prec(1, choice(, but that would have allowed syntax like impl *const u8 and impl impl dyn Trait, which i don't think should be possible.

the conflict
Error when generating parser

Caused by:
    Unresolved conflict for symbol sequence:
    
      '<'  'impl'  identifier  •  '+'  …
    
    Possible interpretations:
    
      1:  '<'  'impl'  (_type  identifier)  •  '+'  …
      2:  '<'  (abstract_type  'impl'  identifier)  •  '+'  …
    
    Possible resolutions:
    
      1:  Specify a higher precedence in `_type` than in the other rules.
      2:  Specify a higher precedence in `abstract_type` than in the other rules.
      3:  Add a conflict for these rules: `_type`, `abstract_type`

two: as a drive-by-fix in 36e527b, i simplified the bounded_type rule, and also made it more correct. previously it would not allow impl use<'a> + 'a + Trait, which it should syntactically according to the reference. i fixed this here, because (at least in my testing) it doesn't actually change anything and i thought it would be a little silly as an extra pr, but i can split it out if you want me to.

as usual, the diff for the rustc test suite (#229):

the diff
--- .tmp/list.txt	2025-02-28 16:16:12.002933806 +0100
+++ .tmp/list.txt.impl-lifetime-first	2025-03-01 00:04:53.211638735 +0100
@@ -167,8 +167,6 @@
 tests/ui/hygiene/trait_items-2.rs
 tests/ui/hygiene/traits-in-scope.rs
 tests/ui/impl-trait/equality-rpass.rs
-tests/ui/implied-bounds/dyn-erasure-no-tait.rs
-tests/ui/implied-bounds/dyn-erasure-tait.rs
 tests/ui/imports/extern-crate-used.rs
 tests/ui/imports/import-glob-crate.rs
 tests/ui/imports/local-modularized-tricky-pass-2.rs
@@ -176,7 +174,6 @@
 tests/ui/inline-const/const-match-pat-range.rs
 tests/ui/inline-const/pat-unsafe.rs
 tests/ui/issues/issue-22471.rs
-tests/ui/issues/issue-26186.rs
 tests/ui/issues/issue-36116.rs
 tests/ui/issues/issue-37051.rs
 tests/ui/issues/issue-37733.rs
@@ -315,8 +312,6 @@
 tests/ui/try-trait/yeet-for-result.rs
 tests/ui/type-alias-impl-trait/closure_parent_substs.rs
 tests/ui/type-alias-impl-trait/issue-57611-trait-alias.rs
-tests/ui/type-alias-impl-trait/issue-58662-coroutine-with-lifetime.rs
-tests/ui/type-alias-impl-trait/issue-58662-simplified.rs
 tests/ui/type/type-alias-bounds.rs
 tests/ui/type_length_limit.rs
 tests/ui/typeck/auxiliary/tdticc_coherence_lib.rs

@m4rch3n1ng m4rch3n1ng force-pushed the impl-lifetime-first branch 2 times, most recently from d7bad75 to 8e18e5c Compare March 6, 2025 00:27
@m4rch3n1ng m4rch3n1ng force-pushed the impl-lifetime-first branch from 8e18e5c to 7b74761 Compare March 6, 2025 08:07
@maxbrunsfeld maxbrunsfeld merged commit e86119b into tree-sitter:master Mar 7, 2025
4 checks passed
@m4rch3n1ng m4rch3n1ng deleted the impl-lifetime-first branch March 7, 2025 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: impl trait bound starting with a lifetime misparsed

2 participants