Skip to content

Commit 2ee038a

Browse files
authored
Rollup merge of #59448 - benesch:macro-doc, r=Centril
Use consistent phrasing for all macro summaries None
2 parents 02c1e3d + 3e0db7c commit 2ee038a

File tree

2 files changed

+47
-44
lines changed

2 files changed

+47
-44
lines changed

src/libcore/macros.rs

+23-22
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
/// Entry point of thread panic. For details, see `std::macros`.
1+
/// Panics the current thread.
2+
///
3+
/// For details, see `std::macros`.
24
#[macro_export]
35
#[allow_internal_unstable(core_panic, __rust_unstable_column)]
46
#[stable(feature = "core", since = "1.6.0")]
@@ -132,7 +134,7 @@ macro_rules! assert_ne {
132134
});
133135
}
134136

135-
/// Ensure that a boolean expression is `true` at runtime.
137+
/// Asserts that a boolean expression is `true` at runtime.
136138
///
137139
/// This will invoke the [`panic!`] macro if the provided expression cannot be
138140
/// evaluated to `true` at runtime.
@@ -236,8 +238,7 @@ macro_rules! debug_assert_ne {
236238
($($arg:tt)*) => (if cfg!(debug_assertions) { assert_ne!($($arg)*); })
237239
}
238240

239-
/// Helper macro for reducing boilerplate code for matching `Result` together
240-
/// with converting downstream errors.
241+
/// Unwraps a result or propagates its error.
241242
///
242243
/// The `?` operator was added to replace `try!` and should be used instead.
243244
/// Furthermore, `try` is a reserved word in Rust 2018, so if you must use
@@ -312,7 +313,7 @@ macro_rules! r#try {
312313
($expr:expr,) => (r#try!($expr));
313314
}
314315

315-
/// Write formatted data into a buffer.
316+
/// Writes formatted data into a buffer.
316317
///
317318
/// This macro accepts a format string, a list of arguments, and a 'writer'. Arguments will be
318319
/// formatted according to the specified format string and the result will be passed to the writer.
@@ -434,7 +435,7 @@ macro_rules! writeln {
434435
);
435436
}
436437

437-
/// A utility macro for indicating unreachable code.
438+
/// Indicates unreachable code.
438439
///
439440
/// This is useful any time that the compiler can't determine that some code is unreachable. For
440441
/// example:
@@ -502,7 +503,7 @@ macro_rules! unreachable {
502503
});
503504
}
504505

505-
/// A standardized placeholder for marking unfinished code.
506+
/// Indicates unfinished code.
506507
///
507508
/// This can be useful if you are prototyping and are just looking to have your
508509
/// code type-check, or if you're implementing a trait that requires multiple
@@ -559,10 +560,10 @@ macro_rules! unimplemented {
559560
($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)*)));
560561
}
561562

562-
/// A standardized placeholder for marking unfinished code.
563+
/// Indicates unfinished code.
563564
///
564565
/// This can be useful if you are prototyping and are just looking to have your
565-
/// code typecheck. `todo!` works exactly like `unimplemented!`, there only
566+
/// code typecheck. `todo!` works exactly like `unimplemented!`. The only
566567
/// difference between the two macros is the name.
567568
///
568569
/// # Panics
@@ -618,7 +619,7 @@ macro_rules! todo {
618619
($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)*)));
619620
}
620621

