Skip to content

Format doc comments #102285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions compiler/rustc_apfloat/src/lib.rs
Original file line number Diff line number Diff line change
@@ -212,7 +212,6 @@ pub struct ParseError(pub &'static str);
/// extended exponent range) (hard).
///
/// New operations: sqrt, nexttoward.
///
pub trait Float:
Copy
+ Default
@@ -538,7 +537,6 @@ pub trait Float:
/// NaN -> \c IEK_NAN
/// 0 -> \c IEK_ZERO
/// Inf -> \c IEK_INF
///
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dismissing my ping on the basis of these being trivial comment-only changes (tho I wish we could've just frozen this directory sigh).

If needed, I could try to go through them and only grab the doc comment changes for the core/std/alloc libraries, removing the rest of the changes.

Consider this comment a (tiny) vote for having a PR just for library/, the compiler itself in general is more likely to be chaotic, and even have weird snippets in comments etc.

But if people are willing to review the PR as-is, I have nothing against that, to be clear.

fn ilogb(self) -> ExpInt;

/// Returns: self * 2<sup>exp</sup> for integral exponents.
1 change: 0 additions & 1 deletion compiler/rustc_arena/src/lib.rs
Original file line number Diff line number Diff line change
@@ -558,7 +558,6 @@ impl DroplessArena {
/// This is odd but harmless, because an empty arena allocates no memory.
/// - Types that are `!Copy` and `Drop`: these must be specified in the
/// arguments. The `TypedArena` will be used for them.
///
#[rustc_macro_transparency = "semitransparent"]
pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
#[derive(Default)]
8 changes: 6 additions & 2 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
@@ -1048,8 +1048,12 @@ impl LocalKind {
///
/// ```
/// match 123 {
/// 0..=10 => { println!("match!") },
/// _ => { println!("no match!") },
/// 0..=10 => {
/// println!("match!")
/// }
/// _ => {
/// println!("no match!")
/// }
/// }
/// ```
#[derive(Clone, Encodable, Decodable, Debug)]
9 changes: 4 additions & 5 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
@@ -248,7 +248,6 @@ enum ImplTraitContext {
/// Treat `impl Trait` as shorthand for a new opaque type.
/// Example: `fn foo() -> impl Debug`, where `impl Debug` is conceptually
/// equivalent to a new opaque type like `type T = impl Debug; fn foo() -> T`.
///
ReturnPositionOpaqueTy {
/// Origin: Either OpaqueTyOrigin::FnReturn or OpaqueTyOrigin::AsyncFn,
origin: hir::OpaqueTyOrigin,
@@ -1830,10 +1829,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
//
// ```rust
// impl<'a> Foo<'a> {
// async fn bar<'b>(&self, x: &'b Vec<f64>, y: &str) -> &u32 {
// // ^ '0 ^ '1 ^ '2
// // elided lifetimes used below
// }
// async fn bar<'b>(&self, x: &'b Vec<f64>, y: &str) -> &u32 {
// // ^ '0 ^ '1 ^ '2
// // elided lifetimes used below
// }
// }
// ```
//
5 changes: 4 additions & 1 deletion compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
@@ -426,7 +426,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
// ```
// let x;
// match y {
// _ if { x = 2; true } => {}
// _ if {
// x = 2;
// true
// } => {}
// _ if {
// x; //~ ERROR
// false
4 changes: 3 additions & 1 deletion compiler/rustc_borrowck/src/diagnostics/region_name.rs
Original file line number Diff line number Diff line change
@@ -759,7 +759,9 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
/// e.g. given the function:
///
/// ```
/// async fn foo() -> i32 { 2 }
/// async fn foo() -> i32 {
/// 2
/// }
/// ```
///
/// this function, given the lowered return type of `foo`, an [`OpaqueDef`] that implements `Future<Output=i32>`,
8 changes: 4 additions & 4 deletions compiler/rustc_borrowck/src/invalidation.rs
Original file line number Diff line number Diff line change
@@ -251,7 +251,7 @@ impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> {
// Simulates consumption of an rvalue
fn consume_rvalue(&mut self, location: Location, rvalue: &Rvalue<'tcx>) {
match *rvalue {
Rvalue::Ref(_ /*rgn*/, bk, place) => {
Rvalue::Ref(_ /* rgn */, bk, place) => {
let access_kind = match bk {
BorrowKind::Shallow => {
(Shallow(Some(ArtificialField::ShallowBorrow)), Read(ReadKind::Borrow(bk)))
@@ -288,9 +288,9 @@ impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> {

Rvalue::Use(ref operand)
| Rvalue::Repeat(ref operand, _)
| Rvalue::UnaryOp(_ /*un_op*/, ref operand)
| Rvalue::Cast(_ /*cast_kind*/, ref operand, _ /*ty*/)
| Rvalue::ShallowInitBox(ref operand, _ /*ty*/) => {
| Rvalue::UnaryOp(_ /* un_op */, ref operand)
| Rvalue::Cast(_ /* cast_kind */, ref operand, _ /* ty */)
| Rvalue::ShallowInitBox(ref operand, _ /* ty */) => {
self.consume_operand(location, operand)
}
Rvalue::CopyForDeref(ref place) => {
10 changes: 5 additions & 5 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1155,7 +1155,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
flow_state: &Flows<'cx, 'tcx>,
) {
match *rvalue {
Rvalue::Ref(_ /*rgn*/, bk, place) => {
Rvalue::Ref(_ /* rgn */, bk, place) => {
let access_kind = match bk {
BorrowKind::Shallow => {
(Shallow(Some(ArtificialField::ShallowBorrow)), Read(ReadKind::Borrow(bk)))
@@ -1224,9 +1224,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {

Rvalue::Use(ref operand)
| Rvalue::Repeat(ref operand, _)
| Rvalue::UnaryOp(_ /*un_op*/, ref operand)
| Rvalue::Cast(_ /*cast_kind*/, ref operand, _ /*ty*/)
| Rvalue::ShallowInitBox(ref operand, _ /*ty*/) => {
| Rvalue::UnaryOp(_ /* un_op */, ref operand)
| Rvalue::Cast(_ /* cast_kind */, ref operand, _ /* ty */)
| Rvalue::ShallowInitBox(ref operand, _ /* ty */) => {
self.consume_operand(location, (operand, span), flow_state)
}
Rvalue::CopyForDeref(place) => {
@@ -2209,7 +2209,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
// as needed:
//
// ```
// fn foo<F: FnOnce()>(_f: F) { }
// fn foo<F: FnOnce()>(_f: F) {}
// fn main() {
// let var = Vec::new();
// foo(move || {
6 changes: 3 additions & 3 deletions compiler/rustc_borrowck/src/prefixes.rs
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@ impl<'cx, 'tcx> Iterator for Prefixes<'cx, 'tcx> {
}
Some((cursor_base, elem)) => {
match elem {
ProjectionElem::Field(_ /*field*/, _ /*ty*/) => {
ProjectionElem::Field(_ /* field */, _ /* ty */) => {
// FIXME: add union handling
self.next = Some(cursor_base);
return Some(cursor);
@@ -120,14 +120,14 @@ impl<'cx, 'tcx> Iterator for Prefixes<'cx, 'tcx> {

let ty = cursor_base.ty(self.body, self.tcx).ty;
match ty.kind() {
ty::RawPtr(_) | ty::Ref(_ /*rgn*/, _ /*ty*/, hir::Mutability::Not) => {
ty::RawPtr(_) | ty::Ref(_ /* rgn */, _ /* ty */, hir::Mutability::Not) => {
// don't continue traversing over derefs of raw pointers or shared
// borrows.
self.next = None;
return Some(cursor);
}

ty::Ref(_ /*rgn*/, _ /*ty*/, hir::Mutability::Mut) => {
ty::Ref(_ /* rgn */, _ /* ty */, hir::Mutability::Mut) => {
self.next = Some(cursor_base);
return Some(cursor);
}
6 changes: 5 additions & 1 deletion compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
@@ -445,7 +445,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
///
/// For example:
/// ```
/// fn foo<'a, 'b>( /* ... */ ) where 'a: 'b { /* ... */ }
/// fn foo<'a, 'b>(/* ... */)
/// where
/// 'a: 'b,
/// { /* ... */
/// }
/// ```
/// would initialize two variables like so:
/// ```ignore (illustrative)
Original file line number Diff line number Diff line change
@@ -260,12 +260,12 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
// Note: we need this in examples like
// ```
// trait Foo {
// type Bar;
// fn foo(&self) -> &Self::Bar;
// type Bar;
// fn foo(&self) -> &Self::Bar;
// }
// impl Foo for () {
// type Bar = ();
// fn foo(&self) -> &() {}
// type Bar = ();
// fn foo(&self) -> &() {}
// }
// ```
// Both &Self::Bar and &() are WF
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/universal_regions.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
//! function and the relationships between them. For example:
//!
//! ```
//! fn foo<'a, 'b, 'c: 'b>() { }
//! fn foo<'a, 'b, 'c: 'b>() {}
//! ```
//!
//! here we would return a map assigning each of `{'a, 'b, 'c}`
23 changes: 11 additions & 12 deletions compiler/rustc_builtin_macros/src/assert/context.rs
Original file line number Diff line number Diff line change
@@ -60,18 +60,17 @@ impl<'cx, 'a> Context<'cx, 'a> {
/// ```rust
/// let elem = 1;
/// {
/// #[allow(unused_imports)]
/// use ::core::asserting::{TryCaptureGeneric, TryCapturePrintable};
/// let mut __capture0 = ::core::asserting::Capture::new();
/// let __local_bind0 = &elem;
/// if !(
/// *{
/// (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0);
/// __local_bind0
/// } == 1
/// ) {
/// panic!("Assertion failed: elem == 1\nWith captures:\n elem = {}", __capture0)
/// }
/// #[allow(unused_imports)]
/// use ::core::asserting::{TryCaptureGeneric, TryCapturePrintable};
/// let mut __capture0 = ::core::asserting::Capture::new();
/// let __local_bind0 = &elem;
/// if !(*{
/// (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0);
/// __local_bind0
/// } == 1)
/// {
/// panic!("Assertion failed: elem == 1\nWith captures:\n elem = {}", __capture0)
/// }
/// }
/// ```
pub(super) fn build(mut self, mut cond_expr: P<Expr>, panic_path: Path) -> P<Expr> {
22 changes: 13 additions & 9 deletions compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
@@ -38,13 +38,15 @@
//!
//! ```rust
//! # #![allow(dead_code)]
//! struct A { x : i32 }
//! struct A {
//! x: i32,
//! }
//!
//! struct B(i32);
//!
//! enum C {
//! C0(i32),
//! C1 { x: i32 }
//! C1 { x: i32 },
//! }
//! ```
//!
@@ -254,7 +256,7 @@ pub struct FieldInfo {
/// Fields for a static method
pub enum StaticFields {
/// Tuple and unit structs/enum variants like this.
Unnamed(Vec<Span>, bool /*is tuple*/),
Unnamed(Vec<Span>, bool /* is tuple */),
/// Normal structs/struct variants.
Named(Vec<(Ident, Span)>),
}
@@ -982,7 +984,10 @@ impl<'a> MethodDef<'a> {
/// ```
/// #[derive(PartialEq)]
/// # struct Dummy;
/// struct A { x: u8, y: u8 }
/// struct A {
/// x: u8,
/// y: u8,
/// }
///
/// // equivalent to:
/// impl PartialEq for A {
@@ -1105,7 +1110,7 @@ impl<'a> MethodDef<'a> {
/// # struct Dummy;
/// enum A {
/// A1,
/// A2(i32)
/// A2(i32),
/// }
/// ```
/// is equivalent to:
@@ -1115,10 +1120,9 @@ impl<'a> MethodDef<'a> {
/// fn eq(&self, other: &A) -> bool {
/// let __self_tag = ::core::intrinsics::discriminant_value(self);
/// let __arg1_tag = ::core::intrinsics::discriminant_value(other);
/// __self_tag == __arg1_tag &&
/// match (self, other) {
/// (A::A2(__self_0), A::A2(__arg1_0)) =>
/// *__self_0 == *__arg1_0,
/// __self_tag == __arg1_tag
/// && match (self, other) {
/// (A::A2(__self_0), A::A2(__arg1_0)) => *__self_0 == *__arg1_0,
/// _ => true,
/// }
/// }
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/base.rs
Original file line number Diff line number Diff line change
@@ -501,7 +501,7 @@ fn codegen_stmt<'tcx>(

#[cfg(any())] // This is never true
match &stmt.kind {
StatementKind::StorageLive(..) | StatementKind::StorageDead(..) => {} // Those are not very useful
StatementKind::StorageLive(..) | StatementKind::StorageDead(..) => {} /* Those are not very useful */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why rust-fmt made that change.

I'll go through each change manually and remove changes like this, and just remove all changes to compiler/ anyway.

_ => {
if fx.clif_comments.enabled() {
let inst = fx.bcx.func.layout.last_inst(cur_block).unwrap();
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/driver/jit.rs
Original file line number Diff line number Diff line change
@@ -177,7 +177,7 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! {
AbiParam::new(jit_module.target_config().pointer_type()),
AbiParam::new(jit_module.target_config().pointer_type()),
],
returns: vec![AbiParam::new(jit_module.target_config().pointer_type() /*isize*/)],
returns: vec![AbiParam::new(jit_module.target_config().pointer_type() /* isize */)],
call_conv: jit_module.target_config().default_call_conv,
};
let start_func_id = jit_module.declare_function("main", Linkage::Import, &start_sig).unwrap();
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs
Original file line number Diff line number Diff line change
@@ -242,7 +242,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
};

let idx = idx_const
.try_to_bits(Size::from_bytes(4 /* u32*/))
.try_to_bits(Size::from_bytes(4 /* u32 */))
.unwrap_or_else(|| panic!("kind not scalar: {:?}", idx_const));
let (lane_count, _lane_ty) = base.layout().ty.simd_size_and_type(fx.tcx);
if idx >= lane_count.into() {
@@ -292,7 +292,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
};

let idx = idx_const
.try_to_bits(Size::from_bytes(4 /* u32*/))
.try_to_bits(Size::from_bytes(4 /* u32 */))
.unwrap_or_else(|| panic!("kind not scalar: {:?}", idx_const));
let (lane_count, _lane_ty) = v.layout().ty.simd_size_and_type(fx.tcx);
if idx >= lane_count.into() {
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/main_shim.rs
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ pub(crate) fn maybe_create_entry_wrapper(
AbiParam::new(m.target_config().pointer_type()),
AbiParam::new(m.target_config().pointer_type()),
],
returns: vec![AbiParam::new(m.target_config().pointer_type() /*isize*/)],
returns: vec![AbiParam::new(m.target_config().pointer_type() /* isize */)],
call_conv: CallConv::triple_default(m.isa().triple()),
};

8 changes: 4 additions & 4 deletions compiler/rustc_codegen_llvm/src/builder.rs
Original file line number Diff line number Diff line change
@@ -1286,26 +1286,26 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
}
pub fn vector_reduce_fmin(&mut self, src: &'ll Value) -> &'ll Value {
unsafe {
llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, /*NoNaNs:*/ false)
llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, /* NoNaNs: */ false)
}
}
pub fn vector_reduce_fmax(&mut self, src: &'ll Value) -> &'ll Value {
unsafe {
llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, /*NoNaNs:*/ false)
llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, /* NoNaNs: */ false)
}
}
pub fn vector_reduce_fmin_fast(&mut self, src: &'ll Value) -> &'ll Value {
unsafe {
let instr =
llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, /*NoNaNs:*/ true);
llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, /* NoNaNs: */ true);
llvm::LLVMRustSetFastMath(instr);
instr
}
}
pub fn vector_reduce_fmax_fast(&mut self, src: &'ll Value) -> &'ll Value {
unsafe {
let instr =
llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, /*NoNaNs:*/ true);
llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, /* NoNaNs: */ true);
llvm::LLVMRustSetFastMath(instr);
instr
}
Loading