Skip to content

Conversation

@Veykril
Copy link
Member

@Veykril Veykril commented Sep 2, 2021

j1OjBt5Nca

Fixes #9866

@matklad
Copy link
Contributor

matklad commented Sep 4, 2021

We really need to up our testing game here :-) The fact that the easiest way to test this is to write a #[test] instead of writing a #[test] points at the proc-macro shaped hole in our testing infra.

My current thinking is that running fully-fledged proc macros inside tests is not a good idea. I think it would be long-term beneficial if "every test runs in a single, static binary" were an invariant of our code-base.

In the base_db layer, procedural macros are already abstracted away as an arbitrary TokenStream -> TokenStream transformation. So I think what we want to do is to add a dummy, test impl of this trait with some example macros, and use that to write most of the tests. The actual proc macro loading cound then be delegated to a few heavy tests I think.

@Veykril
Copy link
Member Author

Veykril commented Sep 4, 2021

Ye we should definitely prioritize testing for now.

Regarding async_trait not working here, I imagine(not 100% sure) that might be due to the syn parser being used in the attribute failing to parse the item input when typing in there... so the expansion fails, this of course works fine for the simple #[test] attribute I used for testing since we just feed back the input item without validating 😬 Now I fear that we probably have to do this some other way as most attributes if not all will fail in this manner as they expect fully correct syntax as input.

@matklad
Copy link
Contributor

matklad commented Sep 4, 2021

It doesn't work even for complete syntax self.pref;, so I think that's not the issue

@Veykril Veykril marked this pull request as draft September 12, 2021 21:26
@Veykril Veykril force-pushed the attr-compl branch 2 times, most recently from 6d83d5a to d143462 Compare September 13, 2021 17:16
@Veykril Veykril marked this pull request as ready for review September 13, 2021 22:16
@Veykril
Copy link
Member Author

Veykril commented Sep 13, 2021

bors r+

@bors
Copy link
Contributor

bors bot commented Sep 13, 2021

@bors bors bot merged commit 6eecd84 into rust-lang:master Sep 13, 2021
@Veykril Veykril deleted the attr-compl branch September 13, 2021 22:31
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.

Completion does not work in attribute macros

2 participants