]> git.lizzy.rs Git - rust.git/commit
Auto merge of #49718 - petrochenkov:fieldcmp, r=eddyb
authorbors <bors@rust-lang.org>
Fri, 13 Apr 2018 01:43:09 +0000 (01:43 +0000)
committerbors <bors@rust-lang.org>
Fri, 13 Apr 2018 01:43:09 +0000 (01:43 +0000)
commitdefcfe7142fca424f7e34aa5c789239e9e9fcfe8
tree8b6e479ea80191563607ff243cd46699c53ce56e
parentc4a03283cd17c86c9bcdc3fdc76d924ab5eaff2a
parentfcf48520a0d63828190217ea59849f9098177427
Auto merge of #49718 - petrochenkov:fieldcmp, r=eddyb

Hygiene 2.0: Avoid comparing fields by name

There are two separate commits here (not counting tests):
- The first one unifies named (`obj.name`) and numeric (`obj.0`) field access expressions in AST and HIR. Before field references in these expressions are resolved it doesn't matter whether the field is named or numeric (it's just a symbol) and 99% of code is common. After field references are resolved we work with
them by index for all fields (see the second commit), so it's again not important whether the field was named or numeric (this includes MIR where all fields were already by index).
(This refactoring actually fixed some bugs in HIR-based borrow checker where borrows through names (`S {
0: ref x }`) and indices (`&s.0`) weren't considered overlapping.)
- The second commit removes all by-name field comparison and instead resolves field references to their indices  once, and then uses those resolutions. (There are still a few name comparisons in save-analysis, because save-analysis is weird, but they are made correctly hygienic).
Thus we are fixing a bunch of "secondary" field hygiene bugs (in borrow checker, lints).

Fixes https://github.com/rust-lang/rust/issues/46314
src/librustc/ty/mod.rs
src/librustc_typeck/collect.rs
src/librustc_typeck/diagnostics.rs