summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikuroXina <ryosukadnak@gmail.com>2021-10-25 22:55:40 +0900
committerEmilio Cobos Álvarez <emilio@crisal.io>2021-10-27 19:22:15 +0200
commit70446e549c3c5096789161dd07f5b21e8ffe51dc (patch)
treedf2f23bd3a86723f600035459348355b5bcdd478
parentf21f6f322f92b3c3739ff97ab2bcb98030addebf (diff)
Shorten patterns
-rw-r--r--src/ir/context.rs84
1 files changed, 13 insertions, 71 deletions
diff --git a/src/ir/context.rs b/src/ir/context.rs
index 5b23a43d..874fb5df 100644
--- a/src/ir/context.rs
+++ b/src/ir/context.rs
@@ -831,83 +831,25 @@ If you encounter an error missing from this list, please file an issue or a PR!"
// TODO: Move all this syntax crap to other part of the code.
/// Mangles a name so it doesn't conflict with any keyword.
+ #[rustfmt::skip]
pub fn rust_mangle<'a>(&self, name: &'a str) -> Cow<'a, str> {
if name.contains('@') ||
name.contains('?') ||
name.contains('$') ||
matches!(
name,
- "abstract" |
- "alignof" |
- "as" |
- "async" |
- "become" |
- "box" |
- "break" |
- "const" |
- "continue" |
- "crate" |
- "do" |
- "dyn" |
- "else" |
- "enum" |
- "extern" |
- "false" |
- "final" |
- "fn" |
- "for" |
- "if" |
- "impl" |
- "in" |
- "let" |
- "loop" |
- "macro" |
- "match" |
- "mod" |
- "move" |
- "mut" |
- "offsetof" |
- "override" |
- "priv" |
- "proc" |
- "pub" |
- "pure" |
- "ref" |
- "return" |
- "Self" |
- "self" |
- "sizeof" |
- "static" |
- "struct" |
- "super" |
- "trait" |
- "true" |
- "type" |
- "typeof" |
- "unsafe" |
- "unsized" |
- "use" |
- "virtual" |
- "where" |
- "while" |
- "yield" |
- "str" |
- "bool" |
- "f32" |
- "f64" |
- "usize" |
- "isize" |
- "u128" |
- "i128" |
- "u64" |
- "i64" |
- "u32" |
- "i32" |
- "u16" |
- "i16" |
- "u8" |
- "i8" |
- "_"
+ "abstract" | "alignof" | "as" | "async" | "become" |
+ "box" | "break" | "const" | "continue" | "crate" | "do" |
+ "dyn" | "else" | "enum" | "extern" | "false" | "final" |
+ "fn" | "for" | "if" | "impl" | "in" | "let" | "loop" |
+ "macro" | "match" | "mod" | "move" | "mut" | "offsetof" |
+ "override" | "priv" | "proc" | "pub" | "pure" | "ref" |
+ "return" | "Self" | "self" | "sizeof" | "static" |
+ "struct" | "super" | "trait" | "true" | "type" | "typeof" |
+ "unsafe" | "unsized" | "use" | "virtual" | "where" |
+ "while" | "yield" | "str" | "bool" | "f32" | "f64" |
+ "usize" | "isize" | "u128" | "i128" | "u64" | "i64" |
+ "u32" | "i32" | "u16" | "i16" | "u8" | "i8" | "_"
)
{
let mut s = name.to_owned();