Skip to content

Commit e43b05c

Browse files
committed
fix ci build
1 parent 7c9ce6d commit e43b05c

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

tl-parser/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ fn parse_definitions<'a>(
111111
Some("type") => types.push(parse_type_definition(id, line, def, &types)?),
112112
Some("error") => errors.push(parse_error_definition(id, line, def, &types, &errors)?),
113113
Some("func") => functions.push(parse_function_definition(id, line, def, &types, &functions)?),
114-
Some(r#type) => return Err(ParseError::InvalidDefinitionType { line, desc: r#type.to_string() }),
114+
Some(r#type) => return Err(ParseError::InvalidDefinitionType { line, desc: r#type.to_owned() }),
115115
None => return Err(ParseError::DefinitionTypeMissing { line }),
116116
};
117117
}
@@ -134,7 +134,7 @@ fn parse_type_definition<'a>(
134134
) -> Result<TypeDefinition, ParseError> {
135135
let name = def.next()
136136
.ok_or(ParseError::DefinitionNameMissing { line })?
137-
.to_string();
137+
.to_owned();
138138
if type_defined(&name, type_definitions) {
139139
return Err(ParseError::DuplicateDefinition { line, desc: name });
140140
}
@@ -143,7 +143,7 @@ fn parse_type_definition<'a>(
143143

144144
let r#enum = def.next()
145145
.ok_or(ParseError::EnumMissing { line })?
146-
.to_string();
146+
.to_owned();
147147

148148
Ok(TypeDefinition { id, name, fields, r#enum })
149149
}
@@ -157,7 +157,7 @@ fn parse_error_definition<'a>(
157157
) -> Result<ErrorDefinition, ParseError> {
158158
let name = def.next()
159159
.ok_or(ParseError::DefinitionNameMissing { line })?
160-
.to_string();
160+
.to_owned();
161161
if error_defined(&name, error_definitions) {
162162
return Err(ParseError::DuplicateDefinition { line, desc: name });
163163
}
@@ -177,7 +177,7 @@ fn parse_function_definition<'a>(
177177
) -> Result<FunctionDefinition, ParseError> {
178178
let name = def.next()
179179
.ok_or(ParseError::DefinitionNameMissing { line })?
180-
.to_string();
180+
.to_owned();
181181
if function_defined(&name, function_definitions) {
182182
return Err(ParseError::DuplicateDefinition { line, desc: name });
183183
}
@@ -207,7 +207,7 @@ fn parse_fields<'a>(
207207

208208
let name = part.next()
209209
.ok_or(ParseError::FieldNameMissing { line })?
210-
.to_string();
210+
.to_owned();
211211
if field_defined(&name, &fields) {
212212
return Err(ParseError::DuplicateField { line, desc: name });
213213
}
@@ -253,8 +253,8 @@ fn parse_type(
253253
type_definitions,
254254
Some(OuterType::Option),
255255
)?)),
256-
_ if enum_defined(r#type, type_definitions) => Type::Defined(r#type.to_string()),
257-
_ => return Err(ParseError::InvalidType { line, field: field.to_string(), desc: r#type.to_string() }),
256+
_ if enum_defined(r#type, type_definitions) => Type::Defined(r#type.to_owned()),
257+
_ => return Err(ParseError::InvalidType { line, field: field.to_owned(), desc: r#type.to_owned() }),
258258
};
259259

260260
if let Some(outer) = outer {
@@ -267,7 +267,7 @@ fn parse_type(
267267
) {
268268
return Err(ParseError::InvalidType {
269269
line,
270-
field: field.to_string(),
270+
field: field.to_owned(),
271271
desc: format!("invalid nested type: {:?}<{:?}>", outer, r#type),
272272
});
273273
}

tl-types/build.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@ fn main() -> anyhow::Result<()> {
66
let out_dir = PathBuf::from(env::var("OUT_DIR")?);
77
let out_file = out_dir.join("schema.rs");
88

9-
let schema = fs::read_to_string("schema.tl")
10-
.context("Failed to read schema.tl")?;
9+
let ci = env::var("CI")
10+
.unwrap_or_else(|_| String::from("false"))
11+
== "true";
12+
13+
let schema = if ci {
14+
String::from("")
15+
} else {
16+
fs::read_to_string("schema.tl")
17+
.context("Failed to read schema.tl")?
18+
};
1119
let schema = tl_parser::parse_schema(&schema)
1220
.context("Failed to parse schema")?;
1321
let code = tl_generator::generate(&schema);

tl-types/src/deserialize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ mod tests {
118118
assert_eq!(de::<f64>(vec![0xbc, 0x90, 0x0e, 0x0f, 0x61, 0x3a, 0x81, 0x40]), 551.297392_f64);
119119
assert_eq!(de::<bool>(vec![0x1]), true);
120120
assert_eq!(de::<bool>(vec![0x0]), false);
121-
assert_eq!(de::<String>(vec![0x5, b'h', b'e', b'l', b'l', b'o']), "hello".to_string());
121+
assert_eq!(de::<String>(vec![0x5, b'h', b'e', b'l', b'l', b'o']), String::from("hello"));
122122
assert_eq!(
123123
de::<Vec<u8>>([vec![0xff, 0xe8, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0], vec![0xdd; 997], vec![b'j', b'o', b'y']].concat()),
124124
[vec![0xdd; 997], vec![b'j', b'o', b'y']].concat()

tl-types/src/serialize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ mod tests {
116116
assert_eq!(ser(551.297392_f64), vec![0xbc, 0x90, 0x0e, 0x0f, 0x61, 0x3a, 0x81, 0x40]);
117117
assert_eq!(ser(true), vec![0x1]);
118118
assert_eq!(ser(false), vec![0x0]);
119-
assert_eq!(ser("hello".to_string()), vec![0x5, b'h', b'e', b'l', b'l', b'o']);
119+
assert_eq!(ser(String::from("hello")), vec![0x5, b'h', b'e', b'l', b'l', b'o']);
120120
assert_eq!(
121121
ser([vec![0xdd; 997], vec![b'j', b'o', b'y']].concat()),
122122
[vec![0xff, 0xe8, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0], vec![0xdd; 997], vec![b'j', b'o', b'y']].concat()

0 commit comments

Comments
 (0)