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

Fix type param bounds #385

Merged
merged 6 commits into from
Mar 2, 2025
Merged

Conversation

brasswood
Copy link
Contributor

@brasswood brasswood commented Oct 9, 2024

fixes #384

@kevinmehall
Copy link
Owner

Can you add a test in tests/run-pass for these return types?

@brasswood
Copy link
Contributor Author

How do I check if my test compiles?

@kevinmehall
Copy link
Owner

cargo test will run all tests, or cargo test -- trybuild trybuild=somefile.rs to run only a specific file.

@brasswood
Copy link
Contributor Author

This is WIP, I need to somehow compare a trait object to something else

@kevinmehall
Copy link
Owner

Since your traits all require Debug, you could format!("{:?}", iter.next()) the trait objects and compare the resulting string.

@brasswood
Copy link
Contributor Author

Should users be allowed to write something like grammar assembly<'b, 'input: 'b>() for str? i.e. constrain some lifetime parameter to make sure 'input outlives it? I tried it and it gave me the error:

error: expected one of ",", ">"
   --> tests/run-pass/assembly_ast_dyn_type_param_bounds.rs:110:28
    |
110 | grammar assembly<'b, 'input: 'b>() for str {
    |                            ^

@kevinmehall kevinmehall merged commit 4928a1e into kevinmehall:master Mar 2, 2025
2 checks passed
@kevinmehall
Copy link
Owner

kevinmehall commented Mar 2, 2025

Thanks!

Should users be allowed to write something like grammar assembly<'b, 'input: 'b>() for str? i.e. constrain some lifetime parameter to make sure 'input outlives it?

I think we should allow the :, but I don't think you'll be able to re-declare 'input like that. #299 stops injecting the 'input lifetime, and makes you declare it yourself if you need it, and it could be declared with additional bounds.

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.

Bounds on trait objects and impl traits not parsing
2 participants