Skip to content

Commit a2cf2c6

Browse files
committed
Auto merge of #25791 - barosl:use-paths-as-items, r=alexcrichton
Currently, for `use` declarations with multiple paths, only the `use` item itself is saved in the AST map, not the individual path nodes. This can lead to a problem when a span of a specific path node is needed. For example, #24818 caused an ICE because of this, in `ImportResolver::check_for_conflicting_import()`. Fixes #25763.
2 parents 5a2c766 + 0ae30e6 commit a2cf2c6

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/libsyntax/ast_map/mod.rs

+10
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,16 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
714714
self.insert(ti.id, NodeTraitItem(ti));
715715
}
716716
}
717+
ItemUse(ref view_path) => {
718+
match view_path.node {
719+
ViewPathList(_, ref paths) => {
720+
for path in paths {
721+
self.insert(path.node.id(), NodeItem(i));
722+
}
723+
}
724+
_ => ()
725+
}
726+
}
717727
_ => {}
718728
}
719729
visit::walk_item(self, i);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Each path node in a `use` declaration must be treated as an item. If not, the following code
12+
// will trigger an ICE.
13+
//
14+
// Related issue: #25763
15+
16+
use std::{mem, ptr};
17+
use std::mem; //~ ERROR has already been imported
18+
19+
fn main() {}

0 commit comments

Comments
 (0)