rustfmt tests/rustdoc-js/.

This commit is contained in:
Nicholas Nethercote 2024-06-03 17:35:56 +10:00
parent 98d65d62c5
commit c6fb703c05
28 changed files with 240 additions and 133 deletions

View file

@ -19,7 +19,6 @@ ignore = [
"/tests/run-make/translation/test.rs", # This test contains syntax errors.
"/tests/rustdoc/", # Some have syntax errors, some are whitespace-sensitive.
"/tests/rustdoc-gui/", # Some tests are sensitive to source code layout.
"/tests/rustdoc-js/",
"/tests/rustdoc-json/",
"/tests/rustdoc-js-std/",
"/tests/rustdoc-ui/",

View file

@ -5,22 +5,27 @@ pub trait MyTrait2<X> {
pub trait MyTrait {
type Item;
fn next(&mut self) -> Option<Self::Item>;
fn fold<B, F>(self, init: B, f: F) -> B where
fn fold<B, F>(self, init: B, f: F) -> B
where
Self: Sized,
F: MyTrait2<(B, Self::Item), Output=B>;
F: MyTrait2<(B, Self::Item), Output = B>;
}
pub struct Cloned<I>(I);
impl<'a, T, I> MyTrait for Cloned<I> where
impl<'a, T, I> MyTrait for Cloned<I>
where
T: 'a + Clone,
I: MyTrait<Item = &'a T>
I: MyTrait<Item = &'a T>,
{
type Item = T;
fn next(&mut self) -> Option<Self::Item> { loop {} }
fn fold<B, F>(self, init: B, f: F) -> B where
fn next(&mut self) -> Option<Self::Item> {
loop {}
}
fn fold<B, F>(self, init: B, f: F) -> B
where
Self: Sized,
F: MyTrait2<(B, Self::Item), Output=B>
F: MyTrait2<(B, Self::Item), Output = B>,
{
loop {}
}
@ -32,7 +37,7 @@ pub trait MyFuture {
pub trait MyIntoFuture {
type Output;
type Fut: MyFuture<Output=Self::Output>;
type Fut: MyFuture<Output = Self::Output>;
fn into_future(self) -> Self::Fut;
fn into_future_2(self, other: Self) -> Self::Fut;
}

View file

@ -1,9 +1,9 @@
#![crate_name="foo"]
#![crate_name = "foo"]
// reduced from sqlx 0.7.3
use std::future::Future;
use std::pin::Pin;
use std::ops::{Deref, DerefMut};
use std::pin::Pin;
pub enum Error {}
pub trait Acquire<'c> {
type Database: Database;
@ -16,7 +16,7 @@ pub trait Connection {
type Database: Database;
type Options: ConnectionOptions<Connection = Self>;
fn begin(
&mut self
&mut self,
) -> Pin<Box<dyn Future<Output = Result<Transaction<'_, Self::Database>, Error>> + Send + '_>>
where
Self: Sized;
@ -28,7 +28,8 @@ pub struct Transaction<'c, DB: Database> {
_db: &'c DB,
}
impl<'t, 'c, DB: Database> Acquire<'t> for &'t mut Transaction<'c, DB>
where <DB as Database>::Connection: Send
where
<DB as Database>::Connection: Send,
{
type Database = DB;
type Connection = &'t mut <DB as Database>::Connection;

View file

@ -77,17 +77,14 @@ pub trait Interner: Sized {
type ClosureKind: Copy + Debug + Hash + Eq;
// Required method
fn mk_canonical_var_infos(
self,
infos: &[CanonicalVarInfo<Self>]
) -> Self::CanonicalVars;
fn mk_canonical_var_infos(self, infos: &[CanonicalVarInfo<Self>]) -> Self::CanonicalVars;
}
pub trait DebugWithInfcx<I: Interner>: Debug {
// Required method
fn fmt<Infcx: InferCtxtLike<Interner = I>>(
this: WithInfcx<'_, Infcx, &Self>,
f: &mut Formatter<'_>
f: &mut Formatter<'_>,
) -> std::fmt::Result;
}
@ -130,11 +127,7 @@ pub trait Flags {
pub trait Ty<I: Interner<Ty = Self>> {
// Required method
fn new_anon_bound(
interner: I,
debruijn: DebruijnIndex,
var: BoundVar
) -> Self;
fn new_anon_bound(interner: I, debruijn: DebruijnIndex, var: BoundVar) -> Self;
}
pub trait PlaceholderLike {
@ -152,12 +145,7 @@ pub trait PlaceholderLike {
pub struct ConstKind<I>(std::marker::PhantomData<I>);
pub trait Const<I: Interner<Const = Self>> {
// Required method
fn new_anon_bound(
interner: I,
debruijn: DebruijnIndex,
var: BoundVar,
ty: I::Ty
) -> Self;
fn new_anon_bound(interner: I, debruijn: DebruijnIndex, var: BoundVar, ty: I::Ty) -> Self;
}
pub trait ConstTy<I: Interner> {
@ -170,25 +158,28 @@ pub trait ConstTy<I: Interner> {
pub struct RegionKind<I>(std::marker::PhantomData<I>);
pub trait Region<I: Interner<Region = Self>> {
// Required method
fn new_anon_bound(
interner: I,
debruijn: DebruijnIndex,
var: BoundVar
) -> Self;
fn new_anon_bound(interner: I, debruijn: DebruijnIndex, var: BoundVar) -> Self;
}
pub trait TypeVisitor<I: Interner>: Sized {
type Result: VisitorResult = ();
// Provided methods
fn visit_binder<T: TypeVisitable<I>>(
&mut self,
t: &I::Binder<T>
) -> Self::Result { unimplemented!() }
fn visit_ty(&mut self, t: I::Ty) -> Self::Result { unimplemented!() }
fn visit_region(&mut self, _r: I::Region) -> Self::Result { unimplemented!() }
fn visit_const(&mut self, c: I::Const) -> Self::Result { unimplemented!() }
fn visit_predicate(&mut self, p: I::Predicate) -> Self::Result { unimplemented!() }
fn visit_binder<T: TypeVisitable<I>>(&mut self, t: &I::Binder<T>) -> Self::Result {
unimplemented!()
}
fn visit_ty(&mut self, t: I::Ty) -> Self::Result {
unimplemented!()
}
fn visit_region(&mut self, _r: I::Region) -> Self::Result {
unimplemented!()
}
fn visit_const(&mut self, c: I::Const) -> Self::Result {
unimplemented!()
}
fn visit_predicate(&mut self, p: I::Predicate) -> Self::Result {
unimplemented!()
}
}
pub trait VisitorResult {
@ -206,7 +197,9 @@ impl VisitorResult for () {
fn output() -> Self {}
fn from_residual(_: Self::Residual) -> Self {}
fn from_branch(_: ControlFlow<Self::Residual>) -> Self {}
fn branch(self) -> ControlFlow<Self::Residual> { ControlFlow::Continue(()) }
fn branch(self) -> ControlFlow<Self::Residual> {
ControlFlow::Continue(())
}
}
pub struct WithInfcx<'a, Infcx: InferCtxtLike, T> {
@ -221,24 +214,18 @@ pub trait InferCtxtLike {
fn interner(&self) -> Self::Interner;
fn universe_of_ty(&self, ty: TyVid) -> Option<UniverseIndex>;
fn root_ty_var(&self, vid: TyVid) -> TyVid;
fn probe_ty_var(
&self,
vid: TyVid
) -> Option<<Self::Interner as Interner>::Ty>;
fn probe_ty_var(&self, vid: TyVid) -> Option<<Self::Interner as Interner>::Ty>;
fn universe_of_lt(
&self,
lt: <Self::Interner as Interner>::InferRegion
lt: <Self::Interner as Interner>::InferRegion,
) -> Option<UniverseIndex>;
fn opportunistic_resolve_lt_var(
&self,
vid: <Self::Interner as Interner>::InferRegion
vid: <Self::Interner as Interner>::InferRegion,
) -> Option<<Self::Interner as Interner>::Region>;
fn universe_of_ct(&self, ct: ConstVid) -> Option<UniverseIndex>;
fn root_ct_var(&self, vid: ConstVid) -> ConstVid;
fn probe_ct_var(
&self,
vid: ConstVid
) -> Option<<Self::Interner as Interner>::Const>;
fn probe_ct_var(&self, vid: ConstVid) -> Option<<Self::Interner as Interner>::Const>;
}
pub struct TyVid;

View file

@ -16,7 +16,9 @@ impl Trait for Struct {
const AssociatedConst: i32 = 12;
#[doc(alias = "ImplTraitFunction")]
fn function() -> Self::Target { 0 }
fn function() -> Self::Target {
0
}
}
#[doc(alias = "EnumItem")]
@ -71,5 +73,5 @@ pub fn method(&self) {}
#[doc(alias = "MacroItem")]
#[macro_export]
macro_rules! Macro {
() => {}
() => {};
}

View file

@ -5,10 +5,14 @@ pub trait MyTrait {
fn not_appearing(&self) -> Option<&Self::T>;
}
pub fn my_fn<X>(t: X) -> X { t }
pub fn my_fn<X>(t: X) -> X {
t
}
pub trait AutoCorrectConfounder {
type InsertUnnecessarilyLongTypeNameHere;
fn assoc_type_acts_like_generic(&self, x: &Self::InsertUnnecessarilyLongTypeNameHere)
-> Option<&Self::InsertUnnecessarilyLongTypeNameHere>;
fn assoc_type_acts_like_generic(
&self,
x: &Self::InsertUnnecessarilyLongTypeNameHere,
) -> Option<&Self::InsertUnnecessarilyLongTypeNameHere>;
}

View file

@ -2,12 +2,11 @@
pub mod aaaaaaa {
extern {
extern "C" {
pub type MyForeignType;
}
impl MyForeignType {
pub fn my_method() {}
}
}

View file

@ -2,16 +2,26 @@ pub mod sac {
pub struct Sac;
impl Sac {
pub fn len(&self) -> usize { 0 }
pub fn len(&self) -> usize {
0
}
}
}
pub mod b {
pub struct Sac;
impl Sac {
pub fn len(&self) -> usize { 0 }
pub fn bar(&self, w: u32) -> usize { 0 }
pub fn bar2(&self, w: u32) -> u32 { 0 }
pub fn string(w: String) -> u32 { 0 }
pub fn len(&self) -> usize {
0
}
pub fn bar(&self, w: u32) -> usize {
0
}
pub fn bar2(&self, w: u32) -> u32 {
0
}
pub fn string(w: String) -> u32 {
0
}
}
}

View file

@ -2,7 +2,15 @@ pub trait Foo {
type Assoc<T>;
}
pub fn sample<X: Foo<Assoc<u8> = u8>>(_: X) -> u32 { loop {} }
pub fn synergy(_: impl Foo<Assoc<u8> = u8>) -> ! { loop {} }
pub fn consider(_: impl Foo<Assoc<u8> = u32>) -> bool { loop {} }
pub fn integrate<T>(_: impl Foo<Assoc<T> = T>) -> T { loop {} }
pub fn sample<X: Foo<Assoc<u8> = u8>>(_: X) -> u32 {
loop {}
}
pub fn synergy(_: impl Foo<Assoc<u8> = u8>) -> ! {
loop {}
}
pub fn consider(_: impl Foo<Assoc<u8> = u32>) -> bool {
loop {}
}
pub fn integrate<T>(_: impl Foo<Assoc<T> = T>) -> T {
loop {}
}

View file

@ -1,4 +1,4 @@
use std::io::{Result as IoResult, Read};
use std::io::{Read, Result as IoResult};
pub struct Aaaaaaa;
@ -29,7 +29,10 @@ pub fn fffffff(_: bool) -> u64 {
pub fn ggggggg(self) -> u64 {
1
}
pub fn hhhhhhh() -> Self where T: Default {
pub fn hhhhhhh() -> Self
where
T: Default,
{
Ddddddd(T::default())
}
}

View file

@ -1,8 +1,16 @@
pub trait SomeTrait {}
pub trait OtherThingxxxxxxxx {}
pub fn alef<T: OtherThingxxxxxxxx>() -> Result<T, ()> { loop {} }
pub fn bet<T: SomeTrait>() -> Result<T, ()> { loop {} }
pub fn alef<T: OtherThingxxxxxxxx>() -> Result<T, ()> {
loop {}
}
pub fn bet<T: SomeTrait>() -> Result<T, ()> {
loop {}
}
pub fn alpha<T: OtherThingxxxxxxxx>(_param: Result<T, ()>) { loop {} }
pub fn beta<T: SomeTrait>(_param: Result<T, ()>) { loop {} }
pub fn alpha<T: OtherThingxxxxxxxx>(_param: Result<T, ()>) {
loop {}
}
pub fn beta<T: SomeTrait>(_param: Result<T, ()>) {
loop {}
}

View file

@ -3,26 +3,41 @@
pub struct R<T>(T);
// returns test
pub fn alef() -> R<P> { loop {} }
pub fn bet() -> R<Q> { loop {} }
pub fn alef() -> R<P> {
loop {}
}
pub fn bet() -> R<Q> {
loop {}
}
// in_args test
pub fn alpha(_x: R<P>) { loop {} }
pub fn beta(_x: R<Q>) { loop {} }
pub fn alpha(_x: R<P>) {
loop {}
}
pub fn beta(_x: R<Q>) {
loop {}
}
// test case with multiple appearances of the same type
pub struct ExtraCreditStructMulti<T, U> { t: T, u: U }
pub struct ExtraCreditStructMulti<T, U> {
t: T,
u: U,
}
pub struct ExtraCreditInnerMulti {}
pub fn extracreditlabhomework(
_param: ExtraCreditStructMulti<ExtraCreditInnerMulti, ExtraCreditInnerMulti>
) { loop {} }
pub fn redherringmatchforextracredit(
_param: ExtraCreditStructMulti<ExtraCreditInnerMulti, ()>
) { loop {} }
_param: ExtraCreditStructMulti<ExtraCreditInnerMulti, ExtraCreditInnerMulti>,
) {
loop {}
}
pub fn redherringmatchforextracredit(_param: ExtraCreditStructMulti<ExtraCreditInnerMulti, ()>) {
loop {}
}
pub trait TraitCat {}
pub trait TraitDog {}
pub fn gamma<T: TraitCat + TraitDog>(t: T) {}
pub fn super_soup(s: Result<String, i32>) -> Result<String, i32> { s }
pub fn super_soup(s: Result<String, i32>) -> Result<String, i32> {
s
}

View file

@ -4,9 +4,9 @@
pub struct Second<T>(T);
pub struct Third<T>(T);
pub fn fn_ptr(_: fn (First<u32>) -> !, _: bool) {}
pub fn fn_once(_: impl FnOnce (Second<u32>) -> !, _: u8) {}
pub fn fn_mut(_: impl FnMut (Third<u32>) -> !, _: i8) {}
pub fn fn_(_: impl Fn (u32) -> !, _: char) {}
pub fn fn_ptr(_: fn(First<u32>) -> !, _: bool) {}
pub fn fn_once(_: impl FnOnce(Second<u32>) -> !, _: u8) {}
pub fn fn_mut(_: impl FnMut(Third<u32>) -> !, _: i8) {}
pub fn fn_(_: impl Fn(u32) -> !, _: char) {}
pub fn multiple(_: impl Fn(&'static str, &'static str) -> i8) {}

View file

@ -1,10 +1,10 @@
#[macro_export]
macro_rules! abracadabra {
() => {}
() => {};
}
#[macro_export]
macro_rules! abracadabra_b {
() => {}
() => {};
}
pub fn abracadabra() {}
pub fn abracadabra_c() {}

View file

@ -3,11 +3,27 @@
#[allow(nonstandard_style)]
pub struct never;
pub fn loops() -> ! { loop {} }
pub fn returns() -> never { never }
pub fn loops() -> ! {
loop {}
}
pub fn returns() -> never {
never
}
pub fn impossible(x: !) { match x {} }
pub fn uninteresting(x: never) { match x { never => {} } }
pub fn impossible(x: !) {
match x {}
}
pub fn uninteresting(x: never) {
match x {
never => {}
}
}
pub fn box_impossible(x: Box<!>) { match *x {} }
pub fn box_uninteresting(x: Box<never>) { match *x { never => {} } }
pub fn box_impossible(x: Box<!>) {
match *x {}
}
pub fn box_uninteresting(x: Box<never>) {
match *x {
never => {}
}
}

View file

@ -1,3 +1,3 @@
#![crate_name="abracadabra"]
#![crate_name = "abracadabra"]
pub struct HocusPocusPrestidigitation;

View file

@ -1,4 +1,4 @@
// The alias needed to be there to reproduce the bug
// that used to be here.
#[doc(alias="other_alias")]
#[doc(alias = "other_alias")]
pub fn something_else() {}

View file

@ -1,5 +1,5 @@
//@ aux-crate: macro_in_module=macro-in-module.rs
#![crate_name="foo"]
#![crate_name = "foo"]
extern crate macro_in_module;
// Test case based on the relationship between alloc and std.

View file

@ -1,5 +1,5 @@
// This test enforces that the (renamed) reexports are present in the search results.
#![crate_name="foo"]
#![crate_name = "foo"]
pub mod fmt {
pub struct Subscriber;
@ -14,5 +14,5 @@ pub fn dostuff(&self) {}
}
}
pub use foo::AnotherOne;
pub use fmt::Subscriber;
pub use foo::AnotherOne;

View file

@ -1,5 +1,5 @@
// This test enforces that the (renamed) reexports are present in the search results.
#![crate_name="foo"]
#![crate_name = "foo"]
pub mod fmt {
pub struct Subscriber;
@ -8,5 +8,5 @@ mod foo {
pub struct AnotherOne;
}
pub use foo::AnotherOne;
pub use fmt::Subscriber;
pub use foo::AnotherOne;

View file

@ -9,5 +9,5 @@ mod foo {
pub struct AnotherOne;
}
pub use foo::AnotherOne;
pub use fmt::Subscriber as FmtSubscriber;
pub use foo::AnotherOne;

View file

@ -7,13 +7,17 @@ pub fn pinky(input: &usize, manage: usize) {
pub struct Thumb;
impl Thumb {
pub fn up(&self, finger: Thumb) { unimplemented!() }
pub fn up(&self, finger: Thumb) {
unimplemented!()
}
}
pub enum Index {}
impl Index {
pub fn point(self, data: &Index) { unimplemented!() }
pub fn point(self, data: &Index) {
unimplemented!()
}
}
pub union Ring {
@ -22,11 +26,15 @@ pub union Ring {
}
impl Ring {
pub fn wear(&mut self, extra: &Ring) { unimplemented!() }
pub fn wear(&mut self, extra: &Ring) {
unimplemented!()
}
}
extern "C" {
pub type Middle;
}
pub fn show(left: &&mut Middle, right: &mut &Middle) { unimplemented!() }
pub fn show(left: &&mut Middle, right: &mut &Middle) {
unimplemented!()
}

View file

@ -3,12 +3,20 @@
pub struct R<T>(T);
// returns test
pub fn alef() -> &'static [R<P>] { loop {} }
pub fn bet() -> R<[Q; 32]> { loop {} }
pub fn alef() -> &'static [R<P>] {
loop {}
}
pub fn bet() -> R<[Q; 32]> {
loop {}
}
// in_args test
pub fn alpha(_x: R<&'static [P]>) { loop {} }
pub fn beta(_x: [R<Q>; 32]) { loop {} }
pub fn alpha(_x: R<&'static [P]>) {
loop {}
}
pub fn beta(_x: [R<Q>; 32]) {
loop {}
}
pub trait TraitCat {}
pub trait TraitDog {}

View file

@ -3,6 +3,6 @@
pub enum Enum {
Bar {
/// This is a name.
name: String
}
name: String,
},
}

View file

@ -1,6 +1,5 @@
#![crate_type = "lib"]
#![crate_name = "summaries"]
#![allow(rustdoc::broken_intra_doc_links)]
//! This *summary* has a [link], [`code`], and [`Sidebar2`] intra-doc.

View file

@ -3,16 +3,24 @@
pub struct R<T>(T);
// Checks that tuple and unit both work
pub fn side_effect() { }
pub fn side_effect() {}
// Check a non-tuple
pub fn not_tuple() -> P { loop {} }
pub fn not_tuple() -> P {
loop {}
}
// Check a 1-tuple
pub fn one() -> (P,) { loop {} }
pub fn one() -> (P,) {
loop {}
}
// Check a 2-tuple
pub fn two() -> (P,P) { loop {} }
pub fn two() -> (P, P) {
loop {}
}
// Check a nested tuple
pub fn nest() -> (Q, R<(u32,)>) { loop {} }
pub fn nest() -> (Q, R<(u32,)>) {
loop {}
}

View file

@ -1,15 +1,23 @@
#![crate_name="foo"]
#![crate_name = "foo"]
pub trait Some {}
impl Some for () {}
pub trait Other {}
impl Other for () {}
pub fn alef<T: Some>() -> T { loop {} }
pub fn alpha() -> impl Some { }
pub fn alef<T: Some>() -> T {
loop {}
}
pub fn alpha() -> impl Some {}
pub fn bet<T, U>(t: T) -> U { loop {} }
pub fn bet<T, U>(t: T) -> U {
loop {}
}
pub fn beta<T>(t: T) -> T {}
pub fn other<T: Other, U: Other>(t: T, u: U) { loop {} }
pub fn alternate<T: Other>(t: T, u: T) { loop {} }
pub fn other<T: Other, U: Other>(t: T, u: U) {
loop {}
}
pub fn alternate<T: Other>(t: T, u: T) {
loop {}
}

View file

@ -4,27 +4,46 @@ pub trait Trait<T> {
fn thank_you(x: T);
}
pub fn abracadabra<X>(_: X) where X: Trait<Nested> {}
pub fn abracadabra<X>(_: X)
where
X: Trait<Nested>,
{
}
pub fn alacazam<X>() -> X where X: Trait<Nested> {}
pub fn alacazam<X>() -> X
where
X: Trait<Nested>,
{
}
pub trait T1 {}
pub trait T2<'a, T> {
fn please(_: &'a T);
}
pub fn presto<A, B>(_: A, _: B) where A: T1, B: for <'b> T2<'b, Nested> {}
pub fn presto<A, B>(_: A, _: B)
where
A: T1,
B: for<'b> T2<'b, Nested>,
{
}
pub trait Shazam {}
pub fn bippety<X>() -> &'static X where X: Shazam {
pub fn bippety<X>() -> &'static X
where
X: Shazam,
{
panic!()
}
pub struct Drizzel<T>(T);
impl<T> Drizzel<T> {
pub fn boppety(&self) -> &T where T: Shazam {
pub fn boppety(&self) -> &T
where
T: Shazam,
{
panic!();
}
}