-
Notifications
You must be signed in to change notification settings - Fork 13k
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
When trying to import two types with the same name, say which line the first one was imported on #20591
Comments
Happy to mentor this |
I would like to take a stab at it. |
How would one find the line number? |
You don't explicitly need to find the line number, you should call |
If you haven't already, look at |
Could you give me a quick explanation of how |
Yeah, span_note, sorry. So, actually, ImportResolution is a more likely candidate for this. That represents a |
A few questions for clarification. Which of the two ids in ImportResolution, |
Whether you want the type or value id depends on whether the new import is importing into the type or value namespace. It might be both, in which case you might need to check which id is already used (if both are set, then they should be set to the same value and you should probably assert! that). The ast map is a mapping from node ids to ast nodes, so to find an ast node, you lookup the node id in the ast map. Check out libsyntax/ast_map/mod.rs to see the functions available. Since there are many kinds of nodes, you'll need to match the result to get the node you want, but there are convenience functions to do this in that file (expect_*) if there is not one for the node you need, add it. See libsyntax/ast.rs for all the node kinds. If you look in ast.rs you'll see how the span is stored, it is a bit different from node to node, some store it explicitly, some use the Spanned helper, but it should be clear which is which. |
How do I know which namespace the import is importing into, or whether it's importing into both? Also, how do I access the ast map, and how do I know which expect_* I want? |
I realised that the ast_map won't in fact have the You access the ast_map via I'm not exactly sure where you're working, but there is usually a namespace arg to tell you which namespace you are dealing with - type is Namespace and its either ValueNS or TypeNS. If it's not obvious which namespace you're dealing with let me know which method you are in and I'll try to be more specific. |
@ddgond, are you still working on it? If not, I'd love to take a stab at it. :) |
Sure, go right ahead! |
@bagedevimo How'd it go? Can I try my hand at it now? |
Go ahead. I totally ran out of time and didn't get to this one.
|
@nrc How do you get the logging statements to show up?
and none of the lines like
|
I'm currently basing this code off of the code for rejecting duplicate function definitions, since that has a similar note to what we want. Line 217 of build_reduced_graph.rs seems to be promising, Why does |
Hmm, that approach does do something, but it's not exactly what I had in mind
My approach gives
which isn't exactly what I want, but it is interesting. |
This isn't quite right, but it's interesting.
@nrc |
Well, I've got something that compiles, at least in |
Alright, looks like it's reasonable, though I had a type that needed fixing. |
@tbelaire argh, sorry I missed your questions here, I've been remiss in checking my email the last few days. I'll have a look at your PR tomorrow. |
This can be closed now, as the feature PR was merged. |
Right now, you can get errors like "a type named
Primitive
has already been imported in this module", which isn't very helpful. The error message would be much more helpful if it would tell you which line the otherPrimitive
type was imported on.The text was updated successfully, but these errors were encountered: