Skip to content

Commit

Permalink
Update to support nightly after 3/22/24
Browse files Browse the repository at this point in the history
  • Loading branch information
howardjohn committed May 21, 2024
1 parent 8020876 commit 1905899
Show file tree
Hide file tree
Showing 12 changed files with 243 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ fn alignment(input: &str) -> IResult<&str, usize> {
preceded(tag("alignment: "), bytes)(input)
}

// Example: "type: {async fn body of fn}"
fn local_type(input: &str) -> IResult<&str, &str> {
preceded(tag("type: "), is_not("\n"))(input)
}

// Example: "offset: 0 bytes"
fn offset(input: &str) -> IResult<&str, usize> {
preceded(tag("offset: "), bytes)(input)
Expand All @@ -62,6 +67,7 @@ fn field(input: &str) -> IResult<&str, Field> {
let (input, (name, _, size)) = tuple((name, tag(": "), bytes))(input)?;
let (input, offset) = opt(preceded(tag(", "), offset))(input)?;
let (input, align) = opt(preceded(tag(", "), alignment))(input)?;
let (input, local_type) = opt(preceded(tag(", "), local_type))(input)?;

let field = Field {
kind,
Expand All @@ -70,6 +76,7 @@ fn field(input: &str) -> IResult<&str, Field> {
size,
align,
offset,
local_type: local_type.map(|s| s.to_string()),
};

Ok((input, field))
Expand Down
1 change: 1 addition & 0 deletions src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub fn read(mut rd: impl BufRead) -> eyre::Result<String> {

while rd.read_line(&mut line)? > 0 {
let Some(refined_line) = line.strip_prefix("print-type-size ") else {
line.clear();
continue
};

Expand Down
1 change: 1 addition & 0 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub struct Field {
pub align: Option<usize>,
// TODO: what is it?
pub offset: Option<usize>,
pub local_type: Option<String>
}

#[derive(Debug, PartialEq, Eq)]
Expand Down
1 change: 1 addition & 0 deletions tests/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ test_sample!(tokio_udp);
test_sample!(several_types);
test_sample!(timex);
test_sample!(async_fn);
test_sample!(compiler_messages);

// TODO: add samples from rustc tests.
14 changes: 14 additions & 0 deletions tests/samples/compiler_messages.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Compiling project v0.0.0 (/home/project)
print-type-size type: `{async fn body of run()}`: 7880 bytes, alignment: 8 bytes
print-type-size discriminant: 1 bytes
print-type-size variant `Unresumed`: 592 bytes
print-type-size upvar `.self`: 568 bytes, offset: 0 bytes, alignment: 8 bytes
print-type-size upvar `.drain`: 24 bytes
print-type-size variant `Suspend0`: 7879 bytes
print-type-size upvar `.self`: 568 bytes, offset: 0 bytes, alignment: 8 bytes
print-type-size upvar `.drain`: 24 bytes
print-type-size local `.self`: 568 bytes
print-type-size padding: 1 bytes
print-type-size local `..coroutine_field3`: 1 bytes, alignment: 1 bytes, type: bool
print-type-size padding: 6 bytes
print-type-size local `.__awaitee`: 6712 bytes, alignment: 8 bytes, type: {async fn body of run()}
13 changes: 13 additions & 0 deletions tests/snapshots/runner__async_fn_types.snap
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ expression: types
offset: Some(
0,
),
local_type: None,
},
),
],
Expand All @@ -47,6 +48,7 @@ expression: types
offset: Some(
0,
),
local_type: None,
},
),
Field(
Expand All @@ -56,6 +58,7 @@ expression: types
size: 8192,
align: None,
offset: None,
local_type: None,
},
),
Field(
Expand All @@ -65,6 +68,7 @@ expression: types
size: 1,
align: None,
offset: None,
local_type: None,
},
),
],
Expand All @@ -84,6 +88,7 @@ expression: types
offset: Some(
0,
),
local_type: None,
},
),
],
Expand All @@ -103,6 +108,7 @@ expression: types
offset: Some(
0,
),
local_type: None,
},
),
],
Expand All @@ -126,6 +132,7 @@ expression: types
size: 8192,
align: None,
offset: None,
local_type: None,
},
),
],
Expand All @@ -152,6 +159,7 @@ expression: types
size: 0,
align: None,
offset: None,
local_type: None,
},
),
Field(
Expand All @@ -161,6 +169,7 @@ expression: types
size: 8192,
align: None,
offset: None,
local_type: None,
},
),
],
Expand Down Expand Up @@ -214,6 +223,7 @@ expression: types
size: 1,
align: None,
offset: None,
local_type: None,
},
),
],
Expand All @@ -240,6 +250,7 @@ expression: types
size: 0,
align: None,
offset: None,
local_type: None,
},
),
Field(
Expand All @@ -249,6 +260,7 @@ expression: types
size: 1,
align: None,
offset: None,
local_type: None,
},
),
],
Expand Down Expand Up @@ -279,6 +291,7 @@ expression: types
size: 0,
align: None,
offset: None,
local_type: None,
},
),
],
Expand Down
16 changes: 16 additions & 0 deletions tests/snapshots/runner__command_types.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ expression: types
size: 32,
align: None,
offset: None,
local_type: None,
},
),
Field(
Expand All @@ -26,6 +27,7 @@ expression: types
size: 16,
align: None,
offset: None,
local_type: None,
},
),
Field(
Expand All @@ -35,6 +37,7 @@ expression: types
size: 16,
align: None,
offset: None,
local_type: None,
},
),
Field(
Expand All @@ -44,6 +47,7 @@ expression: types
size: 16,
align: None,
offset: None,
local_type: None,
},
),
Field(
Expand All @@ -53,6 +57,7 @@ expression: types
size: 24,
align: None,
offset: None,
local_type: None,
},
),
Field(
Expand All @@ -62,6 +67,7 @@ expression: types
size: 24,
align: None,
offset: None,
local_type: None,
},
),
Field(
Expand All @@ -71,6 +77,7 @@ expression: types
size: 24,
align: None,
offset: None,
local_type: None,
},
),
Field(
Expand All @@ -80,6 +87,7 @@ expression: types
size: 8,
align: None,
offset: None,
local_type: None,
},
),
Field(
Expand All @@ -89,6 +97,7 @@ expression: types
size: 8,
align: None,
offset: None,
local_type: None,
},
),
Field(
Expand All @@ -98,6 +107,7 @@ expression: types
size: 8,
align: None,
offset: None,
local_type: None,
},
),
Field(
Expand All @@ -107,6 +117,7 @@ expression: types
size: 8,
align: None,
offset: None,
local_type: None,
},
),
Field(
Expand All @@ -116,6 +127,7 @@ expression: types
size: 8,
align: None,
offset: None,
local_type: None,
},
),
Field(
Expand All @@ -125,6 +137,7 @@ expression: types
size: 8,
align: None,
offset: None,
local_type: None,
},
),
Field(
Expand All @@ -134,6 +147,7 @@ expression: types
size: 1,
align: None,
offset: None,
local_type: None,
},
),
Field(
Expand All @@ -143,6 +157,7 @@ expression: types
size: 1,
align: None,
offset: None,
local_type: None,
},
),
Field(
Expand All @@ -152,6 +167,7 @@ expression: types
size: 1,
align: None,
offset: None,
local_type: None,
},
),
],
Expand Down
Loading

0 comments on commit 1905899

Please sign in to comment.