diff options
| author | bors <bors@rust-lang.org> | 2020-11-26 14:14:57 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-11-26 14:14:57 +0000 |
| commit | 0beba9333754ead8febc5101fc5c35f7dcdfaadf (patch) | |
| tree | dd05baf407cc40304a2b8be15fe3ce3e4b3c7374 /src/test | |
| parent | aefcf1f3427a5e522a8c665d7e25529cf971bc93 (diff) | |
| parent | 89ab56344d560f63481359c2687cf4819f2341be (diff) | |
| download | rust-0beba9333754ead8febc5101fc5c35f7dcdfaadf.tar.gz rust-0beba9333754ead8febc5101fc5c35f7dcdfaadf.zip | |
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
Diffstat (limited to 'src/test')
31 files changed, 138 insertions, 42 deletions
diff --git a/src/test/run-make-fulldeps/coverage-llvmir-base/Makefile b/src/test/run-make-fulldeps/coverage-llvmir-base/Makefile index e84642922d9..219ba15ad11 100644 --- a/src/test/run-make-fulldeps/coverage-llvmir-base/Makefile +++ b/src/test/run-make-fulldeps/coverage-llvmir-base/Makefile @@ -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) diff --git a/src/test/run-make-fulldeps/coverage-llvmir-base/filecheck.testprog.txt b/src/test/run-make-fulldeps/coverage-llvmir-base/filecheck.testprog.txt index bd2a2475d9e..a312ec48e84 100644 --- a/src/test/run-make-fulldeps/coverage-llvmir-base/filecheck.testprog.txt +++ b/src/test/run-make-fulldeps/coverage-llvmir-base/filecheck.testprog.txt @@ -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 diff --git a/src/test/run-make-fulldeps/coverage-reports-base/Makefile b/src/test/run-make-fulldeps/coverage-reports-base/Makefile index 1e2aa056e40..2dac8fc2225 100644 --- a/src/test/run-make-fulldeps/coverage-reports-base/Makefile +++ b/src/test/run-make-fulldeps/coverage-reports-base/Makefile @@ -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 diff --git a/src/test/run-make-fulldeps/coverage-spanview-base/Makefile b/src/test/run-make-fulldeps/coverage-spanview-base/Makefile index 03ef04776a0..9f9440340e0 100644 --- a/src/test/run-make-fulldeps/coverage-spanview-base/Makefile +++ b/src/test/run-make-fulldeps/coverage-spanview-base/Makefile @@ -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 diff --git a/src/test/run-make-fulldeps/coverage/coverage_tools.mk b/src/test/run-make-fulldeps/coverage/coverage_tools.mk index 17f7696a8cf..99a2e0ba952 100644 --- a/src/test/run-make-fulldeps/coverage/coverage_tools.mk +++ b/src/test/run-make-fulldeps/coverage/coverage_tools.mk @@ -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 diff --git a/src/test/rustdoc-js/doc-alias-filter-out.rs b/src/test/rustdoc-js/doc-alias-filter-out.rs index 815e8cedd16..3f0c094794e 100644 --- a/src/test/rustdoc-js/doc-alias-filter-out.rs +++ b/src/test/rustdoc-js/doc-alias-filter-out.rs @@ -1,4 +1,2 @@ -#![feature(doc_alias)] - #[doc(alias = "true")] pub struct Foo; diff --git a/src/test/rustdoc-js/doc-alias-filter.rs b/src/test/rustdoc-js/doc-alias-filter.rs index 8887f8c2b01..d5227814c06 100644 --- a/src/test/rustdoc-js/doc-alias-filter.rs +++ b/src/test/rustdoc-js/doc-alias-filter.rs @@ -1,5 +1,3 @@ -#![feature(doc_alias)] - #[doc(alias = "true")] pub struct Foo; diff --git a/src/test/rustdoc-js/doc-alias-whitespace.rs b/src/test/rustdoc-js/doc-alias-whitespace.rs index bea3e382ae4..16c022c7498 100644 --- a/src/test/rustdoc-js/doc-alias-whitespace.rs +++ b/src/test/rustdoc-js/doc-alias-whitespace.rs @@ -1,4 +1,2 @@ -#![feature(doc_alias)] - #[doc(alias = "Demon Lord")] pub struct Struct; diff --git a/src/test/rustdoc-js/doc-alias.rs b/src/test/rustdoc-js/doc-alias.rs index 41caa98643c..750b7b757bc 100644 --- a/src/test/rustdoc-js/doc-alias.rs +++ b/src/test/rustdoc-js/doc-alias.rs @@ -1,5 +1,3 @@ -#![feature(doc_alias)] - #[doc(alias = "StructItem")] pub struct Struct { #[doc(alias = "StructFieldItem")] diff --git a/src/test/rustdoc-ui/check-doc-alias-attr-location.rs b/src/test/rustdoc-ui/check-doc-alias-attr-location.rs index 545964c7bd6..7de2caa189d 100644 --- a/src/test/rustdoc-ui/check-doc-alias-attr-location.rs +++ b/src/test/rustdoc-ui/check-doc-alias-attr-location.rs @@ -1,5 +1,3 @@ -#![feature(doc_alias)] - pub struct Bar; pub trait Foo { type X; diff --git a/src/test/rustdoc-ui/check-doc-alias-attr-location.stderr b/src/test/rustdoc-ui/check-doc-alias-attr-location.stderr index a66e9939eaf..175626f49dc 100644 --- a/src/test/rustdoc-ui/check-doc-alias-attr-location.stderr +++ b/src/test/rustdoc-ui/check-doc-alias-attr-location.stderr @@ -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")] | ^^^^^^^^^^^^^^^ diff --git a/src/test/rustdoc-ui/check-doc-alias-attr.rs b/src/test/rustdoc-ui/check-doc-alias-attr.rs index 0ca2349a43b..912e35f9165 100644 --- a/src/test/rustdoc-ui/check-doc-alias-attr.rs +++ b/src/test/rustdoc-ui/check-doc-alias-attr.rs @@ -1,5 +1,4 @@ #![crate_type = "lib"] -#![feature(doc_alias)] #[doc(alias = "foo")] // ok! pub struct Bar; diff --git a/src/test/rustdoc-ui/check-doc-alias-attr.stderr b/src/test/rustdoc-ui/check-doc-alias-attr.stderr index 2c417a3bb65..8a729b02e72 100644 --- a/src/test/rustdoc-ui/check-doc-alias-attr.stderr +++ b/src/test/rustdoc-ui/check-doc-alias-attr.stderr @@ -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 ")] | ^^^^^^^^^^^^^^^^ diff --git a/src/test/rustdoc-ui/doc-alias-assoc-const.rs b/src/test/rustdoc-ui/doc-alias-assoc-const.rs index 73e23c152f2..d95324734be 100644 --- a/src/test/rustdoc-ui/doc-alias-assoc-const.rs +++ b/src/test/rustdoc-ui/doc-alias-assoc-const.rs @@ -1,4 +1,3 @@ -#![feature(doc_alias)] #![feature(trait_alias)] pub struct Foo; diff --git a/src/test/rustdoc-ui/doc-alias-assoc-const.stderr b/src/test/rustdoc-ui/doc-alias-assoc-const.stderr index 3c64548cc20..cbca40e1364 100644 --- a/src/test/rustdoc-ui/doc-alias-assoc-const.stderr +++ b/src/test/rustdoc-ui/doc-alias-assoc-const.stderr @@ -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")] | ^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/rustdoc-ui/doc-test-doctest-feature.rs b/src/test/rustdoc-ui/doc-test-doctest-feature.rs index 9a79fb88383..2798804880a 100644 --- a/src/test/rustdoc-ui/doc-test-doctest-feature.rs +++ b/src/test/rustdoc-ui/doc-test-doctest-feature.rs @@ -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)] diff --git a/src/test/rustdoc-ui/doc-test-doctest-feature.stdout b/src/test/rustdoc-ui/doc-test-doctest-feature.stdout index 75d29fab17d..b1cd74bf852 100644 --- a/src/test/rustdoc-ui/doc-test-doctest-feature.stdout +++ b/src/test/rustdoc-ui/doc-test-doctest-feature.stdout @@ -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 diff --git a/src/test/rustdoc/deprecated-future.rs b/src/test/rustdoc/deprecated-future.rs index c5248c52fb9..7db8cc60281 100644 --- a/src/test/rustdoc/deprecated-future.rs +++ b/src/test/rustdoc/deprecated-future.rs @@ -1,5 +1,3 @@ -#![feature(deprecated)] - // @has deprecated_future/index.html '//*[@class="stab deprecated"]' \ // 'Deprecated' // @has deprecated_future/struct.S.html '//*[@class="stab deprecated"]' \ diff --git a/src/test/rustdoc/deprecated.rs b/src/test/rustdoc/deprecated.rs index 18a33438a23..a286856b2c3 100644 --- a/src/test/rustdoc/deprecated.rs +++ b/src/test/rustdoc/deprecated.rs @@ -1,5 +1,3 @@ -#![feature(deprecated)] - // @has deprecated/index.html '//*[@class="docblock-short"]/span[@class="stab deprecated"]' \ // 'Deprecated' // @has - '//*[@class="docblock-short"]' 'Deprecated docs' diff --git a/src/test/rustdoc/issue-76501.rs b/src/test/rustdoc/issue-76501.rs index 605059fe0dd..d468f35e280 100644 --- a/src/test/rustdoc/issue-76501.rs +++ b/src/test/rustdoc/issue-76501.rs @@ -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 { diff --git a/src/test/ui/const-generics/infer/cannot-infer-const-args.full.stderr b/src/test/ui/const-generics/infer/cannot-infer-const-args.full.stderr index b438ed3ad65..05bf67a5ff7 100644 --- a/src/test/ui/const-generics/infer/cannot-infer-const-args.full.stderr +++ b/src/test/ui/const-generics/infer/cannot-infer-const-args.full.stderr @@ -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 diff --git a/src/test/ui/const-generics/infer/cannot-infer-const-args.min.stderr b/src/test/ui/const-generics/infer/cannot-infer-const-args.min.stderr index b438ed3ad65..05bf67a5ff7 100644 --- a/src/test/ui/const-generics/infer/cannot-infer-const-args.min.stderr +++ b/src/test/ui/const-generics/infer/cannot-infer-const-args.min.stderr @@ -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 diff --git a/src/test/ui/const-generics/infer/issue-77092.stderr b/src/test/ui/const-generics/infer/issue-77092.stderr index 63facbf3b8c..99894173bc8 100644 --- a/src/test/ui/const-generics/infer/issue-77092.stderr +++ b/src/test/ui/const-generics/infer/issue-77092.stderr @@ -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 diff --git a/src/test/ui/const-generics/infer/method-chain.full.stderr b/src/test/ui/const-generics/infer/method-chain.full.stderr index 1fb0b23cf11..7aa3bd44df8 100644 --- a/src/test/ui/const-generics/infer/method-chain.full.stderr +++ b/src/test/ui/const-generics/infer/method-chain.full.stderr @@ -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 diff --git a/src/test/ui/const-generics/infer/method-chain.min.stderr b/src/test/ui/const-generics/infer/method-chain.min.stderr index 1fb0b23cf11..7aa3bd44df8 100644 --- a/src/test/ui/const-generics/infer/method-chain.min.stderr +++ b/src/test/ui/const-generics/infer/method-chain.min.stderr @@ -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 diff --git a/src/test/ui/const-generics/infer/one-param-uninferred.full.stderr b/src/test/ui/const-generics/infer/one-param-uninferred.full.stderr new file mode 100644 index 00000000000..cc6c9a47510 --- /dev/null +++ b/src/test/ui/const-generics/infer/one-param-uninferred.full.stderr @@ -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`. diff --git a/src/test/ui/const-generics/infer/one-param-uninferred.min.stderr b/src/test/ui/const-generics/infer/one-param-uninferred.min.stderr new file mode 100644 index 00000000000..cc6c9a47510 --- /dev/null +++ b/src/test/ui/const-generics/infer/one-param-uninferred.min.stderr @@ -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`. diff --git a/src/test/ui/const-generics/infer/one-param-uninferred.rs b/src/test/ui/const-generics/infer/one-param-uninferred.rs new file mode 100644 index 00000000000..0e947131f4c --- /dev/null +++ b/src/test/ui/const-generics/infer/one-param-uninferred.rs @@ -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 +} diff --git a/src/test/ui/const-generics/infer/uninferred-consts.full.stderr b/src/test/ui/const-generics/infer/uninferred-consts.full.stderr index 7a451903e96..4be625ba909 100644 --- a/src/test/ui/const-generics/infer/uninferred-consts.full.stderr +++ b/src/test/ui/const-generics/infer/uninferred-consts.full.stderr @@ -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 diff --git a/src/test/ui/const-generics/infer/uninferred-consts.min.stderr b/src/test/ui/const-generics/infer/uninferred-consts.min.stderr index 7a451903e96..4be625ba909 100644 --- a/src/test/ui/const-generics/infer/uninferred-consts.min.stderr +++ b/src/test/ui/const-generics/infer/uninferred-consts.min.stderr @@ -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 diff --git a/src/test/ui/const-generics/infer/uninferred-consts.rs b/src/test/ui/const-generics/infer/uninferred-consts.rs index ec5b3ffe544..00fb6eac992 100644 --- a/src/test/ui/const-generics/infer/uninferred-consts.rs +++ b/src/test/ui/const-generics/infer/uninferred-consts.rs @@ -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(); |
