2017-01-16 14:50:27 +13:00
|
|
|
// rustfmt-normalize_comments: true
|
2015-11-10 08:03:01 +13:00
|
|
|
// rustfmt-wrap_comments: true
|
2015-05-25 11:03:26 +12:00
|
|
|
|
|
|
|
/// A Doc comment
|
|
|
|
#[AnAttribute]
|
|
|
|
pub struct Foo {
|
|
|
|
#[rustfmt_skip]
|
|
|
|
f : SomeType, // Comment beside a field
|
|
|
|
f: SomeType, // Comment beside a field
|
|
|
|
// Comment on a field
|
2018-01-11 16:53:13 +09:00
|
|
|
#[AnAttribute]
|
|
|
|
g: SomeOtherType,
|
2015-05-25 11:03:26 +12:00
|
|
|
/// A doc comment on a field
|
|
|
|
h: AThirdType,
|
2015-06-10 15:17:59 -06:00
|
|
|
pub i: TypeForPublicField,
|
2015-05-25 11:03:26 +12:00
|
|
|
}
|
|
|
|
|
2017-09-05 01:04:31 +09:00
|
|
|
// #1095
|
|
|
|
struct S<T /* comment */> {
|
|
|
|
t: T,
|
|
|
|
}
|
|
|
|
|
2017-05-27 09:36:25 +09:00
|
|
|
// #1029
|
|
|
|
pub struct Foo {
|
|
|
|
#[doc(hidden)]
|
|
|
|
// This will NOT get deleted!
|
|
|
|
bar: String, // hi
|
|
|
|
}
|
|
|
|
|
|
|
|
// #1029
|
|
|
|
struct X {
|
|
|
|
// `x` is an important number.
|
|
|
|
#[allow(unused)] // TODO: use
|
|
|
|
x: u32,
|
|
|
|
}
|
|
|
|
|
|
|
|
// #410
|
|
|
|
#[allow(missing_docs)]
|
|
|
|
pub struct Writebatch<K: Key> {
|
|
|
|
#[allow(dead_code)] // only used for holding the internal pointer
|
|
|
|
writebatch: RawWritebatch,
|
|
|
|
marker: PhantomData<K>,
|
|
|
|
}
|
|
|
|
|
2015-05-25 11:03:26 +12:00
|
|
|
struct Bar;
|
|
|
|
|
2015-06-23 15:58:58 +02:00
|
|
|
struct NewType(Type, OtherType);
|
|
|
|
|
2017-06-24 19:49:01 +09:00
|
|
|
struct NewInt<T: Copy>(
|
|
|
|
pub i32,
|
|
|
|
SomeType, // inline comment
|
2017-07-06 01:03:20 +09:00
|
|
|
T, // sup
|
2017-06-24 19:49:01 +09:00
|
|
|
);
|
2015-06-23 15:58:58 +02:00
|
|
|
|
2017-06-24 01:12:58 +09:00
|
|
|
struct Qux<
|
|
|
|
'a,
|
|
|
|
N: Clone + 'a,
|
|
|
|
E: Clone + 'a,
|
|
|
|
G: Labeller<'a, N, E> + GraphWalk<'a, N, E>,
|
|
|
|
W: Write + Copy,
|
|
|
|
>(
|
2015-06-23 15:58:58 +02:00
|
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, // Comment
|
|
|
|
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
|
|
|
|
#[AnAttr]
|
|
|
|
// Comment
|
|
|
|
/// Testdoc
|
|
|
|
G,
|
|
|
|
pub W,
|
|
|
|
);
|
|
|
|
|
2017-06-12 16:01:41 +12:00
|
|
|
struct Tuple(
|
|
|
|
// Comment 1
|
|
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
|
|
|
|
// Comment 2
|
2017-06-24 01:12:58 +09:00
|
|
|
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
|
2017-06-12 16:01:41 +12:00
|
|
|
);
|
2015-06-23 15:58:58 +02:00
|
|
|
|
2015-05-25 11:03:26 +12:00
|
|
|
// With a where clause and generics.
|
|
|
|
pub struct Foo<'a, Y: Baz>
|
2017-06-12 16:01:41 +12:00
|
|
|
where
|
|
|
|
X: Whatever,
|
2015-05-25 11:03:26 +12:00
|
|
|
{
|
|
|
|
f: SomeType, // Comment beside a field
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Baz {
|
|
|
|
a: A, // Comment A
|
|
|
|
b: B, // Comment B
|
|
|
|
c: C, // Comment C
|
|
|
|
}
|
|
|
|
|
2015-09-02 14:11:19 +12:00
|
|
|
struct Baz {
|
|
|
|
a: A, // Comment A
|
|
|
|
|
|
|
|
b: B, // Comment B
|
|
|
|
|
|
|
|
c: C, // Comment C
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Baz {
|
|
|
|
a: A,
|
|
|
|
|
|
|
|
b: B,
|
|
|
|
c: C,
|
|
|
|
|
|
|
|
d: D,
|
|
|
|
}
|
|
|
|
|
2015-05-25 11:03:26 +12:00
|
|
|
struct Baz {
|
|
|
|
// Comment A
|
|
|
|
a: A,
|
2015-09-02 14:11:19 +12:00
|
|
|
|
2015-05-25 11:03:26 +12:00
|
|
|
// Comment B
|
|
|
|
b: B,
|
|
|
|
// Comment C
|
|
|
|
c: C,
|
|
|
|
}
|
2015-06-23 15:58:58 +02:00
|
|
|
|
|
|
|
// Will this be a one-liner?
|
2017-06-24 19:49:01 +09:00
|
|
|
struct Tuple(
|
|
|
|
A, // Comment
|
|
|
|
B,
|
|
|
|
);
|
2015-08-21 16:28:32 +02:00
|
|
|
|
|
|
|
pub struct State<F: FnMut() -> time::Timespec> {
|
|
|
|
now: F,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct State<F: FnMut() -> ()> {
|
|
|
|
now: F,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct State<F: FnMut()> {
|
|
|
|
now: F,
|
|
|
|
}
|
2015-09-25 16:53:44 +02:00
|
|
|
|
|
|
|
struct Palette {
|
2017-11-01 07:33:55 +01:00
|
|
|
/// A map of indices in the palette to a count of pixels in approximately
|
2016-05-02 20:54:25 +12:00
|
|
|
/// that color
|
2015-09-25 16:53:44 +02:00
|
|
|
foo: i32,
|
|
|
|
}
|
2015-10-07 19:23:07 -04:00
|
|
|
|
|
|
|
// Splitting a single line comment into a block previously had a misalignment
|
|
|
|
// when the field had attributes
|
|
|
|
struct FieldsWithAttributes {
|
|
|
|
// Pre Comment
|
2017-07-03 18:55:11 +09:00
|
|
|
#[rustfmt_skip] pub host:String, /* Post comment BBBBBBBBBBBBBB BBBBBBBBBBBBBBBB
|
|
|
|
* BBBBBBBBBBBBBBBB BBBBBBBBBBBBBBBBB BBBBBBBBBBB */
|
2015-10-07 19:23:07 -04:00
|
|
|
// Another pre comment
|
|
|
|
#[attr1]
|
|
|
|
#[attr2]
|
2017-07-03 18:55:11 +09:00
|
|
|
pub id: usize, /* CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCC
|
|
|
|
* CCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCC CCCCCCCCCCCC */
|
2015-10-07 19:23:07 -04:00
|
|
|
}
|
2015-10-19 00:25:38 +02:00
|
|
|
|
|
|
|
struct Deep {
|
2017-03-29 20:15:27 +09:00
|
|
|
deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep:
|
|
|
|
node::Handle<IdRef<'id, Node<K, V>>, Type, NodeType>,
|
2015-10-19 00:25:38 +02:00
|
|
|
}
|
2015-11-09 19:00:04 +13:00
|
|
|
|
|
|
|
struct Foo<T>(T);
|
|
|
|
struct Foo<T>(T)
|
2017-06-12 16:01:41 +12:00
|
|
|
where
|
|
|
|
T: Copy,
|
|
|
|
T: Eq;
|
|
|
|
struct Foo<T>(
|
|
|
|
TTTTTTTTTTTTTTTTT,
|
|
|
|
UUUUUUUUUUUUUUUUUUUUUUUU,
|
|
|
|
TTTTTTTTTTTTTTTTTTT,
|
2017-06-24 01:12:58 +09:00
|
|
|
UUUUUUUUUUUUUUUUUUU,
|
2017-06-12 16:01:41 +12:00
|
|
|
);
|
2017-06-24 19:49:01 +09:00
|
|
|
struct Foo<T>(
|
|
|
|
TTTTTTTTTTTTTTTTTT,
|
|
|
|
UUUUUUUUUUUUUUUUUUUUUUUU,
|
|
|
|
TTTTTTTTTTTTTTTTTTT,
|
|
|
|
)
|
2017-06-12 16:01:41 +12:00
|
|
|
where
|
|
|
|
T: PartialEq;
|
2017-06-24 19:49:01 +09:00
|
|
|
struct Foo<T>(
|
|
|
|
TTTTTTTTTTTTTTTTT,
|
|
|
|
UUUUUUUUUUUUUUUUUUUUUUUU,
|
|
|
|
TTTTTTTTTTTTTTTTTTTTT,
|
|
|
|
)
|
2017-06-12 16:01:41 +12:00
|
|
|
where
|
|
|
|
T: PartialEq;
|
|
|
|
struct Foo<T>(
|
|
|
|
TTTTTTTTTTTTTTTTT,
|
|
|
|
UUUUUUUUUUUUUUUUUUUUUUUU,
|
|
|
|
TTTTTTTTTTTTTTTTTTT,
|
2017-06-24 01:12:58 +09:00
|
|
|
UUUUUUUUUUUUUUUUUUU,
|
2017-06-12 16:01:41 +12:00
|
|
|
)
|
|
|
|
where
|
|
|
|
T: PartialEq;
|
|
|
|
struct Foo<T>(
|
2017-07-06 01:03:20 +09:00
|
|
|
TTTTTTTTTTTTTTTTT, // Foo
|
2017-06-12 16:01:41 +12:00
|
|
|
UUUUUUUUUUUUUUUUUUUUUUUU, // Bar
|
|
|
|
// Baz
|
|
|
|
TTTTTTTTTTTTTTTTTTT,
|
|
|
|
// Qux (FIXME #572 - doc comment)
|
2017-06-24 01:12:58 +09:00
|
|
|
UUUUUUUUUUUUUUUUUUU,
|
2017-06-12 16:01:41 +12:00
|
|
|
);
|
2015-11-13 14:31:20 +01:00
|
|
|
|
|
|
|
mod m {
|
|
|
|
struct X<T>
|
2017-06-12 16:01:41 +12:00
|
|
|
where
|
|
|
|
T: Sized,
|
2015-11-13 14:31:20 +01:00
|
|
|
{
|
|
|
|
a: T,
|
|
|
|
}
|
|
|
|
}
|
2015-11-22 22:55:57 +01:00
|
|
|
|
2017-06-12 16:01:41 +12:00
|
|
|
struct Foo<T>(
|
|
|
|
TTTTTTTTTTTTTTTTTTT,
|
|
|
|
/// Qux
|
2017-06-24 01:12:58 +09:00
|
|
|
UUUUUUUUUUUUUUUUUUU,
|
2017-06-12 16:01:41 +12:00
|
|
|
);
|
2015-12-06 01:11:26 +01:00
|
|
|
|
|
|
|
struct Issue677 {
|
|
|
|
pub ptr: *const libc::c_void,
|
|
|
|
pub trace: fn(obj: *const libc::c_void, tracer: *mut JSTracer),
|
|
|
|
}
|
2016-04-12 07:05:54 +12:00
|
|
|
|
|
|
|
struct Foo {}
|
2017-01-09 12:11:12 +09:00
|
|
|
struct Foo {}
|
|
|
|
struct Foo {
|
|
|
|
// comment
|
|
|
|
}
|
|
|
|
struct Foo {
|
|
|
|
// trailing space ->
|
|
|
|
}
|
2018-04-28 14:07:10 +09:00
|
|
|
struct Foo {
|
|
|
|
// comment
|
|
|
|
}
|
|
|
|
struct Foo(
|
|
|
|
// comment
|
|
|
|
);
|
2017-03-29 20:15:27 +09:00
|
|
|
|
|
|
|
struct LongStruct {
|
|
|
|
a: A,
|
|
|
|
the_quick_brown_fox_jumps_over_the_lazy_dog:
|
|
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Deep {
|
|
|
|
deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep:
|
|
|
|
node::Handle<IdRef<'id, Node<Key, Value>>, Type, NodeType>,
|
|
|
|
}
|
2017-03-31 21:57:29 +09:00
|
|
|
|
|
|
|
struct Foo<C = ()>(String);
|
2017-05-04 13:52:35 +09:00
|
|
|
|
|
|
|
// #1364
|
|
|
|
fn foo() {
|
|
|
|
convex_shape.set_point(0, &Vector2f { x: 400.0, y: 100.0 });
|
|
|
|
convex_shape.set_point(1, &Vector2f { x: 500.0, y: 70.0 });
|
|
|
|
convex_shape.set_point(2, &Vector2f { x: 450.0, y: 100.0 });
|
|
|
|
convex_shape.set_point(3, &Vector2f { x: 580.0, y: 150.0 });
|
|
|
|
}
|
2017-07-06 01:03:20 +09:00
|
|
|
|
2017-07-07 09:01:14 +09:00
|
|
|
// Vertical alignment
|
2017-07-06 01:03:20 +09:00
|
|
|
struct Foo {
|
|
|
|
aaaaa: u32, // a
|
|
|
|
|
|
|
|
b: u32, // b
|
|
|
|
cc: u32, // cc
|
|
|
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: u32, // 1
|
|
|
|
yy: u32, // comment2
|
|
|
|
zzz: u32, // comment3
|
|
|
|
|
|
|
|
aaaaaa: u32, // comment4
|
|
|
|
bb: u32, // comment5
|
|
|
|
// separate
|
|
|
|
dd: u32, // comment7
|
|
|
|
c: u32, // comment6
|
|
|
|
|
|
|
|
aaaaaaa: u32, /* multi
|
|
|
|
* line
|
|
|
|
* comment
|
2017-12-17 15:23:17 +09:00
|
|
|
*/
|
2017-07-06 01:03:20 +09:00
|
|
|
b: u32, // hi
|
2017-07-07 09:01:14 +09:00
|
|
|
|
|
|
|
do_not_push_this_comment1: u32, // comment1
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: u32, // 2
|
|
|
|
please_do_not_push_this_comment3: u32, // comment3
|
|
|
|
|
|
|
|
do_not_push_this_comment1: u32, // comment1
|
|
|
|
// separate
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: u32, // 2
|
|
|
|
please_do_not_push_this_comment3: u32, // comment3
|
|
|
|
|
|
|
|
do_not_push_this_comment1: u32, // comment1
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: u32, // 2
|
|
|
|
// separate
|
|
|
|
please_do_not_push_this_comment3: u32, // comment3
|
2017-07-06 01:03:20 +09:00
|
|
|
}
|
2017-07-25 18:51:29 +09:00
|
|
|
|
|
|
|
// structs with long identifier
|
|
|
|
struct Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
|
|
|
|
{}
|
|
|
|
struct Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
|
|
|
|
{}
|
|
|
|
struct Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
|
|
|
|
{}
|
|
|
|
struct Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
|
|
|
|
{
|
|
|
|
x: i32,
|
|
|
|
}
|
2017-11-03 22:25:30 +09:00
|
|
|
|
|
|
|
// structs with visibility, do not duplicate visibility (#2110).
|
2017-11-03 23:38:32 +09:00
|
|
|
pub(self) struct Foo {}
|
|
|
|
pub(super) struct Foo {}
|
|
|
|
pub(crate) struct Foo {}
|
|
|
|
pub(self) struct Foo();
|
2017-11-03 22:25:30 +09:00
|
|
|
pub(super) struct Foo();
|
|
|
|
pub(crate) struct Foo();
|
2017-11-08 11:52:14 +09:00
|
|
|
|
|
|
|
// #2125
|
|
|
|
pub struct ReadinessCheckRegistry(
|
|
|
|
Mutex<HashMap<Arc<String>, Box<Fn() -> ReadinessCheck + Sync + Send>>>,
|
|
|
|
);
|
2017-11-13 08:01:52 +09:00
|
|
|
|
|
|
|
// #2144 unit struct with generics
|
|
|
|
struct MyBox<T: ?Sized>;
|
2017-11-13 11:06:09 +09:00
|
|
|
struct MyBoxx<T, S>
|
|
|
|
where
|
|
|
|
T: ?Sized,
|
|
|
|
S: Clone;
|
2018-02-05 08:38:53 +09:00
|
|
|
|
|
|
|
// #2208
|
|
|
|
struct Test {
|
|
|
|
/// foo
|
|
|
|
#[serde(default)]
|
|
|
|
pub join: Vec<String>,
|
|
|
|
#[serde(default)]
|
|
|
|
pub tls: bool,
|
|
|
|
}
|