Skip to content

Commit 625e76c

Browse files
committed
Fix removal of box_syntax
see rust-lang/rust-analyzer#14504
1 parent 74f1c34 commit 625e76c

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

src/grammar.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ rule str_char<Q>(quote: rule<Q>) -> u8 = escape() / c:$(!quote() [_]) { c.as_byt
2525
rule char_literal() -> Node = "'" s:str_char(<"'">) "'" { Node::Integer(s as u64) }
2626
rule bytes_literal() -> Node = "\"" s:str_char(<"\"">)* "\"" { Node::StringLiteral(s) }
2727

28-
rule negation() -> Node = "-" e:expression() { Node::Negation(box e) }
28+
rule negation() -> Node = "-" e:expression() { Node::Negation(Box::new(e)) }
2929
pub rule expr_atom() -> Node = whitespace()? "(" whitespace()? e:expression() whitespace()? ")" whitespace()? {e.simplify()}
3030
/ whitespace()? n:negation() whitespace()? {n.simplify()}
3131
/ whitespace()? i:integer() whitespace()? {i}
@@ -34,21 +34,21 @@ pub rule expr_atom() -> Node = whitespace()? "(" whitespace()? e:expression() wh
3434
/ whitespace()? c:char_literal() whitespace()? {c}
3535

3636
pub rule expression() -> Node = precedence! {
37-
x:(@) "<<" y:@ { Node::Shl(box x, box y).simplify() }
38-
x:(@) ">>" y:@ { Node::Shr(box x, box y).simplify() }
39-
x:(@) ">>>" y:@ { Node::Ashr(box x, box y).simplify() }
37+
x:(@) "<<" y:@ { Node::Shl(Box::new(x), Box::new(y)).simplify() }
38+
x:(@) ">>" y:@ { Node::Shr(Box::new(x), Box::new(y)).simplify() }
39+
x:(@) ">>>" y:@ { Node::Ashr(Box::new(x), Box::new(y)).simplify() }
4040
--
41-
x:(@) "+" y:@ { Node::Plus(box x, box y).simplify() }
42-
x:(@) "-" y:@ { Node::Minus(box x, box y).simplify() }
41+
x:(@) "+" y:@ { Node::Plus(Box::new(x), Box::new(y)).simplify() }
42+
x:(@) "-" y:@ { Node::Minus(Box::new(x), Box::new(y)).simplify() }
4343
--
44-
x:(@) "*" y:@ { Node::Times(box x, box y).simplify() }
45-
x:(@) "/" y:@ { Node::Divide(box x, box y).simplify() }
44+
x:(@) "*" y:@ { Node::Times(Box::new(x), Box::new(y)).simplify() }
45+
x:(@) "/" y:@ { Node::Divide(Box::new(x), Box::new(y)).simplify() }
4646
--
4747
a:expr_atom() {a}
4848
}
4949

5050
pub rule label() -> Node = whitespace()? i:idstr() whitespace()? ":" { Node::Label(i.to_owned()) } / expected!("label")
51-
pub rule argument() -> Node = whitespace()? e:(register() / expression()) whitespace()? {Node::Argument(box e)}
51+
pub rule argument() -> Node = whitespace()? e:(register() / expression()) whitespace()? {Node::Argument(Box::new(e))}
5252
rule instruction0() -> Node = whitespace()? nm:idstr() whitespace()? { Node::Instruction(nm.to_owned(), vec![]) }
5353
rule instruction1() -> Node = whitespace()? nm:idstr() whitespace() a0:argument() whitespace()? { Node::Instruction(nm.to_owned(), vec![a0]) }
5454
rule instructionN() -> Node = whitespace()? nm:idstr() whitespace() a0:argument() aN:( "," an:argument() {an} )+ {

src/main.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(box_syntax)]
21
#![feature(box_patterns)]
32
#![warn(clippy::all)]
43
#![allow(dead_code)]

src/parser.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -74,47 +74,47 @@ impl Node {
7474

7575
Negation(box a) => {
7676
let sa = a.emitter_simplify(const_provider, pc);
77-
(Negation(box sa.0).simplify(), sa.1)
77+
(Negation(Box::new(sa.0)).simplify(), sa.1)
7878
}
7979
Plus(box a, box b) => {
8080
let sa = a.emitter_simplify(const_provider, pc);
8181
let sb = b.emitter_simplify(const_provider, pc);
82-
(Plus(box sa.0, box sb.0).simplify(), sa.1 && sb.1)
82+
(Plus(Box::new(sa.0), Box::new(sb.0)).simplify(), sa.1 && sb.1)
8383
}
8484
Minus(box a, box b) => {
8585
let sa = a.emitter_simplify(const_provider, pc);
8686
let sb = b.emitter_simplify(const_provider, pc);
87-
(Minus(box sa.0, box sb.0).simplify(), sa.1 && sb.1)
87+
(Minus(Box::new(sa.0), Box::new(sb.0)).simplify(), sa.1 && sb.1)
8888
}
8989
Times(box a, box b) => {
9090
let sa = a.emitter_simplify(const_provider, pc);
9191
let sb = b.emitter_simplify(const_provider, pc);
92-
(Times(box sa.0, box sb.0).simplify(), sa.1 && sb.1)
92+
(Times(Box::new(sa.0), Box::new(sb.0)).simplify(), sa.1 && sb.1)
9393
}
9494
Divide(box a, box b) => {
9595
let sa = a.emitter_simplify(const_provider, pc);
9696
let sb = b.emitter_simplify(const_provider, pc);
97-
(Divide(box sa.0, box sb.0).simplify(), sa.1 && sb.1)
97+
(Divide(Box::new(sa.0), Box::new(sb.0)).simplify(), sa.1 && sb.1)
9898
}
9999
Shl(box a, box b) => {
100100
let sa = a.emitter_simplify(const_provider, pc);
101101
let sb = b.emitter_simplify(const_provider, pc);
102-
(Shl(box sa.0, box sb.0).simplify(), sa.1 && sb.1)
102+
(Shl(Box::new(sa.0), Box::new(sb.0)).simplify(), sa.1 && sb.1)
103103
}
104104
Shr(box a, box b) => {
105105
let sa = a.emitter_simplify(const_provider, pc);
106106
let sb = b.emitter_simplify(const_provider, pc);
107-
(Shr(box sa.0, box sb.0).simplify(), sa.1 && sb.1)
107+
(Shr(Box::new(sa.0), Box::new(sb.0)).simplify(), sa.1 && sb.1)
108108
}
109109
Ashr(box a, box b) => {
110110
let sa = a.emitter_simplify(const_provider, pc);
111111
let sb = b.emitter_simplify(const_provider, pc);
112-
(Ashr(box sa.0, box sb.0).simplify(), sa.1 && sb.1)
112+
(Ashr(Box::new(sa.0), Box::new(sb.0)).simplify(), sa.1 && sb.1)
113113
}
114114

115115
Argument(box node) => {
116116
let s = node.emitter_simplify(const_provider, pc);
117-
(Argument(box s.0), s.1)
117+
(Argument(Box::new(s.0)), s.1)
118118
}
119119
Instruction(iname, args) => {
120120
let mut succ = true;

0 commit comments

Comments
 (0)