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 5 pull requests #57816

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
186 changes: 182 additions & 4 deletions Cargo.lock

Large diffs are not rendered by default.

45 changes: 37 additions & 8 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::cache::{INTERNER, Interned};
use crate::config::Config;

macro_rules! book {
($($name:ident, $path:expr, $book_name:expr;)+) => {
($($name:ident, $path:expr, $book_name:expr, $book_ver:expr;)+) => {
$(
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct $name {
Expand All @@ -49,26 +49,40 @@ macro_rules! book {
builder.ensure(Rustbook {
target: self.target,
name: INTERNER.intern_str($book_name),
version: $book_ver,
})
}
}
)+
}
}

// NOTE: When adding a book here, make sure to ALSO build the book by
// adding a build step in `src/bootstrap/builder.rs`!
book!(
Nomicon, "src/doc/nomicon", "nomicon";
Reference, "src/doc/reference", "reference";
EditionGuide, "src/doc/edition-guide", "edition-guide";
RustdocBook, "src/doc/rustdoc", "rustdoc";
RustcBook, "src/doc/rustc", "rustc";
RustByExample, "src/doc/rust-by-example", "rust-by-example";
EditionGuide, "src/doc/edition-guide", "edition-guide", RustbookVersion::MdBook1;
Nomicon, "src/doc/nomicon", "nomicon", RustbookVersion::MdBook1;
Reference, "src/doc/reference", "reference", RustbookVersion::MdBook1;
RustByExample, "src/doc/rust-by-example", "rust-by-example", RustbookVersion::MdBook1;
RustcBook, "src/doc/rustc", "rustc", RustbookVersion::MdBook1;
RustdocBook, "src/doc/rustdoc", "rustdoc", RustbookVersion::MdBook1;
);

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
enum RustbookVersion {
MdBook1,

/// Note: Currently no books use mdBook v2, but we want the option
/// to be available
#[allow(dead_code)]
MdBook2,
}

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
struct Rustbook {
target: Interned<String>,
name: Interned<String>,
version: RustbookVersion,
}

impl Step for Rustbook {
Expand All @@ -90,6 +104,7 @@ impl Step for Rustbook {
target: self.target,
name: self.name,
src: INTERNER.intern_path(src),
version: self.version,
});
}
}
Expand Down Expand Up @@ -122,6 +137,7 @@ impl Step for UnstableBook {
target: self.target,
name: INTERNER.intern_str("unstable-book"),
src: builder.md_doc_out(self.target),
version: RustbookVersion::MdBook1,
})
}
}
Expand Down Expand Up @@ -175,6 +191,7 @@ struct RustbookSrc {
target: Interned<String>,
name: Interned<String>,
src: Interned<PathBuf>,
version: RustbookVersion,
}

impl Step for RustbookSrc {
Expand Down Expand Up @@ -205,11 +222,19 @@ impl Step for RustbookSrc {
}
builder.info(&format!("Rustbook ({}) - {}", target, name));
let _ = fs::remove_dir_all(&out);

let vers = match self.version {
RustbookVersion::MdBook1 => "1",
RustbookVersion::MdBook2 => "2",
};

builder.run(rustbook_cmd
.arg("build")
.arg(&src)
.arg("-d")
.arg(out));
.arg(out)
.arg("-m")
.arg(vers));
}
}

