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

typeck: if a private field exists, also check for a public method #33342

Merged
merged 1 commit into from
May 15, 2016

Conversation

birkenfeld
Copy link
Contributor

For example, Vec::len is both a field and a method, and usually encountering vec.len just means that the parens were forgotten.

Fixes: #26472

NOTE: I added the parameter allow_private to method::exists since I don't want to suggest inaccessible methods. For the second case, where only the method exists, I think it would make sense to set it to false as well, but I wanted to preserve compatibility for this case.

@rust-highfive
Copy link
Collaborator

r? @Aatch

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

@arielb1
Copy link
Contributor

arielb1 commented May 2, 2016

@bors r+ fcebf52

@bors rollup

steveklabnik added a commit to steveklabnik/rust that referenced this pull request May 2, 2016
typeck: if a private field exists, also check for a public method

For example, `Vec::len` is both a field and a method, and usually encountering `vec.len` just means that the parens were forgotten.

Fixes: rust-lang#26472

NOTE: I added the parameter `allow_private` to `method::exists` since I don't want to suggest inaccessible methods. For the second case, where only the method exists, I think it would make sense to set it to `false` as well, but I wanted to preserve compatibility for this case.
@Nashenas88
Copy link
Contributor

I believe there was some discussion in internals.rust-lang.org about making these kinds of messages help instead of note. I'll add a link if I can find it.

steveklabnik added a commit to steveklabnik/rust that referenced this pull request May 5, 2016
typeck: if a private field exists, also check for a public method

For example, `Vec::len` is both a field and a method, and usually encountering `vec.len` just means that the parens were forgotten.

Fixes: rust-lang#26472

NOTE: I added the parameter `allow_private` to `method::exists` since I don't want to suggest inaccessible methods. For the second case, where only the method exists, I think it would make sense to set it to `false` as well, but I wanted to preserve compatibility for this case.
@steveklabnik
Copy link
Member

@bors: r-

another commit got added here, I don't know why bors still thought it was reviewed

@steveklabnik
Copy link
Member

@birkenfeld
Copy link
Contributor Author

birkenfeld commented May 6, 2016

@steveklabnik I didn't add another commit, I rebased and fixed up the existing after seeing that the rollup failed.

// Also check if an accessible method exists, which is often what is meant.
if method::exists(fcx, field.span, field.node, expr_t, expr.id, false) {
err.note(&format!("a method called `{}` also exists, \
maybe a `()` to call it is missing?",
Copy link
Contributor

@jseyfried jseyfried May 10, 2016

Choose a reason for hiding this comment

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

nit: a method named {} or just `a method `{}

Also, I would prefer perhaps you wish to call it as in this error message (instead of maybe a () to call it is missing?).

@jseyfried
Copy link
Contributor

r=me with the nit addressed

@birkenfeld
Copy link
Contributor Author

r? @jseyfried

@jseyfried
Copy link
Contributor

Thanks!
@bors r+

@bors
Copy link
Contributor

bors commented May 10, 2016

📌 Commit 84034d4 has been approved by jseyfried

steveklabnik added a commit to steveklabnik/rust that referenced this pull request May 10, 2016
typeck: if a private field exists, also check for a public method

For example, `Vec::len` is both a field and a method, and usually encountering `vec.len` just means that the parens were forgotten.

Fixes: rust-lang#26472

NOTE: I added the parameter `allow_private` to `method::exists` since I don't want to suggest inaccessible methods. For the second case, where only the method exists, I think it would make sense to set it to `false` as well, but I wanted to preserve compatibility for this case.
steveklabnik added a commit to steveklabnik/rust that referenced this pull request May 10, 2016
typeck: if a private field exists, also check for a public method

For example, `Vec::len` is both a field and a method, and usually encountering `vec.len` just means that the parens were forgotten.

Fixes: rust-lang#26472

NOTE: I added the parameter `allow_private` to `method::exists` since I don't want to suggest inaccessible methods. For the second case, where only the method exists, I think it would make sense to set it to `false` as well, but I wanted to preserve compatibility for this case.
@bors
Copy link
Contributor

bors commented May 11, 2016

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

bors added a commit that referenced this pull request May 11, 2016
Rollup of 9 pull requests

- Successful merges: #33129, #33260, #33345, #33386, #33522, #33524, #33528, #33539, #33542
- Failed merges: #33342, #33475, #33517
eddyb added a commit to eddyb/rust that referenced this pull request May 12, 2016
typeck: if a private field exists, also check for a public method

For example, `Vec::len` is both a field and a method, and usually encountering `vec.len` just means that the parens were forgotten.

Fixes: rust-lang#26472

NOTE: I added the parameter `allow_private` to `method::exists` since I don't want to suggest inaccessible methods. For the second case, where only the method exists, I think it would make sense to set it to `false` as well, but I wanted to preserve compatibility for this case.
bors added a commit that referenced this pull request May 12, 2016
eddyb added a commit to eddyb/rust that referenced this pull request May 13, 2016
typeck: if a private field exists, also check for a public method

For example, `Vec::len` is both a field and a method, and usually encountering `vec.len` just means that the parens were forgotten.

Fixes: rust-lang#26472

NOTE: I added the parameter `allow_private` to `method::exists` since I don't want to suggest inaccessible methods. For the second case, where only the method exists, I think it would make sense to set it to `false` as well, but I wanted to preserve compatibility for this case.
sanxiyn added a commit to sanxiyn/rust that referenced this pull request May 14, 2016
typeck: if a private field exists, also check for a public method

For example, `Vec::len` is both a field and a method, and usually encountering `vec.len` just means that the parens were forgotten.

Fixes: rust-lang#26472

NOTE: I added the parameter `allow_private` to `method::exists` since I don't want to suggest inaccessible methods. For the second case, where only the method exists, I think it would make sense to set it to `false` as well, but I wanted to preserve compatibility for this case.
bors added a commit that referenced this pull request May 14, 2016
Rollup of 15 pull requests

- Successful merges: #33342, #33393, #33415, #33475, #33517, #33533, #33534, #33565, #33580, #33590, #33591, #33598, #33603, #33604, #33605
- Failed merges: #33578
Manishearth added a commit to Manishearth/rust that referenced this pull request May 15, 2016
typeck: if a private field exists, also check for a public method

For example, `Vec::len` is both a field and a method, and usually encountering `vec.len` just means that the parens were forgotten.

Fixes: rust-lang#26472

NOTE: I added the parameter `allow_private` to `method::exists` since I don't want to suggest inaccessible methods. For the second case, where only the method exists, I think it would make sense to set it to `false` as well, but I wanted to preserve compatibility for this case.
bors added a commit that referenced this pull request May 15, 2016
@bors bors merged commit 843b174 into rust-lang:master May 15, 2016
bors added a commit that referenced this pull request May 16, 2016
@birkenfeld birkenfeld deleted the issue-26472 branch May 22, 2016 06:17
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.

8 participants