Skip to content
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

Rollup of 7 pull requests #104043

Merged
merged 23 commits into from
Nov 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6e1361f
Fixes #103816 make --json work
viandoxdev Nov 1, 2022
ffd4078
fix json running all the time
viandoxdev Nov 1, 2022
972d075
merge JsonStd and Std steps
viandoxdev Nov 2, 2022
1bc2bfa
prevent open with json
viandoxdev Nov 2, 2022
1e25882
fix #102806, suggest use .. to fill in the rest of the fields of Struct
chenyukang Oct 13, 2022
4b77e73
fake a base to suppress later extra error message
chenyukang Oct 13, 2022
cb184bb
rustdoc: clean up `.logo-container` layout CSS
notriddle Nov 4, 2022
dad3270
fix a comment in UnsafeCell::new
RalfJung Nov 5, 2022
ffb2869
Migrate test-arrow to CSS variables
GuillaumeGomez Nov 5, 2022
8e2956d
Extend GUI test for run button
GuillaumeGomez Nov 5, 2022
04583f2
Simplify code
Noratrieb Nov 5, 2022
27e0f03
Add internal descriptions to a few queries
Noratrieb Nov 5, 2022
900af41
fix out dir being wrong in json
viandoxdev Nov 5, 2022
2189480
rustdoc: add test case for huge logo
notriddle Nov 5, 2022
84fe2ee
Add more nonsense to weird-exprs.rs.
m-ou-se Nov 6, 2022
28d82dd
Fix typo
compiler-errors Nov 6, 2022
58f5d57
Rollup merge of #103012 - chenyukang:fix-102806, r=davidtwco,compiler…
matthiaskrgr Nov 6, 2022
131ef95
Rollup merge of #103851 - viandoxdev:103816_bootstrap_fix_json_doc, r…
matthiaskrgr Nov 6, 2022
c013962
Rollup merge of #103990 - notriddle:notriddle/logo-container, r=Guill…
matthiaskrgr Nov 6, 2022
d93b520
Rollup merge of #104002 - RalfJung:unsafecell-new, r=JohnTitor
matthiaskrgr Nov 6, 2022
ef0d79f
Rollup merge of #104014 - GuillaumeGomez:run-button-css-var, r=notriddle
matthiaskrgr Nov 6, 2022
13e62be
Rollup merge of #104016 - Nilstrieb:query-descs-more, r=compiler-errors
matthiaskrgr Nov 6, 2022
619add3
Rollup merge of #104035 - m-ou-se:weird-expr-closure-match, r=compile…
matthiaskrgr Nov 6, 2022
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
3 changes: 3 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/parser.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ parser_missing_semicolon_before_array = expected `;`, found `[`
parser_invalid_block_macro_segment = cannot use a `block` macro fragment here
.label = the `block` fragment is within this context

parser_expect_dotdot_not_dotdotdot = expected `..`, found `...`
.suggestion = use `..` to fill in the rest of the fields

parser_if_expression_missing_then_block = this `if` expression is missing a block after the condition
.add_then_block = add a block here
.condition_possibly_unfinished = this binary operation is possibly unfinished
Expand Down
15 changes: 5 additions & 10 deletions compiler/rustc_interface/src/proc_macro_decls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,16 @@ use rustc_middle::ty::TyCtxt;
use rustc_span::symbol::sym;

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

for id in tcx.hir().items() {
let attrs = finder.tcx.hir().attrs(id.hir_id());
if finder.tcx.sess.contains_name(attrs, sym::rustc_proc_macro_decls) {
finder.decls = Some(id.owner_id.def_id);
let attrs = tcx.hir().attrs(id.hir_id());
if tcx.sess.contains_name(attrs, sym::rustc_proc_macro_decls) {
decls = Some(id.owner_id.def_id);
}
}

finder.decls
}

struct Finder<'tcx> {
tcx: TyCtxt<'tcx>,
decls: Option<LocalDefId>,
decls
}

