Auto merge of #79441 - jonas-schievink:rollup-l9v00bl, r=jonas-schievink

Rollup of 10 pull requests

Successful merges:

 - #77758 (suggest turbofish syntax for uninferred const arguments)
 - #79000 (Move lev_distance to rustc_ast, make non-generic)
 - #79362 (Lower patterns before using the bound variable)
 - #79365 (Upgrades the coverage map to Version 4)
 - #79402 (Fix typos)
 - #79412 (Clean up rustdoc tests by removing unnecessary features)
 - #79413 (Fix persisted doctests on Windows / when using workspaces)
 - #79420 (Fixes a word typo in librustdoc)
 - #79421 (Fix docs formatting for `thir::pattern::_match`)
 - #79428 (Fixup compiler docs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2020-11-26 14:14:57 +00:00
commit 0beba93337
63 changed files with 537 additions and 362 deletions

View file

@ -12,10 +12,12 @@ ifeq ($(UNAME),Darwin)
INSTR_PROF_DATA_SUFFIX=,regular,live_support
DATA_SECTION_PREFIX=__DATA,
LLVM_COV_SECTION_PREFIX=__LLVM_COV,
COMDAT_IF_SUPPORTED=
else
INSTR_PROF_DATA_SUFFIX=
DATA_SECTION_PREFIX=
LLVM_COV_SECTION_PREFIX=
COMDAT_IF_SUPPORTED=, comdat
endif
ifeq ($(LINK_DEAD_CODE),yes)
@ -29,28 +31,39 @@ ifdef IS_WINDOWS
-check-prefixes=CHECK,WINDOWS \
-DPRIVATE_GLOBAL='internal global' \
-DDEFINE_INTERNAL='$(DEFINE_INTERNAL)' \
-DCOMDAT_IF_SUPPORTED='$(COMDAT_IF_SUPPORTED)' \
-DINSTR_PROF_DATA='.lprfd$$M' \
-DINSTR_PROF_NAME='.lprfn$$M' \
-DINSTR_PROF_CNTS='.lprfc$$M' \
-DINSTR_PROF_VALS='.lprfv$$M' \
-DINSTR_PROF_VNODES='.lprfnd$$M' \
-DINSTR_PROF_COVMAP='.lcovmap$$M' \
-DINSTR_PROF_COVFUN='.lcovfun$$M' \
-DINSTR_PROF_ORDERFILE='.lorderfile$$M'
else
LLVM_FILECHECK_OPTIONS=\
-check-prefixes=CHECK \
-DPRIVATE_GLOBAL='private global' \
-DDEFINE_INTERNAL='$(DEFINE_INTERNAL)' \
-DCOMDAT_IF_SUPPORTED='$(COMDAT_IF_SUPPORTED)' \
-DINSTR_PROF_DATA='$(DATA_SECTION_PREFIX)__llvm_prf_data$(INSTR_PROF_DATA_SUFFIX)' \
-DINSTR_PROF_NAME='$(DATA_SECTION_PREFIX)__llvm_prf_names' \
-DINSTR_PROF_CNTS='$(DATA_SECTION_PREFIX)__llvm_prf_cnts' \
-DINSTR_PROF_VALS='$(DATA_SECTION_PREFIX)__llvm_prf_vals' \
-DINSTR_PROF_VNODES='$(DATA_SECTION_PREFIX)__llvm_prf_vnds' \
-DINSTR_PROF_COVMAP='$(LLVM_COV_SECTION_PREFIX)__llvm_covmap' \
-DINSTR_PROF_COVFUN='$(LLVM_COV_SECTION_PREFIX)__llvm_covfun' \
-DINSTR_PROF_ORDERFILE='$(DATA_SECTION_PREFIX)__llvm_orderfile'
endif
ifeq ($(LLVM_VERSION_11_PLUS),true)
all: test_llvm_ir
else
$(info Rust option `-Z instrument-coverage` requires LLVM 11 or higher. Test skipped.)
all:
endif
test_llvm_ir:
# Compile the test program with non-experimental coverage instrumentation, and generate LLVM IR
#
# Note: `-Clink-dead-code=no` disables the option, needed because the option is automatically
@ -62,4 +75,5 @@ all:
-Clink-dead-code=$(LINK_DEAD_CODE) \
--emit=llvm-ir
cat "$(TMPDIR)"/testprog.ll | "$(LLVM_FILECHECK)" $(BASEDIR)/filecheck.testprog.txt $(LLVM_FILECHECK_OPTIONS)
cat "$(TMPDIR)"/testprog.ll | \
"$(LLVM_FILECHECK)" $(BASEDIR)/filecheck.testprog.txt $(LLVM_FILECHECK_OPTIONS)

View file

