Skip to content

Fix #151 #153

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

Merged
merged 2 commits into from
Apr 26, 2016
Merged

Fix #151 #153

merged 2 commits into from
Apr 26, 2016

Conversation

mrBliss
Copy link
Contributor

@mrBliss mrBliss commented Apr 24, 2016

When looking for a where in
rust-rewind-to-beginning-of-current-level-expr, check that it is not
part of a string or comment.

When looking for a `where` in
`rust-rewind-to-beginning-of-current-level-expr`, check that it is not
part of a string or comment.
@rust-highfive
Copy link

r? @huonw

(rust_highfive has picked a reviewer for you, use r? to override)

@mrBliss
Copy link
Contributor Author

mrBliss commented Apr 24, 2016

r? @MicahChalmer

@rust-highfive rust-highfive assigned MicahChalmer and unassigned huonw Apr 24, 2016
@MicahChalmer
Copy link
Contributor

Even with this patch, there are still places in the code that look for where clauses and don't check for comments, so there are still edge cases in which the word "where" in a comment can affect the indentation. For instance, with or without this PR, rust-mode will indent the following code as follows:

fn foo<F,G>(f:F, g:G)
    where F:Send,
// where
    G:Sized
{

}

but if you change the "where" in the comment to another word, the G:Sized is aligned with the F:Send (which I believe is correct.) If you make the comment a a where clause with a type annotation in it, rust-mode starts to align the actual code with the comment:

fn foo<F,G>(f:F, g:G)
    where F:Send,
// where      F:ThisIsNotActualCode,
              G:Sized
{

}

@mrBliss
Copy link
Contributor Author

mrBliss commented Apr 25, 2016

You're right. I'll update all places where we're looking for "where" to use (the existing) rust-in-str-or-cmnt.

Always check whether we're not in a string or comment when looking for
the `where` keyword. Use two helpers for this: `rust-looking-at-where`
and `rust-rewind-to-where`.
@MicahChalmer MicahChalmer merged commit b23efef into rust-lang:master Apr 26, 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.

4 participants