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

Allow multiple modules from the same crate in fixtures #8302

Closed

Conversation

SomeoneToIgnore
Copy link
Contributor

A tiny step towards #6633

As discussed in Zulip, we would need to have a generated code for the completions benchmark.
To better represent a real project, we'd better allow to specify multiple modules in a crate within a single fixture.

@SomeoneToIgnore
Copy link
Contributor Author

changelog internal

bors r+

bors bot added a commit that referenced this pull request Apr 2, 2021
8302: Allow multiple modules from the same crate in fixtures r=SomeoneToIgnore a=SomeoneToIgnore

A tiny step towards #6633

As discussed in [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Completion.20benchmarks), we would need to have a generated code for the completions benchmark.
To better represent a real project, we'd better allow to specify multiple modules in a crate within a single fixture.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
@bors
Copy link
Contributor

bors bot commented Apr 2, 2021

Build failed:

let dep = CrateName::normalize_dashes(&dep);
crate_deps.push((crate_name.clone(), dep))
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, why do we need to change anything here at all? Just the following diff seem to work for me:

diff --git a/crates/ide_assists/src/handlers/auto_import.rs b/crates/ide_assists/src/handlers/auto_import.rs
index 5ccd7f7a2..e04711067 100644
--- a/crates/ide_assists/src/handlers/auto_import.rs
+++ b/crates/ide_assists/src/handlers/auto_import.rs
@@ -918,6 +918,9 @@ fn main() {
             auto_import,
             r"
 //- /lib.rs crate:dep
+pub mod formatters;
+
+//- /formatters.rs
 pub struct FMT;
 pub struct fmt;
 
@@ -926,7 +929,7 @@ fn main() {
     FMT$0;
 }
 ",
-            r"use dep::FMT;
+            r"use dep::formatters::FMT;
 
 fn main() {
     FMT;

I suspect that we just support multifie crates in fixtures without any any extra actions required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, so I've completely misunderstood the //- fixture format.
Thanks for stopping me 🙂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might make sense to clarify the docs then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and reread the updated version finally.

Copy link
Contributor Author

@SomeoneToIgnore SomeoneToIgnore Apr 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The culprit was the fact that there are two places documenting fixtures in the code and the most elaborative description was not near Fixture struct 😄
I've united them: #8382

@SomeoneToIgnore SomeoneToIgnore deleted the multimodule-tests branch April 5, 2021 11:54
bors bot added a commit that referenced this pull request Apr 6, 2021
8382: Make Fixture docs more accessible and fix small doc issues r=SomeoneToIgnore a=SomeoneToIgnore

Follow up of #8302 (comment)

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
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.

2 participants