-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #30882 - petrochenkov:varnamesp, r=nrc
Tuple and unit variants from other crates weren't put into type namespace. Now variant namespacing is aligned with struct namespacing and is not affected by the variant's crate of origin (struct -> type, tuple/unit -> type/value). Additionally, struct variants from other crates are put into value namespace (struct variants from local crate were already in it). This is not a necessity, but a future proofing measure. This fix can result in some new shadowing errors in cross-crate scenarios, crater reports [three regressions](#30882 (comment)). [breaking-change]
- Loading branch information
Showing
6 changed files
with
85 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// 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. | ||
|
||
pub enum XE { | ||
XStruct { a: u8 }, | ||
XTuple(u8), | ||
XUnit, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// 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. | ||
|
||
// aux-build:variant-namespacing.rs | ||
|
||
extern crate variant_namespacing; | ||
pub use variant_namespacing::XE::*; | ||
//~^ ERROR import `XStruct` conflicts with type in this module | ||
//~| ERROR import `XStruct` conflicts with value in this module | ||
//~| ERROR import `XTuple` conflicts with type in this module | ||
//~| ERROR import `XTuple` conflicts with value in this module | ||
//~| ERROR import `XUnit` conflicts with type in this module | ||
//~| ERROR import `XUnit` conflicts with value in this module | ||
pub use E::*; | ||
//~^ ERROR import `Struct` conflicts with type in this module | ||
//~| ERROR import `Struct` conflicts with value in this module | ||
//~| ERROR import `Tuple` conflicts with type in this module | ||
//~| ERROR import `Tuple` conflicts with value in this module | ||
//~| ERROR import `Unit` conflicts with type in this module | ||
//~| ERROR import `Unit` conflicts with value in this module | ||
|
||
enum E { | ||
Struct { a: u8 }, | ||
Tuple(u8), | ||
Unit, | ||
} | ||
|
||
type Struct = u8; | ||
type Tuple = u8; | ||
type Unit = u8; | ||
type XStruct = u8; | ||
type XTuple = u8; | ||
type XUnit = u8; | ||
|
||
const Struct: u8 = 0; | ||
const Tuple: u8 = 0; | ||
const Unit: u8 = 0; | ||
const XStruct: u8 = 0; | ||
const XTuple: u8 = 0; | ||
const XUnit: u8 = 0; | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters