Skip to content

Commit bb8578d

Browse files
authored
Prune stale issues (#4246)
* Prune stale issues Adds regression tests for the following issues which seem to be fixed on master: Closes #1762 Closes #2388 Closes #2672 Closes #2755 Closes #2947 Closes #2978 Closes #3148 Closes #3206 @topecongiro @calebcartwright appologies for the large number of issues in this commit; if you prefer I can split it up into 2+. * fixup! Prune stale issues
1 parent 3035670 commit bb8578d

11 files changed

+274
-0
lines changed

Diff for: tests/source/issue-2947.rs

+25
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+
}

Diff for: tests/source/issue-2978.rs

+11
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+
}

Diff for: tests/source/issue-3206.rs

+35
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+
}

Diff for: tests/target/issue-1762.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// rustfmt-indent_style: Visual
2+
// rustfmt-max_width: 30
3+
4+
fn main() {
5+
let grammar: Vec<_> = ast
6+
.attrs
7+
.iter()
8+
.filter(|attr| match attr.value {
9+
MetaItem::NameValue(ref ident, _) => format!("{}", ident) == "grammar",
10+
_ => false,
11+
})
12+
.collect();
13+
14+
let a = b.iter()
15+
.map(|m| m.hi());
16+
}

Diff for: tests/target/issue-2388.rs

+3
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+
}

Diff for: tests/target/issue-2672.rs

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
}
22+
23+
impl Something {
24+
fn my_function_name_is_way_to_long_but_used_as_a_case_study_or_an_example_its_fine()
25+
-> Result<(), String> {
26+
}
27+
}
28+
29+
impl Something {
30+
fn my_function_name()
31+
-> HashMap<(String, String, (String, String)), (String, String, String, String)> {
32+
}
33+
}
34+
35+
mod A {
36+
mod B {
37+
mod C {
38+
mod D {
39+
mod E {
40+
mod F {
41+
mod G {
42+
mod H {
43+
mod I {
44+
mod J {
45+
mod K {
46+
mod L {
47+
mod M {
48+
fn setup_happy_path()
49+
-> Result<String, CustomTypeA>
50+
{
51+
}
52+
}
53+
}
54+
}
55+
}
56+
}
57+
}
58+
}
59+
}
60+
}
61+
}
62+
}
63+
}
64+
}

Diff for: tests/target/issue-2755.rs

+41
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+
}

Diff for: tests/target/issue-2947.rs

+28
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+
}

Diff for: tests/target/issue-2978.rs

+12
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+
}

Diff for: tests/target/issue-3148.rs

+14
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+
}

Diff for: tests/target/issue-3206.rs

+25
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)