Skip to content

Commit f0dec36

Browse files
committed
Auto merge of #142781 - Kobzol:rollup-l7ng2lf, r=Kobzol
Rollup of 11 pull requests Successful merges: - #142478 (install docs for each target in different directory) - #142629 (Add config builder for bootstrap tests) - #142715 (correct template for `#[align]` attribute) - #142720 (De-dup common code from `ExternalCrate` methods) - #142736 (add issue template for rustdoc) - #142743 (rustc-dev-guide subtree update) - #142744 (Add a mailmap entry for y21) - #142758 (Make sure to rebuild rustdoc if `src/rustdoc-json-types` is changed) - #142764 (Convert `ilog(10)` to `ilog10()`) - #142767 (Some symbol and PathRoot cleanups) - #142769 (remove equivalent new method on context) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9c4ff56 + 7cb6acc commit f0dec36

Some content is hidden

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

59 files changed

+557
-266
lines changed

.github/ISSUE_TEMPLATE/rustdoc.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
name: Problem with rustdoc
3+
about: Report an issue with how docs get generated.
4+
labels: C-bug, T-rustdoc
5+
---
6+
<!--
7+
Thank you for filing a rustdoc issue! Rustdoc is the tool that handles the generation of docs. It is usually invoked via `cargo doc`, but can also be used directly.
8+
9+
If you have an issue with the actual content of the docs, use the "Documentation problem" template instead.
10+
-->
11+
12+
# Code
13+
<!-- problematic snippet and/or link to repo and/or full path of standard library function -->
14+
15+
```rust
16+
<code>
17+
```
18+
19+
# Reproduction Steps
20+
<!--
21+
* command(s) to run, if any
22+
* permalink to hosted documentation, if any
23+
* search query, if any
24+
-->
25+
26+
# Expected Outcome
27+
<!--
28+
What did you want to happen?
29+
30+
For GUI issues, feel free to provide a mockup image of what you want it to look like.
31+
32+
For diagnostics, please provide a mockup of the desired output in a code block.
33+
-->
34+
35+
# Actual Output
36+
<!--
37+
* rustdoc console output
38+
* browser screenshot of generated html
39+
* rustdoc json (prettify by running through `jq` or running thorugh an online formatter)
40+
-->
41+
```console
42+
<code>
43+
```
44+
45+
46+
# Version
47+
<!--
48+
Available via `rustdoc --version` or under the "Help" menu.
49+
50+
If the issue involves opening the documentation in a browser, please also provide the name and version of the browser used.
51+
-->
52+
53+
# Additional Details
54+
<!-- Anything else you think is relevant -->

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,3 +698,4 @@ Zach Pomerantz <[email protected]>
698698
699699
Zack Slayton <[email protected]>
700700
Zbigniew Siciarz <[email protected]> Zbigniew Siciarz <[email protected]>
701+

compiler/rustc_attr_parsing/src/attributes/repr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ pub(crate) struct AlignParser(Option<(Align, Span)>);
273273

274274
impl AlignParser {
275275
const PATH: &'static [Symbol] = &[sym::align];
276-
const TEMPLATE: AttributeTemplate = template!(Word, List: "<alignment in bytes>");
276+
const TEMPLATE: AttributeTemplate = template!(List: "<alignment in bytes>");
277277

278278
fn parse<'c, S: Stage>(
279279
&mut self,

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -422,19 +422,13 @@ impl<'sess> AttributeParser<'sess, Early> {
422422

423423
parsed.pop()
424424
}
425-
426-
pub fn new_early(sess: &'sess Session, features: &'sess Features, tools: Vec<Symbol>) -> Self {
427-
Self { features: Some(features), tools, parse_only: None, sess, stage: PhantomData }
428-
}
429425
}
430426

