Skip to content

Improve placement of use suggestions - #43929

Merged
bors merged 2 commits into
rust-lang:masterfrom
oli-obk:use_placement
Aug 21, 2017
Merged

bors merged 2 commits into
rust-lang:masterfrom
oli-obk:use_placement

Conversation

@oli-obk

@oli-obk oli-obk commented Aug 17, 2017

Copy link
Copy Markdown
Contributor

@estebank estebank left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Love it! The new locations are exactly where they should be. The only wart I see is that by applying these suggestions without any smarts the resulting output would be the following:

use a::A;
struct S;

I don't think we should change the compiler output, I think clients could perform local reformatting to comply with rustfmt instead.

Comment thread src/librustc_resolve/lib.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Space between UseError and {?

Comment thread src/librustc_resolve/lib.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn't the following slightly easier to follow?

    fn visit_mod(&mut self,
                 module: &'tcx ast::Mod,
                 _: Span,
                 _: &[ast::Attribute],
                 node_id: NodeId) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Rustfmt has my version as the new style and I prefer it, too, but I can change it to the other style to fit more into what's still more prominent in rustc.

@oli-obk

oli-obk commented Aug 17, 2017

Copy link
Copy Markdown
Contributor Author

The only wart I see is that by applying these suggestions without any smarts the resulting output would be the following:

use a::A;
struct S;

I don't think we should change the compiler output, I think clients could perform local reformatting to comply with rustfmt instead.

I'm confused... so you want the final output to be use a::A;struct S;?

@estebank

estebank commented Aug 17, 2017 •

Copy link
Copy Markdown
Contributor

I'd want the final output to be

use a::A;

struct S;

But wouldn't change rustc for it, as it makes the cli output worse.

@oli-obk

oli-obk commented Aug 17, 2017

Copy link
Copy Markdown
Contributor Author

But wouldn't change rustc for it, as it makes the cli output worse.

Oh I already have a hack that makes sure the cli is fine ;) Adding another newline to the suggestion output in case the following item is not a use would definitely be possible.

@nrc

nrc commented Aug 21, 2017

Copy link
Copy Markdown
Member

@bors: r+

@bors

bors commented Aug 21, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit 8f56322 has been approved by nrc

@bors

bors commented Aug 21, 2017

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 8f56322 with merge 06bf94a...

bors added a commit that referenced this pull request Aug 21, 2017
Improve placement of `use` suggestions

r? @nrc

cc @estebank @Mark-Simulacrum

fixes #42835
fixes #42548
fixes #43769
@bors

bors commented Aug 21, 2017

Copy link
Copy Markdown
Collaborator

☀️ Test successful - status-appveyor, status-travis
Approved by: nrc
Pushing 06bf94a to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants