rust/src/librustc_resolve
bors 6a3545ef05 Auto merge of #27439 - vberger:more_perseverant_resolve, r=nrc
(This is a second try at #26242. This time I think things should be ok.)

The current algorithm handling import resolutions works sequentially, handling imports in the order they appear in the source file, and blocking/bailing on the first one generating an error/being unresolved.

This can lead to situations where the order of the `use` statements can make the difference between "this code compiles" and "this code fails on an unresolved import" (see #18083 for example). This is especially true when considering glob imports.

This PR changes the behaviour of the algorithm to instead try to resolve all imports in a module. If one fails, it is recorded and the next one is tried (instead of directly giving up). Also, all errors generated are stored (and not reported directly).

The main loop of the algorithms guaranties that the algorithm will always finish: if a round of resolution does not resolve anything new, we are stuck and give up. At this point, the new version of the algorithm will display all errors generated by the last round of resolve. This way we are sure to not silence relevant errors or help messages, but also to not give up too early.

**As a consequence, the import resolution becomes independent of the order in which the `use` statements are written in the source files.** I personally don't see any situations where this could be a problem, but this might need some thought.

I passed `rpass` and `cfail` tests on my computer, and now am compiling a full stage2 compiler to ensure the crates reporting errors in my previous attempts still build correctly. I guess once I have checked it, this will need a crater run?

Fixes #18083.

r? @alexcrichton , cc @nrc @brson
2015-08-05 03:52:39 +00:00
..
build_reduced_graph.rs rustc: replace def::MethodProvenance with ty::ImplOrTraitItemContainer. 2015-08-04 01:16:53 +03:00
check_unused.rs rustc: combine partial_def_map and last_private_map into def_map. 2015-02-24 14:16:02 +02:00
diagnostics.rs Replace "impls" by "implementations" 2015-07-31 12:55:53 +02:00
lib.rs Auto merge of #27439 - vberger:more_perseverant_resolve, r=nrc 2015-08-05 03:52:39 +00:00
record_exports.rs remove get_ident and get_name, make as_str sound 2015-07-28 18:07:20 +02:00
resolve_imports.rs Addressing nits & tests explanations. 2015-08-04 08:14:32 +02:00