@ -3,7 +3,10 @@
WINDOWS: $__llvm_profile_runtime_user = comdat any
CHECK: @__llvm_coverage_mapping = internal constant
CHECK: @__covrec_{{[A-F0-9]+}}u = linkonce_odr hidden constant
CHECK-SAME: section "[[INSTR_PROF_COVFUN]]"[[COMDAT_IF_SUPPORTED]], align 8
CHECK: @__llvm_coverage_mapping = private constant
CHECK-SAME: section "[[INSTR_PROF_COVMAP]]", align 8
WINDOWS: @__llvm_profile_runtime = external global i32

View file

@ -18,7 +18,10 @@ SOURCEDIR=../coverage
# `llvm/release_debuginfo`. Note that some CI builds disable debug assertions (by setting
# `NO_LLVM_ASSERTIONS=1`), so it is not OK to fail the test, but `bless`ed test results cannot be
# generated without debug assertions.
LLVM_COV_DEBUG := $(shell "$(LLVM_BIN_DIR)"/llvm-cov show --debug 2>&1 | grep -q "Unknown command line argument '--debug'"; echo $$?)
LLVM_COV_DEBUG := $(shell \
"$(LLVM_BIN_DIR)"/llvm-cov show --debug 2>&1 | \
grep -q "Unknown command line argument '--debug'"; \
echo $$?)
ifeq ($(LLVM_COV_DEBUG), 1)
DEBUG_FLAG=--debug
endif
@ -30,7 +33,12 @@ ifdef RUSTC_BLESS_TEST
DEBUG_FLAG=--debug
endif
ifeq ($(LLVM_VERSION_11_PLUS),true)
all: $(patsubst $(SOURCEDIR)/%.rs,%,$(wildcard $(SOURCEDIR)/*.rs))
else
$(info Rust option `-Z instrument-coverage` requires LLVM 11 or higher. Test skipped.)
all:
endif
# Ensure there are no `expected` results for tests that may have been removed or renamed
.PHONY: clear_expected_if_blessed

View file

@ -24,7 +24,12 @@ For revisions in Pull Requests (PR):
endef
export SPANVIEW_HEADER
ifeq ($(LLVM_VERSION_11_PLUS),true)
all: $(patsubst $(SOURCEDIR)/%.rs,%,$(wildcard $(SOURCEDIR)/*.rs))
else
$(info Rust option `-Z instrument-coverage` requires LLVM 11 or higher. Test skipped.)
all:
endif
# Ensure there are no `expected` results for tests that may have been removed or renamed
.PHONY: clear_expected_if_blessed

View file

@ -38,6 +38,13 @@ endif
UNAME = $(shell uname)
# Rust option `-Z instrument-coverage` uses LLVM Coverage Mapping Format version 4,
# which requires LLVM 11 or greater.
LLVM_VERSION_11_PLUS := $(shell \
LLVM_VERSION=$$("$(LLVM_BIN_DIR)"/llvm-config --version) && \
LLVM_VERSION_MAJOR=$${LLVM_VERSION/.*/} && \
[ $$LLVM_VERSION_MAJOR -ge 11 ] && echo true || echo false)
# FIXME(richkadel): Can any of the features tested by `run-make-fulldeps/coverage-*` tests be tested
# just as completely by more focused unit tests of the code logic itself, to reduce the number of
# test result files generated and maintained, and to help identify specific test failures and root

View file

@ -1,4 +1,2 @@
#![feature(doc_alias)]
#[doc(alias = "true")]
pub struct Foo;

View file

@ -1,5 +1,3 @@
#![feature(doc_alias)]
#[doc(alias = "true")]
pub struct Foo;

View file

@ -1,4 +1,2 @@
#![feature(doc_alias)]
#[doc(alias = "Demon Lord")]
pub struct Struct;

View file

