mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
Merge pull request #947 from marcusklaas/match-pattern-limit
Fix off-by-one error in pattern formatting
This commit is contained in:
commit
fe993dbdf3
@ -76,8 +76,9 @@ impl Rewrite for Pat {
|
|||||||
if pat_vec.is_empty() {
|
if pat_vec.is_empty() {
|
||||||
Some(path_str)
|
Some(path_str)
|
||||||
} else {
|
} else {
|
||||||
// 1 = (
|
// 2 = "()".len()
|
||||||
let width = try_opt!(width.checked_sub(path_str.len() + 1));
|
let width = try_opt!(width.checked_sub(path_str.len() + 2));
|
||||||
|
// 1 = "(".len()
|
||||||
let offset = offset + path_str.len() + 1;
|
let offset = offset + path_str.len() + 1;
|
||||||
let items = itemize_list(context.codemap,
|
let items = itemize_list(context.codemap,
|
||||||
pat_vec.iter(),
|
pat_vec.iter(),
|
||||||
|
20
tests/source/issue-913.rs
Normal file
20
tests/source/issue-913.rs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
mod client {
|
||||||
|
impl Client {
|
||||||
|
fn test(self) -> Result<()> {
|
||||||
|
let next_state = match self.state {
|
||||||
|
State::V5(v5::State::Command(v5::coand::State::WriteVersion(ref mut response))) => {
|
||||||
|
let x = reformat . meeee() ;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let next_state = match self.state {
|
||||||
|
State::V5(v5::State::Command(v5::comand::State::WriteVersion(ref mut response))) => {
|
||||||
|
// The pattern cannot be formatted in a way that the match stays
|
||||||
|
// within the column limit. The rewrite should therefore be
|
||||||
|
// skipped.
|
||||||
|
let x = dont . reformat . meeee();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
20
tests/target/issue-913.rs
Normal file
20
tests/target/issue-913.rs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
mod client {
|
||||||
|
impl Client {
|
||||||
|
fn test(self) -> Result<()> {
|
||||||
|
let next_state = match self.state {
|
||||||
|
State::V5(v5::State::Command(v5::coand::State::WriteVersion(ref mut response))) => {
|
||||||
|
let x = reformat.meeee();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let next_state = match self.state {
|
||||||
|
State::V5(v5::State::Command(v5::comand::State::WriteVersion(ref mut response))) => {
|
||||||
|
// The pattern cannot be formatted in a way that the match stays
|
||||||
|
// within the column limit. The rewrite should therefore be
|
||||||
|
// skipped.
|
||||||
|
let x = dont . reformat . meeee();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user