Skip to content

Commit 88935e0

Browse files
committed
Auto merge of rust-lang#104043 - matthiaskrgr:rollup-sttf9e8, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#103012 (Suggest use .. to fill in the rest of the fields of Struct) - rust-lang#103851 (Fix json flag in bootstrap doc) - rust-lang#103990 (rustdoc: clean up `.logo-container` layout CSS) - rust-lang#104002 (fix a comment in UnsafeCell::new) - rust-lang#104014 (Migrate test-arrow to CSS variables) - rust-lang#104016 (Add internal descriptions to a few queries) - rust-lang#104035 (Add 'closure match' test to weird-exprs.rs.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents e30fb6a + 619add3 commit 88935e0

File tree

24 files changed

+305
-112
lines changed

24 files changed

+305
-112
lines changed

compiler/rustc_error_messages/locales/en-US/parser.ftl

+3
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ parser_missing_semicolon_before_array = expected `;`, found `[`
112112
parser_invalid_block_macro_segment = cannot use a `block` macro fragment here
113113
.label = the `block` fragment is within this context
114114
115+
parser_expect_dotdot_not_dotdotdot = expected `..`, found `...`
116+
.suggestion = use `..` to fill in the rest of the fields
117+
115118
parser_if_expression_missing_then_block = this `if` expression is missing a block after the condition
116119
.add_then_block = add a block here
117120
.condition_possibly_unfinished = this binary operation is possibly unfinished

compiler/rustc_interface/src/proc_macro_decls.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,16 @@ use rustc_middle::ty::TyCtxt;
44
use rustc_span::symbol::sym;
55

66
fn proc_macro_decls_static(tcx: TyCtxt<'_>, (): ()) -> Option<LocalDefId> {
7-
let mut finder = Finder { tcx, decls: None };
7+
let mut decls = None;
88

99
for id in tcx.hir().items() {
10-
let attrs = finder.tcx.hir().attrs(id.hir_id());
11-
if finder.tcx.sess.contains_name(attrs, sym::rustc_proc_macro_decls) {
12-
finder.decls = Some(id.owner_id.def_id);
10+
let attrs = tcx.hir().attrs(id.hir_id());
11+
if tcx.sess.contains_name(attrs, sym::rustc_proc_macro_decls) {
12+
decls = Some(id.owner_id.def_id);
1313
}
1414
}
1515

16-
finder.decls
17-
}
18-
19-
struct Finder<'tcx> {
20-
tcx: TyCtxt<'tcx>,
21-
decls: Option<LocalDefId>,
16+
decls
2217
}
2318

