-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Update E0138 to new format #35573
Conversation
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. |
@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. |
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. |
This PR looks good. Feel free to file another for the bonus if you get it. @bors r+ rollup |
📌 Commit d16804a has been approved by |
@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. |
@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 |
@KiChjang Thanks for comment. I've considered doing the math, once. But I think the assumption make it ugly. 😞 |
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 r- Looks like there are
You can run tidy by doing:
|
Oops. I'll fix it. |
@jonathandturner Done. |
Thanks! @bors r+ rollup |
📌 Commit 92f7e85 has been approved by |
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)
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)
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)
Rollup of 30 pull requests - Successful merges: #34941, #35392, #35444, #35447, #35491, #35533, #35539, #35558, #35573, #35574, #35577, #35586, #35588, #35594, #35596, #35597, #35598, #35606, #35611, #35615, #35616, #35620, #35622, #35640, #35643, #35644, #35646, #35647, #35648, #35661 - Failed merges: #35395, #35415
Part of #35233
Fix #35510
r? @jonathandturner
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 findSpan
s for function attributes, inputs, outputs, blocks)