@ -1,5 +1,3 @@
#![feature(doc_alias)]
#[doc(alias = "StructItem")]
pub struct Struct {
#[doc(alias = "StructFieldItem")]

View file

@ -1,5 +1,3 @@
#![feature(doc_alias)]
pub struct Bar;
pub trait Foo {
type X;

View file

@ -1,23 +1,23 @@
error: `#[doc(alias = "...")]` isn't allowed on extern block
--> $DIR/check-doc-alias-attr-location.rs:9:7
--> $DIR/check-doc-alias-attr-location.rs:7:7
|
LL | #[doc(alias = "foo")]
| ^^^^^^^^^^^^^
error: `#[doc(alias = "...")]` isn't allowed on implementation block
--> $DIR/check-doc-alias-attr-location.rs:12:7
--> $DIR/check-doc-alias-attr-location.rs:10:7
|
LL | #[doc(alias = "bar")]
| ^^^^^^^^^^^^^
error: `#[doc(alias = "...")]` isn't allowed on implementation block
--> $DIR/check-doc-alias-attr-location.rs:18:7
--> $DIR/check-doc-alias-attr-location.rs:16:7
|
LL | #[doc(alias = "foobar")]
| ^^^^^^^^^^^^^^^^
error: `#[doc(alias = "...")]` isn't allowed on type alias in implementation block
--> $DIR/check-doc-alias-attr-location.rs:20:11
--> $DIR/check-doc-alias-attr-location.rs:18:11
|
LL | #[doc(alias = "assoc")]
| ^^^^^^^^^^^^^^^

View file

@ -1,5 +1,4 @@
#![crate_type = "lib"]
#![feature(doc_alias)]
#[doc(alias = "foo")] // ok!
pub struct Bar;

View file

@ -1,35 +1,35 @@
error: doc alias attribute expects a string: #[doc(alias = "0")]
--> $DIR/check-doc-alias-attr.rs:7:7
--> $DIR/check-doc-alias-attr.rs:6:7
|
LL | #[doc(alias)]
| ^^^^^
error: doc alias attribute expects a string: #[doc(alias = "0")]
--> $DIR/check-doc-alias-attr.rs:8:7
--> $DIR/check-doc-alias-attr.rs:7:7
|
LL | #[doc(alias = 0)]
| ^^^^^^^^^
error: doc alias attribute expects a string: #[doc(alias = "0")]
--> $DIR/check-doc-alias-attr.rs:9:7
--> $DIR/check-doc-alias-attr.rs:8:7
|
LL | #[doc(alias("bar"))]
| ^^^^^^^^^^^^
error: '\"' character isn't allowed in `#[doc(alias = "...")]`
--> $DIR/check-doc-alias-attr.rs:10:7
--> $DIR/check-doc-alias-attr.rs:9:7
|
LL | #[doc(alias = "\"")]
| ^^^^^^^^^^^^
error: '\n' character isn't allowed in `#[doc(alias = "...")]`
--> $DIR/check-doc-alias-attr.rs:11:7
--> $DIR/check-doc-alias-attr.rs:10:7
|
LL | #[doc(alias = "\n")]
| ^^^^^^^^^^^^
error: '\n' character isn't allowed in `#[doc(alias = "...")]`
--> $DIR/check-doc-alias-attr.rs:12:7
--> $DIR/check-doc-alias-attr.rs:11:7
|
LL | #[doc(alias = "
| _______^
@ -37,19 +37,19 @@ LL | | ")]
| |_^
error: '\t' character isn't allowed in `#[doc(alias = "...")]`
--> $DIR/check-doc-alias-attr.rs:14:7
--> $DIR/check-doc-alias-attr.rs:13:7
|
LL | #[doc(alias = "\t")]
| ^^^^^^^^^^^^
error: `#[doc(alias = "...")]` cannot start or end with ' '
--> $DIR/check-doc-alias-attr.rs:15:7
--> $DIR/check-doc-alias-attr.rs:14:7
|
LL | #[doc(alias = " hello")]
| ^^^^^^^^^^^^^^^^
error: `#[doc(alias = "...")]` cannot start or end with ' '
--> $DIR/check-doc-alias-attr.rs:16:7
--> $DIR/check-doc-alias-attr.rs:15:7
|
LL | #[doc(alias = "hello ")]
| ^^^^^^^^^^^^^^^^

View file

@ -1,4 +1,3 @@
#![feature(doc_alias)]
#![feature(trait_alias)]
pub struct Foo;

View file

@ -1,5 +1,5 @@
error: `#[doc(alias = "...")]` isn't allowed on associated constant in trait implementation block
--> $DIR/doc-alias-assoc-const.rs:11:11
--> $DIR/doc-alias-assoc-const.rs:10:11
|
LL | #[doc(alias = "CONST_BAZ")]
| ^^^^^^^^^^^^^^^^^^^

View file

@ -2,13 +2,10 @@
// compile-flags:--test
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR"
#![feature(cfg_doctest)]
// Make sure `cfg(doctest)` is set when finding doctests but not inside
// the doctests.
/// ```
/// #![feature(cfg_doctest)]
/// assert!(!cfg!(doctest));
/// ```
#[cfg(doctest)]

View file

@ -1,6 +1,6 @@
running 1 test
test $DIR/doc-test-doctest-feature.rs - Foo (line 10) ... ok
test $DIR/doc-test-doctest-feature.rs - Foo (line 8) ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

View file

@ -1,5 +1,3 @@
#![feature(deprecated)]
// @has deprecated_future/index.html '//*[@class="stab deprecated"]' \
// 'Deprecated'
// @has deprecated_future/struct.S.html '//*[@class="stab deprecated"]' \

View file

@ -1,5 +1,3 @@
#![feature(deprecated)]
// @has deprecated/index.html '//*[@class="docblock-short"]/span[@class="stab deprecated"]' \
// 'Deprecated'
// @has - '//*[@class="docblock-short"]' 'Deprecated docs'

View file

@ -1,5 +1,3 @@
#![feature(const_fn)]
// @has 'issue_76501/fn.bloop.html' '//pre' 'pub const fn bloop() -> i32'
/// A useless function that always returns 1.
pub const fn bloop() -> i32 {

View file

@ -3,6 +3,11 @@ error[E0282]: type annotations needed
|
LL | foo();
| ^^^ cannot infer the value of const parameter `X` declared on the function `foo`
|
help: consider specifying the const argument
|
LL | foo::<X>();
| ^^^^^^^^
error: aborting due to previous error

View file

@ -3,6 +3,11 @@ error[E0282]: type annotations needed
|
LL | foo();
| ^^^ cannot infer the value of const parameter `X` declared on the function `foo`
|
help: consider specifying the const argument
|
LL | foo::<X>();
| ^^^^^^^^
error: aborting due to previous error

View file

@ -3,6 +3,11 @@ error[E0282]: type annotations needed
|
LL | println!("{:?}", take_array_from_mut(&mut arr, i));
| ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `take_array_from_mut`
|
help: consider specifying the const argument
|
LL | println!("{:?}", take_array_from_mut::<N>(&mut arr, i));
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View file

@ -3,6 +3,11 @@ error[E0282]: type annotations needed
|
LL | Foo.bar().bar().bar().bar().baz();
| ^^^ cannot infer the value of const parameter `N` declared on the associated function `baz`
|
help: consider specifying the const argument
|
LL | Foo.bar().bar().bar().bar().baz::<N>();
| ^^^^^^^^
error: aborting due to previous error

View file

@ -3,6 +3,11 @@ error[E0282]: type annotations needed
|
LL | Foo.bar().bar().bar().bar().baz();
| ^^^ cannot infer the value of const parameter `N` declared on the associated function `baz`
|
help: consider specifying the const argument
|
LL | Foo.bar().bar().bar().bar().baz::<N>();
| ^^^^^^^^
error: aborting due to previous error

View file

@ -0,0 +1,14 @@
error[E0282]: type annotations needed
--> $DIR/one-param-uninferred.rs:15:23
|
LL | let _: [u8; 17] = foo();
| ^^^ cannot infer the value of const parameter `M` declared on the function `foo`
|
help: consider specifying the const argument
|
LL | let _: [u8; 17] = foo::<M>();
| ^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0282`.

View file

@ -0,0 +1,14 @@
error[E0282]: type annotations needed
--> $DIR/one-param-uninferred.rs:15:23
|
LL | let _: [u8; 17] = foo();
| ^^^ cannot infer the value of const parameter `M` declared on the function `foo`
|
help: consider specifying the const argument
|
LL | let _: [u8; 17] = foo::<M>();
| ^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0282`.

View file

@ -0,0 +1,17 @@
// Test that we emit an error if we cannot properly infer a constant.
// revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
fn foo<const N: usize, const M: usize>() -> [u8; N] {
todo!()
}
fn main() {
// FIXME(const_generics): Currently this only suggests one const parameter,
// but instead it should suggest to provide all parameters.
let _: [u8; 17] = foo();
//~^ ERROR type annotations needed
}

View file

@ -2,7 +2,12 @@ error[E0282]: type annotations needed
--> $DIR/uninferred-consts.rs:14:9
|
LL | Foo.foo();
| ^^^ cannot infer the value of const parameter `N` declared on the associated function `foo`
| ^^^ cannot infer the value of const parameter `A` declared on the associated function `foo`
|
help: consider specifying the const argument
|
LL | Foo.foo::<A>();
| ^^^^^^^^
error: aborting due to previous error

View file

@ -2,7 +2,12 @@ error[E0282]: type annotations needed
--> $DIR/uninferred-consts.rs:14:9
|
LL | Foo.foo();
| ^^^ cannot infer the value of const parameter `N` declared on the associated function `foo`
| ^^^ cannot infer the value of const parameter `A` declared on the associated function `foo`
|
help: consider specifying the const argument
|
LL | Foo.foo::<A>();
| ^^^^^^^^
error: aborting due to previous error

View file

@ -8,7 +8,7 @@
// taken from https://github.com/rust-lang/rust/issues/70507#issuecomment-615268893
struct Foo;
impl Foo {
fn foo<const N: usize>(self) {}
fn foo<const A: usize, const B: usize>(self) {}
}
fn main() {
Foo.foo();