forked from rust-lang/rustfmt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove wrong reformatting of qualified paths in struct patterns
- Loading branch information
1 parent
fd6b025
commit e81c393
Showing
3 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#![feature(more_qualified_paths)] | ||
|
||
fn main() { | ||
// destructure through a qualified path | ||
let <Foo as A>::Assoc { br } = StructStruct { br: 2 }; | ||
} | ||
|
||
struct StructStruct { | ||
br: i8, | ||
} | ||
|
||
struct Foo; | ||
|
||
trait A { | ||
type Assoc; | ||
} | ||
|
||
impl A for Foo { | ||
type Assoc = StructStruct; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#![feature(more_qualified_paths)] | ||
|
||
mod foo_bar { | ||
pub enum Example { | ||
Example1 {}, | ||
Example2 {}, | ||
} | ||
} | ||
|
||
fn main() { | ||
foo!(crate::foo_bar::Example, Example1); | ||
|
||
let i1 = foo_bar::Example::Example1 {}; | ||
|
||
assert_eq!(i1.foo_example(), 1); | ||
|
||
let i2 = foo_bar::Example::Example2 {}; | ||
|
||
assert_eq!(i2.foo_example(), 2); | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! foo { | ||
($struct:path, $variant:ident) => { | ||
impl $struct { | ||
pub fn foo_example(&self) -> i32 { | ||
match self { | ||
<$struct>::$variant { .. } => 1, | ||
_ => 2, | ||
} | ||
} | ||
} | ||
}; | ||
} |