Debian Codegraph @

src/common/expr.rs

raw symbols SCIP
1 use quoterust-analyzer cargo quote 1.0.47 crate/::{quoterust-analyzer cargo quote 1.0.47 quote!, ToTokensrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#};
2 use synrust-analyzer cargo syn 2.0.119 crate/::{spannedrust-analyzer cargo syn 2.0.119 spanned/::Spannedrust-analyzer cargo syn 2.0.119 spanned/Spanned#, Exprrust-analyzer cargo syn 2.0.119 expr/Expr#, Litrust-analyzer cargo syn 2.0.119 lit/Lit#, Metarust-analyzer cargo syn 2.0.119 attr/Meta#, Typerust-analyzer cargo syn 2.0.119 ty/Type#};
3
4 use superrust-analyzer cargo educe 0.6.0 common/::pathrust-analyzer cargo educe 0.6.0 common/path/::path_to_stringrust-analyzer cargo educe 0.6.0 common/path/path_to_string().;
5
6 const INT_TYPESrust-analyzer cargo educe 0.6.0 common/expr/INT_TYPES.: [&str; 12] =
7 ["u8", "u16", "u32", "u64", "u128", "usize", "i8", "i16", "i32", "i64", "i128", "isize"];
8
9 const FLOAT_TYPESrust-analyzer cargo educe 0.6.0 common/expr/FLOAT_TYPES.: [&str; 2] = ["f32", "f64"];
10
11 #[inline]
12 pub(craterust-analyzer cargo educe 0.6.0 crate/) fn meta_2_exprrust-analyzer cargo educe 0.6.0 common/expr/meta_2_expr().(meta: &Metarust-analyzer cargo syn 2.0.119 attr/Meta#) -> synrust-analyzer cargo syn 2.0.119 crate/::Resultrust-analyzer cargo syn 2.0.119 error/Result#<Exprrust-analyzer cargo syn 2.0.119 expr/Expr#> {
13 match &meta {
14 Metarust-analyzer cargo syn 2.0.119 attr/Meta#::NameValuerust-analyzer cargo syn 2.0.119 attr/Meta#NameValue#(name_value) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(name_value.valuerust-analyzer cargo syn 2.0.119 attr/MetaNameValue#value..clonerust-analyzer cargo syn 2.0.119 gen/clone/impl#[`crate::Expr`][Clone]clone().()),
15 Metarust-analyzer cargo syn 2.0.119 attr/Meta#::Listrust-analyzer cargo syn 2.0.119 attr/Meta#List#(list) => list.parse_argsrust-analyzer cargo syn 2.0.119 attr/impl#[MetaList]parse_args().::<Exprrust-analyzer cargo syn 2.0.119 expr/Expr#>(),
16 Metarust-analyzer cargo syn 2.0.119 attr/Meta#::Pathrust-analyzer cargo syn 2.0.119 attr/Meta#Path#(path) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(synrust-analyzer cargo syn 2.0.119 crate/::Errorrust-analyzer cargo syn 2.0.119 error/Error#::newrust-analyzer cargo syn 2.0.119 error/impl#[Error]new().(
17 path.spanrust-analyzer cargo syn 2.0.119 spanned/impl#[T][Spanned]span().(),
18 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("expected `{path} = Expr` or `{path}(Expr)`", path = path_to_stringrust-analyzer cargo educe 0.6.0 common/path/path_to_string().(path)),
19 )),
20 }
21 }
22
23 #[inline]
24 pub(craterust-analyzer cargo educe 0.6.0 crate/) fn auto_adjust_exprrust-analyzer cargo educe 0.6.0 common/expr/auto_adjust_expr().(expr: Exprrust-analyzer cargo syn 2.0.119 expr/Expr#, ty: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Typerust-analyzer cargo syn 2.0.119 ty/Type#>) -> Exprrust-analyzer cargo syn 2.0.119 expr/Expr# {
25 match &expr {
26 Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Litrust-analyzer cargo syn 2.0.119 expr/Expr#Lit#(lit) => {
27 match &lit.litrust-analyzer cargo syn 2.0.119 expr/ExprLit#lit. {
28 Litrust-analyzer cargo syn 2.0.119 lit/Lit#::Intrust-analyzer cargo syn 2.0.119 lit/Lit#Int#(lit) => {
29 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Typerust-analyzer cargo syn 2.0.119 ty/Type#::Pathrust-analyzer cargo syn 2.0.119 ty/Type#Path#(ty)) = ty {
30 let ty_string = ty.into_token_streamrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#into_token_stream().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
31
32 if lit.suffixrust-analyzer cargo syn 2.0.119 lit/impl#[LitInt]suffix().() rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[`&str`][`PartialEq<String>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[`&str`][`PartialEq<String>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[`&str`][`PartialEq<String>`]eq().ty_string || INT_TYPESrust-analyzer cargo educe 0.6.0 common/expr/INT_TYPES..containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&ty_string.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()) {
33 // don't call into
34 return expr;
35 }
36 }
37 },
38 Litrust-analyzer cargo syn 2.0.119 lit/Lit#::Floatrust-analyzer cargo syn 2.0.119 lit/Lit#Float#(lit) => {
39 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Typerust-analyzer cargo syn 2.0.119 ty/Type#::Pathrust-analyzer cargo syn 2.0.119 ty/Type#Path#(ty)) = ty {
40 let ty_string = ty.into_token_streamrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#into_token_stream().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
41
42 if lit.suffixrust-analyzer cargo syn 2.0.119 lit/impl#[LitFloat]suffix().() rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[`&str`][`PartialEq<String>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[`&str`][`PartialEq<String>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[`&str`][`PartialEq<String>`]eq().ty_string || FLOAT_TYPESrust-analyzer cargo educe 0.6.0 common/expr/FLOAT_TYPES..containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&ty_string.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()) {
43 // don't call into
44 return expr;
45 }
46 }
47 },
48 Litrust-analyzer cargo syn 2.0.119 lit/Lit#::Strrust-analyzer cargo syn 2.0.119 lit/Lit#Str#(_) => {
49 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Typerust-analyzer cargo syn 2.0.119 ty/Type#::Referencerust-analyzer cargo syn 2.0.119 ty/Type#Reference#(ty)) = ty {
50 let ty_string = ty.elemrust-analyzer cargo syn 2.0.119 ty/TypeReference#elem..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][Clone]clone().().into_token_streamrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#into_token_stream().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
51
52 if ty_string rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq()."str" {
53 // don't call into
54 return expr;
55 }
56 }
57 },
58 Litrust-analyzer cargo syn 2.0.119 lit/Lit#::Boolrust-analyzer cargo syn 2.0.119 lit/Lit#Bool#(_) => {
59 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Typerust-analyzer cargo syn 2.0.119 ty/Type#::Pathrust-analyzer cargo syn 2.0.119 ty/Type#Path#(ty)) = ty {
60 let ty_string = ty.into_token_streamrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#into_token_stream().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
61
62 if ty_string rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq()."bool" {
63 // don't call into
64 return expr;
65 }
66 }
67 },
68 Litrust-analyzer cargo syn 2.0.119 lit/Lit#::Charrust-analyzer cargo syn 2.0.119 lit/Lit#Char#(_) => {
69 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Typerust-analyzer cargo syn 2.0.119 ty/Type#::Pathrust-analyzer cargo syn 2.0.119 ty/Type#Path#(ty)) = ty {
70 let ty_string = ty.into_token_streamrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#into_token_stream().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
71
72 if ty_string rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq()."char" {
73 // don't call into
74 return expr;
75 }
76 }
77 },
78 Litrust-analyzer cargo syn 2.0.119 lit/Lit#::Byterust-analyzer cargo syn 2.0.119 lit/Lit#Byte#(_) => {
79 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Typerust-analyzer cargo syn 2.0.119 ty/Type#::Pathrust-analyzer cargo syn 2.0.119 ty/Type#Path#(ty)) = ty {
80 let ty_string = ty.into_token_streamrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#into_token_stream().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
81
82 if ty_string rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq()."u8" {
83 // don't call into
84 return expr;
85 }
86 }
87 },
88 Litrust-analyzer cargo syn 2.0.119 lit/Lit#::ByteStrrust-analyzer cargo syn 2.0.119 lit/Lit#ByteStr#(_) => {
89 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Typerust-analyzer cargo syn 2.0.119 ty/Type#::Referencerust-analyzer cargo syn 2.0.119 ty/Type#Reference#(ty)) = ty {
90 if let Typerust-analyzer cargo syn 2.0.119 ty/Type#::Arrayrust-analyzer cargo syn 2.0.119 ty/Type#Array#(ty) = ty.elemrust-analyzer cargo syn 2.0.119 ty/TypeReference#elem..as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][`AsRef<T>`]as_ref().() {
91 if let Typerust-analyzer cargo syn 2.0.119 ty/Type#::Pathrust-analyzer cargo syn 2.0.119 ty/Type#Path#(ty) = ty.elemrust-analyzer cargo syn 2.0.119 ty/TypeArray#elem..as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][`AsRef<T>`]as_ref().() {
92 let ty_string = ty.into_token_streamrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#into_token_stream().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
93
94 if ty_string rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq()."u8" {
95 // don't call into
96 return expr;
97 }
98 }
99 }
100 }
101 },
102 _ => (),
103 }
104
105 synrust-analyzer cargo syn 2.0.119 crate/::parse2rust-analyzer cargo syn 2.0.119 parse2().(quoterust-analyzer cargo quote 1.0.47 quote!!(::core::convert::Into::into(#expr))).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
106 },
107 _ => expr,
108 }
109 }