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

Add note when item accessed from module via m.i rather than m::i. #30413

Merged
merged 3 commits into from
Dec 21, 2015

Conversation

pnkfelix
Copy link
Member

Add note when item accessed from module via m.i rather than m::i.

(I tried to make this somewhat future-proofed, in that the UnresolvedNameContext could be expanded in the future with other cases besides paths that are known to be modules.)

This supersedes PR #30356 ; since I'm responsible for a bunch of new code here, someone else should review it. :)

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

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

@pnkfelix
Copy link
Member Author

gaar I posted this before running make check locally ... so of course it has tidy issues...

(update: fixed that and the typo in the unit test; make check-stage-cfail passes locally now)

@GuillaumeGomez
Copy link
Member

I'm still working on adding the two missing additional information.

@pnkfelix
Copy link
Member Author

I'm still working on adding the two missing additional information.

(and I think we do not need to block this PR on that change.)

@pnkfelix
Copy link
Member Author

@GuillaumeGomez Just to be clear: The reason that I turned #30356 into this PR was that I was concerned that it was giving "bad hints" in some contexts.

I wrote up the examples you noted as ways to illustrate cases where #30356 would give bad hints.

But I did not intend to imply something like "we should wait until we have solved all of these cases before we land anything."

My intention in this PR was to continue to solve the same narrow problem that #30356 was trying to solve, but to do it in a more targeted fashion that ensures that we only provide in hint about m.i or m.f(..) in cases where there actually is an m.i or m.f(..) present.


I definitely encourage you to try to come up with good error messages for other cases that this PR does not cover. You should do that work and put it up as a separate PR.

@@ -202,6 +202,12 @@ pub enum ResolutionError<'a> {
AttemptToUseNonConstantValueInConstant,
}

#[derive(Clone, PartialEq, Eq, Debug)]
pub enum UnresolvedNameContext {
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a doc comment on this so it's not confusing for future hackers?

(Also explain what the nodeid is)

@Manishearth
Copy link
Member

r=me with nit

@frewsxcv
Copy link
Member

This should also solve #22692 ?

@pnkfelix
Copy link
Member Author

@bors r=Manishearth 04c05c7 rollup

@nikomatsakis
Copy link
Contributor

@pnkfelix

The reason that I turned #30356 into this PR was that I was concerned that it was giving "bad hints" in some contexts.

Can you add tests that check that we do NOT provide bad hints? Hmm, I guess that's hard to do, isn't it?

@nikomatsakis
Copy link
Contributor

@frewsxcv

This should also solve #22692 ?

I suspect not. This seems targeted at modules, not items found in impls on types (but resolve works in mysterious ways and constructs some pseudo-modules, so maybe it works sometimes).

@pnkfelix
Copy link
Member Author

Can you add tests that check that we do NOT provide bad hints? Hmm, I guess that's hard to do, isn't it?

I don't think I'm going to try to do that. :)

@bors
Copy link
Contributor

bors commented Dec 20, 2015

⌛ Testing commit 04c05c7 with merge ea6e312...

@bors
Copy link
Contributor

bors commented Dec 20, 2015

💔 Test failed - auto-win-gnu-32-opt

@pnkfelix
Copy link
Member Author

What the heck, a bunch of errors in C:/bot/slave/auto-win-gnu-32-opt/build/src/llvm/lib/Target/Mips/MipsInstrInfo.h ...?

@alexcrichton
Copy link
Member

@bors: retry

On Sun, Dec 20, 2015 at 4:38 AM, Felix S Klock II notifications@github.com
wrote:

What the heck, a bunch of errors in
C:/bot/slave/auto-win-gnu-32-opt/build/src/llvm/lib/Target/Mips/MipsInstrInfo.h
...?


Reply to this email directly or view it on GitHub
#30413 (comment).

@bors
Copy link
Contributor

bors commented Dec 21, 2015

⌛ Testing commit 04c05c7 with merge e2834a2...

bors added a commit that referenced this pull request Dec 21, 2015
Add note when item accessed from module via `m.i` rather than `m::i`.

(I tried to make this somewhat future-proofed, in that the `UnresolvedNameContext` could be expanded in the future with other cases besides paths that are known to be modules.)

This supersedes PR #30356 ; since I'm responsible for a bunch of new code here, someone else should review it. :)
@bors bors merged commit 04c05c7 into rust-lang:master Dec 21, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this pull request Jan 8, 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.

8 participants