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

Update E0138 to new format #35573

Merged
merged 1 commit into from
Aug 15, 2016
Merged

Update E0138 to new format #35573

merged 1 commit into from
Aug 15, 2016

Conversation

wdv4758h
Copy link
Contributor

Part of #35233
Fix #35510
r? @jonathandturner

e0138

Question: How can I only underline the function name ? I have observed the debug output and the struct of item, but I can't find the Span for function name. Should I modify the struct I get to save function name's position or there is another way to get it ? (I can only find Spans for function attributes, inputs, outputs, blocks)

@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.

@sophiajt
Copy link
Contributor

@wdv4758h - underlining special parts of the span is different for different areas of the compiler. I know that @KiChjang has been looking at how to update some of the spans and may have looked in this area before.

You can also check out some of the PRs for error codes and see if they talk about doing the bonus section to help get some ideas.

@sophiajt
Copy link
Contributor

It's also totally possible the span isn't there. We're finding that for some of the bonus tasks that the span information just isn't easily accessible. For those we're hoping to come back to it later after more span information has been added to the compiler.

@sophiajt
Copy link
Contributor

This PR looks good. Feel free to file another for the bonus if you get it.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 10, 2016

📌 Commit d16804a has been approved by jonathandturner

@KiChjang
Copy link
Member

@wdv4758h Unfortunately, I think in this case, you'll need to resort into making an educated guess of where the span for the function name is. With the span of the entire fn declaration, you have the starting BytePos of the fn decl, and through some more dereferencing (methodSig.decl.inputs.get(0).pat.span()), you'll get the starting BytePos of the span of the first argument. You can then do some math and calculate where the fn name should be (also factoring in whether the fn is const and/or unsafe).

I'm no big fan of this method, because it assumes 2 things - the first is the amount of whitespaces between tokens, and second is that there's always going to be at least 1 argument in the fn decl, but that's the best we can do for now.

@sophiajt
Copy link
Contributor

@KiChjang - yeah, I'm also not a fan of trying to guess the span by using the surrounding information. If the span information isn't in one of the structures, and if we can't look it up with a span_if_local to get closer to it, then my vote is that we wait until more span information has been added to the compiler.

@wdv4758h
Copy link
Contributor Author

@KiChjang Thanks for comment. I've considered doing the math, once. But I think the assumption make it ugly. 😞

sophiajt pushed a commit to sophiajt/rust that referenced this pull request Aug 10, 2016
Update E0138 to new format

Part of rust-lang#35233
Fix rust-lang#35510
r? @jonathandturner

![e0138](https://cloud.githubusercontent.com/assets/2716047/17562415/7200d93c-5f5d-11e6-98ff-e15c29f40e03.png)

Question: How can I only underline the function name ? I have observed the debug output and the struct of item, but I can't find the `Span` for function name. Should I modify the struct I get to save function name's position or there is another way to get it ? (I can only find `Span`s for function attributes, inputs, outputs, blocks)
@sophiajt
Copy link
Contributor

sophiajt commented Aug 10, 2016

@bors r-

Looks like there are tidy failures:

/build/src/librustc/middle/entry.rs:138: line longer than 100 chars

thread 'main' panicked at 'some tidy checks failed', /build/src/tools/tidy/src/main.rs:53

You can run tidy by doing:

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

@wdv4758h
Copy link
Contributor Author

Oops. I'll fix it.

@wdv4758h
Copy link
Contributor Author

@jonathandturner Done.

@sophiajt
Copy link
Contributor

Thanks!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 11, 2016

📌 Commit 92f7e85 has been approved by jonathandturner

sophiajt pushed a commit to sophiajt/rust that referenced this pull request Aug 13, 2016
Update E0138 to new format

Part of rust-lang#35233
Fix rust-lang#35510
r? @jonathandturner

![e0138](https://cloud.githubusercontent.com/assets/2716047/17562415/7200d93c-5f5d-11e6-98ff-e15c29f40e03.png)

Question: How can I only underline the function name ? I have observed the debug output and the struct of item, but I can't find the `Span` for function name. Should I modify the struct I get to save function name's position or there is another way to get it ? (I can only find `Span`s for function attributes, inputs, outputs, blocks)
eddyb added a commit to eddyb/rust that referenced this pull request Aug 14, 2016
Update E0138 to new format

Part of rust-lang#35233
Fix rust-lang#35510
r? @jonathandturner

![e0138](https://cloud.githubusercontent.com/assets/2716047/17562415/7200d93c-5f5d-11e6-98ff-e15c29f40e03.png)

Question: How can I only underline the function name ? I have observed the debug output and the struct of item, but I can't find the `Span` for function name. Should I modify the struct I get to save function name's position or there is another way to get it ? (I can only find `Span`s for function attributes, inputs, outputs, blocks)
eddyb added a commit to eddyb/rust that referenced this pull request Aug 14, 2016
Update E0138 to new format

Part of rust-lang#35233
Fix rust-lang#35510
r? @jonathandturner

![e0138](https://cloud.githubusercontent.com/assets/2716047/17562415/7200d93c-5f5d-11e6-98ff-e15c29f40e03.png)

Question: How can I only underline the function name ? I have observed the debug output and the struct of item, but I can't find the `Span` for function name. Should I modify the struct I get to save function name's position or there is another way to get it ? (I can only find `Span`s for function attributes, inputs, outputs, blocks)
bors added a commit that referenced this pull request Aug 14, 2016
@bors bors merged commit 92f7e85 into rust-lang:master Aug 15, 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.

None yet

5 participants