Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to purely namespaced enums #18973

Merged
merged 1 commit into from
Nov 17, 2014
Merged

Conversation

sfackler
Copy link
Member

This breaks code that referred to variant names in the same namespace as
their enum. Reexport the variants in the old location or alter code to
refer to the new locations:

pub enum Foo {
    A,
    B
}

fn main() {
    let a = A;
}

=>

pub use self::Foo::{A, B};

pub enum Foo {
    A,
    B
}

fn main() {
    let a = A;
}

or

pub enum Foo {
    A,
    B
}

fn main() {
    let a = Foo::A;
}

[breaking-change]

@rust-highfive
Copy link
Collaborator

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@sfackler
Copy link
Member Author

This is 99% boring reexport additions. There are some interesting changes to resolve that should be looked over.

@ghost
Copy link

ghost commented Nov 15, 2014

To me, this seems like one of these invasive breaking changes where it'd be nice to make sure that diagnostics themselves suggest a solution rather than having the users look for it in the Rust commits. Do you know if it'd be hard to make resolve do that? I'd go as far as say that maybe initially it could be a warning as well and a hard error in a few weeks' time.

@sfackler
Copy link
Member Author

I can't really think of a non-painful way to get that to work off the top of my head, unfortunately.

@aturon
Copy link
Member

aturon commented Nov 16, 2014

So glad to see this on it's way in! Awesome effort, @sfackler.

This breaks code that referred to variant names in the same namespace as
their enum. Reexport the variants in the old location or alter code to
refer to the new locations:

```
pub enum Foo {
    A,
    B
}

fn main() {
    let a = A;
}
```
=>
```
pub use self::Foo::{A, B};

pub enum Foo {
    A,
    B
}

fn main() {
    let a = A;
}
```
or
```
pub enum Foo {
    A,
    B
}

fn main() {
    let a = Foo::A;
}
```

[breaking-change]
bors added a commit that referenced this pull request Nov 17, 2014
This breaks code that referred to variant names in the same namespace as
their enum. Reexport the variants in the old location or alter code to
refer to the new locations:

```
pub enum Foo {
    A,
    B
}

fn main() {
    let a = A;
}
```
=>
```
pub use self::Foo::{A, B};

pub enum Foo {
    A,
    B
}

fn main() {
    let a = A;
}
```
or
```
pub enum Foo {
    A,
    B
}

fn main() {
    let a = Foo::A;
}
```

[breaking-change]
@bors bors closed this Nov 17, 2014
@bors bors merged commit 3dcd215 into rust-lang:master Nov 17, 2014
kyledewey added a commit to kyledewey/uuid that referenced this pull request Nov 17, 2014
kyledewey added a commit to kyledewey/time that referenced this pull request Nov 17, 2014
barosl added a commit to barosl/rust-http-content-type that referenced this pull request Nov 18, 2014
rust-lang/rust#18973 changed the behavior of enums. Enums are now
namespaced.
reima added a commit to reima/rustboy that referenced this pull request Nov 18, 2014
ghost referenced this pull request in Marwes/pretty.rs Nov 18, 2014
Valve pushed a commit to Valve/heliotrope that referenced this pull request Nov 19, 2014
little-arhat added a commit to little-arhat/nix-rust that referenced this pull request Nov 19, 2014
As per this pull request rust-lang/rust#18973,
enum variants require fully qualified path to access them.
This commit introduces boring changes to make nix-rust compiles againts
new rust.
rozaliev added a commit to rozaliev/mio that referenced this pull request Nov 19, 2014
With rust-lang/rust#18973 merged enum variants are namespaced. They should be reexported or used like Enum::Variant.
japaric pushed a commit to japaric-archived/simplot.rs that referenced this pull request Nov 19, 2014
See rust-lang/rust#18973

- The `linspace` and `logspace` functions have been moved into their own crate
- The `color` module has been removed, the `Color` enum is now in the root of
  the crate
- The following enums have been moved into the root of the crate: `Axis`,
  `Grid` and `Scale`
- Renames:
  - `HorizontalPosition` -> `Horizontal`
  - `LeftJustified/RightJustified` -> `Justification::{Left, Right}`
  - `Vertical::Middle` -> `Vertical::Center`
  - `VerticalPosition` -> `Vertical`

[breaking-change]
jgillich pushed a commit to jgillich/hyper that referenced this pull request Nov 19, 2014
caryhaynie pushed a commit to caryhaynie/rust-sdl2 that referenced this pull request Nov 25, 2014
wycats pushed a commit to nix-rust/nix that referenced this pull request Dec 15, 2014
As per this pull request rust-lang/rust#18973,
enum variants require fully qualified path to access them.
This commit introduces boring changes to make nix-rust compiles againts
new rust.
@sfackler sfackler deleted the enum-namespace-pt2 branch November 26, 2016 05:54
seanmonstar pushed a commit to hyperium/headers that referenced this pull request Jul 9, 2018
GauravBholaris pushed a commit to GauravBholaris/criterion.rs that referenced this pull request Jul 20, 2022
See rust-lang/rust#18973

`Tails` variants: `OneTailed` and `TwoTailed` have been renamed to
`Tails::{One, Two}`

[breaking-change]
GauravBholaris pushed a commit to GauravBholaris/criterion.rs that referenced this pull request Jul 20, 2022
See rust-lang/rust#18973

- The `linspace` and `logspace` functions have been moved into their own crate
- The `color` module has been removed, the `Color` enum is now in the root of
  the crate
- The following enums have been moved into the root of the crate: `Axis`,
  `Grid` and `Scale`
- Renames:
  - `HorizontalPosition` -> `Horizontal`
  - `LeftJustified/RightJustified` -> `Justification::{Left, Right}`
  - `Vertical::Middle` -> `Vertical::Center`
  - `VerticalPosition` -> `Vertical`

[breaking-change]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants