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

Better underline for E0057,E0060,E0061 #36222

Merged
merged 1 commit into from
Oct 7, 2016

Conversation

acrrd
Copy link
Contributor

@acrrd acrrd commented Sep 2, 2016

Fix #35214
Part of #35233

r? @jonathandturner

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @jonathandturner (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@@ -2449,6 +2449,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let mut expected_arg_tys = expected_arg_tys;
let expected_arg_count = fn_inputs.len();

let sp_args = if args.len() > 0 {
Span { lo: args[0].span.lo, ..args[args.len()-1].span}
Copy link
Contributor

Choose a reason for hiding this comment

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

Sadly, we can't safely mix spans like this because some arguments may come from incompatible locations (like from macros).

@sophiajt
Copy link
Contributor

sophiajt commented Sep 2, 2016

I added a comment here about not being able to mix spans directly.

Instead, we'll need to use the span information that's already been calculated, or add it when it's safe to add. If the latter is required, you should chat with some people in #rust-internals and see if they have ideas of how best to add it.

@acrrd
Copy link
Contributor Author

acrrd commented Sep 6, 2016

I cannot find any usable span, I'm asking on irc.

@acrrd
Copy link
Contributor Author

acrrd commented Sep 6, 2016

This is what I can achieve with a MultiSpan constructed from the args span
selection_002

@bors
Copy link
Contributor

bors commented Sep 7, 2016

☔ The latest upstream changes (presumably #36303) made this pull request unmergeable. Please resolve the merge conflicts.

@sophiajt
Copy link
Contributor

sophiajt commented Sep 7, 2016

@nrc - is it okay to merge spans if those spans are on the same line? See the above screenshot. It seems like there are cases we could safely merge.

vec!(sp)
};

fn parameter_count_error<'tcx>(sess: &Session, spans: Vec<Span>, fn_inputs: &[Ty<'tcx>],
Copy link
Member

@KiChjang KiChjang Sep 8, 2016

Choose a reason for hiding this comment

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

Can we use an array/slice for spans instead of a Vec here?

Copy link
Contributor Author

@acrrd acrrd Sep 8, 2016

Choose a reason for hiding this comment

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

The field of MultiSpan is a Vec so we have to construct a Vec somewhere.

@sophiajt
Copy link
Contributor

sophiajt commented Sep 9, 2016

I'm chatting with @nrc about what to do here, and we have some ideas. RustConf is currently going on, so it may take us a few more days to get back to this.

@acrrd
Copy link
Contributor Author

acrrd commented Sep 10, 2016

ok!

@sophiajt
Copy link
Contributor

@acrrd - wow, sorry for the looong delay. I just landed a new method on CodeMap you can use to merge spans called merge_spans. This should be able to safely let you merge the parameter spans.

@acrrd
Copy link
Contributor Author

acrrd commented Oct 4, 2016

I merge spans until possible, this allow to underline at least some arguments also if the call is on multiple lines.

@sophiajt
Copy link
Contributor

sophiajt commented Oct 4, 2016

@acrrd - sounds good

You may want to also run tidy on your code:

python src/bootstrap/bootstrap.py --stage 1 --step check-tidy

And fix the errors it has. Looks like there are some in the current PR.

@acrrd
Copy link
Contributor Author

acrrd commented Oct 6, 2016

Fixed

@sophiajt
Copy link
Contributor

sophiajt commented Oct 6, 2016

Great!

The one last thing is to create a test for this in src/test/ui. You can see some of the tests there and how to do them (specifically in src/test/ui/spans).

After you add a test I think we're good to go.

@acrrd
Copy link
Contributor Author

acrrd commented Oct 7, 2016

Test added

@GuillaumeGomez
Copy link
Member

Thanks!

@bors: r+ rollup

@bors
Copy link
Contributor

bors commented Oct 7, 2016

📌 Commit d0c6172 has been approved by GuillaumeGomez

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Oct 7, 2016
bors added a commit that referenced this pull request Oct 7, 2016
Rollup of 5 pull requests

- Successful merges: #36222, #36665, #36929, #37003, #37008
- Failed merges:
@bors bors merged commit d0c6172 into rust-lang:master Oct 7, 2016
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.

E0057 needs to be updated to new format
6 participants