diff options
| author | Pietro Albini <pietro@pietroalbini.org> | 2018-01-21 12:26:01 +0100 |
|---|---|---|
| committer | Pietro Albini <pietro@pietroalbini.org> | 2018-01-21 12:26:01 +0100 |
| commit | e9d0141fa9d55cfafbcdfe81acec94b974c7d487 (patch) | |
| tree | 67683200ed239aa313a8a53add05ba8f2eb9b4f3 /src | |
| parent | 8d3e93beae9562f8b32b7f82c3824389f6ac5bad (diff) | |
| download | rust-e9d0141fa9d55cfafbcdfe81acec94b974c7d487.tar.gz rust-e9d0141fa9d55cfafbcdfe81acec94b974c7d487.zip | |
Fix ICE with `use self;`
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/hir/lowering.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/issue-47623.rs | 13 | ||||
| -rw-r--r-- | src/test/ui/issue-47623.stderr | 8 |
3 files changed, 23 insertions, 1 deletions
diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 238145a061f..32b55a05124 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -2046,7 +2046,8 @@ impl<'a> LoweringContext<'a> { }; // Correctly resolve `self` imports - if path.segments.last().unwrap().identifier.name == keywords::SelfValue.name() { + if path.segments.len() > 1 && + path.segments.last().unwrap().identifier.name == keywords::SelfValue.name() { let _ = path.segments.pop(); if ident.name == keywords::SelfValue.name() { *name = path.segments.last().unwrap().identifier.name; diff --git a/src/test/ui/issue-47623.rs b/src/test/ui/issue-47623.rs new file mode 100644 index 00000000000..0c886fdb52f --- /dev/null +++ b/src/test/ui/issue-47623.rs @@ -0,0 +1,13 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use self; //~ERROR `self` imports are only allowed within a { } list + +fn main() {} diff --git a/src/test/ui/issue-47623.stderr b/src/test/ui/issue-47623.stderr new file mode 100644 index 00000000000..c5a42d4d846 --- /dev/null +++ b/src/test/ui/issue-47623.stderr @@ -0,0 +1,8 @@ +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/issue-47623.rs:11:5 + | +11 | use self; //~ERROR `self` imports are only allowed within a { } list + | ^^^^ + +error: aborting due to previous error + |