pub(crate) fn provide(providers: &mut Providers) {
Expand Down
18 changes: 17 additions & 1 deletion compiler/rustc_middle/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ rustc_queries! {
desc { |tcx| "elaborating item bounds for `{}`", tcx.def_path_str(key) }
}

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

/// Returns a list of all `extern` blocks of a crate.
query foreign_modules(_: CrateNum) -> FxHashMap<DefId, ForeignModule> {
arena_cache
desc { "looking up the foreign modules of a linked crate" }
Expand All @@ -1550,27 +1555,37 @@ rustc_queries! {
query entry_fn(_: ()) -> Option<(DefId, EntryFnType)> {
desc { "looking up the entry function of a crate" }
}

/// Finds the `rustc_proc_macro_decls` item of a crate.
query proc_macro_decls_static(_: ()) -> Option<LocalDefId> {
desc { "looking up the derive registrar for a crate" }
desc { "looking up the proc macro declarations for a crate" }
}

// The macro which defines `rustc_metadata::provide_extern` depends on this query's name.
// Changing the name should cause a compiler error, but in case that changes, be aware.
query crate_hash(_: CrateNum) -> Svh {
eval_always
desc { "looking up the hash a crate" }
separate_provide_extern
}

/// Gets the hash for the host proc macro. Used to support -Z dual-proc-macro.
query crate_host_hash(_: CrateNum) -> Option<Svh> {
eval_always
desc { "looking up the hash of a host version of a crate" }
separate_provide_extern
}

/// Gets the extra data to put in each output filename for a crate.
/// For example, compiling the `foo` crate with `extra-filename=-a` creates a `libfoo-b.rlib` file.
query extra_filename(_: CrateNum) -> String {
arena_cache
eval_always
desc { "looking up the extra filename for a crate" }
separate_provide_extern
}

/// Gets the paths where the crate came from in the file system.
query crate_extern_paths(_: CrateNum) -> Vec<PathBuf> {
arena_cache
eval_always
Expand All @@ -1594,6 +1609,7 @@ rustc_queries! {
separate_provide_extern
}

/// Get the corresponding native library from the `native_libraries` query
query native_library(def_id: DefId) -> Option<&'tcx NativeLib> {
desc { |tcx| "getting the native library for `{}`", tcx.def_path_str(def_id) }
}
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_parse/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,15 @@ pub(crate) struct MissingSemicolonBeforeArray {
pub semicolon: Span,
}

#[derive(Diagnostic)]
#[diag(parser_expect_dotdot_not_dotdotdot)]
pub(crate) struct MissingDotDot {
#[primary_span]
pub token_span: Span,
#[suggestion(applicability = "maybe-incorrect", code = "..", style = "verbose")]
pub sugg_span: Span,
}

#[derive(Diagnostic)]
#[diag(parser_invalid_block_macro_segment)]
pub(crate) struct InvalidBlockMacroSegment {
Expand Down
20 changes: 16 additions & 4 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ use crate::errors::{
InvalidNumLiteralSuffix, LabeledLoopInBreak, LeadingPlusNotSupported, LeftArrowOperator,
LifetimeInBorrowExpression, MacroInvocationWithQualifiedPath, MalformedLoopLabel,
MatchArmBodyWithoutBraces, MatchArmBodyWithoutBracesSugg, MissingCommaAfterMatchArm,
MissingInInForLoop, MissingInInForLoopSub, MissingSemicolonBeforeArray, NoFieldsForFnCall,
NotAsNegationOperator, NotAsNegationOperatorSub, OctalFloatLiteralNotSupported,
OuterAttributeNotAllowedOnIfElse, ParenthesesWithStructFields,
MissingDotDot, MissingInInForLoop, MissingInInForLoopSub, MissingSemicolonBeforeArray,
NoFieldsForFnCall, NotAsNegationOperator, NotAsNegationOperatorSub,
OctalFloatLiteralNotSupported, OuterAttributeNotAllowedOnIfElse, ParenthesesWithStructFields,
RequireColonAfterLabeledExpression, ShiftInterpretedAsGeneric, StructLiteralNotAllowedHere,
StructLiteralNotAllowedHereSugg, TildeAsUnaryOperator, UnexpectedTokenAfterLabel,
UnexpectedTokenAfterLabelSugg, WrapExpressionInParentheses,
Expand Down Expand Up @@ -2880,7 +2880,7 @@ impl<'a> Parser<'a> {
};

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

fn recover_struct_field_dots(&mut self, close_delim: Delimiter) -> bool {
if !self.look_ahead(1, |t| *t == token::CloseDelim(close_delim))
&& self.eat(&token::DotDotDot)
{
// recover from typo of `...`, suggest `..`
let span = self.prev_token.span;
self.sess.emit_err(MissingDotDot { token_span: span, sugg_span: span });
return true;
}
false
}

/// Parses `ident (COLON expr)?`.
fn parse_expr_field(&mut self) -> PResult<'a, ExprField> {
let attrs = self.parse_outer_attributes()?;
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,7 @@ impl<T> UnsafeCell<T> {
/// Constructs a new instance of `UnsafeCell` which will wrap the specified
/// value.
///
/// All access to the inner value through methods is `unsafe`.
/// All access to the inner value through `&UnsafeCell<T>` requires `unsafe` code.
///
/// # Examples
///
Expand Down
7 changes: 6 additions & 1 deletion src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::cache::{Interned, INTERNER};
use crate::channel;
use crate::compile;
use crate::config::TargetSelection;
use crate::doc::DocumentationFormat;
use crate::tarball::{GeneratedTarball, OverlayKind, Tarball};
use crate::tool::{self, Tool};
use crate::util::{exe, is_dylib, output, t, timeit};
Expand Down Expand Up @@ -97,7 +98,11 @@ impl Step for JsonDocs {
/// Builds the `rust-docs-json` installer component.
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
let host = self.host;
builder.ensure(crate::doc::JsonStd { stage: builder.top_stage, target: host });
builder.ensure(crate::doc::Std {
stage: builder.top_stage,
target: host,
format: DocumentationFormat::JSON,
});

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

Expand Down
83 changes: 32 additions & 51 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ impl Step for SharedAssets {
pub struct Std {
pub stage: u32,
pub target: TargetSelection,
pub format: DocumentationFormat,
}

impl Step for Std {
Expand All @@ -432,7 +433,15 @@ impl Step for Std {
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(Std { stage: run.builder.top_stage, target: run.target });
run.builder.ensure(Std {
stage: run.builder.top_stage,
target: run.target,
format: if run.builder.config.cmd.json() {
DocumentationFormat::JSON
} else {
DocumentationFormat::HTML
},
});
}

/// Compile all standard library documentation.
Expand All @@ -442,19 +451,26 @@ impl Step for Std {
fn run(self, builder: &Builder<'_>) {
let stage = self.stage;
let target = self.target;
let out = builder.doc_out(target);
let out = match self.format {
DocumentationFormat::HTML => builder.doc_out(target),
DocumentationFormat::JSON => builder.json_doc_out(target),
};

t!(fs::create_dir_all(&out));

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

let index_page = builder.src.join("src/doc/index.md").into_os_string();
let mut extra_args = vec![
OsStr::new("--markdown-css"),
OsStr::new("rust.css"),
OsStr::new("--markdown-no-toc"),
OsStr::new("--index-page"),
&index_page,
];
let mut extra_args = match self.format {
DocumentationFormat::HTML => vec![
OsStr::new("--markdown-css"),
OsStr::new("rust.css"),
OsStr::new("--markdown-no-toc"),
OsStr::new("--index-page"),
&index_page,
],
DocumentationFormat::JSON => vec![OsStr::new("--output-format"), OsStr::new("json")],
};

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

doc_std(
builder,
DocumentationFormat::HTML,
stage,
target,
&out,
&extra_args,
&requested_crates,
);
doc_std(builder, self.format, stage, target, &out, &extra_args, &requested_crates);

// Don't open if the format is json
if let DocumentationFormat::JSON = self.format {
return;
}

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

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct JsonStd {
pub stage: u32,
pub target: TargetSelection,
}

impl Step for JsonStd {
type Output = ();
const DEFAULT: bool = false;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
let default = run.builder.config.docs && run.builder.config.cmd.json();
run.all_krates("test").path("library").default_condition(default)
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(Std { stage: run.builder.top_stage, target: run.target });
}

/// Build JSON documentation for the standard library crates.
///
/// This is largely just a wrapper around `cargo doc`.
fn run(self, builder: &Builder<'_>) {
let stage = self.stage;
let target = self.target;
let out = builder.json_doc_out(target);
t!(fs::create_dir_all(&out));
let extra_args = [OsStr::new("--output-format"), OsStr::new("json")];
doc_std(builder, DocumentationFormat::JSON, stage, target, &out, &extra_args, &[])
}
}

/// Name of the crates that are visible to consumers of the standard library.
/// Documentation for internal crates is handled by the rustc step, so internal crates will show
/// up there.
Expand All @@ -543,7 +524,7 @@ impl Step for JsonStd {
const STD_PUBLIC_CRATES: [&str; 5] = ["core", "alloc", "std", "proc_macro", "test"];

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
enum DocumentationFormat {
pub enum DocumentationFormat {
HTML,
JSON,
}
Expand Down
7 changes: 6 additions & 1 deletion src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::cache::Interned;
use crate::compile;
use crate::config::TargetSelection;
use crate::dist;
use crate::doc::DocumentationFormat;
use crate::flags::Subcommand;
use crate::native;
use crate::tool::{self, SourceType, Tool};
Expand Down Expand Up @@ -822,7 +823,11 @@ impl Step for RustdocJSStd {
command.arg("--test-file").arg(path);
}
}
builder.ensure(crate::doc::Std { target: self.target, stage: builder.top_stage });
builder.ensure(crate::doc::Std {
target: self.target,
stage: builder.top_stage,
format: DocumentationFormat::HTML,
});
builder.run(&mut command);
} else {
builder.info("No nodejs found, skipping \"src/test/rustdoc-js-std\" tests");
Expand Down
16 changes: 9 additions & 7 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ img {
overflow: visible;
}

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

Expand Down Expand Up @@ -465,10 +466,9 @@ img {
}

.sidebar .logo-container {
display: flex;
margin-top: 10px;
margin-bottom: 10px;
justify-content: center;
text-align: center;
}

.version {
Expand Down Expand Up @@ -1204,6 +1204,12 @@ a.test-arrow {
top: 5px;
right: 5px;
z-index: 1;
color: var(--test-arrow-color);
background-color: var(--test-arrow-background-color);
}
a.test-arrow:hover {
color: var(--test-arrow-hover-color);
background-color: var(--test-arrow-hover-background-color);
}
.example-wrap:hover .test-arrow {
visibility: visible;
Expand Down Expand Up @@ -1755,10 +1761,6 @@ in storage.js
white-space: nowrap;
}

.mobile-topbar .logo-container {
max-height: 45px;
}

.mobile-topbar .logo-container > img {
max-width: 35px;
max-height: 35px;
Expand Down
Loading