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 9 pull requests #74151

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fb9fa5b
adjust ub-enum test to be endianess-independent
RalfJung Jul 3, 2020
81fbfc4
Use relative path for local links to primitives in libcore
sethp Jul 6, 2020
ee3a0f8
Add guard to check for local `core` crate
sethp Jul 6, 2020
33a5d00
Two new rustdoc tests for intra links
sethp Jul 7, 2020
165aecb
build extern docs as well
sethp Jul 7, 2020
865b930
Assert current behavior for links
sethp Jul 7, 2020
56fb717
rustdoc: Rename invalid_codeblock_attribute lint to be plural
ollie27 Jul 7, 2020
f258d98
ignore-tidy-linelength for @has assertions
sethp Jul 7, 2020
b50c13c
Update books
ehuss Jul 7, 2020
8d267db
Revert "Add guard to check for local `core` crate"
sethp Jul 7, 2020
32025fd
Update rust-installer to latest version
michaelforney May 25, 2020
dd07774
Fix broken link in rustdocdoc
JohnTitor Jul 7, 2020
7bc85e2
Liballoc use vec instead of vector
pickfire Jul 8, 2020
0965443
Remove unneeded ToString import in liballoc slice
pickfire Jul 8, 2020
512f9e9
update miri
RalfJung Jul 8, 2020
9366458
Apply #![crate_type = "rlib"] directly to the linker
sethp Jul 8, 2020
f4fcb60
Rollup merge of #73989 - RalfJung:ub-enum-test, r=oli-obk
Manishearth Jul 8, 2020
b3ab41d
Rollup merge of #74077 - sethp:docs/fix-intra-doc-primitive-link, r=j…
Manishearth Jul 8, 2020
5b60bbe
Rollup merge of #74131 - ollie27:rustdoc_invalid_codeblock_attributes…
Manishearth Jul 8, 2020
3ee0f3f
Rollup merge of #74135 - ehuss:update-books, r=ehuss
Manishearth Jul 8, 2020
4057300
Rollup merge of #74136 - JohnTitor:index-page-link, r=GuillaumeGomez
Manishearth Jul 8, 2020
bed5f7d
Rollup merge of #74142 - pickfire:patch-1, r=dtolnay
Manishearth Jul 8, 2020
32a29e1
Rollup merge of #74143 - pickfire:patch-2, r=jonas-schievink
Manishearth Jul 8, 2020
38e67bd
Rollup merge of #74145 - michaelforney:rust-installer, r=Mark-Simulacrum
Manishearth Jul 8, 2020
ef081d1
Rollup merge of #74146 - RalfJung:miri, r=RalfJung
Manishearth Jul 8, 2020
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
2 changes: 1 addition & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1366,8 +1366,8 @@ checksum = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d"
name = "installer"
version = "0.0.0"
dependencies = [
"anyhow",
"clap",
"failure",
"flate2",
"lazy_static",
"num_cpus",
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book
2 changes: 1 addition & 1 deletion src/doc/embedded-book
2 changes: 1 addition & 1 deletion src/doc/reference
2 changes: 1 addition & 1 deletion src/doc/rust-by-example
2 changes: 1 addition & 1 deletion src/doc/rustdoc/src/unstable-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ library, as an equivalent command-line argument is provided to `rustc` when buil
### `--index-page`: provide a top-level landing page for docs

This feature allows you to generate an index-page with a given markdown file. A good example of it
is the [rust documentation index](https://doc.rust-lang.org/index.html).
is the [rust documentation index](https://doc.rust-lang.org/nightly/index.html).

With this, you'll have a page which you can custom as much as you want at the top of your crates.

Expand Down
8 changes: 3 additions & 5 deletions src/liballoc/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ pub use hack::to_vec;
// `test_permutations` test
mod hack {
use crate::boxed::Box;
#[cfg(test)]
use crate::string::ToString;
use crate::vec::Vec;

// We shouldn't add inline attribute to this since this is used in
Expand All @@ -156,9 +154,9 @@ mod hack {
where
T: Clone,
{
let mut vector = Vec::with_capacity(s.len());
vector.extend_from_slice(s);
vector
let mut vec = Vec::with_capacity(s.len());
vec.extend_from_slice(s);
vec
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ use rustc_middle::ty::query::Providers;
use rustc_middle::ty::TyCtxt;
use rustc_session::lint::builtin::{
BARE_TRAIT_OBJECTS, ELIDED_LIFETIMES_IN_PATHS, EXPLICIT_OUTLIVES_REQUIREMENTS,
INTRA_DOC_LINK_RESOLUTION_FAILURE, INVALID_CODEBLOCK_ATTRIBUTE, MISSING_DOC_CODE_EXAMPLES,
INTRA_DOC_LINK_RESOLUTION_FAILURE, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_DOC_CODE_EXAMPLES,
PRIVATE_DOC_TESTS,
};
use rustc_span::symbol::{Ident, Symbol};
Expand Down Expand Up @@ -305,7 +305,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
add_lint_group!(
"rustdoc",
INTRA_DOC_LINK_RESOLUTION_FAILURE,
INVALID_CODEBLOCK_ATTRIBUTE,
INVALID_CODEBLOCK_ATTRIBUTES,
MISSING_DOC_CODE_EXAMPLES,
PRIVATE_DOC_TESTS
);
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_session/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ declare_lint! {
}

declare_lint! {
pub INVALID_CODEBLOCK_ATTRIBUTE,
pub INVALID_CODEBLOCK_ATTRIBUTES,
Warn,
"codeblock attribute looks a lot like a known one"
}
Expand Down Expand Up @@ -602,7 +602,7 @@ declare_lint_pass! {
UNSTABLE_NAME_COLLISIONS,
IRREFUTABLE_LET_PATTERNS,
INTRA_DOC_LINK_RESOLUTION_FAILURE,
INVALID_CODEBLOCK_ATTRIBUTE,
INVALID_CODEBLOCK_ATTRIBUTES,
MISSING_CRATE_LEVEL_DOCS,
MISSING_DOC_CODE_EXAMPLES,
PRIVATE_DOC_TESTS,
Expand Down
10 changes: 6 additions & 4 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ impl Attributes {
/// Cache must be populated before call
pub fn links(&self, krate: &CrateNum) -> Vec<(String, String)> {
use crate::html::format::href;
use crate::html::render::CURRENT_DEPTH;

self.links
.iter()
Expand All @@ -648,12 +649,13 @@ impl Attributes {
if let Some(ref fragment) = *fragment {
let cache = cache();
let url = match cache.extern_locations.get(krate) {
Some(&(_, ref src, ExternalLocation::Local)) => {
src.to_str().expect("invalid file path")
Some(&(_, _, ExternalLocation::Local)) => {
let depth = CURRENT_DEPTH.with(|l| l.get());
"../".repeat(depth)
}
Some(&(_, _, ExternalLocation::Remote(ref s))) => s,
Some(&(_, _, ExternalLocation::Remote(ref s))) => s.to_string(),
Some(&(_, _, ExternalLocation::Unknown)) | None => {
"https://doc.rust-lang.org/nightly"
String::from("https://doc.rust-lang.org/nightly")
}
};
// This is a primitive so the url is done "by hand".
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ pub fn new_handler(

/// This function is used to setup the lint initialization. By default, in rustdoc, everything
/// is "allowed". Depending if we run in test mode or not, we want some of them to be at their
/// default level. For example, the "INVALID_CODEBLOCK_ATTRIBUTE" lint is activated in both
/// default level. For example, the "INVALID_CODEBLOCK_ATTRIBUTES" lint is activated in both
/// modes.
///
/// A little detail easy to forget is that there is a way to set the lint level for all lints
Expand Down Expand Up @@ -315,7 +315,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
let missing_doc_example = rustc_lint::builtin::MISSING_DOC_CODE_EXAMPLES.name;
let private_doc_tests = rustc_lint::builtin::PRIVATE_DOC_TESTS.name;
let no_crate_level_docs = rustc_lint::builtin::MISSING_CRATE_LEVEL_DOCS.name;
let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTE.name;
let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name;

// In addition to those specific lints, we also need to whitelist those given through
// command line, otherwise they'll get ignored and we don't want that.
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ impl<'a, 'b> ExtraInfo<'a, 'b> {
(None, None) => return,
};
self.tcx.struct_span_lint_hir(
lint::builtin::INVALID_CODEBLOCK_ATTRIBUTE,
lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES,
hir_id,
self.sp,
|lint| {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub struct TestOptions {
pub fn run(options: Options) -> Result<(), String> {
let input = config::Input::File(options.input.clone());

let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTE.name;
let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name;

// In addition to those specific lints, we also need to whitelist those given through
// command line, otherwise they'll get ignored and we don't want that.
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/check-attr-test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// compile-flags:--test

#![deny(invalid_codeblock_attribute)]
#![deny(invalid_codeblock_attributes)]

/// foo
///
Expand Down
4 changes: 2 additions & 2 deletions src/test/rustdoc-ui/check-attr-test.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ error: unknown attribute `compile-fail`. Did you mean `compile_fail`?
note: the lint level is defined here
--> $DIR/check-attr-test.rs:3:9
|
3 | #![deny(invalid_codeblock_attribute)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 | #![deny(invalid_codeblock_attributes)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully

error: unknown attribute `compilefail`. Did you mean `compile_fail`?
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/check-attr.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![deny(invalid_codeblock_attribute)]
#![deny(invalid_codeblock_attributes)]

/// foo
//~^ ERROR
Expand Down
4 changes: 2 additions & 2 deletions src/test/rustdoc-ui/check-attr.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ LL | | /// ```
note: the lint level is defined here
--> $DIR/check-attr.rs:1:9
|
LL | #![deny(invalid_codeblock_attribute)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #![deny(invalid_codeblock_attributes)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully

error: unknown attribute `compilefail`. Did you mean `compile_fail`?
Expand Down
19 changes: 19 additions & 0 deletions src/test/rustdoc/auxiliary/my-core.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#![feature(no_core, lang_items)]
#![no_core]
#![crate_type="rlib"]

#[lang = "char"]
impl char {
pub fn len_utf8(self) -> usize {
42
}
}

#[lang = "sized"]
pub trait Sized {}

#[lang = "clone"]
pub trait Clone: Sized {}

#[lang = "copy"]
pub trait Copy: Clone {}
17 changes: 17 additions & 0 deletions src/test/rustdoc/intra-link-prim-methods-external-core.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// aux-build:my-core.rs
// build-aux-docs
// ignore-cross-compile
// ignore-tidy-linelength

#![deny(intra_doc_link_resolution_failure)]
#![feature(no_core, lang_items)]
#![no_core]
#![crate_type = "rlib"]

// @has intra_link_prim_methods_external_core/index.html
// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html"]' 'char'
// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8'

//! A [`char`] and its [`char::len_utf8`].

extern crate my_core;
28 changes: 28 additions & 0 deletions src/test/rustdoc/intra-link-prim-methods-local.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#![deny(intra_doc_link_resolution_failure)]
#![feature(no_core, lang_items)]
#![no_core]
#![crate_type = "rlib"]

// ignore-tidy-linelength

// @has intra_link_prim_methods_local/index.html
// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html"]' 'char'
// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8'

//! A [`char`] and its [`char::len_utf8`].

#[lang = "char"]
impl char {
pub fn len_utf8(self) -> usize {
42
}
}

#[lang = "sized"]
pub trait Sized {}

#[lang = "clone"]
pub trait Clone: Sized {}

#[lang = "copy"]
pub trait Copy: Clone {}
6 changes: 6 additions & 0 deletions src/test/rustdoc/intra-link-prim-methods.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#![deny(intra_doc_link_resolution_failure)]

// ignore-tidy-linelength

// @has intra_link_prim_methods/index.html
// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html"]' 'char'
// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8'

//! A [`char`] and its [`char::len_utf8`].
5 changes: 3 additions & 2 deletions src/test/ui/consts/const-eval/ub-enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute
//~^ ERROR is undefined behavior

// All variants are uninhabited but also have data.
const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(1u64) };
// Use `0` as constant to make behavior endianess-independent.
const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) };
//~^ ERROR is undefined behavior
const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(1u64) };
const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) };
//~^ ERROR is undefined behavior

fn main() {
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/consts/const-eval/ub-enum.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,18 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.

error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-enum.rs:91:1
--> $DIR/ub-enum.rs:92:1
|
LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(1u64) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of the never type `!` at .<enum-variant(Err)>.0.1
LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of uninhabited type Never at .<enum-variant(Ok)>.0.1
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.

error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-enum.rs:93:1
--> $DIR/ub-enum.rs:94:1
|
LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(1u64) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of uninhabited type Never at .<enum-variant(Err)>.0.1
LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of the never type `!` at .<enum-variant(Ok)>.0.1
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.

Expand Down