Skip to content

Commit 36526cf

Browse files
authored
Rollup merge of #112063 - WaffleLapkin:test_incremental_ice, r=cjgillot
Add a test for issue 110457/incremental ICE with closures with the same span Closes #110457 It's probably possible to minimize the test case more, considering that we now know the underlying reason for the ICE, but I didn't. r? `@cjgillot`
2 parents 880da38 + 8d406b8 commit 36526cf

File tree

2 files changed

+137
-0
lines changed

2 files changed

+137
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// force-host
2+
// no-prefer-dynamic
3+
#![crate_type = "proc-macro"]
4+
5+
extern crate proc_macro;
6+
7+
use proc_macro::{Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree};
8+
9+
#[proc_macro]
10+
pub fn expand(_: TokenStream) -> TokenStream {
11+
// Hand expansion/rewriting of
12+
// ```
13+
// quote! {
14+
// output_mut(|o| o.copied_text = "".into());
15+
// output_mut(|o| o.copied_text = format!("{:?}", self.tile_db));
16+
// }.into()
17+
// ```
18+
stream([
19+
ident("output_mut"),
20+
group(
21+
Delimiter::Parenthesis,
22+
[
23+
or(),
24+
ident("o"),
25+
or(),
26+
ident("o"),
27+
dot(),
28+
ident("copied_text"),
29+
eq(),
30+
string(""),
31+
dot(),
32+
ident("into"),
33+
group(Delimiter::Parenthesis, []),
34+
],
35+
),
36+
semi(),
37+
ident("output_mut"),
38+
group(
39+
Delimiter::Parenthesis,
40+
[
41+
or(),
42+
ident("o"),
43+
or(),
44+
ident("o"),
45+
dot(),
46+
ident("copied_text"),
47+
eq(),
48+
ident("format"),
49+
bang(),
50+
group(
51+
Delimiter::Parenthesis,
52+
[string("{:?}"), comma(), ident("self"), dot(), ident("tile_db")],
53+
),
54+
],
55+
),
56+
semi(),
57+
])
58+
}
59+
60+
fn stream(s: impl IntoIterator<Item = TokenTree>) -> TokenStream {
61+
s.into_iter().collect()
62+
}
63+
64+
fn ident(i: &str) -> TokenTree {
65+
TokenTree::Ident(Ident::new(i, Span::call_site()))
66+
}
67+
fn group(d: Delimiter, s: impl IntoIterator<Item = TokenTree>) -> TokenTree {
68+
TokenTree::Group(Group::new(d, s.into_iter().collect()))
69+
}
70+
fn semi() -> TokenTree {
71+
TokenTree::Punct(Punct::new(';', Spacing::Alone))
72+
}
73+
fn or() -> TokenTree {
74+
TokenTree::Punct(Punct::new('|', Spacing::Alone))
75+
}
76+
fn dot() -> TokenTree {
77+
TokenTree::Punct(Punct::new('.', Spacing::Alone))
78+
}
79+
fn eq() -> TokenTree {
80+
TokenTree::Punct(Punct::new('=', Spacing::Alone))
81+
}
82+
fn bang() -> TokenTree {
83+
TokenTree::Punct(Punct::new('!', Spacing::Alone))
84+
}
85+
fn comma() -> TokenTree {
86+
TokenTree::Punct(Punct::new(',', Spacing::Alone))
87+
}
88+
fn string(s: &str) -> TokenTree {
89+
TokenTree::Literal(Literal::string(s))
90+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// aux-build: egui_inspect_derive.rs
2+
// revisions: cpass1 cpass2
3+
4+
extern crate egui_inspect_derive;
5+
6+
pub struct TileDef {
7+
pub layer: (),
8+
#[cfg(cpass2)]
9+
pub blend_graphic: String,
10+
}
11+
12+
pub(crate) struct GameState {
13+
pub(crate) tile_db: TileDb,
14+
}
15+
16+
impl GameState {
17+
fn inspect_mut(&mut self) {
18+
egui_inspect_derive::expand! {}
19+
}
20+
}
21+
22+
fn new() -> GameState {
23+
loop {}
24+
}
25+
26+
fn main() {
27+
let mut app = new();
28+
app.inspect_mut();
29+
}
30+
// this is actually used
31+
pub struct TileDb {
32+
unknown_bg: TileDef,
33+
}
34+
35+
impl std::fmt::Debug for TileDb {
36+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
37+
loop {}
38+
}
39+
}
40+
41+
pub struct PlatformOutput {
42+
pub copied_text: String,
43+
}
44+
45+
pub fn output_mut<R>(writer: impl FnOnce(&mut PlatformOutput) -> R) -> R {
46+
loop {}
47+
}

0 commit comments

Comments
 (0)