Skip to content

Commit 759f335

Browse files
committed
Prune stale issues
Adds regression tests for the following issues which seem to be fixed on master: Closes rust-lang#1762 Closes rust-lang#2388 Closes rust-lang#2672 Closes rust-lang#2755 Closes rust-lang#2947 Closes rust-lang#2978 Closes rust-lang#3148 Closes rust-lang#3206 @topecongiro @calebcartwright appologies for the large number of issues in this commit; if you prefer I can split it up into 2+.
1 parent 3035670 commit 759f335

File tree

11 files changed

+227
-0
lines changed

11 files changed

+227
-0
lines changed

tests/source/issue-2947.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// rustfmt-force_multiline_blocks: true
2+
3+
impl fmt::Display for DeriveError {
4+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5+
match self {
6+
DeriveError::UnionUnsupported(name) => {
7+
write!(f, "Cannot derive `Spaned` for `union {}`", name)
8+
}
9+
DeriveError::UnitStructUnsupported(name) => {
10+
write!(f, "Cannot derive `Spanned` for `struct {};`", name)
11+
}
12+
DeriveError::NamedStructLacksSpan(name) => write!(
13+
f,
14+
"Cannot derive `Spanned` for `struct {}` as it lacks a field `span`",
15+
name
16+
),
17+
DeriveError::TupleStructNotNewtype(name) => {
18+
write!(f,
19+
"Cannot derive `Spanned` for `struct {}` as it does not have a single tuple member",
20+
name,
21+
)
22+
}
23+
}
24+
}
25+
}

tests/source/issue-2978.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// rustfmt-control_brace_style: ClosingNextLine
2+
3+
pub fn test() {
4+
let xxxxxxxxxxxxxxxxxxxxxxxxxxxx = yyyyyyyyyyyyyyyy | zzzzzzzzzzzzzzzzzzzzzzzz | if for_writing
5+
{
6+
fffffffffffffffffffff
7+
}
8+
else {
9+
g
10+
};
11+
}

tests/source/issue-3206.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
fn apply_arithmetic_operation<'a>(op: ArithmeticOperation, state: &mut State) -> Result<'a, ()> {
2+
match ( state.stack.pop (), state.stack.pop () )
3+
4+
5+
6+
7+
8+
{
9+
(Some(value1), Some(value2)) => {
10+
11+
12+
13+
match (value1, value2) {
14+
(Value::Number(num1), Value::Number(num2)) => {
15+
let result = match op {
16+
ArithmeticOperation::Addition => num1 + num2,
17+
ArithmeticOperation::Subtraction => num1 - num2,
18+
ArithmeticOperation::Multiplication => num1 * num2,
19+
ArithmeticOperation::Division => num1 /num2,
20+
ArithmeticOperation::Remainder => num1 % num2,
21+
};
22+
state.stack.push(Value::Number(result));
23+
Ok(())
24+
}
25+
_ =>
26+
Err(Error::RuntimeError(
27+
"cannot sum values on top of stack: the two topmost values on the stack should be numbers",
28+
))
29+
}}
30+
_ =>
31+
return Err(Error::RuntimeError(
32+
"cannot sum values on top of stack: there must be at least two values on the stack",
33+
))
34+
}
35+
}

tests/target/issue-1762.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// rustfmt-indent_style=Visual
2+
3+
fn main() {
4+
let grammar: Vec<_> = ast
5+
.attrs
6+
.iter()
7+
.filter(|attr| match attr.value {
8+
MetaItem::NameValue(ref ident, _) => format!("{}", ident) == "grammar",
9+
_ => false,
10+
})
11+
.collect();
12+
}

tests/target/issue-2388.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
macro lex_err($kind: ident $(, $body: expr)*) {
2+
Err(QlError::LexError(LexError::$kind($($body,)*)))
3+
}

tests/target/issue-2672.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
fn main() {
2+
fn test(
3+
averylongname_asdfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdsffffffffffffffffffffffffffffffffffffffffffffffff: i32,
4+
) {
5+
}
6+
fn test(
7+
shortname: i32,
8+
averylongname_asdfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdsffffffffffffffffffffffffffffffffffffffffffffffff: i32,
9+
) {
10+
}
11+
12+
let averylongname_asdfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff =
13+
0;
14+
}
15+
16+
mod asdf {
17+
fn test(
18+
averylongname_asdfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdsffffffffffffffffffffffffffffffffffffffffffffffff: i32,
19+
) {
20+
}
21+
}

