Skip to content

Commit 5f9c044

Browse files
committedJun 25, 2019
Auto merge of #62119 - Centril:rollup-el20wu0, r=Centril
Rollup of 7 pull requests Successful merges: - #61814 (Fix an ICE with uninhabited consts) - #61987 (rustc: produce AST instead of HIR from `hir::lowering::Resolver` methods.) - #62055 (Fix error counting) - #62078 (Remove built-in derive macros `Send` and `Sync`) - #62085 (Add test for issue-38591) - #62091 (HirIdification: almost there) - #62096 (Implement From<Local> for Place and PlaceBase) Failed merges: r? @ghost
2 parents 303f77e + d406d89 commit 5f9c044

File tree

91 files changed

+463
-356
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+463
-356
lines changed
 

‎src/librustc/hir/lowering.rs

+20-10
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,11 @@ pub struct LoweringContext<'a> {
148148

149149
pub trait Resolver {
150150
/// Resolve a path generated by the lowerer when expanding `for`, `if let`, etc.
151-
fn resolve_hir_path(
151+
fn resolve_ast_path(
152152
&mut self,
153153
path: &ast::Path,
154154
is_value: bool,
155-
) -> hir::Path;
155+
) -> Res<NodeId>;
156156

157157
/// Obtain resolution for a `NodeId` with a single resolution.
158158
fn get_partial_res(&mut self, id: NodeId) -> Option<PartialRes>;
@@ -167,15 +167,15 @@ pub trait Resolver {
167167
/// This should only return `None` during testing.
168168
fn definitions(&mut self) -> &mut Definitions;
169169

170-
/// Given suffix `["b", "c", "d"]`, creates a HIR path for `[::crate_root]::b::c::d` and
170+
/// Given suffix `["b", "c", "d"]`, creates an AST path for `[::crate_root]::b::c::d` and
171171
/// resolves it based on `is_value`.
172172
fn resolve_str_path(
173173
&mut self,
174174
span: Span,
175175
crate_root: Option<Symbol>,
176176
components: &[Symbol],
177177
is_value: bool,
178-
) -> hir::Path;
178+
) -> (ast::Path, Res<NodeId>);
179179
}
180180

181181
/// Context of `impl Trait` in code, which determines whether it is allowed in an HIR subtree,
@@ -5546,16 +5546,26 @@ impl<'a> LoweringContext<'a> {
55465546
params: Option<P<hir::GenericArgs>>,
55475547
is_value: bool,
55485548
) -> hir::Path {
5549-
let mut path = self.resolver
5549+
let (path, res) = self.resolver
55505550
.resolve_str_path(span, self.crate_root, components, is_value);
5551-
path.segments.last_mut().unwrap().args = params;
55525551

5553-
for seg in path.segments.iter_mut() {
5554-
if seg.hir_id.is_some() {
5555-
seg.hir_id = Some(self.next_id());
5552+
let mut segments: Vec<_> = path.segments.iter().map(|segment| {
5553+
let res = self.expect_full_res(segment.id);
5554+
hir::PathSegment {
5555+
ident: segment.ident,
5556+
hir_id: Some(self.lower_node_id(segment.id)),
5557+
res: Some(self.lower_res(res)),
5558+
infer_args: true,
5559+
args: None,
55565560
}
5561+
}).collect();
5562+
segments.last_mut().unwrap().args = params;
5563+
5564+
hir::Path {
5565+
span,
5566+
res: res.map_id(|_| panic!("unexpected node_id")),
5567+
segments: segments.into(),
55575568
}
5558-
path
55595569
}
55605570

55615571
fn ty_path(&mut self, mut hir_id: hir::HirId, span: Span, qpath: hir::QPath) -> hir::Ty {

‎src/librustc/hir/map/blocks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<'a> Code<'a> {
8787
match map.get(id) {
8888
map::Node::Block(_) => {
8989
// Use the parent, hopefully an expression node.
90-
Code::from_node(map, map.get_parent_node_by_hir_id(id))
90+
Code::from_node(map, map.get_parent_node(id))
9191
}
9292
map::Node::Expr(expr) => Some(Code::Expr(expr)),
9393
node => FnLikeNode::from_node(node).map(Code::FnLike)

0 commit comments

Comments
 (0)
Please sign in to comment.