Skip to content

Commit b7cd99d

Browse files
Add regression test for impl associated items sorting
1 parent 318b4f3 commit b7cd99d

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// This test ensures that impl associated items always follow this order:
2+
//
3+
// 1. Types
4+
// 2. Consts
5+
// 3. Functions
6+
7+
#![feature(inherent_associated_types)]
8+
#![allow(incomplete_features)]
9+
#![crate_name = "foo"]
10+
11+
//@ has 'foo/struct.Bar.html'
12+
pub struct Bar;
13+
14+
impl Bar {
15+
//@ has - '//*[@id="implementations-list"]//*[@class="impl-items"]/section[3]/h4' \
16+
// 'pub fn foo()'
17+
pub fn foo() {}
18+
//@ has - '//*[@id="implementations-list"]//*[@class="impl-items"]/section[2]/h4' \
19+
// 'pub const X: u8 = 12u8'
20+
pub const X: u8 = 12;
21+
//@ has - '//*[@id="implementations-list"]//*[@class="impl-items"]/section[1]/h4' \
22+
// 'pub type Y = u8'
23+
pub type Y = u8;
24+
}
25+
26+
pub trait Foo {
27+
const W: u32;
28+
fn yeay();
29+
type Z;
30+
}
31+
32+
impl Foo for Bar {
33+
//@ has - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]/section[2]/h4' \
34+
// 'const W: u32 = 12u32'
35+
const W: u32 = 12;
36+
//@ has - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]/section[1]/h4' \
37+
// 'type Z = u8'
38+
type Z = u8;
39+
//@ has - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]/section[3]/h4' \
40+
// 'fn yeay()'
41+
fn yeay() {}
42+
}

0 commit comments

Comments
 (0)