tests/target/issue-2755.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
macro_rules! __diesel_operator_to_sql {
2+
(
3+
notation = infix,
4+
operator_expr = $op:expr,
5+
field_exprs = ($left:expr, $right:expr),
6+
) => {
7+
$left;
8+
$op;
9+
$right;
10+
};
11+
12+
(
13+
notation = postfix,
14+
operator_expr = $op:expr,
15+
field_exprs = ($expr:expr),
16+
) => {
17+
$expr;
18+
$op;
19+
};
20+
21+
(
22+
notation = prefix,
23+
operator_expr = $op:expr,
24+
field_exprs = ($expr:expr),
25+
) => {
26+
$op;
27+
$expr;
28+
};
29+
30+
($name:ident, $operator:expr, backend: $backend:ty) => {
31+
diesel_postfix_operator!($name, $operator, $crate::sql_types::Bool, backend: $backend);
32+
};
33+
34+
($name:ident, $operator:expr, $return_ty:ty, backend: $backend:ty) => {
35+
__diesel_operator_body!(notation = postfix, struct_name = $name,)
36+
};
37+
38+
($name:ident, $operator:expr, backend: $backend:ty) => {
39+
diesel_prefix_operator!($name, $operator, $crate::sql_types::Bool, backend: $backend);
40+
};
41+
}

tests/target/issue-2947.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// rustfmt-force_multiline_blocks: true
2+
3+
impl fmt::Display for DeriveError {
4+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5+
match self {
6+
DeriveError::UnionUnsupported(name) => {
7+
write!(f, "Cannot derive `Spaned` for `union {}`", name)
8+
}
9+
DeriveError::UnitStructUnsupported(name) => {
10+
write!(f, "Cannot derive `Spanned` for `struct {};`", name)
11+
}
12+
DeriveError::NamedStructLacksSpan(name) => {
13+
write!(
14+
f,
15+
"Cannot derive `Spanned` for `struct {}` as it lacks a field `span`",
16+
name
17+
)
18+
}
19+
DeriveError::TupleStructNotNewtype(name) => {
20+
write!(
21+
f,
22+
"Cannot derive `Spanned` for `struct {}` as it does not have a single tuple member",
23+
name,
24+
)
25+
}
26+
}
27+
}
28+
}

tests/target/issue-2978.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// rustfmt-control_brace_style: ClosingNextLine
2+
3+
pub fn test() {
4+
let xxxxxxxxxxxxxxxxxxxxxxxxxxxx = yyyyyyyyyyyyyyyy
5+
| zzzzzzzzzzzzzzzzzzzzzzzz
6+
| if for_writing {
7+
fffffffffffffffffffff
8+
}
9+
else {
10+
g
11+
};
12+
}

tests/target/issue-3148.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// rustfmt-hard_tabs: true
2+
// rustfmt-normalize_comments: true
3+
4+
/// ```
5+
/// Data {
6+
/// a: "some text data",
7+
/// ..Default::default()
8+
/// };
9+
/// ```
10+
#[derive(Default)]
11+
pub struct Data {
12+
a: &str,
13+
b: u32,
14+
}

tests/target/issue-3206.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
fn apply_arithmetic_operation<'a>(op: ArithmeticOperation, state: &mut State) -> Result<'a, ()> {
2+
match (state.stack.pop(), state.stack.pop()) {
3+
(Some(value1), Some(value2)) => match (value1, value2) {
4+
(Value::Number(num1), Value::Number(num2)) => {
5+
let result = match op {
6+
ArithmeticOperation::Addition => num1 + num2,
7+
ArithmeticOperation::Subtraction => num1 - num2,
8+
ArithmeticOperation::Multiplication => num1 * num2,
9+
ArithmeticOperation::Division => num1 / num2,
10+
ArithmeticOperation::Remainder => num1 % num2,
11+
};
12+
state.stack.push(Value::Number(result));
13+
Ok(())
14+
}
15+
_ => Err(Error::RuntimeError(
16+
"cannot sum values on top of stack: the two topmost values on the stack should be numbers",
17+
)),
18+
},
19+
_ => {
20+
return Err(Error::RuntimeError(
21+
"cannot sum values on top of stack: there must be at least two values on the stack",
22+
));
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)