forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#121695 - oli-obk:split_ty_utils, r=compiler…
…-errors Split rustc_type_ir to avoid rustc_ast from depending on it unblocks rust-lang#121576 and resolves a FIXME in `rustc_ast`'s `Cargo.toml` The new crate is tiny, but it will get bigger in rust-lang#121576
- Loading branch information
Showing
14 changed files
with
117 additions
and
74 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
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,22 @@ | ||
[package] | ||
name = "rustc_ast_ir" | ||
version = "0.0.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
# tidy-alphabetical-start | ||
rustc_data_structures = { path = "../rustc_data_structures", optional = true } | ||
rustc_macros = { path = "../rustc_macros", optional = true } | ||
rustc_serialize = { path = "../rustc_serialize", optional = true } | ||
rustc_span = { path = "../rustc_span", optional = true } | ||
smallvec = { version = "1.8.1" } | ||
# tidy-alphabetical-end | ||
|
||
[features] | ||
default = ["nightly"] | ||
nightly = [ | ||
"rustc_serialize", | ||
"rustc_data_structures", | ||
"rustc_macros", | ||
"rustc_span", | ||
] |
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,68 @@ | ||
#![cfg_attr(feature = "nightly", feature(rustc_attrs))] | ||
#![cfg_attr(feature = "nightly", allow(internal_features))] | ||
|
||
#[cfg(feature = "nightly")] | ||
#[macro_use] | ||
extern crate rustc_macros; | ||
|
||
/// The movability of a coroutine / closure literal: | ||
/// whether a coroutine contains self-references, causing it to be `!Unpin`. | ||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)] | ||
#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_NoContext))] | ||
pub enum Movability { | ||
/// May contain self-references, `!Unpin`. | ||
Static, | ||
/// Must not contain self-references, `Unpin`. | ||
Movable, | ||
} | ||
|
||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)] | ||
#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_NoContext))] | ||
pub enum Mutability { | ||
// N.B. Order is deliberate, so that Not < Mut | ||
Not, | ||
Mut, | ||
} | ||
|
||
impl Mutability { | ||
pub fn invert(self) -> Self { | ||
match self { | ||
Mutability::Mut => Mutability::Not, | ||
Mutability::Not => Mutability::Mut, | ||
} | ||
} | ||
|
||
/// Returns `""` (empty string) or `"mut "` depending on the mutability. | ||
pub fn prefix_str(self) -> &'static str { | ||
match self { | ||
Mutability::Mut => "mut ", | ||
Mutability::Not => "", | ||
} | ||
} | ||
|
||
/// Returns `"&"` or `"&mut "` depending on the mutability. | ||
pub fn ref_prefix_str(self) -> &'static str { | ||
match self { | ||
Mutability::Not => "&", | ||
Mutability::Mut => "&mut ", | ||
} | ||
} | ||
|
||
/// Returns `""` (empty string) or `"mutably "` depending on the mutability. | ||
pub fn mutably_str(self) -> &'static str { | ||
match self { | ||
Mutability::Not => "", | ||
Mutability::Mut => "mutably ", | ||
} | ||
} | ||
|
||
/// Return `true` if self is mutable | ||
pub fn is_mut(self) -> bool { | ||
matches!(self, Self::Mut) | ||
} | ||
|
||
/// Return `true` if self is **not** mutable | ||
pub fn is_not(self) -> bool { | ||
matches!(self, Self::Not) | ||
} | ||
} |
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
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
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