431-
impl<'sess> AttributeParser<'sess, Late> {
427+
impl<'sess, S: Stage> AttributeParser<'sess, S> {
432428
pub fn new(sess: &'sess Session, features: &'sess Features, tools: Vec<Symbol>) -> Self {
433429
Self { features: Some(features), tools, parse_only: None, sess, stage: PhantomData }
434430
}
435-
}
436431

437-
impl<'sess, S: Stage> AttributeParser<'sess, S> {
438432
pub(crate) fn sess(&self) -> &'sess Session {
439433
&self.sess
440434
}

compiler/rustc_builtin_macros/src/alloc_error_handler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ pub(crate) fn expand(
6262
fn generate_handler(cx: &ExtCtxt<'_>, handler: Ident, span: Span, sig_span: Span) -> Stmt {
6363
let usize = cx.path_ident(span, Ident::new(sym::usize, span));
6464
let ty_usize = cx.ty_path(usize);
65-
let size = Ident::from_str_and_span("size", span);
66-
let align = Ident::from_str_and_span("align", span);
65+
let size = Ident::new(sym::size, span);
66+
let align = Ident::new(sym::align, span);
6767

6868
let layout_new = cx.std_path(&[sym::alloc, sym::Layout, sym::from_size_align_unchecked]);
6969
let layout_new = cx.expr_path(cx.path(span, layout_new));

compiler/rustc_builtin_macros/src/autodiff.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,10 @@ mod llvm_enzyme {
652652
exprs = ecx.expr_call(new_decl_span, bb_call_expr, thin_vec![exprs]);
653653
} else {
654654
let q = QSelf { ty: d_ret_ty, path_span: span, position: 0 };
655-
let y =
656-
ExprKind::Path(Some(P(q)), ecx.path_ident(span, Ident::from_str("default")));
655+
let y = ExprKind::Path(
656+
Some(P(q)),
657+
ecx.path_ident(span, Ident::with_dummy_span(kw::Default)),
658+
);
657659
let default_call_expr = ecx.expr(span, y);
658660
let default_call_expr =
659661
ecx.expr_call(new_decl_span, default_call_expr, thin_vec![]);

compiler/rustc_builtin_macros/src/proc_macro_harness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub fn inject(
5656
is_test_crate: bool,
5757
dcx: DiagCtxtHandle<'_>,
5858
) {
59-
let ecfg = ExpansionConfig::default("proc_macro".to_string(), features);
59+
let ecfg = ExpansionConfig::default(sym::proc_macro, features);
6060
let mut cx = ExtCtxt::new(sess, ecfg, resolver, None);
6161

6262
let mut collect = CollectProcMacros {

compiler/rustc_builtin_macros/src/standard_library_imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn inject(
3636
let span = DUMMY_SP.with_def_site_ctxt(expn_id.to_expn_id());
3737
let call_site = DUMMY_SP.with_call_site_ctxt(expn_id.to_expn_id());
3838

39-
let ecfg = ExpansionConfig::default("std_lib_injection".to_string(), features);
39+
let ecfg = ExpansionConfig::default(sym::std_lib_injection, features);
4040
let cx = ExtCtxt::new(sess, ecfg, resolver, None);
4141

4242
let ident_span = if edition >= Edition2018 { span } else { call_site };

compiler/rustc_builtin_macros/src/test_harness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ fn generate_test_harness(
227227
panic_strategy: PanicStrategy,
228228
test_runner: Option<ast::Path>,
229229
) {
230-
let econfig = ExpansionConfig::default("test".to_string(), features);
230+
let econfig = ExpansionConfig::default(sym::test, features);
231231
let ext_cx = ExtCtxt::new(sess, econfig, resolver, None);
232232

233233
let expn_id = ext_cx.resolver.expansion_for_ast_pass(

compiler/rustc_expand/src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,12 @@ pub(crate) struct FeatureNotAllowed {
183183
#[derive(Diagnostic)]
184184
#[diag(expand_recursion_limit_reached)]
185185
#[help]
186-
pub(crate) struct RecursionLimitReached<'a> {
186+
pub(crate) struct RecursionLimitReached {
187187
#[primary_span]
188188
pub span: Span,
189189
pub descr: String,
190190
pub suggested_limit: Limit,
191-
pub crate_name: &'a str,
191+
pub crate_name: Symbol,
192192
}
193193

194194
#[derive(Diagnostic)]

compiler/rustc_expand/src/expand.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use rustc_session::lint::builtin::{UNUSED_ATTRIBUTES, UNUSED_DOC_COMMENTS};
2626
use rustc_session::parse::feature_err;
2727
use rustc_session::{Limit, Session};
2828
use rustc_span::hygiene::SyntaxContext;
29-
use rustc_span::{ErrorGuaranteed, FileName, Ident, LocalExpnId, Span, sym};
29+
use rustc_span::{ErrorGuaranteed, FileName, Ident, LocalExpnId, Span, Symbol, sym};
3030
use smallvec::SmallVec;
3131

3232
use crate::base::*;
@@ -473,7 +473,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
473473
let dir_path = file_path.parent().unwrap_or(&file_path).to_owned();
474474
self.cx.root_path = dir_path.clone();
475475
self.cx.current_expansion.module = Rc::new(ModuleData {
476-
mod_path: vec![Ident::from_str(&self.cx.ecfg.crate_name)],
476+
mod_path: vec![Ident::with_dummy_span(self.cx.ecfg.crate_name)],
477477
file_path_stack: vec![file_path],
478478
dir_path,
479479
});
@@ -689,7 +689,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
689689
span: expn_data.call_site,
690690
descr: expn_data.kind.descr(),
691691
suggested_limit,
692-
crate_name: &self.cx.ecfg.crate_name,
692+
crate_name: self.cx.ecfg.crate_name,
693693
});
694694

695695
self.cx.trace_macros_diag();
@@ -2458,7 +2458,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
24582458
}
24592459

24602460
pub struct ExpansionConfig<'feat> {
2461-
pub crate_name: String,
2461+
pub crate_name: Symbol,
24622462
pub features: &'feat Features,
24632463
pub recursion_limit: Limit,
24642464
pub trace_mac: bool,
@@ -2471,7 +2471,7 @@ pub struct ExpansionConfig<'feat> {
24712471
}
24722472

24732473
impl ExpansionConfig<'_> {
2474-
pub fn default(crate_name: String, features: &Features) -> ExpansionConfig<'_> {
2474+
pub fn default(crate_name: Symbol, features: &Features) -> ExpansionConfig<'_> {
24752475
ExpansionConfig {
24762476
crate_name,
24772477
features,

compiler/rustc_feature/src/unstable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ declare_features! (
510510
(unstable, ffi_pure, "1.45.0", Some(58329)),
511511
/// Controlling the behavior of fmt::Debug
512512
(unstable, fmt_debug, "1.82.0", Some(129709)),
513-
/// Allows using `#[repr(align(...))]` on function items
513+
/// Allows using `#[align(...)]` on function items
514514
(unstable, fn_align, "1.53.0", Some(82232)),
515515
/// Support delegating implementation of functions to other already implemented functions.
516516
(incomplete, fn_delegation, "1.76.0", Some(118212)),

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use rustc_hir::{
2222
TyPatKind,
2323
};
2424
use rustc_span::source_map::SourceMap;
25-
use rustc_span::{FileName, Ident, Span, Symbol, kw};
25+
use rustc_span::{FileName, Ident, Span, Symbol, kw, sym};
2626
use {rustc_ast as ast, rustc_hir as hir};
2727

2828
pub fn id_to_string(cx: &dyn rustc_hir::intravisit::HirTyCtxt<'_>, hir_id: HirId) -> String {
@@ -1517,7 +1517,7 @@ impl<'a> State<'a> {
15171517
self.bopen(ib);
15181518

15191519
// Print `let _t = $init;`:
1520-
let temp = Ident::from_str("_t");
1520+
let temp = Ident::with_dummy_span(sym::_t);
15211521
self.print_local(false, Some(init), None, |this| this.print_ident(temp));
15221522
self.word(";");
15231523

compiler/rustc_interface/src/passes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn configure_and_expand(
192192
// Create the config for macro expansion
193193
let recursion_limit = get_recursion_limit(pre_configured_attrs, sess);
194194
let cfg = rustc_expand::expand::ExpansionConfig {
195-
crate_name: crate_name.to_string(),
195+
crate_name,
196196
features,
197197
recursion_limit,
198198
trace_mac: sess.opts.unstable_opts.trace_macros,

compiler/rustc_passes/src/check_attr.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use rustc_session::lint::builtin::{
3535
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, UNUSED_ATTRIBUTES,
3636
};
3737
use rustc_session::parse::feature_err;
38-
use rustc_span::{BytePos, DUMMY_SP, Span, Symbol, edition, sym};
38+
use rustc_span::{BytePos, DUMMY_SP, Span, Symbol, edition, kw, sym};
3939
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
4040
use rustc_trait_selection::infer::{TyCtxtInferExt, ValuePairs};
4141
use rustc_trait_selection::traits::ObligationCtxt;
@@ -724,7 +724,10 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
724724
&& !matches!(other_attr.path().as_slice(), [sym::rustfmt, ..])
725725
{
726726
let path = other_attr.path();
727-
let path: Vec<_> = path.iter().map(|s| s.as_str()).collect();
727+
let path: Vec<_> = path
728+
.iter()
729+
.map(|s| if *s == kw::PathRoot { "" } else { s.as_str() })
730+
.collect();
728731
let other_attr_name = path.join("::");
729732

730733
self.dcx().emit_err(errors::NakedFunctionIncompatibleAttribute {

compiler/rustc_resolve/src/def_collector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::mem;
33
use rustc_ast::visit::FnKind;
44
use rustc_ast::*;
55
use rustc_ast_pretty::pprust;
6-
use rustc_attr_parsing::{AttributeParser, OmitDoc};
6+
use rustc_attr_parsing::{AttributeParser, Early, OmitDoc};
77
use rustc_expand::expand::AstFragment;
88
use rustc_hir as hir;
99
use rustc_hir::def::{CtorKind, CtorOf, DefKind};
@@ -128,7 +128,7 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> {
128128
// FIXME(jdonszelmann) make one of these in the resolver?
129129
// FIXME(jdonszelmann) don't care about tools here maybe? Just parse what we can.
130130
// Does that prevents errors from happening? maybe
131-
let mut parser = AttributeParser::new_early(
131+
let mut parser = AttributeParser::<'_, Early>::new(
132132
&self.resolver.tcx.sess,
133133
self.resolver.tcx.features(),
134134
Vec::new(),

compiler/rustc_span/src/symbol.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,7 @@ symbols! {
396396
__S,
397397
__awaitee,
398398
__try_var,
399-
_d,
400-
_e,
399+
_t,
401400
_task_context,
402401
a32,
403402
aarch64_target_feature,
@@ -2052,6 +2051,7 @@ symbols! {
20522051
static_recursion,
20532052
staticlib,
20542053
std,
2054+
std_lib_injection,
20552055
std_panic,
20562056
std_panic_2015_macro,
20572057
std_panic_macro,

library/alloc/src/string.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2841,7 +2841,7 @@ macro_rules! impl_to_string {
28412841
impl SpecToString for $signed {
28422842
#[inline]
28432843
fn spec_to_string(&self) -> String {
2844-
const SIZE: usize = $signed::MAX.ilog(10) as usize + 1;
2844+
const SIZE: usize = $signed::MAX.ilog10() as usize + 1;
28452845
let mut buf = [core::mem::MaybeUninit::<u8>::uninit(); SIZE];
28462846
// Only difference between signed and unsigned are these 8 lines.
28472847
let mut out;
@@ -2861,7 +2861,7 @@ macro_rules! impl_to_string {
28612861
impl SpecToString for $unsigned {
28622862
#[inline]
28632863
fn spec_to_string(&self) -> String {
2864-
const SIZE: usize = $unsigned::MAX.ilog(10) as usize + 1;
2864+
const SIZE: usize = $unsigned::MAX.ilog10() as usize + 1;
28652865
let mut buf = [core::mem::MaybeUninit::<u8>::uninit(); SIZE];
28662866

28672867
self._fmt(&mut buf).to_string()

library/core/src/fmt/num.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ macro_rules! impl_Display {
208208
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
209209
#[cfg(not(feature = "optimize_for_size"))]
210210
{
211-
const MAX_DEC_N: usize = $unsigned::MAX.ilog(10) as usize + 1;
211+
const MAX_DEC_N: usize = $unsigned::MAX.ilog10() as usize + 1;
212212
// Buffer decimals for $unsigned with right alignment.
213213
let mut buf = [MaybeUninit::<u8>::uninit(); MAX_DEC_N];
214214

@@ -226,7 +226,7 @@ macro_rules! impl_Display {
226226
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
227227
#[cfg(not(feature = "optimize_for_size"))]
228228
{
229-
const MAX_DEC_N: usize = $unsigned::MAX.ilog(10) as usize + 1;
229+
const MAX_DEC_N: usize = $unsigned::MAX.ilog10() as usize + 1;
230230
// Buffer decimals for $unsigned with right alignment.
231231
let mut buf = [MaybeUninit::<u8>::uninit(); MAX_DEC_N];
232232

@@ -323,7 +323,7 @@ macro_rules! impl_Display {
323323

324324
#[cfg(feature = "optimize_for_size")]
325325
fn $gen_name(mut n: $u, is_nonnegative: bool, f: &mut fmt::Formatter<'_>) -> fmt::Result {
326-
const MAX_DEC_N: usize = $u::MAX.ilog(10) as usize + 1;
326+
const MAX_DEC_N: usize = $u::MAX.ilog10() as usize + 1;
327327
let mut buf = [MaybeUninit::<u8>::uninit(); MAX_DEC_N];
328328
let mut curr = MAX_DEC_N;
329329
let buf_ptr = MaybeUninit::slice_as_mut_ptr(&mut buf);
@@ -565,7 +565,7 @@ mod imp {
565565
}
566566
impl_Exp!(i128, u128 as u128 via to_u128 named exp_u128);
567567

568-
const U128_MAX_DEC_N: usize = u128::MAX.ilog(10) as usize + 1;
568+
const U128_MAX_DEC_N: usize = u128::MAX.ilog10() as usize + 1;
569569

570570
#[stable(feature = "rust1", since = "1.0.0")]
571571
impl fmt::Display for u128 {

src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,13 @@ impl Step for Docs {
7676
let host = self.host;
7777
builder.default_doc(&[]);
7878

79-
let dest = "share/doc/rust/html";
79+
let dest = format!("share/doc/rust/html/{host}");
8080

8181
let mut tarball = Tarball::new(builder, "rust-docs", &host.triple);
82+
tarball.include_target_in_component_name(true);
8283
tarball.set_product_name("Rust Documentation");
83-
tarball.add_bulk_dir(builder.doc_out(host), dest);
84-
tarball.add_file(builder.src.join("src/doc/robots.txt"), dest, FileType::Regular);
84+
tarball.add_bulk_dir(builder.doc_out(host), &dest);
85+
tarball.add_file(builder.src.join("src/doc/robots.txt"), &dest, FileType::Regular);
8586
Some(tarball.generate())
8687
}
8788
}
@@ -113,12 +114,13 @@ impl Step for JsonDocs {
113114
DocumentationFormat::Json,
114115
));
115116

116-
let dest = "share/doc/rust/json";
117+
let dest = format!("share/doc/rust/json/{host}");
117118

118119
let mut tarball = Tarball::new(builder, "rust-docs-json", &host.triple);
120+
tarball.include_target_in_component_name(true);
119121
tarball.set_product_name("Rust Documentation In JSON Format");
120122
tarball.is_preview(true);
121-
tarball.add_bulk_dir(builder.json_doc_out(host), dest);
123+
tarball.add_bulk_dir(builder.json_doc_out(host), &dest);
122124
Some(tarball.generate())
123125
}
124126
}

src/bootstrap/src/core/build_steps/tool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ impl Step for Rustdoc {
716716
&& target_compiler.stage > 0
717717
&& builder.rust_info().is_managed_git_subrepository()
718718
{
719-
let files_to_track = &["src/librustdoc", "src/tools/rustdoc"];
719+
let files_to_track = &["src/librustdoc", "src/tools/rustdoc", "src/rustdoc-json-types"];
720720

721721
// Check if unchanged
722722
if !builder.config.has_changes_from_upstream(files_to_track) {

0 commit comments

Comments
 (0)