]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #32131 - petrochenkov:prim, r=eddyb
authorManish Goregaokar <manishsmail@gmail.com>
Sat, 26 Mar 2016 03:37:20 +0000 (09:07 +0530)
committerManish Goregaokar <manishsmail@gmail.com>
Sat, 26 Mar 2016 03:37:20 +0000 (09:07 +0530)
commitb8b17a54cf1f6d216d83c5679cf9d7951656e36c
treedd0b177ccc15012c68f7ecc0945e559c6d0d8f9c
parent8d2d2be6c61c17da8027a72da91f87a0e2487f74
parentb418cd23068b1074e78d8631aec923b865bcc583
Rollup merge of #32131 - petrochenkov:prim, r=eddyb

resolve: Minimize hacks in name resolution of primitive types

When resolving the first unqualified segment in a path with `n` segments and `n - 1` associated item segments, e.g. (`a` or `a::assoc` or `a::assoc::assoc` etc) try to resolve `a` without considering primitive types first. If the "normal" lookup fails or results in a module, then try to resolve `a` as a primitive type as a fallback.

This way backward compatibility is respected, but the restriction from E0317 can be lifted, i.e. primitive names mostly can be shadowed like any other names.

Furthermore, if names of primitive types are [put into prelude](https://github.com/petrochenkov/rust/tree/prim2) (now it's possible to do), then most of names will be resolved in conventional way and amount of code relying on this fallback will be greatly reduced. Although, it's not entirely convenient to put them into prelude right now due to temporary conflicts like `use prelude::v1::*; use usize;` in libcore/libstd, I'd better wait for proper glob shadowing before doing it.
I wish the `no_prelude` attribute were unstable as intended :(

cc @jseyfried @arielb1
r? @eddyb
src/librustc_resolve/lib.rs