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 #74138

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 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
5702e02
Only allow `repr(i128/u128)` on enum
nbdd0121 Jul 6, 2020
97867bb
Add UI test for issue 74082
nbdd0121 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
561d5ac
Fix occasional bootstrap panic in docs.
ehuss 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
1a021ed
Update cargo
ehuss Jul 7, 2020
db84b32
Rollup merge of #73989 - RalfJung:ub-enum-test, r=oli-obk
Manishearth Jul 7, 2020
e6fee38
Rollup merge of #74077 - sethp:docs/fix-intra-doc-primitive-link, r=D…
Manishearth Jul 7, 2020
8cf88d5
Rollup merge of #74109 - nbdd0121:issue-74082, r=petrochenkov
Manishearth Jul 7, 2020
94ea187
Rollup merge of #74124 - ehuss:fix-doc-dry-run-up-to-date, r=Mark-Sim…
Manishearth Jul 7, 2020
3702a2f
Rollup merge of #74131 - ollie27:rustdoc_invalid_codeblock_attributes…
Manishearth Jul 7, 2020
9e308ff
Rollup merge of #74135 - ehuss:update-books, r=ehuss
Manishearth Jul 7, 2020
08f8624
Rollup merge of #74137 - ehuss:update-cargo, r=ehuss
Manishearth Jul 7, 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 src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl Step for RustbookSrc {
let index = out.join("index.html");
let rustbook = builder.tool_exe(Tool::Rustbook);
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
if up_to_date(&src, &index) && up_to_date(&rustbook, &index) {
if builder.config.dry_run || up_to_date(&src, &index) && up_to_date(&rustbook, &index) {
return;
}
builder.info(&format!("Rustbook ({}) - {}", target, name));
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
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
2 changes: 2 additions & 0 deletions src/librustc_passes/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ impl CheckAttrVisitor<'tcx> {
| sym::u32
| sym::i64
| sym::u64
| sym::i128
| sym::u128
| sym::isize
| sym::usize => {
int_reprs += 1;
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
18 changes: 18 additions & 0 deletions src/test/rustdoc/auxiliary/my-core.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#![feature(no_core, lang_items)]
#![no_core]

#[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 {}
16 changes: 16 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,16 @@
// 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]

// @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;
27 changes: 27 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,27 @@
#![deny(intra_doc_link_resolution_failure)]
#![feature(no_core, lang_items)]
#![no_core]

// 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
9 changes: 9 additions & 0 deletions src/test/ui/issues/issue-74082.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![allow(dead_code)]

#[repr(i128)] //~ ERROR: attribute should be applied to enum
struct Foo;

#[repr(u128)] //~ ERROR: attribute should be applied to enum
struct Bar;

fn main() {}
19 changes: 19 additions & 0 deletions src/test/ui/issues/issue-74082.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0517]: attribute should be applied to enum
--> $DIR/issue-74082.rs:3:8
|
LL | #[repr(i128)]
| ^^^^
LL | struct Foo;
| ----------- not an enum

error[E0517]: attribute should be applied to enum
--> $DIR/issue-74082.rs:6:8
|
LL | #[repr(u128)]
| ^^^^
LL | struct Bar;
| ----------- not an enum

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0517`.
2 changes: 1 addition & 1 deletion src/tools/cargo
Submodule cargo updated 70 files
+7 −0 src/bin/cargo/cli.rs
+4 −1 src/cargo/ops/cargo_compile.rs
+6 −26 src/cargo/ops/cargo_package.rs
+21 −1 src/cargo/util/config/de.rs
+8 −0 src/doc/man/generated/cargo-bench.html
+8 −0 src/doc/man/generated/cargo-build.html
+8 −0 src/doc/man/generated/cargo-check.html
+8 −0 src/doc/man/generated/cargo-clean.html
+8 −0 src/doc/man/generated/cargo-doc.html
+8 −0 src/doc/man/generated/cargo-fetch.html
+8 −0 src/doc/man/generated/cargo-fix.html
+8 −0 src/doc/man/generated/cargo-generate-lockfile.html
+8 −0 src/doc/man/generated/cargo-init.html
+8 −0 src/doc/man/generated/cargo-install.html
+8 −0 src/doc/man/generated/cargo-locate-project.html
+8 −0 src/doc/man/generated/cargo-login.html
+17 −0 src/doc/man/generated/cargo-metadata.html
+8 −0 src/doc/man/generated/cargo-new.html
+8 −0 src/doc/man/generated/cargo-owner.html
+8 −0 src/doc/man/generated/cargo-package.html
+8 −0 src/doc/man/generated/cargo-pkgid.html
+8 −0 src/doc/man/generated/cargo-publish.html
+8 −0 src/doc/man/generated/cargo-run.html
+8 −0 src/doc/man/generated/cargo-rustc.html
+8 −0 src/doc/man/generated/cargo-rustdoc.html
+8 −0 src/doc/man/generated/cargo-search.html
+8 −0 src/doc/man/generated/cargo-test.html
+8 −0 src/doc/man/generated/cargo-tree.html
+8 −0 src/doc/man/generated/cargo-uninstall.html
+8 −0 src/doc/man/generated/cargo-update.html
+8 −0 src/doc/man/generated/cargo-vendor.html
+8 −0 src/doc/man/generated/cargo-verify-project.html
+8 −0 src/doc/man/generated/cargo-yank.html
+8 −0 src/doc/man/generated/cargo.html
+7 −0 src/doc/man/options-common.adoc
+12 −2 src/etc/man/cargo-bench.1
+10 −0 src/etc/man/cargo-build.1
+10 −0 src/etc/man/cargo-check.1
+10 −0 src/etc/man/cargo-clean.1
+12 −2 src/etc/man/cargo-doc.1
+10 −0 src/etc/man/cargo-fetch.1
+12 −2 src/etc/man/cargo-fix.1
+10 −0 src/etc/man/cargo-generate-lockfile.1
+2 −2 src/etc/man/cargo-help.1
+12 −2 src/etc/man/cargo-init.1
+12 −2 src/etc/man/cargo-install.1
+10 −0 src/etc/man/cargo-locate-project.1
+12 −2 src/etc/man/cargo-login.1
+22 −3 src/etc/man/cargo-metadata.1
+12 −2 src/etc/man/cargo-new.1
+12 −2 src/etc/man/cargo-owner.1
+12 −2 src/etc/man/cargo-package.1
+10 −0 src/etc/man/cargo-pkgid.1
+10 −0 src/etc/man/cargo-publish.1
+12 −2 src/etc/man/cargo-run.1
+12 −2 src/etc/man/cargo-rustc.1
+12 −2 src/etc/man/cargo-rustdoc.1
+12 −2 src/etc/man/cargo-search.1
+12 −2 src/etc/man/cargo-test.1
+12 −2 src/etc/man/cargo-tree.1
+12 −2 src/etc/man/cargo-uninstall.1
+10 −0 src/etc/man/cargo-update.1
+12 −2 src/etc/man/cargo-vendor.1
+10 −0 src/etc/man/cargo-verify-project.1
+2 −2 src/etc/man/cargo-version.1
+12 −2 src/etc/man/cargo-yank.1
+12 −2 src/etc/man/cargo.1
+40 −0 tests/testsuite/config.rs
+44 −0 tests/testsuite/package.rs
+11 −0 tests/testsuite/rustdoc.rs