2419
pub(crate) fn provide(providers: &mut Providers) {

compiler/rustc_middle/src/query/mod.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ rustc_queries! {
271271
desc { |tcx| "elaborating item bounds for `{}`", tcx.def_path_str(key) }
272272
}
273273

274+
/// Look up all native libraries this crate depends on.
275+
/// These are assembled from the following places:
276+
/// - `extern` blocks (depending on their `link` attributes)
277+
/// - the `libs` (`-l`) option
274278
query native_libraries(_: CrateNum) -> Vec<NativeLib> {
275279
arena_cache
276280
desc { "looking up the native libraries of a linked crate" }
@@ -1539,6 +1543,7 @@ rustc_queries! {
15391543
desc { "available upstream drop-glue for `{:?}`", substs }
15401544
}
15411545

1546+
/// Returns a list of all `extern` blocks of a crate.
15421547
query foreign_modules(_: CrateNum) -> FxHashMap<DefId, ForeignModule> {
15431548
arena_cache
15441549
desc { "looking up the foreign modules of a linked crate" }
@@ -1550,27 +1555,37 @@ rustc_queries! {
15501555
query entry_fn(_: ()) -> Option<(DefId, EntryFnType)> {
15511556
desc { "looking up the entry function of a crate" }
15521557
}
1558+
1559+
/// Finds the `rustc_proc_macro_decls` item of a crate.
15531560
query proc_macro_decls_static(_: ()) -> Option<LocalDefId> {
1554-
desc { "looking up the derive registrar for a crate" }
1561+
desc { "looking up the proc macro declarations for a crate" }
15551562
}
1563+
15561564
// The macro which defines `rustc_metadata::provide_extern` depends on this query's name.
15571565
// Changing the name should cause a compiler error, but in case that changes, be aware.
15581566
query crate_hash(_: CrateNum) -> Svh {
15591567
eval_always
15601568
desc { "looking up the hash a crate" }
15611569
separate_provide_extern
15621570
}
1571+
1572+
/// Gets the hash for the host proc macro. Used to support -Z dual-proc-macro.
15631573
query crate_host_hash(_: CrateNum) -> Option<Svh> {
15641574
eval_always
15651575
desc { "looking up the hash of a host version of a crate" }
15661576
separate_provide_extern
15671577
}
1578+
1579+
/// Gets the extra data to put in each output filename for a crate.
1580+
/// For example, compiling the `foo` crate with `extra-filename=-a` creates a `libfoo-b.rlib` file.
15681581
query extra_filename(_: CrateNum) -> String {
15691582
arena_cache
15701583
eval_always
15711584
desc { "looking up the extra filename for a crate" }
15721585
separate_provide_extern
15731586
}
1587+
1588+
/// Gets the paths where the crate came from in the file system.
15741589
query crate_extern_paths(_: CrateNum) -> Vec<PathBuf> {
15751590
arena_cache
15761591
eval_always
@@ -1594,6 +1609,7 @@ rustc_queries! {
15941609
separate_provide_extern
15951610
}
15961611

1612+
/// Get the corresponding native library from the `native_libraries` query
15971613
query native_library(def_id: DefId) -> Option<&'tcx NativeLib> {
15981614
desc { |tcx| "getting the native library for `{}`", tcx.def_path_str(def_id) }
15991615
}

compiler/rustc_parse/src/errors.rs

+9
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,15 @@ pub(crate) struct MissingSemicolonBeforeArray {
368368
pub semicolon: Span,
369369
}
370370

371+
#[derive(Diagnostic)]
372+
#[diag(parser_expect_dotdot_not_dotdotdot)]
373+
pub(crate) struct MissingDotDot {
374+
#[primary_span]
375+
pub token_span: Span,
376+
#[suggestion(applicability = "maybe-incorrect", code = "..", style = "verbose")]
377+
pub sugg_span: Span,
378+
}
379+
371380
#[derive(Diagnostic)]
372381
#[diag(parser_invalid_block_macro_segment)]
373382
pub(crate) struct InvalidBlockMacroSegment {

compiler/rustc_parse/src/parser/expr.rs

+16-4
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ use crate::errors::{
2020
InvalidNumLiteralSuffix, LabeledLoopInBreak, LeadingPlusNotSupported, LeftArrowOperator,
2121
LifetimeInBorrowExpression, MacroInvocationWithQualifiedPath, MalformedLoopLabel,
2222
MatchArmBodyWithoutBraces, MatchArmBodyWithoutBracesSugg, MissingCommaAfterMatchArm,
23-
MissingInInForLoop, MissingInInForLoopSub, MissingSemicolonBeforeArray, NoFieldsForFnCall,
24-
NotAsNegationOperator, NotAsNegationOperatorSub, OctalFloatLiteralNotSupported,
25-
OuterAttributeNotAllowedOnIfElse, ParenthesesWithStructFields,
23+
MissingDotDot, MissingInInForLoop, MissingInInForLoopSub, MissingSemicolonBeforeArray,
24+
NoFieldsForFnCall, NotAsNegationOperator, NotAsNegationOperatorSub,
25+
OctalFloatLiteralNotSupported, OuterAttributeNotAllowedOnIfElse, ParenthesesWithStructFields,
2626
RequireColonAfterLabeledExpression, ShiftInterpretedAsGeneric, StructLiteralNotAllowedHere,
2727
StructLiteralNotAllowedHereSugg, TildeAsUnaryOperator, UnexpectedTokenAfterLabel,
2828
UnexpectedTokenAfterLabelSugg, WrapExpressionInParentheses,
@@ -2880,7 +2880,7 @@ impl<'a> Parser<'a> {
28802880
};
28812881

28822882
while self.token != token::CloseDelim(close_delim) {
2883-
if self.eat(&token::DotDot) {
2883+
if self.eat(&token::DotDot) || self.recover_struct_field_dots(close_delim) {
28842884
let exp_span = self.prev_token.span;
28852885
// We permit `.. }` on the left-hand side of a destructuring assignment.
28862886
if self.check(&token::CloseDelim(close_delim)) {
@@ -3027,6 +3027,18 @@ impl<'a> Parser<'a> {
30273027
self.recover_stmt();
30283028
}
30293029

3030+
fn recover_struct_field_dots(&mut self, close_delim: Delimiter) -> bool {
3031+
if !self.look_ahead(1, |t| *t == token::CloseDelim(close_delim))
3032+
&& self.eat(&token::DotDotDot)
3033+
{
3034+
// recover from typo of `...`, suggest `..`
3035+
let span = self.prev_token.span;
3036+
self.sess.emit_err(MissingDotDot { token_span: span, sugg_span: span });
3037+
return true;
3038+
}
3039+
false
3040+
}
3041+
30303042
/// Parses `ident (COLON expr)?`.
30313043
fn parse_expr_field(&mut self) -> PResult<'a, ExprField> {
30323044
let attrs = self.parse_outer_attributes()?;

library/core/src/cell.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1936,7 +1936,7 @@ impl<T> UnsafeCell<T> {
19361936
/// Constructs a new instance of `UnsafeCell` which will wrap the specified
19371937
/// value.
19381938
///
1939-
/// All access to the inner value through methods is `unsafe`.
1939+
/// All access to the inner value through `&UnsafeCell<T>` requires `unsafe` code.
19401940
///
19411941
/// # Examples
19421942
///

src/bootstrap/dist.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use crate::cache::{Interned, INTERNER};
1919
use crate::channel;
2020
use crate::compile;
2121
use crate::config::TargetSelection;
22+
use crate::doc::DocumentationFormat;
2223
use crate::tarball::{GeneratedTarball, OverlayKind, Tarball};
2324
use crate::tool::{self, Tool};
2425
use crate::util::{exe, is_dylib, output, t, timeit};
@@ -97,7 +98,11 @@ impl Step for JsonDocs {
9798
/// Builds the `rust-docs-json` installer component.
9899
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
99100
let host = self.host;
100-
builder.ensure(crate::doc::JsonStd { stage: builder.top_stage, target: host });
101+
builder.ensure(crate::doc::Std {
102+
stage: builder.top_stage,
103+
target: host,
104+
format: DocumentationFormat::JSON,
105+
});
101106

102107
let dest = "share/doc/rust/json";
103108

src/bootstrap/doc.rs

+32-51
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ impl Step for SharedAssets {
420420
pub struct Std {
421421
pub stage: u32,
422422
pub target: TargetSelection,
423+
pub format: DocumentationFormat,
423424
}
424425

425426
impl Step for Std {
@@ -432,7 +433,15 @@ impl Step for Std {
432433
}
433434

434435
fn make_run(run: RunConfig<'_>) {
435-
run.builder.ensure(Std { stage: run.builder.top_stage, target: run.target });
436+
run.builder.ensure(Std {
437+
stage: run.builder.top_stage,
438+
target: run.target,
439+
format: if run.builder.config.cmd.json() {
440+
DocumentationFormat::JSON
441+
} else {
442+
DocumentationFormat::HTML
443+
},
444+
});
436445
}
437446

438447
/// Compile all standard library documentation.
@@ -442,19 +451,26 @@ impl Step for Std {
442451
fn run(self, builder: &Builder<'_>) {
443452
let stage = self.stage;
444453
let target = self.target;
445-
let out = builder.doc_out(target);
454+
let out = match self.format {
455+
DocumentationFormat::HTML => builder.doc_out(target),
456+
DocumentationFormat::JSON => builder.json_doc_out(target),
457+
};
458+
446459
t!(fs::create_dir_all(&out));
447460

448461
builder.ensure(SharedAssets { target: self.target });
449462

450463
let index_page = builder.src.join("src/doc/index.md").into_os_string();
451-
let mut extra_args = vec![
452-
OsStr::new("--markdown-css"),
453-
OsStr::new("rust.css"),
454-
OsStr::new("--markdown-no-toc"),
455-
OsStr::new("--index-page"),
456-
&index_page,
457-
];
464+
let mut extra_args = match self.format {
465+
DocumentationFormat::HTML => vec![
466+
OsStr::new("--markdown-css"),
467+
OsStr::new("rust.css"),
468+
OsStr::new("--markdown-no-toc"),
469+
OsStr::new("--index-page"),
470+
&index_page,
471+
],
472+
DocumentationFormat::JSON => vec![OsStr::new("--output-format"), OsStr::new("json")],
473+
};
458474

459475
if !builder.config.docs_minification {
460476
extra_args.push(OsStr::new("--disable-minification"));
@@ -478,15 +494,12 @@ impl Step for Std {
478494
})
479495
.collect::<Vec<_>>();
480496

481-
doc_std(
482-
builder,
483-
DocumentationFormat::HTML,
484-
stage,
485-
target,
486-
&out,
487-
&extra_args,
488-
&requested_crates,
489-
);
497+
doc_std(builder, self.format, stage, target, &out, &extra_args, &requested_crates);
498+
499+
// Don't open if the format is json
500+
if let DocumentationFormat::JSON = self.format {
501+
return;
502+
}
490503

491504
// Look for library/std, library/core etc in the `x.py doc` arguments and
492505
// open the corresponding rendered docs.
@@ -499,38 +512,6 @@ impl Step for Std {
499512
}
500513
}
501514

502-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
503-
pub struct JsonStd {
504-
pub stage: u32,
505-
pub target: TargetSelection,
506-
}
507-
508-
impl Step for JsonStd {
509-
type Output = ();
510-
const DEFAULT: bool = false;
511-
512-
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
513-
let default = run.builder.config.docs && run.builder.config.cmd.json();
514-
run.all_krates("test").path("library").default_condition(default)
515-
}
516-
517-
fn make_run(run: RunConfig<'_>) {
518-
run.builder.ensure(Std { stage: run.builder.top_stage, target: run.target });
519-
}
520-
521-
/// Build JSON documentation for the standard library crates.
522-
///
523-
/// This is largely just a wrapper around `cargo doc`.
524-
fn run(self, builder: &Builder<'_>) {
525-
let stage = self.stage;
526-
let target = self.target;
527-
let out = builder.json_doc_out(target);
528-
t!(fs::create_dir_all(&out));
529-
let extra_args = [OsStr::new("--output-format"), OsStr::new("json")];
530-
doc_std(builder, DocumentationFormat::JSON, stage, target, &out, &extra_args, &[])
531-
}
532-
}
533-
534515
/// Name of the crates that are visible to consumers of the standard library.
535516
/// Documentation for internal crates is handled by the rustc step, so internal crates will show
536517
/// up there.
@@ -543,7 +524,7 @@ impl Step for JsonStd {
543524
const STD_PUBLIC_CRATES: [&str; 5] = ["core", "alloc", "std", "proc_macro", "test"];
544525

545526
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
546-
enum DocumentationFormat {
527+
pub enum DocumentationFormat {
547528
HTML,
548529
JSON,
549530
}

src/bootstrap/test.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use crate::cache::Interned;
1616
use crate::compile;
1717
use crate::config::TargetSelection;
1818
use crate::dist;
19+
use crate::doc::DocumentationFormat;
1920
use crate::flags::Subcommand;
2021
use crate::native;
2122
use crate::tool::{self, SourceType, Tool};
@@ -822,7 +823,11 @@ impl Step for RustdocJSStd {
822823
command.arg("--test-file").arg(path);
823824
}
824825
}
825-
builder.ensure(crate::doc::Std { target: self.target, stage: builder.top_stage });
826+
builder.ensure(crate::doc::Std {
827+
target: self.target,
828+
stage: builder.top_stage,
829+
format: DocumentationFormat::HTML,
830+
});
826831
builder.run(&mut command);
827832
} else {
828833
builder.info("No nodejs found, skipping \"src/test/rustdoc-js-std\" tests");

src/librustdoc/html/static/css/rustdoc.css

+9-7
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,8 @@ img {
367367
overflow: visible;
368368
}
369369

370-
.sub-logo-container {
370+
.sub-logo-container, .logo-container {
371+
/* zero text boxes so that computed line height = image height exactly */
371372
line-height: 0;
372373
}
373374

@@ -465,10 +466,9 @@ img {
465466
}
466467

467468
.sidebar .logo-container {
468-
display: flex;
469469
margin-top: 10px;
470470
margin-bottom: 10px;
471-
justify-content: center;
471+
text-align: center;
472472
}
473473

474474
.version {
@@ -1204,6 +1204,12 @@ a.test-arrow {
12041204
top: 5px;
12051205
right: 5px;
12061206
z-index: 1;
1207+
color: var(--test-arrow-color);
1208+
background-color: var(--test-arrow-background-color);
1209+
}
1210+
a.test-arrow:hover {
1211+
color: var(--test-arrow-hover-color);
1212+
background-color: var(--test-arrow-hover-background-color);
12071213
}
12081214
.example-wrap:hover .test-arrow {
12091215
visibility: visible;
@@ -1755,10 +1761,6 @@ in storage.js
17551761
white-space: nowrap;
17561762
}
17571763

1758-
.mobile-topbar .logo-container {
1759-
max-height: 45px;
1760-
}
1761-
17621764
.mobile-topbar .logo-container > img {
17631765
max-width: 35px;
17641766
max-height: 35px;

0 commit comments

Comments
 (0)