Skip to content

Commit 8c6bf2b

Browse files
committed
Auto merge of #104990 - matthiaskrgr:rollup-oskk8v3, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #104955 (Switch rustdoc-gui test to function call) - #104976 (Prefer doc comments over `//`-comments in compiler) - #104984 (Remove Crate::primitives field) - #104989 (update Miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 07e664c + 2ccb38b commit 8c6bf2b

File tree

169 files changed

+1343
-909
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+1343
-909
lines changed

compiler/rustc_ast/src/ast.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ impl<CTX: rustc_span::HashStableContext> HashStable<CTX> for Path {
111111
}
112112

113113
impl Path {
114-
// Convert a span and an identifier to the corresponding
115-
// one-segment path.
114+
/// Convert a span and an identifier to the corresponding
115+
/// one-segment path.
116116
pub fn from_ident(ident: Ident) -> Path {
117117
Path { segments: thin_vec![PathSegment::from_ident(ident)], span: ident.span, tokens: None }
118118
}
@@ -1283,7 +1283,7 @@ impl Expr {
12831283
)
12841284
}
12851285

1286-
// To a first-order approximation, is this a pattern
1286+
/// To a first-order approximation, is this a pattern?
12871287
pub fn is_approximately_pattern(&self) -> bool {
12881288
match &self.peel_parens().kind {
12891289
ExprKind::Box(_)

compiler/rustc_ast/src/attr/mod.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ use thin_vec::thin_vec;
2626
pub struct MarkedAttrs(GrowableBitSet<AttrId>);
2727

2828
impl MarkedAttrs {
29-
// We have no idea how many attributes there will be, so just
30-
// initiate the vectors with 0 bits. We'll grow them as necessary.
3129
pub fn new() -> Self {
30+
// We have no idea how many attributes there will be, so just
31+
// initiate the vectors with 0 bits. We'll grow them as necessary.
3232
MarkedAttrs(GrowableBitSet::new_empty())
3333
}
3434

@@ -174,9 +174,11 @@ impl MetaItem {
174174
self.ident().unwrap_or_else(Ident::empty).name
175175
}
176176

177-
// Example:
178-
// #[attribute(name = "value")]
179-
// ^^^^^^^^^^^^^^
177+
/// ```text
178+
/// Example:
179+
/// #[attribute(name = "value")]
180+
/// ^^^^^^^^^^^^^^
181+
/// ```
180182
pub fn name_value_literal(&self) -> Option<&Lit> {
181183
match &self.kind {
182184
MetaItemKind::NameValue(v) => Some(v),

compiler/rustc_ast/src/mut_visit.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -725,10 +725,10 @@ pub fn visit_lazy_tts<T: MutVisitor>(lazy_tts: &mut Option<LazyAttrTokenStream>,
725725
visit_lazy_tts_opt_mut(lazy_tts.as_mut(), vis);
726726
}
727727

728+
/// Applies ident visitor if it's an ident; applies other visits to interpolated nodes.
729+
/// In practice the ident part is not actually used by specific visitors right now,
730+
/// but there's a test below checking that it works.
728731
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
729-
// Applies ident visitor if it's an ident; applies other visits to interpolated nodes.
730-
// In practice the ident part is not actually used by specific visitors right now,
731-
// but there's a test below checking that it works.
732732
pub fn visit_token<T: MutVisitor>(t: &mut Token, vis: &mut T) {
733733
let Token { kind, span } = t;
734734
match kind {

compiler/rustc_ast/src/token.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,9 @@ impl TokenKind {
302302
Literal(Lit::new(kind, symbol, suffix))
303303
}
304304

305-
// An approximation to proc-macro-style single-character operators used by rustc parser.
306-
// If the operator token can be broken into two tokens, the first of which is single-character,
307-
// then this function performs that operation, otherwise it returns `None`.
305+
/// An approximation to proc-macro-style single-character operators used by rustc parser.
306+
/// If the operator token can be broken into two tokens, the first of which is single-character,
307+
/// then this function performs that operation, otherwise it returns `None`.
308308
pub fn break_two_token_op(&self) -> Option<(TokenKind, TokenKind)> {
309309
Some(match *self {
310310
Le => (Lt, Eq),
@@ -538,10 +538,10 @@ impl Token {
538538
}
539539
}
540540

541-
// A convenience function for matching on identifiers during parsing.
542-
// Turns interpolated identifier (`$i: ident`) or lifetime (`$l: lifetime`) token
543-
// into the regular identifier or lifetime token it refers to,
544-
// otherwise returns the original token.
541+
/// A convenience function for matching on identifiers during parsing.
542+
/// Turns interpolated identifier (`$i: ident`) or lifetime (`$l: lifetime`) token
543+
/// into the regular identifier or lifetime token it refers to,
544+
/// otherwise returns the original token.
545545
pub fn uninterpolate(&self) -> Cow<'_, Token> {
546546
match &self.kind {
547547
Interpolated(nt) => match **nt {
@@ -621,7 +621,7 @@ impl Token {
621621
false
622622
}
623623

624-
// Is the token an interpolated block (`$b:block`)?
624+
/// Is the token an interpolated block (`$b:block`)?
625625
pub fn is_whole_block(&self) -> bool {
626626
if let Interpolated(nt) = &self.kind && let NtBlock(..) = **nt {
627627
return true;
@@ -665,8 +665,8 @@ impl Token {
665665
self.is_non_raw_ident_where(Ident::is_path_segment_keyword)
666666
}
667667

668-
// Returns true for reserved identifiers used internally for elided lifetimes,
669-
// unnamed method parameters, crate root module, error recovery etc.
668+
/// Returns true for reserved identifiers used internally for elided lifetimes,
669+
/// unnamed method parameters, crate root module, error recovery etc.
670670
pub fn is_special_ident(&self) -> bool {
671671
self.is_non_raw_ident_where(Ident::is_special)
672672
}

compiler/rustc_ast/src/tokenstream.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ impl TokenTree {
8686
}
8787
}
8888

89-
// Create a `TokenTree::Token` with alone spacing.
89+
/// Create a `TokenTree::Token` with alone spacing.
9090
pub fn token_alone(kind: TokenKind, span: Span) -> TokenTree {
9191
TokenTree::Token(Token::new(kind, span), Spacing::Alone)
9292
}
9393

94-
// Create a `TokenTree::Token` with joint spacing.
94+
/// Create a `TokenTree::Token` with joint spacing.
9595
pub fn token_joint(kind: TokenKind, span: Span) -> TokenTree {
9696
TokenTree::Token(Token::new(kind, span), Spacing::Joint)
9797
}
@@ -413,17 +413,17 @@ impl TokenStream {
413413
TokenStream(Lrc::new(self.0.iter().enumerate().map(|(i, tree)| f(i, tree)).collect()))
414414
}
415415

416-
// Create a token stream containing a single token with alone spacing.
416+
/// Create a token stream containing a single token with alone spacing.
417417
pub fn token_alone(kind: TokenKind, span: Span) -> TokenStream {
418418
TokenStream::new(vec![TokenTree::token_alone(kind, span)])
419419
}
420420

421-
// Create a token stream containing a single token with joint spacing.
421+
/// Create a token stream containing a single token with joint spacing.
422422
pub fn token_joint(kind: TokenKind, span: Span) -> TokenStream {
423423
TokenStream::new(vec![TokenTree::token_joint(kind, span)])
424424
}
425425

426-
// Create a token stream containing a single `Delimited`.
426+
/// Create a token stream containing a single `Delimited`.
427427
pub fn delimited(span: DelimSpan, delim: Delimiter, tts: TokenStream) -> TokenStream {
428428
TokenStream::new(vec![TokenTree::Delimited(span, delim, tts)])
429429
}
@@ -522,8 +522,8 @@ impl TokenStream {
522522
}
523523
}
524524

525-
// Push `tt` onto the end of the stream, possibly gluing it to the last
526-
// token. Uses `make_mut` to maximize efficiency.
525+
/// Push `tt` onto the end of the stream, possibly gluing it to the last
526+
/// token. Uses `make_mut` to maximize efficiency.
527527
pub fn push_tree(&mut self, tt: TokenTree) {
528528
let vec_mut = Lrc::make_mut(&mut self.0);
529529

@@ -534,9 +534,9 @@ impl TokenStream {
534534
}
535535
}
536536

537-
// Push `stream` onto the end of the stream, possibly gluing the first
538-
// token tree to the last token. (No other token trees will be glued.)
539-
// Uses `make_mut` to maximize efficiency.
537+
/// Push `stream` onto the end of the stream, possibly gluing the first
538+
/// token tree to the last token. (No other token trees will be glued.)
539+
/// Uses `make_mut` to maximize efficiency.
540540
pub fn push_stream(&mut self, stream: TokenStream) {
541541
let vec_mut = Lrc::make_mut(&mut self.0);
542542

compiler/rustc_ast_pretty/src/helpers.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ impl Printer {
3636
self.nbsp()
3737
}
3838

39-
// Synthesizes a comment that was not textually present in the original
40-
// source file.
39+
/// Synthesizes a comment that was not textually present in the original
40+
/// source file.
4141
pub fn synth_comment(&mut self, text: impl Into<Cow<'static, str>>) {
4242
self.word("/*");
4343
self.space();

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ impl<'a> State<'a> {
5858
self.print_expr_cond_paren(expr, Self::cond_needs_par(expr))
5959
}
6060

61-
// Does `expr` need parentheses when printed in a condition position?
62-
//
63-
// These cases need parens due to the parse error observed in #26461: `if return {}`
64-
// parses as the erroneous construct `if (return {})`, not `if (return) {}`.
61+
/// Does `expr` need parentheses when printed in a condition position?
62+
///
63+
/// These cases need parens due to the parse error observed in #26461: `if return {}`
64+
/// parses as the erroneous construct `if (return {})`, not `if (return) {}`.
6565
pub(super) fn cond_needs_par(expr: &ast::Expr) -> bool {
6666
match expr.kind {
6767
ast::ExprKind::Break(..)

compiler/rustc_attr/src/session_diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub(crate) struct IncorrectMetaItem {
4141
pub span: Span,
4242
}
4343

44-
// Error code: E0541
44+
/// Error code: E0541
4545
pub(crate) struct UnknownMetaItem<'a> {
4646
pub span: Span,
4747
pub item: String,
@@ -200,7 +200,7 @@ pub(crate) struct InvalidReprHintNoValue {
200200
pub name: String,
201201
}
202202

203-
// Error code: E0565
203+
/// Error code: E0565
204204
pub(crate) struct UnsupportedLiteral {
205205
pub span: Span,
206206
pub reason: UnsupportedLiteralReason,

compiler/rustc_borrowck/src/diagnostics/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ impl UseSpans<'_> {
590590
}
591591
}
592592

593-
// Add a span label to the arguments of the closure, if it exists.
593+
/// Add a span label to the arguments of the closure, if it exists.
594594
pub(super) fn args_span_label(self, err: &mut Diagnostic, message: impl Into<String>) {
595595
if let UseSpans::ClosureUse { args_span, .. } = self {
596596
err.span_label(args_span, message);
@@ -628,7 +628,7 @@ impl UseSpans<'_> {
628628
}
629629
}
630630

631-
// Add a span label to the use of the captured variable, if it exists.
631+
/// Add a span label to the use of the captured variable, if it exists.
632632
pub(super) fn var_span_label(
633633
self,
634634
err: &mut Diagnostic,

compiler/rustc_borrowck/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ mod type_check;
8383
mod universal_regions;
8484
mod used_muts;
8585

86-
// A public API provided for the Rust compiler consumers.
86+
/// A public API provided for the Rust compiler consumers.
8787
pub mod consumers;
8888

8989
use borrow_set::{BorrowData, BorrowSet};

compiler/rustc_borrowck/src/type_check/liveness/polonius.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ pub(super) fn populate_access_facts<'a, 'tcx>(
121121
}
122122
}
123123

124-
// For every potentially drop()-touched region `region` in `local`'s type
125-
// (`kind`), emit a Polonius `use_of_var_derefs_origin(local, origin)` fact.
124+
/// For every potentially drop()-touched region `region` in `local`'s type
125+
/// (`kind`), emit a Polonius `use_of_var_derefs_origin(local, origin)` fact.
126126
pub(super) fn add_drop_of_var_derefs_origin<'tcx>(
127127
typeck: &mut TypeChecker<'_, 'tcx>,
128128
local: Local,

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,12 @@ struct TypeParameter {
300300
ty: P<ast::Ty>,
301301
}
302302

303-
// The code snippets built up for derived code are sometimes used as blocks
304-
// (e.g. in a function body) and sometimes used as expressions (e.g. in a match
305-
// arm). This structure avoids committing to either form until necessary,
306-
// avoiding the insertion of any unnecessary blocks.
307-
//
308-
// The statements come before the expression.
303+
/// The code snippets built up for derived code are sometimes used as blocks
304+
/// (e.g. in a function body) and sometimes used as expressions (e.g. in a match
305+
/// arm). This structure avoids committing to either form until necessary,
306+
/// avoiding the insertion of any unnecessary blocks.
307+
///
308+
/// The statements come before the expression.
309309
pub struct BlockOrExpr(Vec<ast::Stmt>, Option<P<Expr>>);
310310

311311
impl BlockOrExpr {

compiler/rustc_builtin_macros/src/edition_panic.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ use rustc_span::edition::Edition;
66
use rustc_span::symbol::sym;
77
use rustc_span::Span;
88

9-
// This expands to either
10-
// - `$crate::panic::panic_2015!(...)` or
11-
// - `$crate::panic::panic_2021!(...)`
12-
// depending on the edition.
13-
//
14-
// This is used for both std::panic!() and core::panic!().
15-
//
16-
// `$crate` will refer to either the `std` or `core` crate depending on which
17-
// one we're expanding from.
9+
/// This expands to either
10+
/// - `$crate::panic::panic_2015!(...)` or
11+
/// - `$crate::panic::panic_2021!(...)`
12+
/// depending on the edition.
13+
///
14+
/// This is used for both std::panic!() and core::panic!().
15+
///
16+
/// `$crate` will refer to either the `std` or `core` crate depending on which
17+
/// one we're expanding from.
1818
pub fn expand_panic<'cx>(
1919
cx: &'cx mut ExtCtxt<'_>,
2020
sp: Span,
@@ -24,10 +24,10 @@ pub fn expand_panic<'cx>(
2424
expand(mac, cx, sp, tts)
2525
}
2626

27-
// This expands to either
28-
// - `$crate::panic::unreachable_2015!(...)` or
29-
// - `$crate::panic::unreachable_2021!(...)`
30-
// depending on the edition.
27+
/// This expands to either
28+
/// - `$crate::panic::unreachable_2015!(...)` or
29+
/// - `$crate::panic::unreachable_2021!(...)`
30+
/// depending on the edition.
3131
pub fn expand_unreachable<'cx>(
3232
cx: &'cx mut ExtCtxt<'_>,
3333
sp: Span,

compiler/rustc_builtin_macros/src/source_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ pub fn expand_include<'cx>(
164164
Box::new(ExpandResult { p, node_id: cx.current_expansion.lint_node_id })
165165
}
166166

167-
// include_str! : read the given file, insert it as a literal string expr
167+
/// `include_str!`: read the given file, insert it as a literal string expr
168168
pub fn expand_include_str(
169169
cx: &mut ExtCtxt<'_>,
170170
sp: Span,

compiler/rustc_builtin_macros/src/test.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ use rustc_span::Span;
1313
use std::iter;
1414
use thin_vec::thin_vec;
1515

16-
// #[test_case] is used by custom test authors to mark tests
17-
// When building for test, it needs to make the item public and gensym the name
18-
// Otherwise, we'll omit the item. This behavior means that any item annotated
19-
// with #[test_case] is never addressable.
20-
//
21-
// We mark item with an inert attribute "rustc_test_marker" which the test generation
22-
// logic will pick up on.
16+
/// #[test_case] is used by custom test authors to mark tests
17+
/// When building for test, it needs to make the item public and gensym the name
18+
/// Otherwise, we'll omit the item. This behavior means that any item annotated
19+
/// with #[test_case] is never addressable.
20+
///
21+
/// We mark item with an inert attribute "rustc_test_marker" which the test generation
22+
/// logic will pick up on.
2323
pub fn expand_test_case(
2424
ecx: &mut ExtCtxt<'_>,
2525
attr_sp: Span,

compiler/rustc_builtin_macros/src/test_harness.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ struct TestCtxt<'a> {
3434
test_runner: Option<ast::Path>,
3535
}
3636

37-
// Traverse the crate, collecting all the test functions, eliding any
38-
// existing main functions, and synthesizing a main test harness
37+
/// Traverse the crate, collecting all the test functions, eliding any
38+
/// existing main functions, and synthesizing a main test harness
3939
pub fn inject(sess: &Session, resolver: &mut dyn ResolverExpand, krate: &mut ast::Crate) {
4040
let span_diagnostic = sess.diagnostic();
4141
let panic_strategy = sess.panic_strategy();

compiler/rustc_codegen_cranelift/src/value_and_place.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ impl<'tcx> CValue<'tcx> {
108108
}
109109

110110
// FIXME remove
111-
// Forces the data value of a dyn* value to the stack and returns a pointer to it as well as the
112-
// vtable pointer.
111+
/// Forces the data value of a dyn* value to the stack and returns a pointer to it as well as the
112+
/// vtable pointer.
113113
pub(crate) fn dyn_star_force_data_on_stack(
114114
self,
115115
fx: &mut FunctionCx<'_, '_, 'tcx>,

compiler/rustc_codegen_gcc/src/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ pub struct CodegenCx<'gcc, 'tcx> {
8888
pub vtables: RefCell<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), RValue<'gcc>>>,
8989

9090
// TODO(antoyo): improve the SSA API to not require those.
91-
// Mapping from function pointer type to indexes of on stack parameters.
91+
/// Mapping from function pointer type to indexes of on stack parameters.
9292
pub on_stack_params: RefCell<FxHashMap<FunctionPtrType<'gcc>, FxHashSet<usize>>>,
93-
// Mapping from function to indexes of on stack parameters.
93+
/// Mapping from function to indexes of on stack parameters.
9494
pub on_stack_function_params: RefCell<FxHashMap<Function<'gcc>, FxHashSet<usize>>>,
9595

9696
/// Cache of emitted const globals (value -> global)

compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const VAR_ALIGN_BYTES: usize = 8;
3737

3838
/// A context object for maintaining all state needed by the coverageinfo module.
3939
pub struct CrateCoverageContext<'ll, 'tcx> {
40-
// Coverage data for each instrumented function identified by DefId.
40+
/// Coverage data for each instrumented function identified by DefId.
4141
pub(crate) function_coverage_map: RefCell<FxHashMap<Instance<'tcx>, FunctionCoverage<'tcx>>>,
4242
pub(crate) pgo_func_name_var_map: RefCell<FxHashMap<Instance<'tcx>, &'ll llvm::Value>>,
4343
}

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub enum LLVMRustResult {
3535
pub struct LLVMRustCOFFShortExport {
3636
pub name: *const c_char,
3737
pub ordinal_present: bool,
38-
// value of `ordinal` only important when `ordinal_present` is true
38+
/// value of `ordinal` only important when `ordinal_present` is true
3939
pub ordinal: u16,
4040
}
4141

0 commit comments

Comments
 (0)