621-
/// A macro to create an array of [`MaybeUninit`]
622+
/// Creates an array of [`MaybeUninit`].
622623
///
623624
/// This macro constructs an uninitialized array of the type `[MaybeUninit<K>; N]`.
624625
///
@@ -645,7 +646,7 @@ macro_rules! uninitialized_array {
645646
#[cfg(rustdoc)]
646647
mod builtin {
647648

648-
/// Unconditionally causes compilation to fail with the given error message when encountered.
649+
/// Causes compilation to fail with the given error message when encountered.
649650
///
650651
/// For more information, see the documentation for [`std::compile_error!`].
651652
///
@@ -657,7 +658,7 @@ mod builtin {
657658
($msg:expr,) => ({ /* compiler built-in */ });
658659
}
659660

660-
/// The core macro for formatted string creation & output.
661+
/// Constructs parameters for the other string-formatting macros.
661662
///
662663
/// For more information, see the documentation for [`std::format_args!`].
663664
///
@@ -669,7 +670,7 @@ mod builtin {
669670
($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ });
670671
}
671672

672-
/// Inspect an environment variable at compile time.
673+
/// Inspects an environment variable at compile time.
673674
///
674675
/// For more information, see the documentation for [`std::env!`].
675676
///
@@ -681,7 +682,7 @@ mod builtin {
681682
($name:expr,) => ({ /* compiler built-in */ });
682683
}
683684

684-
/// Optionally inspect an environment variable at compile time.
685+
/// Optionally inspects an environment variable at compile time.
685686
///
686687
/// For more information, see the documentation for [`std::option_env!`].
687688
///
@@ -693,7 +694,7 @@ mod builtin {
693694
($name:expr,) => ({ /* compiler built-in */ });
694695
}
695696

696-
/// Concatenate identifiers into one identifier.
697+
/// Concatenates identifiers into one identifier.
697698
///
698699
/// For more information, see the documentation for [`std::concat_idents!`].
699700
///
@@ -717,7 +718,7 @@ mod builtin {
717718
($($e:expr,)*) => ({ /* compiler built-in */ });
718719
}
719720

720-
/// A macro which expands to the line number on which it was invoked.
721+
/// Expands to the line number on which it was invoked.
721722
///
722723
/// For more information, see the documentation for [`std::line!`].
723724
///
@@ -726,7 +727,7 @@ mod builtin {
726727
#[rustc_doc_only_macro]
727728
macro_rules! line { () => ({ /* compiler built-in */ }) }
728729

729-
/// A macro which expands to the column number on which it was invoked.
730+
/// Expands to the column number on which it was invoked.
730731
///
731732
/// For more information, see the documentation for [`std::column!`].
732733
///
@@ -735,7 +736,7 @@ mod builtin {
735736
#[rustc_doc_only_macro]
736737
macro_rules! column { () => ({ /* compiler built-in */ }) }
737738

738-
/// A macro which expands to the file name from which it was invoked.
739+
/// Expands to the file name from which it was invoked.
739740
///
740741
/// For more information, see the documentation for [`std::file!`].
741742
///
@@ -744,7 +745,7 @@ mod builtin {
744745
#[rustc_doc_only_macro]
745746
macro_rules! file { () => ({ /* compiler built-in */ }) }
746747

747-
/// A macro which stringifies its arguments.
748+
/// Stringifies its arguments.
748749
///
749750
/// For more information, see the documentation for [`std::stringify!`].
750751
///
@@ -786,7 +787,7 @@ mod builtin {
786787
#[rustc_doc_only_macro]
787788
macro_rules! module_path { () => ({ /* compiler built-in */ }) }
788789

789-
/// Boolean evaluation of configuration flags, at compile-time.
790+
/// Evaluates boolean combinations of configuration flags, at compile-time.
790791
///
791792
/// For more information, see the documentation for [`std::cfg!`].
792793
///
@@ -795,7 +796,7 @@ mod builtin {
795796
#[rustc_doc_only_macro]
796797
macro_rules! cfg { ($($cfg:tt)*) => ({ /* compiler built-in */ }) }
797798

798-
/// Parse a file as an expression or an item according to the context.
799+
/// Parses a file as an expression or an item according to the context.
799800
///
800801
/// For more information, see the documentation for [`std::include!`].
801802
///
@@ -807,7 +808,7 @@ mod builtin {
807808
($file:expr,) => ({ /* compiler built-in */ });
808809
}
809810

810-
/// Ensure that a boolean expression is `true` at runtime.
811+
/// Asserts that a boolean expression is `true` at runtime.
811812
///
812813
/// For more information, see the documentation for [`std::assert!`].
813814
///

src/libstd/macros.rs

+24-22
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! library. Each macro is available for use when linking against the standard
55
//! library.
66
7-
/// The entry point for panic of Rust threads.
7+
/// Panics the current thread.
88
///
99
/// This allows a program to terminate immediately and provide feedback
1010
/// to the caller of the program. `panic!` should be used when a program reaches
@@ -70,7 +70,7 @@ macro_rules! panic {
7070
});
7171
}
7272

73-
/// Macro for printing to the standard output.
73+
/// Prints to the standard output.
7474
///
7575
/// Equivalent to the [`println!`] macro except that a newline is not printed at
7676
/// the end of the message.
@@ -116,7 +116,7 @@ macro_rules! print {
116116
($($arg:tt)*) => ($crate::io::_print(format_args!($($arg)*)));
117117
}
118118

119-
/// Macro for printing to the standard output, with a newline.
119+
/// Prints to the standard output, with a newline.
120120
///
121121
/// On all platforms, the newline is the LINE FEED character (`\n`/`U+000A`) alone
122122
/// (no additional CARRIAGE RETURN (`\r`/`U+000D`).
@@ -151,7 +151,7 @@ macro_rules! println {
151151
})
152152
}
153153

154-
/// Macro for printing to the standard error.
154+
/// Prints to the standard error.
155155
///
156156
/// Equivalent to the [`print!`] macro, except that output goes to
157157
/// [`io::stderr`] instead of `io::stdout`. See [`print!`] for
@@ -179,7 +179,7 @@ macro_rules! eprint {
179179
($($arg:tt)*) => ($crate::io::_eprint(format_args!($($arg)*)));
180180
}
181181

182-
/// Macro for printing to the standard error, with a newline.
182+
/// Prints to the standard error, with a newline.
183183
///
184184
/// Equivalent to the [`println!`] macro, except that output goes to
185185
/// [`io::stderr`] instead of `io::stdout`. See [`println!`] for
@@ -210,8 +210,10 @@ macro_rules! eprintln {
210210
})
211211
}
212212

