Auto merge of #27085 - Ryman:gh17546, r=alexcrichton

This also changes how variant values are printed in errors, they are no
longer printed in their parent scope. As far as I can tell, this is
leftover from pre-namespacing of enums.

Closes #17546.
This commit is contained in:
bors 2015-07-18 06:02:50 +00:00
commit 3f50dca386
6 changed files with 78 additions and 27 deletions

View file

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -14,6 +14,6 @@ enum Foo {
Bar
}
fn foo(x: Foo::Bar) {} //~ERROR found value name used as a type
fn foo(x: Foo::Bar) {} //~ERROR found value `Foo::Bar` used as a type
fn main() {}

View file

@ -0,0 +1,50 @@
// Copyright 2015 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 foo::MyEnum::Result;
use foo::NoResult; // Through a re-export
mod foo {
pub use self::MyEnum::NoResult;
enum MyEnum {
Result,
NoResult
}
fn new() -> NoResult<MyEnum, String> {
//~^ ERROR: found value `foo::MyEnum::NoResult` used as a type
unimplemented!()
}
}
mod bar {
use foo::MyEnum::Result;
use foo;
fn new() -> Result<foo::MyEnum, String> {
//~^ ERROR: found value `foo::MyEnum::Result` used as a type
unimplemented!()
}
}
fn new() -> Result<foo::MyEnum, String> {
//~^ ERROR: found value `foo::MyEnum::Result` used as a type
unimplemented!()
}
fn newer() -> NoResult<foo::MyEnum, String> {
//~^ ERROR: found value `foo::MyEnum::NoResult` used as a type
unimplemented!()
}
fn main() {
let _ = new();
}

View file

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -30,7 +30,7 @@ pub enum Lonely<X,Y> { Zero, One(X), Two(X, Y) }
#[rustc_move_fragments]
pub fn test_match_partial(p: Lonely<D, D>) {
//~^ ERROR parent_of_fragments: `$(local p)`
//~| ERROR assigned_leaf_path: `($(local p) as Zero)`
//~| ERROR assigned_leaf_path: `($(local p) as Lonely::Zero)`
match p {
Zero(..) => {}
_ => {}
@ -40,9 +40,9 @@ pub fn test_match_partial(p: Lonely<D, D>) {
#[rustc_move_fragments]
pub fn test_match_full(p: Lonely<D, D>) {
//~^ ERROR parent_of_fragments: `$(local p)`
//~| ERROR assigned_leaf_path: `($(local p) as Zero)`
//~| ERROR assigned_leaf_path: `($(local p) as One)`
//~| ERROR assigned_leaf_path: `($(local p) as Two)`
//~| ERROR assigned_leaf_path: `($(local p) as Lonely::Zero)`
//~| ERROR assigned_leaf_path: `($(local p) as Lonely::One)`
//~| ERROR assigned_leaf_path: `($(local p) as Lonely::Two)`
match p {
Zero(..) => {}
One(..) => {}
@ -53,10 +53,10 @@ pub fn test_match_full(p: Lonely<D, D>) {
#[rustc_move_fragments]
pub fn test_match_bind_one(p: Lonely<D, D>) {
//~^ ERROR parent_of_fragments: `$(local p)`
//~| ERROR assigned_leaf_path: `($(local p) as Zero)`
//~| ERROR parent_of_fragments: `($(local p) as One)`
//~| ERROR moved_leaf_path: `($(local p) as One).#0`
//~| ERROR assigned_leaf_path: `($(local p) as Two)`
//~| ERROR assigned_leaf_path: `($(local p) as Lonely::Zero)`
//~| ERROR parent_of_fragments: `($(local p) as Lonely::One)`
//~| ERROR moved_leaf_path: `($(local p) as Lonely::One).#0`
//~| ERROR assigned_leaf_path: `($(local p) as Lonely::Two)`
//~| ERROR assigned_leaf_path: `$(local data)`
match p {
Zero(..) => {}
@ -68,13 +68,13 @@ pub fn test_match_bind_one(p: Lonely<D, D>) {
#[rustc_move_fragments]
pub fn test_match_bind_many(p: Lonely<D, D>) {
//~^ ERROR parent_of_fragments: `$(local p)`
//~| ERROR assigned_leaf_path: `($(local p) as Zero)`
//~| ERROR parent_of_fragments: `($(local p) as One)`
//~| ERROR moved_leaf_path: `($(local p) as One).#0`
//~| ERROR assigned_leaf_path: `($(local p) as Lonely::Zero)`
//~| ERROR parent_of_fragments: `($(local p) as Lonely::One)`
//~| ERROR moved_leaf_path: `($(local p) as Lonely::One).#0`
//~| ERROR assigned_leaf_path: `$(local data)`
//~| ERROR parent_of_fragments: `($(local p) as Two)`
//~| ERROR moved_leaf_path: `($(local p) as Two).#0`
//~| ERROR moved_leaf_path: `($(local p) as Two).#1`
//~| ERROR parent_of_fragments: `($(local p) as Lonely::Two)`
//~| ERROR moved_leaf_path: `($(local p) as Lonely::Two).#0`
//~| ERROR moved_leaf_path: `($(local p) as Lonely::Two).#1`
//~| ERROR assigned_leaf_path: `$(local left)`
//~| ERROR assigned_leaf_path: `$(local right)`
match p {

View file

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -30,11 +30,11 @@ pub enum Lonely<X,Y> { Zero, One(X), Two(X, Y) }
#[rustc_move_fragments]
pub fn test_match_bind_and_underscore(p: Lonely<D, D>) {
//~^ ERROR parent_of_fragments: `$(local p)`
//~| ERROR assigned_leaf_path: `($(local p) as Zero)`
//~| ERROR assigned_leaf_path: `($(local p) as One)`
//~| ERROR parent_of_fragments: `($(local p) as Two)`
//~| ERROR moved_leaf_path: `($(local p) as Two).#0`
//~| ERROR unmoved_fragment: `($(local p) as Two).#1`
//~| ERROR assigned_leaf_path: `($(local p) as Lonely::Zero)`
//~| ERROR assigned_leaf_path: `($(local p) as Lonely::One)`
//~| ERROR parent_of_fragments: `($(local p) as Lonely::Two)`
//~| ERROR moved_leaf_path: `($(local p) as Lonely::Two).#0`
//~| ERROR unmoved_fragment: `($(local p) as Lonely::Two).#1`
//~| ERROR assigned_leaf_path: `$(local left)`
match p {