Expand Down Expand Up @@ -255,6 +280,7 @@ impl Step for TheBook {
builder.ensure(Rustbook {
target,
name: INTERNER.intern_string(name.to_string()),
version: RustbookVersion::MdBook1,
});

// building older edition redirects
Expand All @@ -263,18 +289,21 @@ impl Step for TheBook {
builder.ensure(Rustbook {
target,
name: INTERNER.intern_string(source_name),
version: RustbookVersion::MdBook1,
});

let source_name = format!("{}/second-edition", name);
builder.ensure(Rustbook {
target,
name: INTERNER.intern_string(source_name),
version: RustbookVersion::MdBook1,
});

let source_name = format!("{}/2018-edition", name);
builder.ensure(Rustbook {
target,
name: INTERNER.intern_string(source_name),
version: RustbookVersion::MdBook1,
});

// build the version info page and CSS
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1931,7 +1931,7 @@ impl<'a> LoweringContext<'a> {

fn lower_parenthesized_parameter_data(
&mut self,
data: &ParenthesisedArgs,
data: &ParenthesizedArgs,
) -> (hir::GenericArgs, bool) {
// Switch to `PassThrough` mode for anonymous lifetimes: this
// means that we permit things like `&Ref<T>`, where `Ref` has
Expand All @@ -1941,7 +1941,7 @@ impl<'a> LoweringContext<'a> {
self.with_anonymous_lifetime_mode(
AnonymousLifetimeMode::PassThrough,
|this| {
let &ParenthesisedArgs { ref inputs, ref output, span } = data;
let &ParenthesizedArgs { ref inputs, ref output, span } = data;
let inputs = inputs
.iter()
.map(|ty| this.lower_ty_direct(ty, ImplTraitContext::disallowed()))
Expand Down
14 changes: 12 additions & 2 deletions src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
);
if let Some(suggestion) = suggestion {
// enum variant
err.help(&format!("did you mean `{}`?", suggestion));
err.span_suggestion_with_applicability(
item_name.span,
"did you mean",
suggestion.to_string(),
Applicability::MaybeIncorrect,
);
}
err
}
Expand Down Expand Up @@ -440,7 +445,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}

if let Some(lev_candidate) = lev_candidate {
err.help(&format!("did you mean `{}`?", lev_candidate.ident));
err.span_suggestion_with_applicability(
span,
"did you mean",
lev_candidate.ident.to_string(),
Applicability::MaybeIncorrect,
);
}
err.emit();
}
Expand Down
9 changes: 7 additions & 2 deletions src/librustdoc/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
root_path = page.root_path,
css_class = page.css_class,
logo = if layout.logo.is_empty() {
String::new()
format!("<a href='{}{}/index.html'>\
<img src='{static_root_path}rust-logo{suffix}.png' alt='logo' width='100'></a>",
static_root_path=static_root_path,
suffix=page.resource_suffix)
} else {
format!("<a href='{}{}/index.html'>\
<img src='{}' alt='logo' width='100'></a>",
Expand All @@ -188,7 +191,9 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
description = page.description,
keywords = page.keywords,
favicon = if layout.favicon.is_empty() {
String::new()
format!(r#"<link rel="shortcut icon" href="{static_root_path}favicon{suffix}.ico">"#,
static_root_path=static_root_path,
suffix=page.resource_suffix)
} else {
format!(r#"<link rel="shortcut icon" href="{}">"#, layout.favicon)
},
Expand Down
10 changes: 8 additions & 2 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,14 @@ fn write_shared(
themes.insert(theme.to_owned());
}

if (*cx.shared).layout.logo.is_empty() {
write(cx.dst.join(&format!("rust-logo{}.png", cx.shared.resource_suffix)),
static_files::RUST_LOGO)?;
}
if (*cx.shared).layout.favicon.is_empty() {
write(cx.dst.join(&format!("favicon{}.ico", cx.shared.resource_suffix)),
static_files::RUST_FAVICON)?;
}
write(cx.dst.join(&format!("brush{}.svg", cx.shared.resource_suffix)),
static_files::BRUSH_SVG)?;
write(cx.dst.join(&format!("wheel{}.svg", cx.shared.resource_suffix)),
Expand Down Expand Up @@ -2068,8 +2076,6 @@ impl Context {
themes.push(PathBuf::from("settings.css"));
let mut layout = self.shared.layout.clone();
layout.krate = String::new();
layout.logo = String::new();
layout.favicon = String::new();
try_err!(layout::render(&mut w, &layout,
&page, &sidebar, &settings,
self.shared.css_file_extension.is_some(),
Expand Down
Binary file added src/librustdoc/html/static/favicon.ico
Binary file not shown.
Binary file added src/librustdoc/html/static/rust-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/librustdoc/html/static_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ pub static LICENSE_APACHE: &'static [u8] = include_bytes!("static/LICENSE-APACHE
/// The contents of `LICENSE-MIT.txt`, the text of the MIT License.
pub static LICENSE_MIT: &'static [u8] = include_bytes!("static/LICENSE-MIT.txt");

/// The contents of `rust-logo.png`, the default icon of the documentation.
pub static RUST_LOGO: &'static [u8] = include_bytes!("static/rust-logo.png");
/// The contents of `favicon.ico`, the default favicon of the documentation.
pub static RUST_FAVICON: &'static [u8] = include_bytes!("static/favicon.ico");

/// The built-in themes given to every documentation site.
pub mod themes {
/// The "light" theme, selected by default when no setting is available. Used as the basis for
Expand Down
6 changes: 3 additions & 3 deletions src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub enum GenericArgs {
/// The `<'a, A,B,C>` in `foo::bar::baz::<'a, A,B,C>`
AngleBracketed(AngleBracketedArgs),
/// The `(A,B)` and `C` in `Foo(A,B) -> C`
Parenthesized(ParenthesisedArgs),
Parenthesized(ParenthesizedArgs),
}

impl GenericArgs {
Expand Down Expand Up @@ -173,15 +173,15 @@ impl Into<Option<P<GenericArgs>>> for AngleBracketedArgs {
}
}

impl Into<Option<P<GenericArgs>>> for ParenthesisedArgs {
impl Into<Option<P<GenericArgs>>> for ParenthesizedArgs {
fn into(self) -> Option<P<GenericArgs>> {
Some(P(GenericArgs::Parenthesized(self)))
}
}

/// A path like `Foo(A,B) -> C`
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct ParenthesisedArgs {
pub struct ParenthesizedArgs {
/// Overall span
pub span: Span,

Expand Down
12 changes: 6 additions & 6 deletions src/libsyntax/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ pub trait Folder : Sized {
noop_fold_angle_bracketed_parameter_data(p, self)
}

fn fold_parenthesized_parameter_data(&mut self, p: ParenthesisedArgs)
-> ParenthesisedArgs
fn fold_parenthesized_parameter_data(&mut self, p: ParenthesizedArgs)
-> ParenthesizedArgs
{
noop_fold_parenthesized_parameter_data(p, self)
}
Expand Down Expand Up @@ -504,12 +504,12 @@ pub fn noop_fold_angle_bracketed_parameter_data<T: Folder>(data: AngleBracketedA
}
}

pub fn noop_fold_parenthesized_parameter_data<T: Folder>(data: ParenthesisedArgs,
pub fn noop_fold_parenthesized_parameter_data<T: Folder>(data: ParenthesizedArgs,
fld: &mut T)
-> ParenthesisedArgs
-> ParenthesizedArgs
{
let ParenthesisedArgs { inputs, output, span } = data;
ParenthesisedArgs {
let ParenthesizedArgs { inputs, output, span } = data;
ParenthesizedArgs {
inputs: inputs.move_map(|ty| fld.fold_ty(ty)),
output: output.map(|ty| fld.fold_ty(ty)),
span: fld.new_span(span)
Expand Down
17 changes: 12 additions & 5 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rustc_target::spec::abi::{self, Abi};
use ast::{AngleBracketedArgs, ParenthesisedArgs, AttrStyle, BareFnTy};
use ast::{AngleBracketedArgs, ParenthesizedArgs, AttrStyle, BareFnTy};
use ast::{GenericBound, TraitBoundModifier};
use ast::Unsafety;
use ast::{Mod, AnonConst, Arg, Arm, Guard, Attribute, BindingMode, TraitItemKind};
Expand Down Expand Up @@ -2203,7 +2203,7 @@ impl<'a> Parser<'a> {
} else {
None
};
ParenthesisedArgs { inputs, output, span }.into()
ParenthesizedArgs { inputs, output, span }.into()
};

PathSegment { ident, args, id: ast::DUMMY_NODE_ID }
Expand Down Expand Up @@ -7275,9 +7275,16 @@ impl<'a> Parser<'a> {
// CONST ITEM
if self.eat_keyword(keywords::Mut) {
let prev_span = self.prev_span;
self.diagnostic().struct_span_err(prev_span, "const globals cannot be mutable")
.help("did you mean to declare a static?")
.emit();
let mut err = self.diagnostic()
.struct_span_err(prev_span, "const globals cannot be mutable");
err.span_label(prev_span, "cannot be mutable");
err.span_suggestion_with_applicability(
const_span,
"you might want to declare a static instead",
"static".to_owned(),
Applicability::MaybeIncorrect,
);
err.emit();
}
let (ident, item_, extra_attrs) = self.parse_item_const(None)?;
let prev_span = self.prev_span;
Expand Down
3 changes: 1 addition & 2 deletions src/test/ui/auto-ref-slice-plus-ref.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ error[E0599]: no method named `test_mut` found for type `std::vec::Vec<{integer}
--> $DIR/auto-ref-slice-plus-ref.rs:7:7
|
LL | a.test_mut(); //~ ERROR no method named `test_mut` found
| ^^^^^^^^
| ^^^^^^^^ help: did you mean: `get_mut`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `test_mut`, perhaps you need to implement it:
candidate #1: `MyIter`
= help: did you mean `get_mut`?

error[E0599]: no method named `test` found for type `std::vec::Vec<{integer}>` in the current scope
--> $DIR/auto-ref-slice-plus-ref.rs:8:7
Expand Down
4 changes: 1 addition & 3 deletions src/test/ui/block-result/issue-3563.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ error[E0599]: no method named `b` found for type `&Self` in the current scope
--> $DIR/issue-3563.rs:3:17
|
LL | || self.b()
| ^
|
= help: did you mean `a`?
| ^ help: did you mean: `a`

error: aborting due to previous error

Expand Down
10 changes: 4 additions & 6 deletions src/test/ui/empty/empty-struct-braces-expr.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,18 @@ error[E0599]: no variant named `Empty3` found for type `empty_struct::XE` in the
|
LL | let xe3 = XE::Empty3; //~ ERROR no variant named `Empty3` found for type
| ----^^^^^^
| |
| | |
| | help: did you mean: `XEmpty3`
| variant not found in `empty_struct::XE`
|
= help: did you mean `XEmpty3`?

error[E0599]: no variant named `Empty3` found for type `empty_struct::XE` in the current scope
--> $DIR/empty-struct-braces-expr.rs:23:19
|
LL | let xe3 = XE::Empty3(); //~ ERROR no variant named `Empty3` found for type
| ----^^^^^^
| |
| | |
| | help: did you mean: `XEmpty3`
| variant not found in `empty_struct::XE`
|
= help: did you mean `XEmpty3`?

error: aborting due to 8 previous errors

Expand Down
5 changes: 2 additions & 3 deletions src/test/ui/issues/issue-23217.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ LL | pub enum SomeEnum {
| ----------------- variant `A` not found here
LL | B = SomeEnum::A,
| ----------^
| |
| | |
| | help: did you mean: `B`
| variant not found in `SomeEnum`
|
= help: did you mean `B`?

error: aborting due to previous error

Expand Down
Loading