213-
/// A macro for quick and dirty debugging with which you can inspect
214-
/// the value of a given expression. An example:
213+
/// Prints and returns the value of a given expression for quick and dirty
214+
/// debugging.
215+
///
216+
/// An example:
215217
///
216218
/// ```rust
217219
/// let a = 2;
@@ -328,7 +330,7 @@ macro_rules! dbg {
328330
}
329331
}
330332

331-
/// A macro to await on an async call.
333+
/// Awaits the completion of an async call.
332334
#[macro_export]
333335
#[unstable(feature = "await_macro", issue = "50547")]
334336
#[allow_internal_unstable(gen_future, generators)]
@@ -351,7 +353,7 @@ macro_rules! r#await {
351353
} }
352354
}
353355

354-
/// A macro to select an event from a number of receivers.
356+
/// Selects the first successful receive event from a number of receivers.
355357
///
356358
/// This macro is used to wait for the first event to occur on a number of
357359
/// receivers. It places no restrictions on the types of receivers given to
@@ -423,7 +425,7 @@ macro_rules! assert_approx_eq {
423425
#[cfg(rustdoc)]
424426
mod builtin {
425427

426-
/// Unconditionally causes compilation to fail with the given error message when encountered.
428+
/// Causes compilation to fail with the given error message when encountered.
427429
///
428430
/// This macro should be used when a crate uses a conditional compilation strategy to provide
429431
/// better error messages for erroneous conditions. It's the compiler-level form of [`panic!`],
@@ -465,7 +467,7 @@ mod builtin {
465467
($msg:expr,) => ({ /* compiler built-in */ });
466468
}
467469

468-
/// The core macro for formatted string creation & output.
470+
/// Constructs parameters for the other string-formatting macros.
469471
///
470472
/// This macro functions by taking a formatting string literal containing
471473
/// `{}` for each additional argument passed. `format_args!` prepares the
@@ -517,7 +519,7 @@ mod builtin {
517519
($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ });
518520
}
519521

520-
/// Inspect an environment variable at compile time.
522+
/// Inspects an environment variable at compile time.
521523
///
522524
/// This macro will expand to the value of the named environment variable at
523525
/// compile time, yielding an expression of type `&'static str`.
@@ -555,7 +557,7 @@ mod builtin {
555557
($name:expr,) => ({ /* compiler built-in */ });
556558
}
557559

558-
/// Optionally inspect an environment variable at compile time.
560+
/// Optionally inspects an environment variable at compile time.
559561
///
560562
/// If the named environment variable is present at compile time, this will
561563
/// expand into an expression of type `Option<&'static str>` whose value is
@@ -581,7 +583,7 @@ mod builtin {
581583
($name:expr,) => ({ /* compiler built-in */ });
582584
}
583585

584-
/// Concatenate identifiers into one identifier.
586+
/// Concatenates identifiers into one identifier.
585587
///
586588
/// This macro takes any number of comma-separated identifiers, and
587589
/// concatenates them all into one, yielding an expression which is a new
@@ -634,7 +636,7 @@ mod builtin {
634636
($($e:expr,)*) => ({ /* compiler built-in */ });
635637
}
636638

637-
/// A macro which expands to the line number on which it was invoked.
639+
/// Expands to the line number on which it was invoked.
638640
///
639641
/// With [`column!`] and [`file!`], these macros provide debugging information for
640642
/// developers about the location within the source.
@@ -659,7 +661,7 @@ mod builtin {
659661
#[rustc_doc_only_macro]
660662
macro_rules! line { () => ({ /* compiler built-in */ }) }
661663

662-
/// A macro which expands to the column number on which it was invoked.
664+
/// Expands to the column number at which it was invoked.
663665
///
664666
/// With [`line!`] and [`file!`], these macros provide debugging information for
665667
/// developers about the location within the source.
@@ -684,7 +686,7 @@ mod builtin {
684686
#[rustc_doc_only_macro]
685687
macro_rules! column { () => ({ /* compiler built-in */ }) }
686688

687-
/// A macro which expands to the file name from which it was invoked.
689+
/// Expands to the file name in which it was invoked.
688690
///
689691
/// With [`line!`] and [`column!`], these macros provide debugging information for
690692
/// developers about the location within the source.
@@ -708,7 +710,7 @@ mod builtin {
708710
#[rustc_doc_only_macro]
709711
macro_rules! file { () => ({ /* compiler built-in */ }) }
710712

711-
/// A macro which stringifies its arguments.
713+
/// Stringifies its arguments.
712714
///
713715
/// This macro will yield an expression of type `&'static str` which is the
714716
/// stringification of all the tokens passed to the macro. No restrictions
@@ -822,7 +824,7 @@ mod builtin {
822824
#[rustc_doc_only_macro]
823825
macro_rules! module_path { () => ({ /* compiler built-in */ }) }
824826

825-
/// Boolean evaluation of configuration flags, at compile-time.
827+
/// Evaluates boolean combinations of configuration flags at compile-time.
826828
///
827829
/// In addition to the `#[cfg]` attribute, this macro is provided to allow
828830
/// boolean expression evaluation of configuration flags. This frequently
@@ -844,7 +846,7 @@ mod builtin {
844846
#[rustc_doc_only_macro]
845847
macro_rules! cfg { ($($cfg:tt)*) => ({ /* compiler built-in */ }) }
846848

847-
/// Parse a file as an expression or an item according to the context.
849+
/// Parses a file as an expression or an item according to the context.
848850
///
849851
/// The file is located relative to the current file (similarly to how
850852
/// modules are found).
@@ -890,7 +892,7 @@ mod builtin {
890892
($file:expr,) => ({ /* compiler built-in */ });
891893
}
892894

893-
/// Ensure that a boolean expression is `true` at runtime.
895+
/// Asserts that a boolean expression is `true` at runtime.
894896
///
895897
/// This will invoke the [`panic!`] macro if the provided expression cannot be
896898
/// evaluated to `true` at runtime.
@@ -944,7 +946,7 @@ mod builtin {
944946
}
945947
}
946948

947-
/// A macro for defining `#[cfg]` if-else statements.
949+
/// Defines `#[cfg]` if-else statements.
948950
///
949951
/// This is similar to the `if/elif` C preprocessor macro by allowing definition
950952
/// of a cascade of `#[cfg]` cases, emitting the implementation which matches

0 commit comments

Comments
 (0)