diff options
Diffstat (limited to 'src/test')
287 files changed, 3588 insertions, 1543 deletions
diff --git a/src/test/assembly/asm/aarch64-types.rs b/src/test/assembly/asm/aarch64-types.rs index 04b5f4aed9b..66c39a48c6e 100644 --- a/src/test/assembly/asm/aarch64-types.rs +++ b/src/test/assembly/asm/aarch64-types.rs @@ -2,7 +2,7 @@ // compile-flags: --target aarch64-unknown-linux-gnu // needs-llvm-components: aarch64 -#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym)] +#![feature(no_core, lang_items, rustc_attrs, repr_simd)] #![crate_type = "rlib"] #![no_core] #![allow(asm_sub_register, non_camel_case_types)] diff --git a/src/test/assembly/asm/arm-types.rs b/src/test/assembly/asm/arm-types.rs index 5ac1af6afd6..b22a26ce36f 100644 --- a/src/test/assembly/asm/arm-types.rs +++ b/src/test/assembly/asm/arm-types.rs @@ -3,7 +3,7 @@ // compile-flags: -C target-feature=+neon // needs-llvm-components: arm -#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym)] +#![feature(no_core, lang_items, rustc_attrs, repr_simd)] #![crate_type = "rlib"] #![no_core] #![allow(asm_sub_register, non_camel_case_types)] diff --git a/src/test/assembly/asm/avr-types.rs b/src/test/assembly/asm/avr-types.rs index 58bf1ad9e35..b2d11a8826f 100644 --- a/src/test/assembly/asm/avr-types.rs +++ b/src/test/assembly/asm/avr-types.rs @@ -2,7 +2,7 @@ // compile-flags: --target avr-unknown-gnu-atmega328 // needs-llvm-components: avr -#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch)] +#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)] #![crate_type = "rlib"] #![no_core] #![allow(non_camel_case_types)] diff --git a/src/test/assembly/asm/bpf-types.rs b/src/test/assembly/asm/bpf-types.rs index f894644cc20..e177b8d0dbe 100644 --- a/src/test/assembly/asm/bpf-types.rs +++ b/src/test/assembly/asm/bpf-types.rs @@ -2,7 +2,7 @@ // compile-flags: --target bpfel-unknown-none -C target_feature=+alu32 // needs-llvm-components: bpf -#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)] +#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)] #![crate_type = "rlib"] #![no_core] #![allow(asm_sub_register, non_camel_case_types)] diff --git a/src/test/assembly/asm/global_asm.rs b/src/test/assembly/asm/global_asm.rs index 4cf73b40faf..0b361a7ed96 100644 --- a/src/test/assembly/asm/global_asm.rs +++ b/src/test/assembly/asm/global_asm.rs @@ -4,7 +4,7 @@ // compile-flags: -C llvm-args=--x86-asm-syntax=intel // compile-flags: -C symbol-mangling-version=v0 -#![feature(asm_const, asm_sym)] +#![feature(asm_const)] #![crate_type = "rlib"] use std::arch::global_asm; @@ -28,4 +28,6 @@ global_asm!("lea rax, [rip + {}]", sym MY_STATIC); // CHECK: call _RNvCsiubXh4Yz005_10global_asm6foobar global_asm!("call {}", sym foobar); // CHECK: _RNvCsiubXh4Yz005_10global_asm6foobar: -fn foobar() { loop {} } +fn foobar() { + loop {} +} diff --git a/src/test/assembly/asm/hexagon-types.rs b/src/test/assembly/asm/hexagon-types.rs index eff9a0bb431..af16faedbc4 100644 --- a/src/test/assembly/asm/hexagon-types.rs +++ b/src/test/assembly/asm/hexagon-types.rs @@ -2,7 +2,7 @@ // compile-flags: --target hexagon-unknown-linux-musl // needs-llvm-components: hexagon -#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)] +#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)] #![crate_type = "rlib"] #![no_core] #![allow(asm_sub_register, non_camel_case_types)] diff --git a/src/test/assembly/asm/mips-types.rs b/src/test/assembly/asm/mips-types.rs index 04bf49a40ef..6aa28b062db 100644 --- a/src/test/assembly/asm/mips-types.rs +++ b/src/test/assembly/asm/mips-types.rs @@ -5,7 +5,7 @@ //[mips64] compile-flags: --target mips64-unknown-linux-gnuabi64 //[mips64] needs-llvm-components: mips -#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)] +#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)] #![crate_type = "rlib"] #![no_core] #![allow(asm_sub_register, non_camel_case_types)] diff --git a/src/test/assembly/asm/msp430-types.rs b/src/test/assembly/asm/msp430-types.rs index 4fa2e8081f8..2c73b3b098d 100644 --- a/src/test/assembly/asm/msp430-types.rs +++ b/src/test/assembly/asm/msp430-types.rs @@ -2,7 +2,7 @@ // compile-flags: --target msp430-none-elf // needs-llvm-components: msp430 -#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch, asm_const)] +#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch, asm_const)] #![crate_type = "rlib"] #![no_core] #![allow(non_camel_case_types)] diff --git a/src/test/assembly/asm/nvptx-types.rs b/src/test/assembly/asm/nvptx-types.rs index 3ebd5b4b896..c319946b5f5 100644 --- a/src/test/assembly/asm/nvptx-types.rs +++ b/src/test/assembly/asm/nvptx-types.rs @@ -3,7 +3,7 @@ // compile-flags: --crate-type cdylib // needs-llvm-components: nvptx -#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch)] +#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)] #![no_core] #[rustc_builtin_macro] diff --git a/src/test/assembly/asm/powerpc-types.rs b/src/test/assembly/asm/powerpc-types.rs index 0ca8908497a..e27b0052068 100644 --- a/src/test/assembly/asm/powerpc-types.rs +++ b/src/test/assembly/asm/powerpc-types.rs @@ -5,7 +5,7 @@ //[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu //[powerpc64] needs-llvm-components: powerpc -#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)] +#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)] #![crate_type = "rlib"] #![no_core] #![allow(asm_sub_register, non_camel_case_types)] diff --git a/src/test/assembly/asm/riscv-types.rs b/src/test/assembly/asm/riscv-types.rs index 68dc186ea0c..f18ba294d0c 100644 --- a/src/test/assembly/asm/riscv-types.rs +++ b/src/test/assembly/asm/riscv-types.rs @@ -6,7 +6,7 @@ //[riscv32] needs-llvm-components: riscv // compile-flags: -C target-feature=+d -#![feature(no_core, lang_items, rustc_attrs, asm_sym)] +#![feature(no_core, lang_items, rustc_attrs)] #![crate_type = "rlib"] #![no_core] #![allow(asm_sub_register)] diff --git a/src/test/assembly/asm/s390x-types.rs b/src/test/assembly/asm/s390x-types.rs index 6a12902a046..2fb404dd9b2 100644 --- a/src/test/assembly/asm/s390x-types.rs +++ b/src/test/assembly/asm/s390x-types.rs @@ -3,7 +3,7 @@ //[s390x] compile-flags: --target s390x-unknown-linux-gnu //[s390x] needs-llvm-components: systemz -#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)] +#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)] #![crate_type = "rlib"] #![no_core] #![allow(asm_sub_register, non_camel_case_types)] diff --git a/src/test/assembly/asm/wasm-types.rs b/src/test/assembly/asm/wasm-types.rs index 3aa128c46ac..3b1ac1b455a 100644 --- a/src/test/assembly/asm/wasm-types.rs +++ b/src/test/assembly/asm/wasm-types.rs @@ -3,7 +3,7 @@ // compile-flags: --crate-type cdylib // needs-llvm-components: webassembly -#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch)] +#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)] #![no_core] #[rustc_builtin_macro] diff --git a/src/test/assembly/asm/x86-types.rs b/src/test/assembly/asm/x86-types.rs index e871535cfde..81be79cbaac 100644 --- a/src/test/assembly/asm/x86-types.rs +++ b/src/test/assembly/asm/x86-types.rs @@ -7,7 +7,7 @@ // compile-flags: -C llvm-args=--x86-asm-syntax=intel // compile-flags: -C target-feature=+avx512bw -#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym)] +#![feature(no_core, lang_items, rustc_attrs, repr_simd)] #![crate_type = "rlib"] #![no_core] #![allow(asm_sub_register, non_camel_case_types)] diff --git a/src/test/codegen/deduced-param-attrs.rs b/src/test/codegen/deduced-param-attrs.rs new file mode 100644 index 00000000000..153046eef3c --- /dev/null +++ b/src/test/codegen/deduced-param-attrs.rs @@ -0,0 +1,60 @@ +// compile-flags: -O + +#![crate_type = "lib"] +#![allow(incomplete_features)] +#![feature(unsized_locals, unsized_fn_params)] + +use std::cell::Cell; +use std::hint; + +// Check to make sure that we can deduce the `readonly` attribute from function bodies for +// parameters passed indirectly. + +pub struct BigStruct { + blah: [i32; 1024], +} + +pub struct BigCellContainer { + blah: [Cell<i32>; 1024], +} + +// The by-value parameter for this big struct can be marked readonly. +// +// CHECK: @use_big_struct_immutably({{.*}} readonly {{.*}} %big_struct) +#[no_mangle] +pub fn use_big_struct_immutably(big_struct: BigStruct) { + hint::black_box(&big_struct); +} + +// The by-value parameter for this big struct can't be marked readonly, because we mutate it. +// +// CHECK-NOT: @use_big_struct_mutably({{.*}} readonly {{.*}} %big_struct) +#[no_mangle] +pub fn use_big_struct_mutably(mut big_struct: BigStruct) { + big_struct.blah[987] = 654; + hint::black_box(&big_struct); +} + +// The by-value parameter for this big struct can't be marked readonly, because it contains +// UnsafeCell. +// +// CHECK-NOT: @use_big_cell_container({{.*}} readonly {{.*}} %big_cell_container) +#[no_mangle] +pub fn use_big_cell_container(big_cell_container: BigCellContainer) { + hint::black_box(&big_cell_container); +} + +// Make sure that we don't mistakenly mark a big struct as `readonly` when passed through a generic +// type parameter if it contains UnsafeCell. +// +// CHECK-NOT: @use_something({{.*}} readonly {{.*}} %something) +#[no_mangle] +#[inline(never)] +pub fn use_something<T>(something: T) { + hint::black_box(&something); +} + +#[no_mangle] +pub fn forward_big_cell_container(big_cell_container: BigCellContainer) { + use_something(big_cell_container) +} diff --git a/src/test/codegen/function-arguments.rs b/src/test/codegen/function-arguments.rs index bc650ebf5ee..44fee952307 100644 --- a/src/test/codegen/function-arguments.rs +++ b/src/test/codegen/function-arguments.rs @@ -127,7 +127,7 @@ pub fn mutable_notunpin_borrow(_: &mut NotUnpin) { pub fn notunpin_borrow(_: &NotUnpin) { } -// CHECK: @indirect_struct({{%S\*|ptr}} noalias nocapture noundef dereferenceable(32) %_1) +// CHECK: @indirect_struct({{%S\*|ptr}} noalias nocapture noundef readonly dereferenceable(32) %_1) #[no_mangle] pub fn indirect_struct(_: S) { } diff --git a/src/test/pretty/issue-85089.pp b/src/test/pretty/issue-85089.pp new file mode 100644 index 00000000000..f84e9df04a2 --- /dev/null +++ b/src/test/pretty/issue-85089.pp @@ -0,0 +1,20 @@ +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; +// Test to print lifetimes on HIR pretty-printing. + +// pretty-compare-only +// pretty-mode:hir +// pp-exact:issue-85089.pp + +trait A<'x> { } +trait B<'x> { } + +struct Foo<'b> { + bar: &'b dyn for<'a> A<'a>, +} + +impl <'a> B<'a> for dyn for<'b> A<'b> { } + +impl <'a> A<'a> for Foo<'a> { } diff --git a/src/test/pretty/issue-85089.rs b/src/test/pretty/issue-85089.rs new file mode 100644 index 00000000000..eb45d473119 --- /dev/null +++ b/src/test/pretty/issue-85089.rs @@ -0,0 +1,16 @@ +// Test to print lifetimes on HIR pretty-printing. + +// pretty-compare-only +// pretty-mode:hir +// pp-exact:issue-85089.pp + +trait A<'x> {} +trait B<'x> {} + +struct Foo<'b> { + pub bar: &'b dyn for<'a> A<'a>, +} + +impl<'a> B<'a> for dyn for<'b> A<'b> {} + +impl<'a> A<'a> for Foo<'a> {} diff --git a/src/test/pretty/raw-str-nonexpr.rs b/src/test/pretty/raw-str-nonexpr.rs index 7af80979b43..12440b5ae6e 100644 --- a/src/test/pretty/raw-str-nonexpr.rs +++ b/src/test/pretty/raw-str-nonexpr.rs @@ -1,3 +1,4 @@ +// needs-asm-support // pp-exact #[cfg(foo = r#"just parse this"#)] diff --git a/src/test/pretty/tests-are-sorted.pp b/src/test/pretty/tests-are-sorted.pp new file mode 100644 index 00000000000..15dcd4ed97d --- /dev/null +++ b/src/test/pretty/tests-are-sorted.pp @@ -0,0 +1,69 @@ +#![feature(prelude_import)] +#![no_std] +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; +// compile-flags: --crate-type=lib --test +// pretty-compare-only +// pretty-mode:expanded +// pp-exact:tests-are-sorted.pp + +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "m_test"] +pub const m_test: test::TestDescAndFn = + test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("m_test"), + ignore: false, + ignore_message: ::core::option::Option::None, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::Unknown, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(m_test())), + }; +fn m_test() {} + +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "z_test"] +pub const z_test: test::TestDescAndFn = + test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("z_test"), + ignore: false, + ignore_message: ::core::option::Option::None, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::Unknown, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(z_test())), + }; +fn z_test() {} + +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "a_test"] +pub const a_test: test::TestDescAndFn = + test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("a_test"), + ignore: false, + ignore_message: ::core::option::Option::None, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::Unknown, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(a_test())), + }; +fn a_test() {} +#[rustc_main] +pub fn main() -> () { + extern crate test; + test::test_main_static(&[&a_test, &m_test, &z_test]) +} diff --git a/src/test/pretty/tests-are-sorted.rs b/src/test/pretty/tests-are-sorted.rs new file mode 100644 index 00000000000..1f737d54719 --- /dev/null +++ b/src/test/pretty/tests-are-sorted.rs @@ -0,0 +1,13 @@ +// compile-flags: --crate-type=lib --test +// pretty-compare-only +// pretty-mode:expanded +// pp-exact:tests-are-sorted.pp + +#[test] +fn m_test() {} + +#[test] +fn z_test() {} + +#[test] +fn a_test() {} diff --git a/src/test/run-make-fulldeps/intrinsic-unreachable/Makefile b/src/test/run-make-fulldeps/intrinsic-unreachable/Makefile index 3c4dade0f52..ff9cc57098c 100644 --- a/src/test/run-make-fulldeps/intrinsic-unreachable/Makefile +++ b/src/test/run-make-fulldeps/intrinsic-unreachable/Makefile @@ -1,5 +1,6 @@ include ../tools.mk +# needs-asm-support # ignore-windows-msvc # # Because of Windows exception handling, the code is not necessarily any shorter. diff --git a/src/test/run-make-fulldeps/issue-19371/foo.rs b/src/test/run-make-fulldeps/issue-19371/foo.rs index fd294b018af..7e1b6aeb315 100644 --- a/src/test/run-make-fulldeps/issue-19371/foo.rs +++ b/src/test/run-make-fulldeps/issue-19371/foo.rs @@ -5,7 +5,6 @@ extern crate rustc_driver; extern crate rustc_session; extern crate rustc_span; -use rustc_session::DiagnosticOutput; use rustc_session::config::{Input, Options, OutputType, OutputTypes}; use rustc_interface::interface; use rustc_span::source_map::FileName; @@ -55,7 +54,6 @@ fn compile(code: String, output: PathBuf, sysroot: PathBuf) { output_file: Some(output), output_dir: None, file_loader: None, - diagnostic_output: DiagnosticOutput::Default, lint_caps: Default::default(), parse_sess_created: None, register_lints: None, diff --git a/src/test/run-make/coverage-reports/Makefile b/src/test/run-make/coverage-reports/Makefile index 6fc2a6bada9..407992c9f43 100644 --- a/src/test/run-make/coverage-reports/Makefile +++ b/src/test/run-make/coverage-reports/Makefile @@ -1,6 +1,11 @@ # needs-profiler-support # ignore-windows-gnu +# FIXME(pietroalbini): this test currently does not work on cross-compiled +# targets because remote-test is not capable of sending back the *.profraw +# files generated by the LLVM instrumentation. +# ignore-cross-compile + # Rust coverage maps support LLVM Coverage Mapping Format versions 5 and 6, # corresponding with LLVM versions 12 and 13, respectively. # When upgrading LLVM versions, consider whether to enforce a minimum LLVM @@ -81,13 +86,13 @@ include clear_expected_if_blessed # Compile the test library with coverage instrumentation $(RUSTC) $(SOURCEDIR)/lib/$@.rs \ $$( sed -n 's/^\/\/ compile-flags: \([^#]*\).*/\1/p' $(SOURCEDIR)/lib/$@.rs ) \ - --crate-type rlib -Cinstrument-coverage + --crate-type rlib -Cinstrument-coverage --target $(TARGET) %: $(SOURCEDIR)/%.rs # Compile the test program with coverage instrumentation $(RUSTC) $(SOURCEDIR)/$@.rs \ $$( sed -n 's/^\/\/ compile-flags: \([^#]*\).*/\1/p' $(SOURCEDIR)/$@.rs ) \ - -L "$(TMPDIR)" -Cinstrument-coverage + -L "$(TMPDIR)" -Cinstrument-coverage --target $(TARGET) # Run it in order to generate some profiling data, # with `LLVM_PROFILE_FILE=<profdata_file>` environment variable set to diff --git a/src/test/rustdoc-gui/anchors.goml b/src/test/rustdoc-gui/anchors.goml index 6673e9c20fe..fb8e288fae8 100644 --- a/src/test/rustdoc-gui/anchors.goml +++ b/src/test/rustdoc-gui/anchors.goml @@ -1,154 +1,107 @@ // This test is to ensure that the anchors (`§`) have the expected color and position. -goto: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html" -// This is needed to ensure that the text color is computed. -show-text: true - -// Set the theme to light. -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} -// We reload the page so the local storage settings are being used. -reload: - -assert-css: ("#toggle-all-docs", {"color": "rgb(0, 0, 0)"}) -assert-css: (".fqn a:nth-of-type(1)", {"color": "rgb(0, 0, 0)"}) -assert-css: (".fqn a:nth-of-type(2)", {"color": "rgb(173, 55, 138)"}) -assert-css: ( - ".rightside .srclink", - {"color": "rgb(56, 115, 173)", "text-decoration": "none solid rgb(56, 115, 173)"}, - ALL, -) -compare-elements-css: (".rightside .srclink", ".rightside.srclink", ["color", "text-decoration"]) -compare-elements-css: (".main-heading .srclink", ".rightside.srclink", ["color", "text-decoration"]) - -move-cursor-to: ".main-heading .srclink" -assert-css: ( - ".main-heading .srclink", - {"color": "rgb(56, 115, 173)", "text-decoration": "underline solid rgb(56, 115, 173)"}, -) -move-cursor-to: ".impl-items .rightside .srclink" -assert-css: ( - ".impl-items .rightside .srclink", - {"color": "rgb(56, 115, 173)", "text-decoration": "none solid rgb(56, 115, 173)"}, -) -move-cursor-to: ".impl-items .rightside.srclink" -assert-css: ( - ".impl-items .rightside.srclink", - {"color": "rgb(56, 115, 173)", "text-decoration": "none solid rgb(56, 115, 173)"}, -) - -goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" - -assert-css: ("#top-doc-prose-title", {"color": "rgb(0, 0, 0)"}) - -assert-css: (".sidebar a", {"color": "rgb(53, 109, 164)"}) -assert-css: ("h1.fqn a", {"color": "rgb(0, 0, 0)"}) - -// We move the cursor over the "Implementations" title so the anchor is displayed. -move-cursor-to: "h2#implementations" -assert-css: ("h2#implementations a.anchor", {"color": "rgb(0, 0, 0)"}) - -// Same thing with the impl block title. -move-cursor-to: "#impl-HeavilyDocumentedStruct" -assert-css: ("#impl-HeavilyDocumentedStruct a.anchor", {"color": "rgb(0, 0, 0)"}) - -assert-css: ("#title-for-struct-impl-item-doc", {"margin-left": "0px"}) - -// -// We do the same checks with the dark theme now. -// -local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"} -goto: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html" - -assert-css: ("#toggle-all-docs", {"color": "rgb(221, 221, 221)"}) -assert-css: (".fqn a:nth-of-type(1)", {"color": "rgb(221, 221, 221)"}) -assert-css: (".fqn a:nth-of-type(2)", {"color": "rgb(45, 191, 184)"}) -assert-css: ( - ".rightside .srclink", - {"color": "rgb(210, 153, 29)", "text-decoration": "none solid rgb(210, 153, 29)"}, - ALL, -) -compare-elements-css: (".rightside .srclink", ".rightside.srclink", ["color", "text-decoration"]) -compare-elements-css: (".main-heading .srclink", ".rightside.srclink", ["color", "text-decoration"]) - -move-cursor-to: ".main-heading .srclink" -assert-css: ( - ".main-heading .srclink", - {"color": "rgb(210, 153, 29)", "text-decoration": "underline solid rgb(210, 153, 29)"}, +define-function: ( + "check-colors", + (theme, main_color, title_color, fqn_color, fqn_type_color, src_link_color, sidebar_link_color), + [ + ("goto", "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html"), + // This is needed to ensure that the text color is computed. + ("show-text", true), + + // Setting the theme. + ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + // We reload the page so the local storage settings are being used. + ("reload"), + + ("assert-css", ("#toggle-all-docs", {"color": |main_color|})), + ("assert-css", (".fqn a:nth-of-type(1)", {"color": |fqn_color|})), + ("assert-css", (".fqn a:nth-of-type(2)", {"color": |fqn_type_color|})), + ("assert-css", ( + ".rightside .srclink", + {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, + ALL, + )), + ( + "compare-elements-css", + (".rightside .srclink", ".rightside.srclink", ["color", "text-decoration"]), + ), + ( + "compare-elements-css", + (".main-heading .srclink", ".rightside.srclink", ["color", "text-decoration"]), + ), + + ("move-cursor-to", ".main-heading .srclink"), + ("assert-css", ( + ".main-heading .srclink", + {"color": |src_link_color|, "text-decoration": "underline solid " + |src_link_color|}, + )), + ("move-cursor-to", ".impl-items .rightside .srclink"), + ("assert-css", ( + ".impl-items .rightside .srclink", + {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, + )), + ("move-cursor-to", ".impl-items .rightside.srclink"), + ("assert-css", ( + ".impl-items .rightside.srclink", + {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, + )), + + ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"), + // Since we changed page, we need to set the theme again. + ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + // We reload the page so the local storage settings are being used. + ("reload"), + + ("assert-css", ("#top-doc-prose-title", {"color": |title_color|})), + + ("assert-css", (".sidebar a", {"color": |sidebar_link_color|})), + ("assert-css", ("h1.fqn a", {"color": |title_color|})), + + // We move the cursor over the "Implementations" title so the anchor is displayed. + ("move-cursor-to", "h2#implementations"), + ("assert-css", ("h2#implementations a.anchor", {"color": |main_color|})), + + // Same thing with the impl block title. + ("move-cursor-to", "#impl-HeavilyDocumentedStruct"), + ("assert-css", ("#impl-HeavilyDocumentedStruct a.anchor", {"color": |main_color|})), + + ("assert-css", ("#title-for-struct-impl-item-doc", {"margin-left": "0px"})), + ], ) -move-cursor-to: ".impl-items .rightside .srclink" -assert-css: ( - ".impl-items .rightside .srclink", - {"color": "rgb(210, 153, 29)", "text-decoration": "none solid rgb(210, 153, 29)"}, -) -move-cursor-to: ".impl-items .rightside.srclink" -assert-css: ( - ".impl-items .rightside.srclink", - {"color": "rgb(210, 153, 29)", "text-decoration": "none solid rgb(210, 153, 29)"}, -) - -goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" - -assert-css: ("#top-doc-prose-title", {"color": "rgb(221, 221, 221)"}) - -assert-css: (".sidebar a", {"color": "rgb(253, 191, 53)"}) -assert-css: ("h1.fqn a", {"color": "rgb(221, 221, 221)"}) - -// We move the cursor over the "Implementations" title so the anchor is displayed. -move-cursor-to: "h2#implementations" -assert-css: ("h2#implementations a.anchor", {"color": "rgb(221, 221, 221)"}) - -// Same thing with the impl block title. -move-cursor-to: "#impl-HeavilyDocumentedStruct" -assert-css: ("#impl-HeavilyDocumentedStruct a.anchor", {"color": "rgb(221, 221, 221)"}) - -assert-css: ("#title-for-struct-impl-item-doc", {"margin-left": "0px"}) - -// -// We do the same checks with the ayu theme now. -// -local-storage: {"rustdoc-theme": "ayu", "rustdoc-use-system-theme": "false"} -goto: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html" -assert-css: ("#toggle-all-docs", {"color": "rgb(197, 197, 197)"}) -assert-css: (".fqn a:nth-of-type(1)", {"color": "rgb(255, 255, 255)"}) -assert-css: (".fqn a:nth-of-type(2)", {"color": "rgb(255, 160, 165)"}) -assert-css: ( - ".rightside .srclink", - {"color": "rgb(57, 175, 215)", "text-decoration": "none solid rgb(57, 175, 215)"}, - ALL, +call-function: ( + "check-colors", + { + "theme": "ayu", + "main_color": "rgb(197, 197, 197)", + "title_color": "rgb(255, 255, 255)", + "fqn_color": "rgb(255, 255, 255)", + "fqn_type_color": "rgb(255, 160, 165)", + "src_link_color": "rgb(57, 175, 215)", + "sidebar_link_color": "rgb(83, 177, 219)", + }, ) -compare-elements-css: (".rightside .srclink", ".rightside.srclink", ["color", "text-decoration"]) -compare-elements-css: (".main-heading .srclink", ".rightside.srclink", ["color", "text-decoration"]) - -move-cursor-to: ".main-heading .srclink" -assert-css: ( - ".main-heading .srclink", - {"color": "rgb(57, 175, 215)", "text-decoration": "underline solid rgb(57, 175, 215)"}, -) -move-cursor-to: ".impl-items .rightside .srclink" -assert-css: ( - ".impl-items .rightside .srclink", - {"color": "rgb(57, 175, 215)", "text-decoration": "none solid rgb(57, 175, 215)"}, +call-function: ( + "check-colors", + { + "theme": "dark", + "main_color": "rgb(221, 221, 221)", + "title_color": "rgb(221, 221, 221)", + "fqn_color": "rgb(221, 221, 221)", + "fqn_type_color": "rgb(45, 191, 184)", + "src_link_color": "rgb(210, 153, 29)", + "sidebar_link_color": "rgb(253, 191, 53)", + }, ) -move-cursor-to: ".impl-items .rightside.srclink" -assert-css: ( - ".impl-items .rightside.srclink", - {"color": "rgb(57, 175, 215)", "text-decoration": "none solid rgb(57, 175, 215)"}, +call-function: ( + "check-colors", + { + "theme": "light", + "main_color": "rgb(0, 0, 0)", + "title_color": "rgb(0, 0, 0)", + "fqn_color": "rgb(0, 0, 0)", + "fqn_type_color": "rgb(173, 55, 138)", + "src_link_color": "rgb(56, 115, 173)", + "sidebar_link_color": "rgb(53, 109, 164)", + }, ) - -goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" - -assert-css: ("#top-doc-prose-title", {"color": "rgb(255, 255, 255)"}) - -assert-css: (".sidebar a", {"color": "rgb(83, 177, 219)"}) -assert-css: ("h1.fqn a", {"color": "rgb(255, 255, 255)"}) - -// We move the cursor over the "Implementations" title so the anchor is displayed. -move-cursor-to: "h2#implementations" -assert-css: ("h2#implementations a.anchor", {"color": "rgb(197, 197, 197)"}) - -// Same thing with the impl block title. -move-cursor-to: "#impl-HeavilyDocumentedStruct" -assert-css: ("#impl-HeavilyDocumentedStruct a.anchor", {"color": "rgb(197, 197, 197)"}) - -assert-css: ("#title-for-struct-impl-item-doc", {"margin-left": "0px"}) diff --git a/src/test/rustdoc-gui/code-color.goml b/src/test/rustdoc-gui/code-color.goml index 4136677cdd5..118f04ad6dc 100644 --- a/src/test/rustdoc-gui/code-color.goml +++ b/src/test/rustdoc-gui/code-color.goml @@ -5,26 +5,20 @@ goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" // If the text isn't displayed, the browser doesn't compute color style correctly... show-text: true -// Set the theme to dark. -local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"} -// We reload the page so the local storage settings are being used. -reload: -assert-css: (".docblock pre > code", {"color": "rgb(221, 221, 221)"}, ALL) -assert-css: (".docblock > p > code", {"color": "rgb(221, 221, 221)"}, ALL) +define-function: ( + "check-colors", + (theme, doc_code_color, doc_inline_code_color), + [ + // Set the theme. + ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + // We reload the page so the local storage settings are being used. + ("reload"), + ("assert-css", (".docblock pre > code", {"color": |doc_code_color|}, ALL)), + ("assert-css", (".docblock > p > code", {"color": |doc_inline_code_color|}, ALL)), + ], +) -// Set the theme to ayu. -local-storage: {"rustdoc-theme": "ayu", "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false"} -// We reload the page so the local storage settings are being used. -reload: - -assert-css: (".docblock pre > code", {"color": "rgb(230, 225, 207)"}, ALL) -assert-css: (".docblock > p > code", {"color": "rgb(255, 180, 84)"}, ALL) - -// Set the theme to light. -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} -// We reload the page so the local storage settings are being used. -reload: - -assert-css: (".docblock pre > code", {"color": "rgb(0, 0, 0)"}, ALL) -assert-css: (".docblock > p > code", {"color": "rgb(0, 0, 0)"}, ALL) +call-function: ("check-colors", ("ayu", "rgb(230, 225, 207)", "rgb(255, 180, 84)")) +call-function: ("check-colors", ("dark", "rgb(221, 221, 221)", "rgb(221, 221, 221)")) +call-function: ("check-colors", ("light", "rgb(0, 0, 0)", "rgb(0, 0, 0)")) diff --git a/src/test/rustdoc-gui/codeblock-tooltip.goml b/src/test/rustdoc-gui/codeblock-tooltip.goml index f01e0c3c6cc..8e681a2a0c3 100644 --- a/src/test/rustdoc-gui/codeblock-tooltip.goml +++ b/src/test/rustdoc-gui/codeblock-tooltip.goml @@ -2,95 +2,79 @@ goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" show-text: true -// Dark theme. -local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"} -reload: - -// compile_fail block -assert-css: (".docblock .example-wrap.compile_fail .tooltip", {"color": "rgba(255, 0, 0, 0.5)"}) -assert-css: (".docblock .example-wrap.compile_fail", {"border-left": "2px solid rgba(255, 0, 0, 0.5)"}) - -move-cursor-to: ".docblock .example-wrap.compile_fail" - -assert-css: (".docblock .example-wrap.compile_fail .tooltip", {"color": "rgb(255, 0, 0)"}) -assert-css: (".docblock .example-wrap.compile_fail", {"border-left": "2px solid rgb(255, 0, 0)"}) - -// should_panic block -assert-css: (".docblock .example-wrap.should_panic .tooltip", {"color": "rgba(255, 0, 0, 0.5)"}) -assert-css: (".docblock .example-wrap.should_panic", {"border-left": "2px solid rgba(255, 0, 0, 0.5)"}) - -move-cursor-to: ".docblock .example-wrap.should_panic" - -assert-css: (".docblock .example-wrap.should_panic .tooltip", {"color": "rgb(255, 0, 0)"}) -assert-css: (".docblock .example-wrap.should_panic", {"border-left": "2px solid rgb(255, 0, 0)"}) - -// ignore block -assert-css: (".docblock .example-wrap.ignore .tooltip", {"color": "rgba(255, 142, 0, 0.6)"}) -assert-css: (".docblock .example-wrap.ignore", {"border-left": "2px solid rgba(255, 142, 0, 0.6)"}) - -move-cursor-to: ".docblock .example-wrap.ignore" - -assert-css: (".docblock .example-wrap.ignore .tooltip", {"color": "rgb(255, 142, 0)"}) -assert-css: (".docblock .example-wrap.ignore", {"border-left": "2px solid rgb(255, 142, 0)"}) - - -// Light theme. -local-storage: {"rustdoc-theme": "light"} -reload: - -assert-css: (".docblock .example-wrap.compile_fail .tooltip", {"color": "rgba(255, 0, 0, 0.5)"}) -assert-css: (".docblock .example-wrap.compile_fail", {"border-left": "2px solid rgba(255, 0, 0, 0.5)"}) - -move-cursor-to: ".docblock .example-wrap.compile_fail" - -assert-css: (".docblock .example-wrap.compile_fail .tooltip", {"color": "rgb(255, 0, 0)"}) -assert-css: (".docblock .example-wrap.compile_fail", {"border-left": "2px solid rgb(255, 0, 0)"}) - -// should_panic block -assert-css: (".docblock .example-wrap.should_panic .tooltip", {"color": "rgba(255, 0, 0, 0.5)"}) -assert-css: (".docblock .example-wrap.should_panic", {"border-left": "2px solid rgba(255, 0, 0, 0.5)"}) - -move-cursor-to: ".docblock .example-wrap.should_panic" - -assert-css: (".docblock .example-wrap.should_panic .tooltip", {"color": "rgb(255, 0, 0)"}) -assert-css: (".docblock .example-wrap.should_panic", {"border-left": "2px solid rgb(255, 0, 0)"}) - -// ignore block -assert-css: (".docblock .example-wrap.ignore .tooltip", {"color": "rgba(255, 142, 0, 0.6)"}) -assert-css: (".docblock .example-wrap.ignore", {"border-left": "2px solid rgba(255, 142, 0, 0.6)"}) - -move-cursor-to: ".docblock .example-wrap.ignore" - -assert-css: (".docblock .example-wrap.ignore .tooltip", {"color": "rgb(255, 142, 0)"}) -assert-css: (".docblock .example-wrap.ignore", {"border-left": "2px solid rgb(255, 142, 0)"}) - - -// Ayu theme. -local-storage: {"rustdoc-theme": "ayu"} -reload: - -assert-css: (".docblock .example-wrap.compile_fail .tooltip", {"color": "rgba(255, 0, 0, 0.5)"}) -assert-css: (".docblock .example-wrap.compile_fail", {"border-left": "2px solid rgba(255, 0, 0, 0.5)"}) - -move-cursor-to: ".docblock .example-wrap.compile_fail" - -assert-css: (".docblock .example-wrap.compile_fail .tooltip", {"color": "rgb(255, 0, 0)"}) -assert-css: (".docblock .example-wrap.compile_fail", {"border-left": "2px solid rgb(255, 0, 0)"}) - -// should_panic block -assert-css: (".docblock .example-wrap.should_panic .tooltip", {"color": "rgba(255, 0, 0, 0.5)"}) -assert-css: (".docblock .example-wrap.should_panic", {"border-left": "2px solid rgba(255, 0, 0, 0.5)"}) - -move-cursor-to: ".docblock .example-wrap.should_panic" - -assert-css: (".docblock .example-wrap.should_panic .tooltip", {"color": "rgb(255, 0, 0)"}) -assert-css: (".docblock .example-wrap.should_panic", {"border-left": "2px solid rgb(255, 0, 0)"}) - -// ignore block -assert-css: (".docblock .example-wrap.ignore .tooltip", {"color": "rgba(255, 142, 0, 0.6)"}) -assert-css: (".docblock .example-wrap.ignore", {"border-left": "2px solid rgba(255, 142, 0, 0.6)"}) - -move-cursor-to: ".docblock .example-wrap.ignore" - -assert-css: (".docblock .example-wrap.ignore .tooltip", {"color": "rgb(255, 142, 0)"}) -assert-css: (".docblock .example-wrap.ignore", {"border-left": "2px solid rgb(255, 142, 0)"}) +define-function: ( + "check-colors", + (theme), + [ + // Setting the theme. + ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + ("reload"), + + // compile_fail block + ("assert-css", ( + ".docblock .example-wrap.compile_fail .tooltip", + {"color": "rgba(255, 0, 0, 0.5)"}, + )), + ("assert-css", ( + ".docblock .example-wrap.compile_fail", + {"border-left": "2px solid rgba(255, 0, 0, 0.5)"}, + )), + + ("move-cursor-to", ".docblock .example-wrap.compile_fail"), + + ("assert-css", ( + ".docblock .example-wrap.compile_fail .tooltip", + {"color": "rgb(255, 0, 0)"}, + )), + ("assert-css", ( + ".docblock .example-wrap.compile_fail", + {"border-left": "2px solid rgb(255, 0, 0)"}, + )), + + // should_panic block + ("assert-css", ( + ".docblock .example-wrap.should_panic .tooltip", + {"color": "rgba(255, 0, 0, 0.5)"}, + )), + ("assert-css", ( + ".docblock .example-wrap.should_panic", + {"border-left": "2px solid rgba(255, 0, 0, 0.5)"}, + )), + + ("move-cursor-to", ".docblock .example-wrap.should_panic"), + + ("assert-css", ( + ".docblock .example-wrap.should_panic .tooltip", + {"color": "rgb(255, 0, 0)"}, + )), + ("assert-css", ( + ".docblock .example-wrap.should_panic", + {"border-left": "2px solid rgb(255, 0, 0)"}, + )), + + // ignore block + ("assert-css", ( + ".docblock .example-wrap.ignore .tooltip", + {"color": "rgba(255, 142, 0, 0.6)"}, + )), + ("assert-css", ( + ".docblock .example-wrap.ignore", + {"border-left": "2px solid rgba(255, 142, 0, 0.6)"}, + )), + + ("move-cursor-to", ".docblock .example-wrap.ignore"), + + ("assert-css", ( + ".docblock .example-wrap.ignore .tooltip", + {"color": "rgb(255, 142, 0)"}, + )), + ("assert-css", ( + ".docblock .example-wrap.ignore", + {"border-left": "2px solid rgb(255, 142, 0)"}, + )), + ], +) + +call-function: ("check-colors", ("ayu")) +call-function: ("check-colors", ("dark")) +call-function: ("check-colors", ("light")) diff --git a/src/test/rustdoc-gui/docblock-details.goml b/src/test/rustdoc-gui/docblock-details.goml index f3cbe5767ae..9ae571efbb5 100644 --- a/src/test/rustdoc-gui/docblock-details.goml +++ b/src/test/rustdoc-gui/docblock-details.goml @@ -21,3 +21,14 @@ assert-property: (".top-doc .docblock summary h4", {"offsetHeight": "33"}) assert-css: (".top-doc .docblock summary h4", {"margin-top": "15px", "margin-bottom": "5px"}) // So `33 + 15 + 5` == `53` assert-property: (".top-doc .docblock summary", {"offsetHeight": "53"}) + +// We now check the `<summary>` on a method. +assert-css: ( + ".method-toggle .docblock summary h4", + {"border-bottom-width": "0px"}, +) +// This allows to ensure that summary is on one line only! +assert-property: (".method-toggle .docblock summary h4", {"offsetHeight": "30"}) +assert-css: (".method-toggle .docblock summary h4", {"margin-top": "15px", "margin-bottom": "5px"}) +// So `30 + 15 + 5` == `50` +assert-property: (".method-toggle .docblock summary", {"offsetHeight": "50"}) diff --git a/src/test/rustdoc-gui/headers-color.goml b/src/test/rustdoc-gui/headers-color.goml index 9b7e3a23112..c80a49c52f0 100644 --- a/src/test/rustdoc-gui/headers-color.goml +++ b/src/test/rustdoc-gui/headers-color.goml @@ -1,117 +1,70 @@ // This test check for headers text and background colors for the different themes. -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" -// This is needed so that the text color is computed. -show-text: true - -// Ayu theme -local-storage: { - "rustdoc-theme": "ayu", - "rustdoc-preferred-dark-theme": "ayu", - "rustdoc-use-system-theme": "false", -} -reload: - -assert-css: ( - ".impl", - {"color": "rgb(197, 197, 197)", "background-color": "rgba(0, 0, 0, 0)"}, - ALL, -) -assert-css: ( - ".impl .code-header", - {"color": "rgb(230, 225, 207)", "background-color": "rgba(0, 0, 0, 0)"}, - ALL, +define-function: ( + "check-colors", + (theme, color, code_header_color, focus_background_color, headings_color), + [ + ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"), + // This is needed so that the text color is computed. + ("show-text", true), + ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + ("reload"), + ("assert-css", ( + ".impl", + {"color": |color|, "background-color": "rgba(0, 0, 0, 0)"}, + ALL, + )), + ("assert-css", ( + ".impl .code-header", + {"color": |code_header_color|, "background-color": "rgba(0, 0, 0, 0)"}, + ALL, + )), + ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#impl-Foo"), + ("assert-css", ( + "#impl-Foo", + {"color": |color|, "background-color": |focus_background_color|}, + )), + ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#method.must_use"), + ("assert-css", ( + "#method\.must_use", + {"color": |color|, "background-color": |focus_background_color|}, + ALL, + )), + ("goto", "file://" + |DOC_PATH| + "/test_docs/index.html"), + ("assert-css", (".small-section-header a", {"color": |color|}, ALL)), + ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"), + // We select headings (h2, h3, h...). + ("assert-css", (".docblock > :not(p) > a", {"color": |headings_color|}, ALL)), + ], ) -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#impl-Foo" -assert-css: ( - "#impl-Foo", - {"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"}, +call-function: ( + "check-colors", + { + "theme": "ayu", + "color": "rgb(197, 197, 197)", + "code_header_color": "rgb(230, 225, 207)", + "focus_background_color": "rgba(255, 236, 164, 0.06)", + "headings_color": "rgb(57, 175, 215)", + }, ) - -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#method.must_use" -assert-css: ( - "#method\.must_use", - {"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"}, - ALL, +call-function: ( + "check-colors", + { + "theme": "dark", + "color": "rgb(221, 221, 221)", + "code_header_color": "rgb(221, 221, 221)", + "focus_background_color": "rgb(73, 74, 61)", + "headings_color": "rgb(210, 153, 29)", + }, ) - -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" -assert-css: (".small-section-header a", {"color": "rgb(197, 197, 197)"}, ALL) - -goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" -// We select headings (h2, h3, h...). -assert-css: (".docblock > :not(p) > a", {"color": "rgb(57, 175, 215)"}, ALL) - -// Dark theme -local-storage: { - "rustdoc-theme": "dark", - "rustdoc-preferred-dark-theme": "dark", - "rustdoc-use-system-theme": "false", -} -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" - -assert-css: ( - ".impl", - {"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"}, - ALL, -) -assert-css: ( - ".impl .code-header", - {"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"}, - ALL, -) - -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#impl-Foo" -assert-css: ( - "#impl-Foo", - {"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"}, -) - -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#method.must_use" -assert-css: ( - "#method\.must_use", - {"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"}, - ALL, +call-function: ( + "check-colors", + { + "theme": "light", + "color": "rgb(0, 0, 0)", + "code_header_color": "rgb(0, 0, 0)", + "focus_background_color": "rgb(253, 255, 211)", + "headings_color": "rgb(56, 115, 173)", + }, ) - -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" -assert-css: (".small-section-header a", {"color": "rgb(221, 221, 221)"}, ALL) - -goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" -// We select headings (h2, h3, h...). -assert-css: (".docblock > :not(p) > a", {"color": "rgb(210, 153, 29)"}, ALL) - -// Light theme -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} -reload: - -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" - -assert-css: ( - ".impl", - {"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"}, - ALL, -) -assert-css: ( - ".impl .code-header", - {"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"}, - ALL, -) - -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#impl-Foo" -assert-css: ("#impl-Foo", {"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"}) - -goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#method.must_use" -assert-css: ( - "#method\.must_use", - {"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"}, - ALL, -) - -goto: "file://" + |DOC_PATH| + "/test_docs/index.html" -assert-css: (".small-section-header a", {"color": "rgb(0, 0, 0)"}, ALL) - -goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" -// We select headings (h2, h3, h...). -assert-css: (".docblock > :not(p) > a", {"color": "rgb(56, 115, 173)"}, ALL) diff --git a/src/test/rustdoc-gui/headings.goml b/src/test/rustdoc-gui/headings.goml index 9a77d8bbd15..85e17ca9551 100644 --- a/src/test/rustdoc-gui/headings.goml +++ b/src/test/rustdoc-gui/headings.goml @@ -150,109 +150,85 @@ assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"}) assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "20px"}) assert-css: ("h3#top-doc-prose-sub-heading", {"border-bottom-width": "1px"}) -// Checking colors now. +// Needed to check colors show-text: true -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" -assert-css: ( - ".top-doc .docblock h2", - {"color": "rgb(0, 0, 0)", "border-bottom": "1px solid rgb(221, 221, 221)"}, -) -assert-css: ( - ".top-doc .docblock h3", - {"color": "rgb(0, 0, 0)", "border-bottom": "1px solid rgb(221, 221, 221)"}, -) -assert-css: ( - ".top-doc .docblock h4", - {"color": "rgb(0, 0, 0)", "border-bottom": "1px solid rgb(221, 221, 221)"}, -) -assert-css: ( - ".top-doc .docblock h5", - {"color": "rgb(0, 0, 0)", "border-bottom-width": "0px"}, -) -assert-css: ( - "#implementations-list .docblock h4", - {"color": "rgb(0, 0, 0)", "border-bottom-width": "0px"}, -) -assert-css: ( - "#implementations-list .docblock h5", - {"color": "rgb(0, 0, 0)", "border-bottom-width": "0px"}, -) -assert-css: ( - "#implementations-list .docblock h6", - {"color": "rgb(0, 0, 0)", "border-bottom-width": "0px"}, -) -local-storage: {"rustdoc-theme": "dark"} -reload: -assert-css: ( - ".top-doc .docblock h2", - {"color": "rgb(221, 221, 221)", "border-bottom": "1px solid rgb(210, 210, 210)"}, -) -assert-css: ( - ".top-doc .docblock h3", - {"color": "rgb(221, 221, 221)", "border-bottom": "1px solid rgb(210, 210, 210)"}, -) -assert-css: ( - ".top-doc .docblock h4", - {"color": "rgb(221, 221, 221)", "border-bottom": "1px solid rgb(210, 210, 210)"}, -) -assert-css: ( - ".top-doc .docblock h5", - {"color": "rgb(221, 221, 221)", "border-bottom-width": "0px"}, -) -assert-css: ( - "#implementations-list .docblock h4", - {"color": "rgb(221, 221, 221)", "border-bottom-width": "0px"}, -) -assert-css: ( - "#implementations-list .docblock h5", - {"color": "rgb(221, 221, 221)", "border-bottom-width": "0px"}, -) -assert-css: ( - "#implementations-list .docblock h6", - {"color": "rgb(221, 221, 221)", "border-bottom-width": "0px"}, +define-function: ( + "check-colors", + (theme, heading_color, small_heading_color, heading_border_color), + [ + ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + ("reload"), + ("assert-css", ( + ".top-doc .docblock h2", + {"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|}, + )), + ("assert-css", ( + ".top-doc .docblock h3", + {"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|}, + )), + ("assert-css", ( + ".top-doc .docblock h4", + {"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|}, + )), + ("assert-css", ( + ".top-doc .docblock h5", + {"color": |small_heading_color|, "border-bottom-width": "0px"}, + )), + ("assert-css", ( + "#implementations-list .docblock h4", + {"color": |heading_color|, "border-bottom-width": "0px"}, + )), + ("assert-css", ( + "#implementations-list .docblock h5", + {"color": |small_heading_color|, "border-bottom-width": "0px"}, + )), + ("assert-css", ( + "#implementations-list .docblock h6", + {"color": |small_heading_color|, "border-bottom-width": "0px"}, + )), + ], +) +call-function: ( + "check-colors", + { + "theme": "ayu", + "heading_color": "rgb(255, 255, 255)", + "small_heading_color": "rgb(197, 197, 197)", + "heading_border_color": "rgb(92, 103, 115)", + }, +) +call-function: ( + "check-colors", + { + "theme": "dark", + "heading_color": "rgb(221, 221, 221)", + "small_heading_color": "rgb(221, 221, 221)", + "heading_border_color": "rgb(210, 210, 210)", + }, +) +call-function: ( + "check-colors", + { + "theme": "light", + "heading_color": "rgb(0, 0, 0)", + "small_heading_color": "rgb(0, 0, 0)", + "heading_border_color": "rgb(221, 221, 221)", + }, +) + +define-function: ( + "check-since-color", + (theme), + [ + ("local-storage", {"rustdoc-theme": |theme|}), + ("reload"), + ("assert-css", (".since", {"color": "rgb(128, 128, 128)"}, ALL)), + ], ) -local-storage: {"rustdoc-theme": "ayu"} -reload: -assert-css: ( - ".top-doc .docblock h2", - {"color": "rgb(255, 255, 255)", "border-bottom": "1px solid rgb(92, 103, 115)"}, -) -assert-css: ( - ".top-doc .docblock h2", - {"color": "rgb(255, 255, 255)", "border-bottom": "1px solid rgb(92, 103, 115)"}, -) -assert-css: ( - ".top-doc .docblock h4", - {"color": "rgb(255, 255, 255)", "border-bottom": "1px solid rgb(92, 103, 115)"}, -) -assert-css: ( - ".top-doc .docblock h5", - {"color": "rgb(197, 197, 197)", "border-bottom-width": "0px"}, -) -assert-css: ( - "#implementations-list .docblock h4", - {"color": "rgb(255, 255, 255)", "border-bottom-width": "0px"}, -) -assert-css: ( - "#implementations-list .docblock h5", - {"color": "rgb(197, 197, 197)", "border-bottom-width": "0px"}, -) -assert-css: ( - "#implementations-list .docblock h6", - {"color": "rgb(197, 197, 197)", "border-bottom-width": "0px"}, -) - -local-storage: {"rustdoc-theme": "light"} goto: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html" -assert-css: (".since", {"color": "rgb(128, 128, 128)"}, ALL) - -local-storage: {"rustdoc-theme": "dark"} -reload: -assert-css: (".since", {"color": "rgb(128, 128, 128)"}, ALL) - -local-storage: {"rustdoc-theme": "ayu"} -reload: -assert-css: (".since", {"color": "rgb(128, 128, 128)"}, ALL) +call-function: ("check-since-color", ("ayu")) +call-function: ("check-since-color", ("dark")) +call-function: ("check-since-color", ("light")) diff --git a/src/test/rustdoc-gui/help-page.goml b/src/test/rustdoc-gui/help-page.goml new file mode 100644 index 00000000000..521e14748af --- /dev/null +++ b/src/test/rustdoc-gui/help-page.goml @@ -0,0 +1,24 @@ +// This test ensures that opening the help page in its own tab works. +goto: "file://" + |DOC_PATH| + "/help.html" +size: (1000, 1000) // Try desktop size first. +wait-for: "#help" +assert-css: ("#help", {"display": "block"}) +click: "#help-button > a" +assert-css: ("#help", {"display": "block"}) +compare-elements-property: (".sub", "#help", ["offsetWidth"]) +compare-elements-position: (".sub", "#help", ("x")) +size: (500, 1000) // Try mobile next. +assert-css: ("#help", {"display": "block"}) +compare-elements-property: (".sub", "#help", ["offsetWidth"]) +compare-elements-position: (".sub", "#help", ("x")) + +// This test ensures that opening the help popover without switching pages works. +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +size: (1000, 1000) // Only supported on desktop. +assert-false: "#help" +click: "#help-button > a" +assert-css: ("#help", {"display": "block"}) +click: "#help-button > a" +assert-css: ("#help", {"display": "none"}) +compare-elements-property-false: (".sub", "#help", ["offsetWidth"]) +compare-elements-position-false: (".sub", "#help", ("x")) diff --git a/src/test/rustdoc-gui/item-decl-colors.goml b/src/test/rustdoc-gui/item-decl-colors.goml new file mode 100644 index 00000000000..ce688287a74 --- /dev/null +++ b/src/test/rustdoc-gui/item-decl-colors.goml @@ -0,0 +1,74 @@ +// This test ensures that the color of the items in the type decl are working as expected. +define-function: ( + "check-colors", + ( + theme, + attr_color, + trait_color, + struct_color, + enum_color, + primitive_color, + constant_color, + fn_color, + assoc_type_color, + ), + [ + ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.WithGenerics.html"), + ("show-text", true), + ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + ("reload"), + ("assert-css", (".item-decl .code-attribute", {"color": |attr_color|}, ALL)), + ("assert-css", (".item-decl .trait", {"color": |trait_color|}, ALL)), + // We need to add `code` here because otherwise it would select the parent too. + ("assert-css", (".item-decl code .struct", {"color": |struct_color|}, ALL)), + ("assert-css", (".item-decl .enum", {"color": |enum_color|}, ALL)), + ("assert-css", (".item-decl .primitive", {"color": |primitive_color|}, ALL)), + ("goto", "file://" + |DOC_PATH| + "/test_docs/trait.TraitWithoutGenerics.html"), + ("assert-css", (".item-decl .constant", {"color": |constant_color|}, ALL)), + ("assert-css", (".item-decl .fnname", {"color": |fn_color|}, ALL)), + ("assert-css", (".item-decl .associatedtype", {"color": |assoc_type_color|}, ALL)), + ], +) + +call-function: ( + "check-colors", + { + "theme": "ayu", + "attr_color": "rgb(153, 153, 153)", + "trait_color": "rgb(57, 175, 215)", + "struct_color": "rgb(255, 160, 165)", + "enum_color": "rgb(255, 160, 165)", + "primitive_color": "rgb(255, 160, 165)", + "constant_color": "rgb(57, 175, 215)", + "fn_color": "rgb(253, 214, 135)", + "assoc_type_color": "rgb(57, 175, 215)", + }, +) +call-function: ( + "check-colors", + { + "theme": "dark", + "attr_color": "rgb(153, 153, 153)", + "trait_color": "rgb(183, 140, 242)", + "struct_color": "rgb(45, 191, 184)", + "enum_color": "rgb(45, 191, 184)", + "primitive_color": "rgb(45, 191, 184)", + "constant_color": "rgb(210, 153, 29)", + "fn_color": "rgb(43, 171, 99)", + "assoc_type_color": "rgb(210, 153, 29)", + }, +) +call-function: ( + "check-colors", + { + "theme": "light", + "attr_color": "rgb(153, 153, 153)", + "trait_color": "rgb(110, 79, 201)", + "struct_color": "rgb(173, 55, 138)", + "enum_color": "rgb(173, 55, 138)", + "primitive_color": "rgb(173, 55, 138)", + "constant_color": "rgb(56, 115, 173)", + "fn_color": "rgb(173, 124, 55)", + "assoc_type_color": "rgb(56, 115, 173)", + }, +) diff --git a/src/test/rustdoc-gui/jump-to-def-background.goml b/src/test/rustdoc-gui/jump-to-def-background.goml index 31c7d0ce3c8..b65faf13d0c 100644 --- a/src/test/rustdoc-gui/jump-to-def-background.goml +++ b/src/test/rustdoc-gui/jump-to-def-background.goml @@ -1,43 +1,22 @@ // We check the background color on the jump to definition links in the source code page. goto: "file://" + |DOC_PATH| + "/src/link_to_definition/lib.rs.html" -// Set the theme to dark. -local-storage: { - "rustdoc-theme": "dark", - "rustdoc-preferred-dark-theme": "dark", - "rustdoc-use-system-theme": "false", -} -// We reload the page so the local storage settings are being used. -reload: - -assert-css: ( - "body.source .example-wrap pre.rust a", - {"background-color": "rgb(51, 51, 51)"}, - ALL, -) - -// Set the theme to ayu. -local-storage: { - "rustdoc-theme": "ayu", - "rustdoc-preferred-dark-theme": "ayu", - "rustdoc-use-system-theme": "false", -} -// We reload the page so the local storage settings are being used. -reload: - -assert-css: ( - "body.source .example-wrap pre.rust a", - {"background-color": "rgb(51, 51, 51)"}, - ALL, +define-function: ( + "check-background-color", + (theme, background_color), + [ + // Set the theme. + ("local-storage", { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false" }), + // We reload the page so the local storage settings are being used. + ("reload"), + ("assert-css", ( + "body.source .example-wrap pre.rust a", + {"background-color": |background_color|}, + ALL, + )), + ], ) -// Set the theme to light. -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} -// We reload the page so the local storage settings are being used. -reload: - -assert-css: ( - "body.source .example-wrap pre.rust a", - {"background-color": "rgb(238, 238, 238)"}, - ALL, -) +call-function: ("check-background-color", ("ayu", "rgb(51, 51, 51)")) +call-function: ("check-background-color", ("dark", "rgb(51, 51, 51)")) +call-function: ("check-background-color", ("light", "rgb(238, 238, 238)")) diff --git a/src/test/rustdoc-gui/mobile.goml b/src/test/rustdoc-gui/mobile.goml index 22a53dea616..704542a39d2 100644 --- a/src/test/rustdoc-gui/mobile.goml +++ b/src/test/rustdoc-gui/mobile.goml @@ -12,7 +12,7 @@ assert-css: (".main-heading", { "flex-direction": "column" }) -assert-property: (".mobile-topbar h2.location", {"offsetHeight": 36}) +assert-property: (".mobile-topbar h2", {"offsetHeight": 36}) // Note: We can't use assert-text here because the 'Since' is set by CSS and // is therefore not part of the DOM. diff --git a/src/test/rustdoc-gui/search-form-elements.goml b/src/test/rustdoc-gui/search-form-elements.goml index fba9cc8777f..542db348c3b 100644 --- a/src/test/rustdoc-gui/search-form-elements.goml +++ b/src/test/rustdoc-gui/search-form-elements.goml @@ -33,7 +33,7 @@ assert-css: ( {"border-color": "rgb(197, 197, 197)"}, ) assert-css: ( - "#help-button > button", + "#help-button > a", { "color": "rgb(255, 255, 255)", "border-color": "rgb(92, 103, 115)", @@ -47,13 +47,21 @@ assert-css: ( ) // Only "border-color" should change. assert-css: ( - "#help-button:hover > button", + "#help-button:hover > a", { "color": "rgb(255, 255, 255)", "border-color": "rgb(224, 224, 224)", "background-color": "rgb(20, 25, 32)", }, ) +// Link color inside +click: "#help-button" +assert-css: ( + "#help a", + { + "color": "rgb(57, 175, 215)", + }, +) assert-css: ( "#settings-menu", @@ -62,7 +70,6 @@ assert-css: ( assert-css: ( "#settings-menu > a", { - "color": "rgb(255, 255, 255)", "border-color": "rgb(92, 103, 115)", "background-color": "rgb(20, 25, 32)", }, @@ -76,7 +83,6 @@ assert-css: ( assert-css: ( "#settings-menu:hover > a", { - "color": "rgb(255, 255, 255)", "border-color": "rgb(224, 224, 224)", "background-color": "rgb(20, 25, 32)", }, @@ -113,7 +119,7 @@ assert-css: ( {"border-color": "rgb(221, 221, 221)"}, ) assert-css: ( - "#help-button > button", + "#help-button > a", { "color": "rgb(0, 0, 0)", "border-color": "rgb(224, 224, 224)", @@ -127,13 +133,21 @@ assert-css: ( ) // Only "border-color" should change. assert-css: ( - "#help-button:hover > button", + "#help-button:hover > a", { "color": "rgb(0, 0, 0)", "border-color": "rgb(255, 185, 0)", "background-color": "rgb(240, 240, 240)", }, ) +// Link color inside +click: "#help-button" +assert-css: ( + "#help a", + { + "color": "rgb(210, 153, 29)", + }, +) assert-css: ( "#settings-menu", @@ -142,7 +156,6 @@ assert-css: ( assert-css: ( "#settings-menu > a", { - "color": "rgb(0, 0, 0)", "border-color": "rgb(224, 224, 224)", "background-color": "rgb(240, 240, 240)", }, @@ -193,7 +206,7 @@ assert-css: ( {"border-color": "rgb(0, 0, 0)"}, ) assert-css: ( - "#help-button > button", + "#help-button > a", { "color": "rgb(0, 0, 0)", "border-color": "rgb(224, 224, 224)", @@ -207,13 +220,21 @@ assert-css: ( ) // Only "border-color" should change. assert-css: ( - "#help-button:hover > button", + "#help-button:hover > a", { "color": "rgb(0, 0, 0)", "border-color": "rgb(113, 113, 113)", "background-color": "rgb(255, 255, 255)", }, ) +// Link color inside +click: "#help-button" +assert-css: ( + "#help a", + { + "color": "rgb(56, 115, 173)", + }, +) assert-css: ( "#settings-menu", @@ -222,7 +243,6 @@ assert-css: ( assert-css: ( "#settings-menu > a", { - "color": "rgb(56, 115, 173)", "border-color": "rgb(224, 224, 224)", "background-color": "rgb(255, 255, 255)", }, @@ -236,7 +256,7 @@ assert-css: ( assert-css: ( "#settings-menu:hover > a", { - "color": "rgb(56, 115, 173)", + "color": "rgb(0, 0, 0)", "border-color": "rgb(113, 113, 113)", "background-color": "rgb(255, 255, 255)", }, diff --git a/src/test/rustdoc-gui/settings.goml b/src/test/rustdoc-gui/settings.goml index dfbf1d38e0e..f258f4d2a83 100644 --- a/src/test/rustdoc-gui/settings.goml +++ b/src/test/rustdoc-gui/settings.goml @@ -1,4 +1,5 @@ -// This test ensures that the settings menu display is working as expected. +// This test ensures that the settings menu display is working as expected and that +// the settings page is also rendered as expected. goto: "file://" + |DOC_PATH| + "/test_docs/index.html" show-text: true // needed when we check for colors below. // First, we check that the settings page doesn't exist. @@ -140,7 +141,13 @@ assert-css: ("#settings-menu .popover", {"display": "none"}) // Now we go to the settings page to check that the CSS is loaded as expected. goto: "file://" + |DOC_PATH| + "/settings.html" wait-for: "#settings" -assert-css: (".setting-line .toggle .slider", {"width": "45px", "margin-right": "20px"}) +assert-css: ( + ".setting-line .toggle .slider", + {"width": "45px", "margin-right": "20px", "border": "0px none rgb(0, 0, 0)"}, +) + +assert-attribute-false: ("#settings", {"class": "popover"}, CONTAINS) +compare-elements-position: (".sub form", "#settings", ("x")) // We now check the display with JS disabled. assert-false: "noscript section" diff --git a/src/test/rustdoc-gui/shortcuts.goml b/src/test/rustdoc-gui/shortcuts.goml index ea6f55272ff..9068680d640 100644 --- a/src/test/rustdoc-gui/shortcuts.goml +++ b/src/test/rustdoc-gui/shortcuts.goml @@ -11,3 +11,21 @@ press-key: "?" assert-css: ("#help-button .popover", {"display": "block"}) press-key: "Escape" assert-css: ("#help-button .popover", {"display": "none"}) +// Checking doc collapse and expand. +// It should be displaying a "-": +assert-text: ("#toggle-all-docs", "[\u2212]") +press-key: "-" +wait-for-text: ("#toggle-all-docs", "[+]") +assert-attribute: ("#toggle-all-docs", {"class": "will-expand"}) +// Pressing it again shouldn't do anything. +press-key: "-" +assert-text: ("#toggle-all-docs", "[+]") +assert-attribute: ("#toggle-all-docs", {"class": "will-expand"}) +// Expanding now. +press-key: "+" +wait-for-text: ("#toggle-all-docs", "[\u2212]") +assert-attribute: ("#toggle-all-docs", {"class": ""}) +// Pressing it again shouldn't do anything. +press-key: "+" +assert-text: ("#toggle-all-docs", "[\u2212]") +assert-attribute: ("#toggle-all-docs", {"class": ""}) diff --git a/src/test/rustdoc-gui/sidebar-mobile-scroll.goml b/src/test/rustdoc-gui/sidebar-mobile-scroll.goml index f1cba172ee3..2449269b192 100644 --- a/src/test/rustdoc-gui/sidebar-mobile-scroll.goml +++ b/src/test/rustdoc-gui/sidebar-mobile-scroll.goml @@ -1,12 +1,12 @@ // This test ensures that the mobile sidebar preserves scroll position. goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" // Switching to "mobile view" by reducing the width to 600px. -size: (600, 600) +size: (700, 600) assert-css: (".sidebar", {"display": "block", "left": "-1000px"}) // Scroll down. scroll-to: "//h2[@id='blanket-implementations']" -assert-window-property: {"pageYOffset": "651"} +assert-window-property: {"pageYOffset": "627"} // Open the sidebar menu. click: ".sidebar-menu-toggle" @@ -21,11 +21,11 @@ assert-window-property: {"pageYOffset": "0"} // Close the sidebar menu. Make sure the scroll position gets restored. click: ".sidebar-menu-toggle" wait-for-css: (".sidebar", {"left": "-1000px"}) -assert-window-property: {"pageYOffset": "651"} +assert-window-property: {"pageYOffset": "627"} // Now test that scrollability returns when the browser window is just resized. click: ".sidebar-menu-toggle" wait-for-css: (".sidebar", {"left": "0px"}) assert-window-property: {"pageYOffset": "0"} size: (900, 600) -assert-window-property: {"pageYOffset": "651"} +assert-window-property: {"pageYOffset": "627"} diff --git a/src/test/rustdoc-gui/sidebar-mobile.goml b/src/test/rustdoc-gui/sidebar-mobile.goml index 4cded2c773d..453873f1b81 100644 --- a/src/test/rustdoc-gui/sidebar-mobile.goml +++ b/src/test/rustdoc-gui/sidebar-mobile.goml @@ -13,7 +13,7 @@ click: ".sidebar-menu-toggle" assert-css: (".sidebar", {"display": "block", "left": "-1000px"}) // Force the sidebar open by focusing a link inside it. // This makes it easier for keyboard users to get to it. -focus: ".sidebar-title a" +focus: ".sidebar-elems h3 a" assert-css: (".sidebar", {"display": "block", "left": "0px"}) // When we tab out of the sidebar, close it. focus: ".search-input" @@ -23,6 +23,11 @@ assert-css: (".sidebar", {"display": "block", "left": "-1000px"}) click: ".sidebar-menu-toggle" assert-css: (".sidebar", {"left": "0px"}) +// Make sure the "struct Foo" header is hidden, since the mobile topbar already does it. +assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[text()='Foo']/parent::h2", {"display": "none"}) +// Make sure the global navigation is still here. +assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[text()='In test_docs']/parent::h2", {"display": "block"}) + // Click elsewhere. click: "body" assert-css: (".sidebar", {"display": "block", "left": "-1000px"}) @@ -39,7 +44,7 @@ assert-position: ("#method\.must_use", {"y": 45}) // Check that the bottom-most item on the sidebar menu can be scrolled fully into view. click: ".sidebar-menu-toggle" scroll-to: ".block.keyword li:nth-child(1)" -compare-elements-position-near: (".block.keyword li:nth-child(1)", ".mobile-topbar", {"y": 543}) +compare-elements-position-near: (".block.keyword li:nth-child(1)", ".mobile-topbar", {"y": 543.19}) // Now checking the background color of the sidebar. show-text: true diff --git a/src/test/rustdoc-gui/sidebar.goml b/src/test/rustdoc-gui/sidebar.goml index 54193234af9..5058630f469 100644 --- a/src/test/rustdoc-gui/sidebar.goml +++ b/src/test/rustdoc-gui/sidebar.goml @@ -9,6 +9,7 @@ reload: assert-text: (".sidebar > .location", "Crate test_docs") // In modules, we only have one "location" element. assert-count: (".sidebar .location", 1) +assert-count: (".sidebar h2", 1) assert-text: ("#all-types", "All Items") assert-css: ("#all-types", {"color": "rgb(53, 109, 164)"}) // We check that we have the crates list and that the "current" on is "test_docs". @@ -19,16 +20,18 @@ assert-text: (".sidebar-elems section ul > li:nth-child(2)", "Modules") assert-text: (".sidebar-elems section ul > li:nth-child(3)", "Macros") assert-text: (".sidebar-elems section ul > li:nth-child(4)", "Structs") assert-text: (".sidebar-elems section ul > li:nth-child(5)", "Enums") -assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Traits") -assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Functions") -assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Type Definitions") -assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Unions") -assert-text: (".sidebar-elems section ul > li:nth-child(10)", "Keywords") +assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Constants") +assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Traits") +assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Functions") +assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Type Definitions") +assert-text: (".sidebar-elems section ul > li:nth-child(10)", "Unions") +assert-text: (".sidebar-elems section ul > li:nth-child(11)", "Keywords") assert-text: ("#structs + .item-table .item-left > a", "Foo") click: "#structs + .item-table .item-left > a" // PAGE: struct.Foo.html -assert-count: (".sidebar .location", 2) +assert-count: (".sidebar .location", 1) +assert-count: (".sidebar h2", 2) // We check that there is no crate listed outside of the top level. assert-false: ".sidebar-elems > .crate" @@ -60,10 +63,11 @@ assert-text: ("#functions + .item-table .item-left > a", "foobar") click: "#functions + .item-table .item-left > a" // PAGE: fn.foobar.html -// In items containing no items (like functions or constants) and in modules, we have one -// "location" elements. -assert-count: (".sidebar .location", 1) -assert-text: (".sidebar .sidebar-elems .location", "In lib2") +// In items containing no items (like functions or constants) and in modules, we have no +// "location" elements. Only the parent module h2. +assert-count: (".sidebar .location", 0) +assert-count: (".sidebar h2", 1) +assert-text: (".sidebar .sidebar-elems h2", "In lib2") // We check that we don't have the crate list. assert-false: ".sidebar-elems > .crate" diff --git a/src/test/rustdoc-gui/source-code-page.goml b/src/test/rustdoc-gui/source-code-page.goml index 76260d621ea..29d65fc7ebc 100644 --- a/src/test/rustdoc-gui/source-code-page.goml +++ b/src/test/rustdoc-gui/source-code-page.goml @@ -23,7 +23,7 @@ assert-css: (".src-line-numbers", {"text-align": "right"}) show-text: true goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" // We use this assert-position to know where we will click. -assert-position: ("//*[@id='1']", {"x": 104, "y": 103}) +assert-position: ("//*[@id='1']", {"x": 104, "y": 112}) // We click on the left of the "1" span but still in the "src-line-number" `<pre>`. click: (103, 103) assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH) @@ -47,3 +47,25 @@ assert-property: ("#source-sidebar details:first-of-type", {"open": "false"}) // Check the spacing. assert-css: ("#source-sidebar > details.dir-entry", {"padding-left": "4px"}) + +// Check the search form +assert-css: ("nav.sub", {"flex-direction": "row"}) +// The goal of this test is to ensure the search input is perfectly centered +// between the top of the page and the top of the gray code block. +// To check this, we maintain the invariant: +// +// offsetTop[nav.sub form] = offsetTop[#main-content] - offsetHeight[nav.sub form] - offsetTop[nav.sub form] +assert-property: ("nav.sub form", {"offsetTop": 28, "offsetHeight": 34}) +assert-property: ("#main-content", {"offsetTop": 90}) +// 28 = 90 - 34 - 28 + +// Now do the same check on moderately-sized mobile. +size: (700, 700) +assert-css: ("nav.sub", {"flex-direction": "row"}) +assert-property: ("nav.sub form", {"offsetTop": 21, "offsetHeight": 34}) +assert-property: ("#main-content", {"offsetTop": 76}) +// 21 = 76 - 34 - 21 + +// Tiny mobile gets a different display where the logo is stacked on top. +size: (450, 700) +assert-css: ("nav.sub", {"flex-direction": "column"}) diff --git a/src/test/rustdoc-gui/src/test_docs/lib.rs b/src/test/rustdoc-gui/src/test_docs/lib.rs index cc0efe7231a..fdf97e492aa 100644 --- a/src/test/rustdoc-gui/src/test_docs/lib.rs +++ b/src/test/rustdoc-gui/src/test_docs/lib.rs @@ -5,6 +5,7 @@ #![crate_name = "test_docs"] #![feature(rustdoc_internals)] #![feature(doc_cfg)] +#![feature(associated_type_defaults)] /*! Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy @@ -316,6 +317,18 @@ pub mod details { /// <div>I'm the content of the details!</div> /// </details> pub struct Details; + + impl Details { + /// We check the appearance of the `<details>`/`<summary>` in here. + /// + /// ## Hello + /// + /// <details> + /// <summary><h4>I'm a summary</h4></summary> + /// <div>I'm the content of the details!</div> + /// </details> + pub fn method() {} + } } pub mod doc_block_table { @@ -386,3 +399,20 @@ impl TypeWithNoDocblocks { pub unsafe fn unsafe_fn() {} pub fn safe_fn() {} + +#[repr(C)] +pub struct WithGenerics<T: TraitWithNoDocblocks, S = String, E = WhoLetTheDogOut, P = i8> { + s: S, + t: T, + e: E, + p: P, +} + +pub const CONST: u8 = 0; + +pub trait TraitWithoutGenerics { + const C: u8 = CONST; + type T = SomeType; + + fn foo(); +} diff --git a/src/test/rustdoc-gui/type-declation-overflow.goml b/src/test/rustdoc-gui/type-declation-overflow.goml index 657c3cfa4b6..fce3002e750 100644 --- a/src/test/rustdoc-gui/type-declation-overflow.goml +++ b/src/test/rustdoc-gui/type-declation-overflow.goml @@ -32,6 +32,6 @@ assert-property: (".item-decl pre", {"scrollWidth": "950"}) size: (600, 600) goto: "file://" + |DOC_PATH| + "/lib2/too_long/struct.SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName.html" // It shouldn't have an overflow in the topbar either. -store-property: (scrollWidth, ".mobile-topbar .location", "scrollWidth") -assert-property: (".mobile-topbar .location", {"clientWidth": |scrollWidth|}) -assert-css: (".mobile-topbar .location", {"overflow-x": "hidden"}) +store-property: (scrollWidth, ".mobile-topbar h2", "scrollWidth") +assert-property: (".mobile-topbar h2", {"clientWidth": |scrollWidth|}) +assert-css: (".mobile-topbar h2", {"overflow-x": "hidden"}) diff --git a/src/test/rustdoc-ui/z-help.stdout b/src/test/rustdoc-ui/z-help.stdout index dbf3a8f00ee..46f11d2e5d1 100644 --- a/src/test/rustdoc-ui/z-help.stdout +++ b/src/test/rustdoc-ui/z-help.stdout @@ -36,6 +36,7 @@ -Z dump-mir-graphviz=val -- in addition to `.mir` files, create graphviz `.dot` files (and with `-Z instrument-coverage`, also create a `.dot` file for the MIR-derived coverage graph) (default: no) -Z dump-mir-spanview=val -- in addition to `.mir` files, create `.html` files to view spans for all `statement`s (including terminators), only `terminator` spans, or computed `block` spans (one span encompassing a block's terminator and all statements). If `-Z instrument-coverage` is also enabled, create an additional `.html` file showing the computed coverage spans. -Z dwarf-version=val -- version of DWARF debug information to emit (default: 2 or 4, depending on platform) + -Z dylib-lto=val -- enables LTO for dylib crate type -Z emit-stack-sizes=val -- emit a section containing stack size metadata (default: no) -Z emit-thin-lto=val -- emit the bc module with thin LTO info (default: yes) -Z export-executable-symbols=val -- export symbols from executables, as if they were dynamic libraries diff --git a/src/test/rustdoc/associated-consts.rs b/src/test/rustdoc/associated-consts.rs index 9319a073bb7..adb155bb525 100644 --- a/src/test/rustdoc/associated-consts.rs +++ b/src/test/rustdoc/associated-consts.rs @@ -9,7 +9,7 @@ pub trait Trait { pub struct Bar; // @has 'foo/struct.Bar.html' -// @!has - '//h3[@class="sidebar-title"]' 'Associated Constants' +// @!has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' // @!has - '//div[@class="sidebar-elems"]//a' 'FOO' impl Trait for Bar { const FOO: u32 = 1; @@ -22,7 +22,7 @@ pub enum Foo { } // @has 'foo/enum.Foo.html' -// @!has - '//h3[@class="sidebar-title"]' 'Associated Constants' +// @!has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' // @!has - '//div[@class="sidebar-elems"]//a' 'FOO' impl Trait for Foo { const FOO: u32 = 1; @@ -33,7 +33,7 @@ impl Trait for Foo { pub struct Baz; // @has 'foo/struct.Baz.html' -// @has - '//h3[@class="sidebar-title"]' 'Associated Constants' +// @has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' // @has - '//div[@class="sidebar-elems"]//a' 'FOO' impl Baz { pub const FOO: u32 = 42; @@ -44,7 +44,7 @@ pub enum Quux { } // @has 'foo/enum.Quux.html' -// @has - '//h3[@class="sidebar-title"]' 'Associated Constants' +// @has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' // @has - '//div[@class="sidebar-elems"]//a' 'FOO' impl Quux { pub const FOO: u32 = 42; diff --git a/src/test/rustdoc/deref-recursive-pathbuf.rs b/src/test/rustdoc/deref-recursive-pathbuf.rs index 746df9c804e..be2b42b5ac6 100644 --- a/src/test/rustdoc/deref-recursive-pathbuf.rs +++ b/src/test/rustdoc/deref-recursive-pathbuf.rs @@ -7,9 +7,9 @@ // @has '-' '//*[@class="impl-items"]//*[@id="method.as_path"]' 'pub fn as_path(&self)' // @has '-' '//*[@id="deref-methods-Path"]' 'Methods from Deref<Target = Path>' // @has '-' '//*[@class="impl-items"]//*[@id="method.exists"]' 'pub fn exists(&self)' -// @has '-' '//*[@class="sidebar-title"]/a[@href="#deref-methods-PathBuf"]' 'Methods from Deref<Target=PathBuf>' +// @has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-PathBuf"]' 'Methods from Deref<Target=PathBuf>' // @has '-' '//*[@class="sidebar-elems"]//*[@class="block"]//a[@href="#method.as_path"]' 'as_path' -// @has '-' '//*[@class="sidebar-title"]/a[@href="#deref-methods-Path"]' 'Methods from Deref<Target=Path>' +// @has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-Path"]' 'Methods from Deref<Target=Path>' // @has '-' '//*[@class="sidebar-elems"]//*[@class="block"]//a[@href="#method.exists"]' 'exists' #![crate_name = "foo"] diff --git a/src/test/rustdoc/deref-recursive.rs b/src/test/rustdoc/deref-recursive.rs index d5f8473f284..0436f2f86f5 100644 --- a/src/test/rustdoc/deref-recursive.rs +++ b/src/test/rustdoc/deref-recursive.rs @@ -7,9 +7,9 @@ // @has '-' '//*[@class="impl-items"]//*[@id="method.bar"]' 'pub fn bar(&self)' // @has '-' '//*[@id="deref-methods-Baz"]' 'Methods from Deref<Target = Baz>' // @has '-' '//*[@class="impl-items"]//*[@id="method.baz"]' 'pub fn baz(&self)' -// @has '-' '//*[@class="sidebar-title"]/a[@href="#deref-methods-Bar"]' 'Methods from Deref<Target=Bar>' +// @has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-Bar"]' 'Methods from Deref<Target=Bar>' // @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.bar"]' 'bar' -// @has '-' '//*[@class="sidebar-title"]/a[@href="#deref-methods-Baz"]' 'Methods from Deref<Target=Baz>' +// @has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-Baz"]' 'Methods from Deref<Target=Baz>' // @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.baz"]' 'baz' #![crate_name = "foo"] diff --git a/src/test/rustdoc/deref-typedef.rs b/src/test/rustdoc/deref-typedef.rs index 28f977e315a..32424d13eb8 100644 --- a/src/test/rustdoc/deref-typedef.rs +++ b/src/test/rustdoc/deref-typedef.rs @@ -6,7 +6,7 @@ // @has '-' '//*[@class="impl-items"]//*[@id="method.foo_b"]' 'pub fn foo_b(&self)' // @has '-' '//*[@class="impl-items"]//*[@id="method.foo_c"]' 'pub fn foo_c(&self)' // @has '-' '//*[@class="impl-items"]//*[@id="method.foo_j"]' 'pub fn foo_j(&self)' -// @has '-' '//*[@class="sidebar-title"]/a[@href="#deref-methods-FooJ"]' 'Methods from Deref<Target=FooJ>' +// @has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-FooJ"]' 'Methods from Deref<Target=FooJ>' // @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_a"]' 'foo_a' // @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_b"]' 'foo_b' // @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_c"]' 'foo_c' diff --git a/src/test/rustdoc/escape-deref-methods.rs b/src/test/rustdoc/escape-deref-methods.rs index a62ad2c4001..66919d73eeb 100644 --- a/src/test/rustdoc/escape-deref-methods.rs +++ b/src/test/rustdoc/escape-deref-methods.rs @@ -27,7 +27,7 @@ impl Deref for TitleList { } // @has foo/struct.TitleList.html -// @has - '//*[@class="sidebar-title"]' 'Methods from Deref<Target=Vec<Title>>' +// @has - '//div[@class="sidebar-elems"]//h3' 'Methods from Deref<Target=Vec<Title>>' impl DerefMut for TitleList { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.members diff --git a/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.out0.html b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.out0.html new file mode 100644 index 00000000000..8934bc1ee33 --- /dev/null +++ b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.out0.html @@ -0,0 +1 @@ +<h4 class="code-header">type <a href="#associatedtype.Out0" class="associatedtype">Out0</a>: <a class="trait" href="../assoc_item_trait_bounds/trait.Support.html" title="trait assoc_item_trait_bounds::Support">Support</a><Item = <a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>></h4> \ No newline at end of file diff --git a/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.out2.html b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.out2.html new file mode 100644 index 00000000000..bf330670ed0 --- /dev/null +++ b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.out2.html @@ -0,0 +1 @@ +<h4 class="code-header">type <a href="#associatedtype.Out2" class="associatedtype">Out2</a><T>: <a class="trait" href="../assoc_item_trait_bounds/trait.Support.html" title="trait assoc_item_trait_bounds::Support">Support</a><Item = T></h4> \ No newline at end of file diff --git a/src/test/rustdoc/inline_cross/assoc_item_trait_bounds_with_bindings.out9.html b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.out9.html index 69d84e1b2c1..69d84e1b2c1 100644 --- a/src/test/rustdoc/inline_cross/assoc_item_trait_bounds_with_bindings.out9.html +++ b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.out9.html diff --git a/src/test/rustdoc/inline_cross/assoc_item_trait_bounds_with_bindings.rs b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.rs index 00976aa7442..5f4712aab5b 100644 --- a/src/test/rustdoc/inline_cross/assoc_item_trait_bounds_with_bindings.rs +++ b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds.rs @@ -1,13 +1,10 @@ // Regression test for issues #77763, #84579 and #102142. #![crate_name = "main"] -// aux-build:assoc_item_trait_bounds_with_bindings.rs +// aux-build:assoc_item_trait_bounds.rs // build-aux-docs // ignore-cross-compile -extern crate assoc_item_trait_bounds_with_bindings as aux; - -// FIXME(fmease): Don't render an incorrect `T: ?Sized` where-clause for parameters -// of GATs like `Main::Out{2,4}`. Add a snapshot test once it's fixed. +extern crate assoc_item_trait_bounds as aux; // @has main/trait.Main.html // @has - '//*[@id="associatedtype.Out0"]' 'type Out0: Support<Item = ()>' @@ -24,11 +21,15 @@ extern crate assoc_item_trait_bounds_with_bindings as aux; // @has - '//*[@id="associatedtype.Out11"]' "type Out11: for<'r, 's> Helper<A<'s> = &'s (), B<'r> = ()>" // @has - '//*[@id="associatedtype.Out12"]' "type Out12: for<'w> Helper<B<'w> = Cow<'w, str>, A<'w> = bool>" // @has - '//*[@id="associatedtype.Out13"]' "type Out13: for<'fst, 'snd> Aid<'snd, Result<'fst> = &'fst mut str>" +// @has - '//*[@id="associatedtype.Out14"]' "type Out14<P: Copy + Eq, Q: ?Sized>" // -// Snapshots: Check that we do not render any where-clauses for those associated types since all of -// the trait bounds contained within were moved to the bounds of the respective item. +// Snapshots: +// Check that we don't render any where-clauses for the following associated types since +// all corresponding projection equality predicates should have already been re-sugared +// to associated type bindings: // // @snapshot out0 - '//*[@id="associatedtype.Out0"]/*[@class="code-header"]' +// @snapshot out2 - '//*[@id="associatedtype.Out2"]/*[@class="code-header"]' // @snapshot out9 - '//*[@id="associatedtype.Out9"]/*[@class="code-header"]' // // @has - '//*[@id="tymethod.make"]' \ diff --git a/src/test/rustdoc/inline_cross/assoc_item_trait_bounds_with_bindings.out0.html b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds_with_bindings.out0.html deleted file mode 100644 index 927a1a42a1f..00000000000 --- a/src/test/rustdoc/inline_cross/assoc_item_trait_bounds_with_bindings.out0.html +++ /dev/null @@ -1 +0,0 @@ -<h4 class="code-header">type <a href="#associatedtype.Out0" class="associatedtype">Out0</a>: <a class="trait" href="../assoc_item_trait_bounds_with_bindings/trait.Support.html" title="trait assoc_item_trait_bounds_with_bindings::Support">Support</a><Item = <a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>></h4> \ No newline at end of file diff --git a/src/test/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds_with_bindings.rs b/src/test/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs index f451b1a0e99..d326e61daea 100644 --- a/src/test/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds_with_bindings.rs +++ b/src/test/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs @@ -15,6 +15,7 @@ pub trait Main { type Out11: for<'r, 's> Helper<A<'s> = &'s (), B<'r> = ()>; type Out12: for<'w> Helper<B<'w> = std::borrow::Cow<'w, str>, A<'w> = bool>; type Out13: for<'fst, 'snd> Aid<'snd, Result<'fst> = &'fst mut str>; + type Out14<P: Copy + Eq, Q: ?Sized>; fn make<F>(_: F, _: impl FnMut(&str) -> bool) where diff --git a/src/test/rustdoc/inline_cross/auxiliary/issue-24183.rs b/src/test/rustdoc/inline_cross/auxiliary/issue-24183.rs new file mode 100644 index 00000000000..e7a13acc6f8 --- /dev/null +++ b/src/test/rustdoc/inline_cross/auxiliary/issue-24183.rs @@ -0,0 +1,14 @@ +#![crate_type = "lib"] + +pub trait U/*: ?Sized */ { + fn modified(self) -> Self + where + Self: Sized + { + self + } + + fn touch(&self)/* where Self: ?Sized */{} +} + +pub trait S: Sized {} diff --git a/src/test/rustdoc/inline_cross/issue-24183.method_no_where_self_sized.html b/src/test/rustdoc/inline_cross/issue-24183.method_no_where_self_sized.html new file mode 100644 index 00000000000..6955a961499 --- /dev/null +++ b/src/test/rustdoc/inline_cross/issue-24183.method_no_where_self_sized.html @@ -0,0 +1 @@ +<h4 class="code-header">fn <a href="#method.touch" class="fnname">touch</a>(&self)</h4> \ No newline at end of file diff --git a/src/test/rustdoc/inline_cross/issue-24183.rs b/src/test/rustdoc/inline_cross/issue-24183.rs new file mode 100644 index 00000000000..d11b6955f3c --- /dev/null +++ b/src/test/rustdoc/inline_cross/issue-24183.rs @@ -0,0 +1,18 @@ +#![crate_type = "lib"] +#![crate_name = "usr"] + +// aux-crate:issue_24183=issue-24183.rs +// edition: 2021 + +// @has usr/trait.U.html +// @has - '//*[@class="item-decl"]' "pub trait U {" +// @has - '//*[@id="method.modified"]' \ +// "fn modified(self) -> Self\ +// where \ +// Self: Sized" +// @snapshot method_no_where_self_sized - '//*[@id="method.touch"]/*[@class="code-header"]' +pub use issue_24183::U; + +// @has usr/trait.S.html +// @has - '//*[@class="item-decl"]' 'pub trait S: Sized {' +pub use issue_24183::S; diff --git a/src/test/rustdoc/intra-doc/no-doc-primitive.rs b/src/test/rustdoc/intra-doc/no-doc-primitive.rs new file mode 100644 index 00000000000..e5eba1d8d48 --- /dev/null +++ b/src/test/rustdoc/intra-doc/no-doc-primitive.rs @@ -0,0 +1,15 @@ +// Crate tree without a `doc(primitive)` module for primitive type linked to by a doc link. + +#![deny(rustdoc::broken_intra_doc_links)] +#![feature(no_core, lang_items, rustc_attrs)] +#![no_core] +#![rustc_coherence_is_core] +#![crate_type = "rlib"] + +// @has no_doc_primitive/index.html +//! A [`char`] and its [`char::len_utf8`]. +impl char { + pub fn len_utf8(self) -> usize { + 42 + } +} diff --git a/src/test/rustdoc/issue-100241.rs b/src/test/rustdoc/issue-100241.rs new file mode 100644 index 00000000000..9e9cba13a22 --- /dev/null +++ b/src/test/rustdoc/issue-100241.rs @@ -0,0 +1,12 @@ +//! See [`S`]. + +// Check that this isn't an ICE +// should-fail + +mod foo { + pub use inner::S; + //~^ ERROR unresolved imports `inner`, `foo::S` +} + +use foo::*; +use foo::S; diff --git a/src/test/rustdoc/logo-class-default.rs b/src/test/rustdoc/logo-class-default.rs index a7016d227b1..d2d4391997f 100644 --- a/src/test/rustdoc/logo-class-default.rs +++ b/src/test/rustdoc/logo-class-default.rs @@ -1,4 +1,4 @@ // Note: this test is paired with logo-class.rs. // @has logo_class_default/struct.SomeStruct.html '//*[@class="logo-container"]/img[@class="rust-logo"]' '' -// @has logo_class_default/struct.SomeStruct.html '//*[@class="sub-logo-container"]/img[@class="rust-logo"]' '' +// @has src/logo_class_default/logo-class-default.rs.html '//*[@class="sub-logo-container"]/img[@class="rust-logo"]' '' pub struct SomeStruct; diff --git a/src/test/rustdoc/logo-class.rs b/src/test/rustdoc/logo-class.rs index f071f356a6d..d3aa446dab9 100644 --- a/src/test/rustdoc/logo-class.rs +++ b/src/test/rustdoc/logo-class.rs @@ -5,6 +5,6 @@ // @has logo_class/struct.SomeStruct.html '//*[@class="logo-container"]/img[@src="https://raw.githubusercontent.com/sagebind/isahc/master/media/isahc.svg.png"]' '' // @!has logo_class/struct.SomeStruct.html '//*[@class="logo-container"]/img[@class="rust-logo"]' '' // -// @has logo_class/struct.SomeStruct.html '//*[@class="sub-logo-container"]/img[@src="https://raw.githubusercontent.com/sagebind/isahc/master/media/isahc.svg.png"]' '' -// @!has logo_class/struct.SomeStruct.html '//*[@class="sub-logo-container"]/img[@class="rust-logo"]' '' +// @has src/logo_class/logo-class.rs.html '//*[@class="sub-logo-container"]/img[@src="https://raw.githubusercontent.com/sagebind/isahc/master/media/isahc.svg.png"]' '' +// @!has src/logo_class/logo-class.rs.html '//*[@class="sub-logo-container"]/img[@class="rust-logo"]' '' pub struct SomeStruct; diff --git a/src/test/rustdoc/negative-impl-sidebar.rs b/src/test/rustdoc/negative-impl-sidebar.rs index b995fff1f9a..4af6d008492 100644 --- a/src/test/rustdoc/negative-impl-sidebar.rs +++ b/src/test/rustdoc/negative-impl-sidebar.rs @@ -4,6 +4,6 @@ pub struct Foo; // @has foo/struct.Foo.html -// @has - '//*[@class="sidebar-title"]/a[@href="#trait-implementations"]' 'Trait Implementations' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#trait-implementations"]' 'Trait Implementations' // @has - '//*[@class="sidebar-elems"]//section//a' '!Sync' impl !Sync for Foo {} diff --git a/src/test/rustdoc/not-wf-ambiguous-normalization.rs b/src/test/rustdoc/not-wf-ambiguous-normalization.rs new file mode 100644 index 00000000000..1e9f925f845 --- /dev/null +++ b/src/test/rustdoc/not-wf-ambiguous-normalization.rs @@ -0,0 +1,24 @@ +// compile-flags: -Znormalize-docs + +#![feature(type_alias_impl_trait)] + +trait Allocator { + type Buffer; +} + +struct DefaultAllocator; + +// This unconstrained impl parameter causes the normalization of +// `<DefaultAllocator as Allocator>::Buffer` to be ambiguous, +// which caused an ICE with `-Znormalize-docs`. +impl<T> Allocator for DefaultAllocator { + type Buffer = (); +} + +type A = impl Fn(<DefaultAllocator as Allocator>::Buffer); + +fn foo() -> A { + |_| () +} + +fn main() {} diff --git a/src/test/rustdoc/sidebar-items.rs b/src/test/rustdoc/sidebar-items.rs index b5b681ab085..6f7afa59bdd 100644 --- a/src/test/rustdoc/sidebar-items.rs +++ b/src/test/rustdoc/sidebar-items.rs @@ -2,17 +2,17 @@ #![crate_name = "foo"] // @has foo/trait.Foo.html -// @has - '//*[@class="sidebar-title"]/a[@href="#required-methods"]' 'Required Methods' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#required-methods"]' 'Required Methods' // @has - '//*[@class="sidebar-elems"]//section//a' 'bar' -// @has - '//*[@class="sidebar-title"]/a[@href="#provided-methods"]' 'Provided Methods' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#provided-methods"]' 'Provided Methods' // @has - '//*[@class="sidebar-elems"]//section//a' 'foo' -// @has - '//*[@class="sidebar-title"]/a[@href="#required-associated-consts"]' 'Required Associated Constants' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#required-associated-consts"]' 'Required Associated Constants' // @has - '//*[@class="sidebar-elems"]//section//a' 'FOO' -// @has - '//*[@class="sidebar-title"]/a[@href="#provided-associated-consts"]' 'Provided Associated Constants' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#provided-associated-consts"]' 'Provided Associated Constants' // @has - '//*[@class="sidebar-elems"]//section//a' 'BAR' -// @has - '//*[@class="sidebar-title"]/a[@href="#required-associated-types"]' 'Required Associated Types' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#required-associated-types"]' 'Required Associated Types' // @has - '//*[@class="sidebar-elems"]//section//a' 'Output' -// @has - '//*[@class="sidebar-title"]/a[@href="#provided-associated-types"]' 'Provided Associated Types' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#provided-associated-types"]' 'Provided Associated Types' // @has - '//*[@class="sidebar-elems"]//section//a' 'Extra' pub trait Foo { const FOO: usize; @@ -25,7 +25,7 @@ pub trait Foo { } // @has foo/struct.Bar.html -// @has - '//*[@class="sidebar-title"]/a[@href="#fields"]' 'Fields' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#fields"]' 'Fields' // @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f"]' 'f' // @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.u"]' 'u' // @!has - '//*[@class="sidebar-elems"]//section//a' 'waza' @@ -36,7 +36,7 @@ pub struct Bar { } // @has foo/enum.En.html -// @has - '//*[@class="sidebar-title"]/a[@href="#variants"]' 'Variants' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#variants"]' 'Variants' // @has - '//*[@class="sidebar-elems"]//section//a' 'Foo' // @has - '//*[@class="sidebar-elems"]//section//a' 'Bar' pub enum En { @@ -45,7 +45,7 @@ pub enum En { } // @has foo/union.MyUnion.html -// @has - '//*[@class="sidebar-title"]/a[@href="#fields"]' 'Fields' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#fields"]' 'Fields' // @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f1"]' 'f1' // @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f2"]' 'f2' // @!has - '//*[@class="sidebar-elems"]//section//a' 'waza' diff --git a/src/test/rustdoc/sidebar-links-to-foreign-impl.rs b/src/test/rustdoc/sidebar-links-to-foreign-impl.rs index 6712af527a3..11e94694802 100644 --- a/src/test/rustdoc/sidebar-links-to-foreign-impl.rs +++ b/src/test/rustdoc/sidebar-links-to-foreign-impl.rs @@ -3,7 +3,7 @@ #![crate_name = "foo"] // @has foo/trait.Foo.html -// @has - '//*[@class="sidebar-title"]/a[@href="#foreign-impls"]' 'Implementations on Foreign Types' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#foreign-impls"]' 'Implementations on Foreign Types' // @has - '//h2[@id="foreign-impls"]' 'Implementations on Foreign Types' // @has - '//*[@class="sidebar-elems"]//section//a[@href="#impl-Foo-for-u32"]' 'u32' // @has - '//*[@id="impl-Foo-for-u32"]//h3[@class="code-header"]' 'impl Foo for u32' diff --git a/src/test/rustdoc/tuple-struct-fields-doc.rs b/src/test/rustdoc/tuple-struct-fields-doc.rs index 66bb409325c..8ab1143d1f7 100644 --- a/src/test/rustdoc/tuple-struct-fields-doc.rs +++ b/src/test/rustdoc/tuple-struct-fields-doc.rs @@ -2,7 +2,7 @@ // @has foo/struct.Foo.html // @has - '//h2[@id="fields"]' 'Tuple Fields' -// @has - '//h3[@class="sidebar-title"]/a[@href="#fields"]' 'Tuple Fields' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#fields"]' 'Tuple Fields' // @has - '//*[@id="structfield.0"]' '0: u32' // @has - '//*[@id="main-content"]/div[@class="docblock"]' 'hello' // @!has - '//*[@id="structfield.1"]' '' diff --git a/src/test/ui-fulldeps/fluent-messages/test.rs b/src/test/ui-fulldeps/fluent-messages/test.rs index 256857e52a7..4e8147e2b76 100644 --- a/src/test/ui-fulldeps/fluent-messages/test.rs +++ b/src/test/ui-fulldeps/fluent-messages/test.rs @@ -49,6 +49,7 @@ mod duplicate { use super::fluent_messages; fluent_messages! { +//~^ ERROR the name `a_b_key` is defined multiple times a => "./duplicate-a.ftl", a_b => "./duplicate-a-b.ftl", //~^ ERROR overrides existing message: `a_b_key` @@ -80,7 +81,7 @@ mod valid { valid => "./valid.ftl", } - use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, valid::key}; + use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, valid_key}; } mod missing_crate_name { @@ -93,5 +94,5 @@ mod missing_crate_name { //~| ERROR name `with-hyphens` does not start with the crate name } - use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, test_crate::{foo, with_hyphens}}; + use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, test_crate_foo, with_hyphens}; } diff --git a/src/test/ui-fulldeps/fluent-messages/test.stderr b/src/test/ui-fulldeps/fluent-messages/test.stderr index 26d87430a8f..d1cd4fe26da 100644 --- a/src/test/ui-fulldeps/fluent-messages/test.stderr +++ b/src/test/ui-fulldeps/fluent-messages/test.stderr @@ -30,19 +30,31 @@ error: expected a message field for "missing_message" | error: overrides existing message: `a_b_key` - --> $DIR/test.rs:53:16 + --> $DIR/test.rs:54:16 | LL | a_b => "./duplicate-a-b.ftl", | ^^^^^^^^^^^^^^^^^^^^^ | help: previously defined in this resource - --> $DIR/test.rs:52:14 + --> $DIR/test.rs:53:14 | LL | a => "./duplicate-a.ftl", | ^^^^^^^^^^^^^^^^^^^ +error[E0428]: the name `a_b_key` is defined multiple times + --> $DIR/test.rs:51:5 + | +LL | fluent_messages! { + | ^^^^^^^^^^^^^^^^ + | | + | `a_b_key` redefined here + | previous definition of the value `a_b_key` here + | + = note: os-specific message + = note: os-specific message + error: name `slug_with_hyphens_this-slug-has-hyphens` contains a '-' character - --> $DIR/test.rs:62:30 + --> $DIR/test.rs:63:30 | LL | slug_with_hyphens => "./slug-with-hyphens.ftl", | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -50,7 +62,7 @@ LL | slug_with_hyphens => "./slug-with-hyphens.ftl", = help: replace any '-'s with '_'s error: attribute `label-has-hyphens` contains a '-' character - --> $DIR/test.rs:71:31 + --> $DIR/test.rs:72:31 | LL | label_with_hyphens => "./label-with-hyphens.ftl", | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -58,7 +70,7 @@ LL | label_with_hyphens => "./label-with-hyphens.ftl", = help: replace any '-'s with '_'s error: name `with-hyphens` contains a '-' character - --> $DIR/test.rs:90:23 + --> $DIR/test.rs:91:23 | LL | test_crate => "./missing-crate-name.ftl", | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -66,7 +78,7 @@ LL | test_crate => "./missing-crate-name.ftl", = help: replace any '-'s with '_'s error: name `with-hyphens` does not start with the crate name - --> $DIR/test.rs:90:23 + --> $DIR/test.rs:91:23 | LL | test_crate => "./missing-crate-name.ftl", | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -74,12 +86,13 @@ LL | test_crate => "./missing-crate-name.ftl", = help: prepend `test_crate_` to the slug name: `test_crate_with_hyphens` error: name `test-crate_foo` contains a '-' character - --> $DIR/test.rs:90:23 + --> $DIR/test.rs:91:23 | LL | test_crate => "./missing-crate-name.ftl", | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: replace any '-'s with '_'s -error: aborting due to 9 previous errors +error: aborting due to 10 previous errors +For more information about this error, try `rustc --explain E0428`. diff --git a/src/test/ui-fulldeps/internal-lints/diagnostics.rs b/src/test/ui-fulldeps/internal-lints/diagnostics.rs index 462f5e78498..643e81d99c6 100644 --- a/src/test/ui-fulldeps/internal-lints/diagnostics.rs +++ b/src/test/ui-fulldeps/internal-lints/diagnostics.rs @@ -19,14 +19,14 @@ use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::Span; #[derive(Diagnostic)] -#[diag(compiletest::example)] +#[diag(compiletest_example)] struct DeriveDiagnostic { #[primary_span] span: Span, } #[derive(Subdiagnostic)] -#[note(compiletest::example)] +#[note(compiletest_example)] struct Note { #[primary_span] span: Span, @@ -45,7 +45,7 @@ pub struct TranslatableInIntoDiagnostic; impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for TranslatableInIntoDiagnostic { fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> { - handler.struct_err(fluent::compiletest::example) + handler.struct_err(fluent::compiletest_example) } } @@ -68,12 +68,12 @@ impl AddToDiagnostic for TranslatableInAddToDiagnostic { where F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage, { - diag.note(fluent::compiletest::note); + diag.note(fluent::note); } } pub fn make_diagnostics<'a>(handler: &'a Handler) { - let _diag = handler.struct_err(fluent::compiletest::example); + let _diag = handler.struct_err(fluent::compiletest_example); //~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls let _diag = handler.struct_err("untranslatable diagnostic"); diff --git a/src/test/ui-fulldeps/internal-lints/diagnostics.stderr b/src/test/ui-fulldeps/internal-lints/diagnostics.stderr index ac820a79db2..510d6a17108 100644 --- a/src/test/ui-fulldeps/internal-lints/diagnostics.stderr +++ b/src/test/ui-fulldeps/internal-lints/diagnostics.stderr @@ -19,7 +19,7 @@ LL | diag.note("untranslatable diagnostic"); error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls --> $DIR/diagnostics.rs:76:25 | -LL | let _diag = handler.struct_err(fluent::compiletest::example); +LL | let _diag = handler.struct_err(fluent::compiletest_example); | ^^^^^^^^^^ | note: the lint level is defined here diff --git a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs index e873c36e0b3..46164d573b0 100644 --- a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs +++ b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs @@ -28,15 +28,15 @@ use rustc_errors::{Applicability, MultiSpan}; extern crate rustc_session; #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct Hello {} #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct HelloWarn {} #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] //~^ ERROR unsupported type attribute for diagnostic derive enum enum DiagnosticOnEnum { Foo, @@ -46,13 +46,13 @@ enum DiagnosticOnEnum { } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] #[diag = "E0123"] //~^ ERROR `#[diag = ...]` is not a valid attribute struct WrongStructAttrStyle {} #[derive(Diagnostic)] -#[nonsense(compiletest::example, code = "E0123")] +#[nonsense(compiletest_example, code = "E0123")] //~^ ERROR `#[nonsense(...)]` is not a valid attribute //~^^ ERROR diagnostic slug not specified //~^^^ ERROR cannot find attribute `nonsense` in this scope @@ -90,12 +90,12 @@ struct InvalidNestedStructAttr2 {} struct InvalidNestedStructAttr3 {} #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123", slug = "foo")] +#[diag(compiletest_example, code = "E0123", slug = "foo")] //~^ ERROR `#[diag(slug = ...)]` is not a valid attribute struct InvalidNestedStructAttr4 {} #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct WrongPlaceField { #[suggestion = "bar"] //~^ ERROR `#[suggestion = ...]` is not a valid attribute @@ -103,20 +103,20 @@ struct WrongPlaceField { } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] -#[diag(compiletest::example, code = "E0456")] +#[diag(compiletest_example, code = "E0123")] +#[diag(compiletest_example, code = "E0456")] //~^ ERROR specified multiple times //~^^ ERROR specified multiple times struct DiagSpecifiedTwice {} #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0456", code = "E0457")] +#[diag(compiletest_example, code = "E0456", code = "E0457")] //~^ ERROR specified multiple times struct CodeSpecifiedTwice {} #[derive(Diagnostic)] -#[diag(compiletest::example, compiletest::example, code = "E0456")] -//~^ ERROR `#[diag(compiletest::example)]` is not a valid attribute +#[diag(compiletest_example, compiletest_example, code = "E0456")] +//~^ ERROR `#[diag(compiletest_example)]` is not a valid attribute struct SlugSpecifiedTwice {} #[derive(Diagnostic)] @@ -128,11 +128,11 @@ struct KindNotProvided {} //~ ERROR diagnostic slug not specified struct SlugNotProvided {} #[derive(Diagnostic)] -#[diag(compiletest::example)] +#[diag(compiletest_example)] struct CodeNotProvided {} #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct MessageWrongType { #[primary_span] //~^ ERROR `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan` @@ -140,7 +140,7 @@ struct MessageWrongType { } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct InvalidPathFieldAttr { #[nonsense] //~^ ERROR `#[nonsense]` is not a valid attribute @@ -149,34 +149,34 @@ struct InvalidPathFieldAttr { } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithField { name: String, - #[label(compiletest::label)] + #[label(label)] span: Span, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithMessageAppliedToField { - #[label(compiletest::label)] + #[label(label)] //~^ ERROR the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` name: String, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithNonexistentField { - #[suggestion(compiletest::suggestion, code = "{name}")] + #[suggestion(suggestion, code = "{name}")] //~^ ERROR `name` doesn't refer to a field on this type suggestion: (Span, Applicability), } #[derive(Diagnostic)] //~^ ERROR invalid format string: expected `'}'` -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ErrorMissingClosingBrace { - #[suggestion(compiletest::suggestion, code = "{name")] + #[suggestion(suggestion, code = "{name")] suggestion: (Span, Applicability), name: String, val: usize, @@ -184,49 +184,49 @@ struct ErrorMissingClosingBrace { #[derive(Diagnostic)] //~^ ERROR invalid format string: unmatched `}` -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ErrorMissingOpeningBrace { - #[suggestion(compiletest::suggestion, code = "name}")] + #[suggestion(suggestion, code = "name}")] suggestion: (Span, Applicability), name: String, val: usize, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct LabelOnSpan { - #[label(compiletest::label)] + #[label(label)] sp: Span, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct LabelOnNonSpan { - #[label(compiletest::label)] + #[label(label)] //~^ ERROR the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` id: u32, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct Suggest { - #[suggestion(compiletest::suggestion, code = "This is the suggested code")] - #[suggestion_short(compiletest::suggestion, code = "This is the suggested code")] - #[suggestion_hidden(compiletest::suggestion, code = "This is the suggested code")] - #[suggestion_verbose(compiletest::suggestion, code = "This is the suggested code")] + #[suggestion(suggestion, code = "This is the suggested code")] + #[suggestion_short(suggestion, code = "This is the suggested code")] + #[suggestion_hidden(suggestion, code = "This is the suggested code")] + #[suggestion_verbose(suggestion, code = "This is the suggested code")] suggestion: (Span, Applicability), } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct SuggestWithoutCode { - #[suggestion(compiletest::suggestion)] + #[suggestion(suggestion)] //~^ ERROR suggestion without `code = "..."` suggestion: (Span, Applicability), } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct SuggestWithBadKey { #[suggestion(nonsense = "bar")] //~^ ERROR `#[suggestion(nonsense = ...)]` is not a valid attribute @@ -235,7 +235,7 @@ struct SuggestWithBadKey { } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct SuggestWithShorthandMsg { #[suggestion(msg = "bar")] //~^ ERROR `#[suggestion(msg = ...)]` is not a valid attribute @@ -244,52 +244,52 @@ struct SuggestWithShorthandMsg { } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct SuggestWithoutMsg { #[suggestion(code = "bar")] suggestion: (Span, Applicability), } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct SuggestWithTypesSwapped { - #[suggestion(compiletest::suggestion, code = "This is suggested code")] + #[suggestion(suggestion, code = "This is suggested code")] suggestion: (Applicability, Span), } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct SuggestWithWrongTypeApplicabilityOnly { - #[suggestion(compiletest::suggestion, code = "This is suggested code")] + #[suggestion(suggestion, code = "This is suggested code")] //~^ ERROR wrong field type for suggestion suggestion: Applicability, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct SuggestWithSpanOnly { - #[suggestion(compiletest::suggestion, code = "This is suggested code")] + #[suggestion(suggestion, code = "This is suggested code")] suggestion: Span, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct SuggestWithDuplicateSpanAndApplicability { - #[suggestion(compiletest::suggestion, code = "This is suggested code")] + #[suggestion(suggestion, code = "This is suggested code")] suggestion: (Span, Span, Applicability), //~^ ERROR specified multiple times } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct SuggestWithDuplicateApplicabilityAndSpan { - #[suggestion(compiletest::suggestion, code = "This is suggested code")] + #[suggestion(suggestion, code = "This is suggested code")] suggestion: (Applicability, Applicability, Span), //~^ ERROR specified multiple times } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct WrongKindOfAnnotation { #[label = "bar"] //~^ ERROR `#[label = ...]` is not a valid attribute @@ -297,38 +297,38 @@ struct WrongKindOfAnnotation { } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct OptionsInErrors { - #[label(compiletest::label)] + #[label(label)] label: Option<Span>, - #[suggestion(compiletest::suggestion, code = "...")] + #[suggestion(suggestion, code = "...")] opt_sugg: Option<(Span, Applicability)>, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0456")] +#[diag(compiletest_example, code = "E0456")] struct MoveOutOfBorrowError<'tcx> { name: Ident, ty: Ty<'tcx>, #[primary_span] - #[label(compiletest::label)] + #[label(label)] span: Span, - #[label(compiletest::label)] + #[label(label)] other_span: Span, - #[suggestion(compiletest::suggestion, code = "{name}.clone()")] + #[suggestion(suggestion, code = "{name}.clone()")] opt_sugg: Option<(Span, Applicability)>, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithLifetime<'a> { - #[label(compiletest::label)] + #[label(label)] span: Span, name: &'a str, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithDefaultLabelAttr<'a> { #[label] span: Span, @@ -337,7 +337,7 @@ struct ErrorWithDefaultLabelAttr<'a> { #[derive(Diagnostic)] //~^ ERROR the trait bound `Hello: IntoDiagnosticArg` is not satisfied -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ArgFieldWithoutSkip { #[primary_span] span: Span, @@ -345,7 +345,7 @@ struct ArgFieldWithoutSkip { } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ArgFieldWithSkip { #[primary_span] span: Span, @@ -356,132 +356,132 @@ struct ArgFieldWithSkip { } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithSpannedNote { #[note] span: Span, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithSpannedNoteCustom { - #[note(compiletest::note)] + #[note(note)] span: Span, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] #[note] struct ErrorWithNote { val: String, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] -#[note(compiletest::note)] +#[diag(compiletest_example, code = "E0123")] +#[note(note)] struct ErrorWithNoteCustom { val: String, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithSpannedHelp { #[help] span: Span, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithSpannedHelpCustom { - #[help(compiletest::help)] + #[help(help)] span: Span, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] #[help] struct ErrorWithHelp { val: String, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] -#[help(compiletest::help)] +#[diag(compiletest_example, code = "E0123")] +#[help(help)] struct ErrorWithHelpCustom { val: String, } #[derive(Diagnostic)] #[help] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithHelpWrongOrder { val: String, } #[derive(Diagnostic)] -#[help(compiletest::help)] -#[diag(compiletest::example, code = "E0123")] +#[help(help)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithHelpCustomWrongOrder { val: String, } #[derive(Diagnostic)] #[note] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithNoteWrongOrder { val: String, } #[derive(Diagnostic)] -#[note(compiletest::note)] -#[diag(compiletest::example, code = "E0123")] +#[note(note)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithNoteCustomWrongOrder { val: String, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ApplicabilityInBoth { - #[suggestion(compiletest::suggestion, code = "...", applicability = "maybe-incorrect")] + #[suggestion(suggestion, code = "...", applicability = "maybe-incorrect")] //~^ ERROR specified multiple times suggestion: (Span, Applicability), } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct InvalidApplicability { - #[suggestion(compiletest::suggestion, code = "...", applicability = "batman")] + #[suggestion(suggestion, code = "...", applicability = "batman")] //~^ ERROR invalid applicability suggestion: Span, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ValidApplicability { - #[suggestion(compiletest::suggestion, code = "...", applicability = "maybe-incorrect")] + #[suggestion(suggestion, code = "...", applicability = "maybe-incorrect")] suggestion: Span, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct NoApplicability { - #[suggestion(compiletest::suggestion, code = "...")] + #[suggestion(suggestion, code = "...")] suggestion: Span, } #[derive(Subdiagnostic)] -#[note(parser::add_paren)] +#[note(parser_add_paren)] struct Note; #[derive(Diagnostic)] -#[diag(compiletest::example)] +#[diag(compiletest_example)] struct Subdiagnostic { #[subdiagnostic] note: Note, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct VecField { #[primary_span] #[label] @@ -489,58 +489,58 @@ struct VecField { } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct UnitField { #[primary_span] spans: Span, #[help] foo: (), - #[help(compiletest::help)] + #[help(help)] bar: (), } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct OptUnitField { #[primary_span] spans: Span, #[help] foo: Option<()>, - #[help(compiletest::help)] + #[help(help)] bar: Option<()>, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct LabelWithTrailingPath { - #[label(compiletest::label, foo)] + #[label(label, foo)] //~^ ERROR `#[label(foo)]` is not a valid attribute span: Span, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct LabelWithTrailingNameValue { - #[label(compiletest::label, foo = "...")] + #[label(label, foo = "...")] //~^ ERROR `#[label(foo = ...)]` is not a valid attribute span: Span, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct LabelWithTrailingList { - #[label(compiletest::label, foo("..."))] + #[label(label, foo("..."))] //~^ ERROR `#[label(foo(...))]` is not a valid attribute span: Span, } #[derive(LintDiagnostic)] -#[diag(compiletest::example)] +#[diag(compiletest_example)] struct LintsGood { } #[derive(LintDiagnostic)] -#[diag(compiletest::example)] +#[diag(compiletest_example)] struct PrimarySpanOnLint { #[primary_span] //~^ ERROR `#[primary_span]` is not a valid attribute @@ -548,42 +548,42 @@ struct PrimarySpanOnLint { } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithMultiSpan { #[primary_span] span: MultiSpan, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] #[warning] struct ErrorWithWarn { val: String, } #[derive(Diagnostic)] -#[error(compiletest::example, code = "E0123")] +#[error(compiletest_example, code = "E0123")] //~^ ERROR `#[error(...)]` is not a valid attribute //~| ERROR diagnostic slug not specified //~| ERROR cannot find attribute `error` in this scope struct ErrorAttribute {} #[derive(Diagnostic)] -#[warn_(compiletest::example, code = "E0123")] +#[warn_(compiletest_example, code = "E0123")] //~^ ERROR `#[warn_(...)]` is not a valid attribute //~| ERROR diagnostic slug not specified //~| ERROR cannot find attribute `warn_` in this scope struct WarnAttribute {} #[derive(Diagnostic)] -#[lint(compiletest::example, code = "E0123")] +#[lint(compiletest_example, code = "E0123")] //~^ ERROR `#[lint(...)]` is not a valid attribute //~| ERROR diagnostic slug not specified //~| ERROR cannot find attribute `lint` in this scope struct LintAttributeOnSessionDiag {} #[derive(LintDiagnostic)] -#[lint(compiletest::example, code = "E0123")] +#[lint(compiletest_example, code = "E0123")] //~^ ERROR `#[lint(...)]` is not a valid attribute //~| ERROR `#[lint(...)]` is not a valid attribute //~| ERROR diagnostic slug not specified @@ -591,55 +591,55 @@ struct LintAttributeOnSessionDiag {} struct LintAttributeOnLintDiag {} #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct DuplicatedSuggestionCode { - #[suggestion(compiletest::suggestion, code = "...", code = ",,,")] + #[suggestion(suggestion, code = "...", code = ",,,")] //~^ ERROR specified multiple times suggestion: Span, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct InvalidTypeInSuggestionTuple { - #[suggestion(compiletest::suggestion, code = "...")] + #[suggestion(suggestion, code = "...")] suggestion: (Span, usize), //~^ ERROR wrong types for suggestion } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct MissingApplicabilityInSuggestionTuple { - #[suggestion(compiletest::suggestion, code = "...")] + #[suggestion(suggestion, code = "...")] suggestion: (Span,), //~^ ERROR wrong types for suggestion } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct MissingCodeInSuggestion { - #[suggestion(compiletest::suggestion)] + #[suggestion(suggestion)] //~^ ERROR suggestion without `code = "..."` suggestion: Span, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] -#[multipart_suggestion(compiletest::suggestion)] +#[diag(compiletest_example, code = "E0123")] +#[multipart_suggestion(suggestion)] //~^ ERROR `#[multipart_suggestion(...)]` is not a valid attribute //~| ERROR cannot find attribute `multipart_suggestion` in this scope #[multipart_suggestion()] //~^ ERROR `#[multipart_suggestion(...)]` is not a valid attribute //~| ERROR cannot find attribute `multipart_suggestion` in this scope struct MultipartSuggestion { - #[multipart_suggestion(compiletest::suggestion)] + #[multipart_suggestion(suggestion)] //~^ ERROR `#[multipart_suggestion(...)]` is not a valid attribute //~| ERROR cannot find attribute `multipart_suggestion` in this scope suggestion: Span, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] -#[suggestion(compiletest::suggestion, code = "...")] +#[diag(compiletest_example, code = "E0123")] +#[suggestion(suggestion, code = "...")] //~^ ERROR `#[suggestion(...)]` is not a valid attribute struct SuggestionOnStruct { #[primary_span] @@ -647,7 +647,7 @@ struct SuggestionOnStruct { } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] #[label] //~^ ERROR `#[label]` is not a valid attribute struct LabelOnStruct { @@ -657,30 +657,30 @@ struct LabelOnStruct { #[derive(Diagnostic)] enum ExampleEnum { - #[diag(compiletest::example)] + #[diag(compiletest_example)] Foo { #[primary_span] sp: Span, #[note] note_sp: Span, }, - #[diag(compiletest::example)] + #[diag(compiletest_example)] Bar { #[primary_span] sp: Span, }, - #[diag(compiletest::example)] + #[diag(compiletest_example)] Baz, } #[derive(Diagnostic)] -#[diag(compiletest::example, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct RawIdentDiagnosticArg { pub r#type: String, } #[derive(Diagnostic)] -#[diag(compiletest::example)] +#[diag(compiletest_example)] struct SubdiagnosticBad { #[subdiagnostic(bad)] //~^ ERROR `#[subdiagnostic(bad)]` is not a valid attribute @@ -688,7 +688,7 @@ struct SubdiagnosticBad { } #[derive(Diagnostic)] -#[diag(compiletest::example)] +#[diag(compiletest_example)] struct SubdiagnosticBadStr { #[subdiagnostic = "bad"] //~^ ERROR `#[subdiagnostic = ...]` is not a valid attribute @@ -696,7 +696,7 @@ struct SubdiagnosticBadStr { } #[derive(Diagnostic)] -#[diag(compiletest::example)] +#[diag(compiletest_example)] struct SubdiagnosticBadTwice { #[subdiagnostic(bad, bad)] //~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute @@ -704,7 +704,7 @@ struct SubdiagnosticBadTwice { } #[derive(Diagnostic)] -#[diag(compiletest::example)] +#[diag(compiletest_example)] struct SubdiagnosticBadLitStr { #[subdiagnostic("bad")] //~^ ERROR `#[subdiagnostic("...")]` is not a valid attribute @@ -712,7 +712,7 @@ struct SubdiagnosticBadLitStr { } #[derive(LintDiagnostic)] -#[diag(compiletest::example)] +#[diag(compiletest_example)] struct SubdiagnosticEagerLint { #[subdiagnostic(eager)] //~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute @@ -720,7 +720,7 @@ struct SubdiagnosticEagerLint { } #[derive(Diagnostic)] -#[diag(compiletest::example)] +#[diag(compiletest_example)] struct SubdiagnosticEagerCorrect { #[subdiagnostic(eager)] note: Note, @@ -732,7 +732,7 @@ struct SubdiagnosticEagerCorrect { #[derive(Subdiagnostic)] #[suggestion_short( - parser::use_instead, + use_instead, applicability = "machine-applicable", code = "{correct}" )] @@ -744,8 +744,17 @@ pub(crate) struct SubdiagnosticWithSuggestion { } #[derive(Diagnostic)] -#[diag(compiletest::example)] +#[diag(compiletest_example)] struct SubdiagnosticEagerSuggestion { #[subdiagnostic(eager)] sub: SubdiagnosticWithSuggestion, } + +/// with a doc comment on the type.. +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct WithDocComment { + /// ..and the field + #[primary_span] + span: Span, +} diff --git a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr index 7a42d618707..0a1c4bddb06 100644 --- a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr +++ b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -1,8 +1,8 @@ error: unsupported type attribute for diagnostic derive enum --> $DIR/diagnostic-derive.rs:39:1 | -LL | #[diag(compiletest::example, code = "E0123")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[diag(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:42:5 @@ -10,7 +10,7 @@ error: diagnostic slug not specified LL | Foo, | ^^^ | - = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis::example_error)]` + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:44:5 @@ -18,7 +18,7 @@ error: diagnostic slug not specified LL | Bar, | ^^^ | - = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis::example_error)]` + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[diag = ...]` is not a valid attribute --> $DIR/diagnostic-derive.rs:50:1 @@ -29,20 +29,20 @@ LL | #[diag = "E0123"] error: `#[nonsense(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:55:1 | -LL | #[nonsense(compiletest::example, code = "E0123")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[nonsense(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:55:1 | -LL | / #[nonsense(compiletest::example, code = "E0123")] +LL | / #[nonsense(compiletest_example, code = "E0123")] LL | | LL | | LL | | LL | | struct InvalidStructAttr {} | |___________________________^ | - = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis::example_error)]` + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[diag("...")]` is not a valid attribute --> $DIR/diagnostic-derive.rs:62:8 @@ -61,7 +61,7 @@ LL | | LL | | struct InvalidLitNestedAttr {} | |______________________________^ | - = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis::example_error)]` + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[diag(nonsense(...))]` is not a valid attribute --> $DIR/diagnostic-derive.rs:73:8 @@ -80,7 +80,7 @@ LL | | LL | | struct InvalidNestedStructAttr1 {} | |__________________________________^ | - = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis::example_error)]` + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[diag(nonsense = ...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:79:8 @@ -108,7 +108,7 @@ LL | | LL | | struct InvalidNestedStructAttr2 {} | |__________________________________^ | - = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis::example_error)]` + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[diag(nonsense = ...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:86:8 @@ -134,13 +134,13 @@ LL | | LL | | struct InvalidNestedStructAttr3 {} | |__________________________________^ | - = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis::example_error)]` + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[diag(slug = ...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:93:46 + --> $DIR/diagnostic-derive.rs:93:45 | -LL | #[diag(compiletest::example, code = "E0123", slug = "foo")] - | ^^^^^^^^^^^^ +LL | #[diag(compiletest_example, code = "E0123", slug = "foo")] + | ^^^^^^^^^^^^ | = help: only `code` is a valid nested attributes following the slug @@ -153,44 +153,44 @@ LL | #[suggestion = "bar"] error: specified multiple times --> $DIR/diagnostic-derive.rs:107:8 | -LL | #[diag(compiletest::example, code = "E0456")] - | ^^^^^^^^^^^^^^^^^^^^ +LL | #[diag(compiletest_example, code = "E0456")] + | ^^^^^^^^^^^^^^^^^^^ | note: previously specified here --> $DIR/diagnostic-derive.rs:106:8 | -LL | #[diag(compiletest::example, code = "E0123")] - | ^^^^^^^^^^^^^^^^^^^^ +LL | #[diag(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^ error: specified multiple times - --> $DIR/diagnostic-derive.rs:107:37 + --> $DIR/diagnostic-derive.rs:107:36 | -LL | #[diag(compiletest::example, code = "E0456")] - | ^^^^^^^ +LL | #[diag(compiletest_example, code = "E0456")] + | ^^^^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:106:37 + --> $DIR/diagnostic-derive.rs:106:36 | -LL | #[diag(compiletest::example, code = "E0123")] - | ^^^^^^^ +LL | #[diag(compiletest_example, code = "E0123")] + | ^^^^^^^ error: specified multiple times - --> $DIR/diagnostic-derive.rs:113:53 + --> $DIR/diagnostic-derive.rs:113:52 | -LL | #[diag(compiletest::example, code = "E0456", code = "E0457")] - | ^^^^^^^ +LL | #[diag(compiletest_example, code = "E0456", code = "E0457")] + | ^^^^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:113:37 + --> $DIR/diagnostic-derive.rs:113:36 | -LL | #[diag(compiletest::example, code = "E0456", code = "E0457")] - | ^^^^^^^ +LL | #[diag(compiletest_example, code = "E0456", code = "E0457")] + | ^^^^^^^ -error: `#[diag(compiletest::example)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:118:30 +error: `#[diag(compiletest_example)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:118:29 | -LL | #[diag(compiletest::example, compiletest::example, code = "E0456")] - | ^^^^^^^^^^^^^^^^^^^^ +LL | #[diag(compiletest_example, compiletest_example, code = "E0456")] + | ^^^^^^^^^^^^^^^^^^^ | = help: diagnostic slug must be the first argument @@ -200,7 +200,7 @@ error: diagnostic slug not specified LL | struct KindNotProvided {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis::example_error)]` + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:126:1 @@ -210,7 +210,7 @@ LL | | LL | | struct SlugNotProvided {} | |_________________________^ | - = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis::example_error)]` + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan` --> $DIR/diagnostic-derive.rs:137:5 @@ -227,14 +227,14 @@ LL | #[nonsense] error: the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` --> $DIR/diagnostic-derive.rs:162:5 | -LL | #[label(compiletest::label)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[label(label)] + | ^^^^^^^^^^^^^^^ error: `name` doesn't refer to a field on this type - --> $DIR/diagnostic-derive.rs:170:50 + --> $DIR/diagnostic-derive.rs:170:37 | -LL | #[suggestion(compiletest::suggestion, code = "{name}")] - | ^^^^^^^^ +LL | #[suggestion(suggestion, code = "{name}")] + | ^^^^^^^^ error: invalid format string: expected `'}'` but string was terminated --> $DIR/diagnostic-derive.rs:175:10 @@ -257,14 +257,14 @@ LL | #[derive(Diagnostic)] error: the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` --> $DIR/diagnostic-derive.rs:205:5 | -LL | #[label(compiletest::label)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[label(label)] + | ^^^^^^^^^^^^^^^ error: suggestion without `code = "..."` --> $DIR/diagnostic-derive.rs:223:5 | -LL | #[suggestion(compiletest::suggestion)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[suggestion(suggestion)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[suggestion(nonsense = ...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:231:18 @@ -297,7 +297,7 @@ LL | #[suggestion(msg = "bar")] error: wrong field type for suggestion --> $DIR/diagnostic-derive.rs:263:5 | -LL | / #[suggestion(compiletest::suggestion, code = "This is suggested code")] +LL | / #[suggestion(suggestion, code = "This is suggested code")] LL | | LL | | suggestion: Applicability, | |_____________________________^ @@ -335,10 +335,10 @@ LL | #[label = "bar"] | ^^^^^^^^^^^^^^^^ error: specified multiple times - --> $DIR/diagnostic-derive.rs:445:57 + --> $DIR/diagnostic-derive.rs:445:44 | -LL | #[suggestion(compiletest::suggestion, code = "...", applicability = "maybe-incorrect")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[suggestion(suggestion, code = "...", applicability = "maybe-incorrect")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: previously specified here --> $DIR/diagnostic-derive.rs:447:24 @@ -347,30 +347,30 @@ LL | suggestion: (Span, Applicability), | ^^^^^^^^^^^^^ error: invalid applicability - --> $DIR/diagnostic-derive.rs:453:57 + --> $DIR/diagnostic-derive.rs:453:44 | -LL | #[suggestion(compiletest::suggestion, code = "...", applicability = "batman")] - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[suggestion(suggestion, code = "...", applicability = "batman")] + | ^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[label(foo)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:516:33 + --> $DIR/diagnostic-derive.rs:516:20 | -LL | #[label(compiletest::label, foo)] - | ^^^ +LL | #[label(label, foo)] + | ^^^ | = help: a diagnostic slug must be the first argument to the attribute error: `#[label(foo = ...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:524:33 + --> $DIR/diagnostic-derive.rs:524:20 | -LL | #[label(compiletest::label, foo = "...")] - | ^^^^^^^^^^^ +LL | #[label(label, foo = "...")] + | ^^^^^^^^^^^ error: `#[label(foo(...))]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:532:33 + --> $DIR/diagnostic-derive.rs:532:20 | -LL | #[label(compiletest::label, foo("..."))] - | ^^^^^^^^^^ +LL | #[label(label, foo("..."))] + | ^^^^^^^^^^ error: `#[primary_span]` is not a valid attribute --> $DIR/diagnostic-derive.rs:545:5 @@ -383,73 +383,73 @@ LL | #[primary_span] error: `#[error(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:565:1 | -LL | #[error(compiletest::example, code = "E0123")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[error(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:565:1 | -LL | / #[error(compiletest::example, code = "E0123")] +LL | / #[error(compiletest_example, code = "E0123")] LL | | LL | | LL | | LL | | struct ErrorAttribute {} | |________________________^ | - = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis::example_error)]` + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[warn_(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:572:1 | -LL | #[warn_(compiletest::example, code = "E0123")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[warn_(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:572:1 | -LL | / #[warn_(compiletest::example, code = "E0123")] +LL | / #[warn_(compiletest_example, code = "E0123")] LL | | LL | | LL | | LL | | struct WarnAttribute {} | |_______________________^ | - = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis::example_error)]` + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[lint(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:579:1 | -LL | #[lint(compiletest::example, code = "E0123")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[lint(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:579:1 | -LL | / #[lint(compiletest::example, code = "E0123")] +LL | / #[lint(compiletest_example, code = "E0123")] LL | | LL | | LL | | LL | | struct LintAttributeOnSessionDiag {} | |____________________________________^ | - = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis::example_error)]` + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[lint(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:586:1 | -LL | #[lint(compiletest::example, code = "E0123")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[lint(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[lint(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:586:1 | -LL | #[lint(compiletest::example, code = "E0123")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[lint(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:586:1 | -LL | / #[lint(compiletest::example, code = "E0123")] +LL | / #[lint(compiletest_example, code = "E0123")] LL | | LL | | LL | | @@ -457,19 +457,19 @@ LL | | LL | | struct LintAttributeOnLintDiag {} | |_________________________________^ | - = help: specify the slug as the first argument to the attribute, such as `#[diag(compiletest::example)]` + = help: specify the slug as the first argument to the attribute, such as `#[diag(compiletest_example)]` error: specified multiple times - --> $DIR/diagnostic-derive.rs:596:57 + --> $DIR/diagnostic-derive.rs:596:44 | -LL | #[suggestion(compiletest::suggestion, code = "...", code = ",,,")] - | ^^^^^^^^^^^^ +LL | #[suggestion(suggestion, code = "...", code = ",,,")] + | ^^^^^^^^^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:596:43 + --> $DIR/diagnostic-derive.rs:596:30 | -LL | #[suggestion(compiletest::suggestion, code = "...", code = ",,,")] - | ^^^^^^^^^^^^ +LL | #[suggestion(suggestion, code = "...", code = ",,,")] + | ^^^^^^^^^^^^ error: wrong types for suggestion --> $DIR/diagnostic-derive.rs:605:24 @@ -490,14 +490,14 @@ LL | suggestion: (Span,), error: suggestion without `code = "..."` --> $DIR/diagnostic-derive.rs:620:5 | -LL | #[suggestion(compiletest::suggestion)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[suggestion(suggestion)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[multipart_suggestion(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:627:1 | -LL | #[multipart_suggestion(compiletest::suggestion)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[multipart_suggestion(suggestion)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider creating a `Subdiagnostic` instead @@ -512,16 +512,16 @@ LL | #[multipart_suggestion()] error: `#[multipart_suggestion(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:634:5 | -LL | #[multipart_suggestion(compiletest::suggestion)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[multipart_suggestion(suggestion)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider creating a `Subdiagnostic` instead error: `#[suggestion(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:642:1 | -LL | #[suggestion(compiletest::suggestion, code = "...")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[suggestion(suggestion, code = "...")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: `#[label]` and `#[suggestion]` can only be applied to fields @@ -576,7 +576,7 @@ LL | #[subdiagnostic(eager)] error: cannot find attribute `nonsense` in this scope --> $DIR/diagnostic-derive.rs:55:3 | -LL | #[nonsense(compiletest::example, code = "E0123")] +LL | #[nonsense(compiletest_example, code = "E0123")] | ^^^^^^^^ error: cannot find attribute `nonsense` in this scope @@ -588,31 +588,31 @@ LL | #[nonsense] error: cannot find attribute `error` in this scope --> $DIR/diagnostic-derive.rs:565:3 | -LL | #[error(compiletest::example, code = "E0123")] +LL | #[error(compiletest_example, code = "E0123")] | ^^^^^ error: cannot find attribute `warn_` in this scope --> $DIR/diagnostic-derive.rs:572:3 | -LL | #[warn_(compiletest::example, code = "E0123")] +LL | #[warn_(compiletest_example, code = "E0123")] | ^^^^^ help: a built-in attribute with a similar name exists: `warn` error: cannot find attribute `lint` in this scope --> $DIR/diagnostic-derive.rs:579:3 | -LL | #[lint(compiletest::example, code = "E0123")] +LL | #[lint(compiletest_example, code = "E0123")] | ^^^^ help: a built-in attribute with a similar name exists: `link` error: cannot find attribute `lint` in this scope --> $DIR/diagnostic-derive.rs:586:3 | -LL | #[lint(compiletest::example, code = "E0123")] +LL | #[lint(compiletest_example, code = "E0123")] | ^^^^ help: a built-in attribute with a similar name exists: `link` error: cannot find attribute `multipart_suggestion` in this scope --> $DIR/diagnostic-derive.rs:627:3 | -LL | #[multipart_suggestion(compiletest::suggestion)] +LL | #[multipart_suggestion(suggestion)] | ^^^^^^^^^^^^^^^^^^^^ error: cannot find attribute `multipart_suggestion` in this scope @@ -624,7 +624,7 @@ LL | #[multipart_suggestion()] error: cannot find attribute `multipart_suggestion` in this scope --> $DIR/diagnostic-derive.rs:634:7 | -LL | #[multipart_suggestion(compiletest::suggestion)] +LL | #[multipart_suggestion(suggestion)] | ^^^^^^^^^^^^^^^^^^^^ error[E0425]: cannot find value `nonsense` in module `rustc_errors::fluent` diff --git a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs index 84ee5af42de..9088ca6ce46 100644 --- a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs +++ b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs @@ -20,7 +20,7 @@ use rustc_span::Span; use rustc_macros::Subdiagnostic; #[derive(Subdiagnostic)] -#[label(parser::add_paren)] +#[label(parser_add_paren)] struct A { #[primary_span] span: Span, @@ -29,13 +29,13 @@ struct A { #[derive(Subdiagnostic)] enum B { - #[label(parser::add_paren)] + #[label(parser_add_paren)] A { #[primary_span] span: Span, var: String, }, - #[label(parser::add_paren)] + #[label(parser_add_paren)] B { #[primary_span] span: Span, @@ -44,7 +44,7 @@ enum B { } #[derive(Subdiagnostic)] -#[label(parser::add_paren)] +#[label(parser_add_paren)] //~^ ERROR label without `#[primary_span]` field struct C { var: String, @@ -138,7 +138,7 @@ struct M { } #[derive(Subdiagnostic)] -#[label(parser::add_paren, code = "...")] +#[label(parser_add_paren, code = "...")] //~^ ERROR `#[label(code = ...)]` is not a valid attribute struct N { #[primary_span] @@ -147,7 +147,7 @@ struct N { } #[derive(Subdiagnostic)] -#[label(parser::add_paren, applicability = "machine-applicable")] +#[label(parser_add_paren, applicability = "machine-applicable")] //~^ ERROR `#[label(applicability = ...)]` is not a valid attribute struct O { #[primary_span] @@ -160,7 +160,7 @@ struct O { //~^ ERROR cannot find attribute `foo` in this scope //~^^ ERROR unsupported type attribute for subdiagnostic enum enum P { - #[label(parser::add_paren)] + #[label(parser_add_paren)] A { #[primary_span] span: Span, @@ -230,14 +230,13 @@ enum U { #[derive(Subdiagnostic)] enum V { - #[label(parser::add_paren)] + #[label(parser_add_paren)] A { #[primary_span] span: Span, var: String, }, B { - //~^ ERROR subdiagnostic kind not specified #[primary_span] span: Span, var: String, @@ -245,7 +244,7 @@ enum V { } #[derive(Subdiagnostic)] -#[label(parser::add_paren)] +#[label(parser_add_paren)] //~^ ERROR label without `#[primary_span]` field struct W { #[primary_span] @@ -254,7 +253,7 @@ struct W { } #[derive(Subdiagnostic)] -#[label(parser::add_paren)] +#[label(parser_add_paren)] struct X { #[primary_span] span: Span, @@ -264,7 +263,7 @@ struct X { } #[derive(Subdiagnostic)] -#[label(parser::add_paren)] +#[label(parser_add_paren)] struct Y { #[primary_span] span: Span, @@ -275,7 +274,7 @@ struct Y { } #[derive(Subdiagnostic)] -#[label(parser::add_paren)] +#[label(parser_add_paren)] struct Z { #[primary_span] span: Span, @@ -286,7 +285,7 @@ struct Z { } #[derive(Subdiagnostic)] -#[label(parser::add_paren)] +#[label(parser_add_paren)] struct AA { #[primary_span] span: Span, @@ -297,7 +296,7 @@ struct AA { } #[derive(Subdiagnostic)] -#[label(parser::add_paren)] +#[label(parser_add_paren)] struct AB { #[primary_span] span: Span, @@ -313,23 +312,23 @@ union AC { } #[derive(Subdiagnostic)] -#[label(parser::add_paren)] -#[label(parser::add_paren)] +#[label(parser_add_paren)] +#[label(parser_add_paren)] struct AD { #[primary_span] span: Span, } #[derive(Subdiagnostic)] -#[label(parser::add_paren, parser::add_paren)] -//~^ ERROR `#[label(parser::add_paren)]` is not a valid attribute +#[label(parser_add_paren, parser_add_paren)] +//~^ ERROR `#[label(parser_add_paren)]` is not a valid attribute struct AE { #[primary_span] span: Span, } #[derive(Subdiagnostic)] -#[label(parser::add_paren)] +#[label(parser_add_paren)] struct AF { #[primary_span] //~^ NOTE previously specified here @@ -347,7 +346,7 @@ struct AG { } #[derive(Subdiagnostic)] -#[suggestion(parser::add_paren, code = "...")] +#[suggestion(parser_add_paren, code = "...")] struct AH { #[primary_span] span: Span, @@ -358,7 +357,7 @@ struct AH { #[derive(Subdiagnostic)] enum AI { - #[suggestion(parser::add_paren, code = "...")] + #[suggestion(parser_add_paren, code = "...")] A { #[primary_span] span: Span, @@ -366,7 +365,7 @@ enum AI { applicability: Applicability, var: String, }, - #[suggestion(parser::add_paren, code = "...")] + #[suggestion(parser_add_paren, code = "...")] B { #[primary_span] span: Span, @@ -377,7 +376,7 @@ enum AI { } #[derive(Subdiagnostic)] -#[suggestion(parser::add_paren, code = "...", code = "...")] +#[suggestion(parser_add_paren, code = "...", code = "...")] //~^ ERROR specified multiple times //~^^ NOTE previously specified here struct AJ { @@ -388,7 +387,7 @@ struct AJ { } #[derive(Subdiagnostic)] -#[suggestion(parser::add_paren, code = "...")] +#[suggestion(parser_add_paren, code = "...")] struct AK { #[primary_span] span: Span, @@ -401,7 +400,7 @@ struct AK { } #[derive(Subdiagnostic)] -#[suggestion(parser::add_paren, code = "...")] +#[suggestion(parser_add_paren, code = "...")] struct AL { #[primary_span] span: Span, @@ -411,14 +410,14 @@ struct AL { } #[derive(Subdiagnostic)] -#[suggestion(parser::add_paren, code = "...")] +#[suggestion(parser_add_paren, code = "...")] struct AM { #[primary_span] span: Span, } #[derive(Subdiagnostic)] -#[suggestion(parser::add_paren)] +#[suggestion(parser_add_paren)] //~^ ERROR suggestion without `code = "..."` struct AN { #[primary_span] @@ -428,7 +427,7 @@ struct AN { } #[derive(Subdiagnostic)] -#[suggestion(parser::add_paren, code ="...", applicability = "foo")] +#[suggestion(parser_add_paren, code ="...", applicability = "foo")] //~^ ERROR invalid applicability struct AO { #[primary_span] @@ -436,24 +435,24 @@ struct AO { } #[derive(Subdiagnostic)] -#[help(parser::add_paren)] +#[help(parser_add_paren)] struct AP { var: String } #[derive(Subdiagnostic)] -#[note(parser::add_paren)] +#[note(parser_add_paren)] struct AQ; #[derive(Subdiagnostic)] -#[suggestion(parser::add_paren, code = "...")] +#[suggestion(parser_add_paren, code = "...")] //~^ ERROR suggestion without `#[primary_span]` field struct AR { var: String, } #[derive(Subdiagnostic)] -#[suggestion(parser::add_paren, code ="...", applicability = "machine-applicable")] +#[suggestion(parser_add_paren, code ="...", applicability = "machine-applicable")] struct AS { #[primary_span] span: Span, @@ -463,7 +462,7 @@ struct AS { #[label] //~^ ERROR unsupported type attribute for subdiagnostic enum enum AT { - #[label(parser::add_paren)] + #[label(parser_add_paren)] A { #[primary_span] span: Span, @@ -472,7 +471,7 @@ enum AT { } #[derive(Subdiagnostic)] -#[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] +#[suggestion(parser_add_paren, code ="{var}", applicability = "machine-applicable")] struct AU { #[primary_span] span: Span, @@ -480,7 +479,7 @@ struct AU { } #[derive(Subdiagnostic)] -#[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] +#[suggestion(parser_add_paren, code ="{var}", applicability = "machine-applicable")] //~^ ERROR `var` doesn't refer to a field on this type struct AV { #[primary_span] @@ -489,7 +488,7 @@ struct AV { #[derive(Subdiagnostic)] enum AW { - #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] + #[suggestion(parser_add_paren, code ="{var}", applicability = "machine-applicable")] A { #[primary_span] span: Span, @@ -499,7 +498,7 @@ enum AW { #[derive(Subdiagnostic)] enum AX { - #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] + #[suggestion(parser_add_paren, code ="{var}", applicability = "machine-applicable")] //~^ ERROR `var` doesn't refer to a field on this type A { #[primary_span] @@ -508,18 +507,18 @@ enum AX { } #[derive(Subdiagnostic)] -#[warning(parser::add_paren)] +#[warning(parser_add_paren)] struct AY {} #[derive(Subdiagnostic)] -#[warning(parser::add_paren)] +#[warning(parser_add_paren)] struct AZ { #[primary_span] span: Span, } #[derive(Subdiagnostic)] -#[suggestion(parser::add_paren, code = "...")] +#[suggestion(parser_add_paren, code = "...")] //~^ ERROR suggestion without `#[primary_span]` field struct BA { #[suggestion_part] @@ -534,7 +533,7 @@ struct BA { } #[derive(Subdiagnostic)] -#[multipart_suggestion(parser::add_paren, code = "...", applicability = "machine-applicable")] +#[multipart_suggestion(parser_add_paren, code = "...", applicability = "machine-applicable")] //~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields //~| ERROR `#[multipart_suggestion(code = ...)]` is not a valid attribute struct BBa { @@ -542,7 +541,7 @@ struct BBa { } #[derive(Subdiagnostic)] -#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] +#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] struct BBb { #[suggestion_part] //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` @@ -550,7 +549,7 @@ struct BBb { } #[derive(Subdiagnostic)] -#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] +#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] struct BBc { #[suggestion_part()] //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` @@ -558,7 +557,7 @@ struct BBc { } #[derive(Subdiagnostic)] -#[multipart_suggestion(parser::add_paren)] +#[multipart_suggestion(parser_add_paren)] //~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields struct BC { #[primary_span] @@ -567,7 +566,7 @@ struct BC { } #[derive(Subdiagnostic)] -#[multipart_suggestion(parser::add_paren)] +#[multipart_suggestion(parser_add_paren)] struct BD { #[suggestion_part] //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` @@ -587,7 +586,7 @@ struct BD { } #[derive(Subdiagnostic)] -#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] +#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] struct BE { #[suggestion_part(code = "...", code = ",,,")] //~^ ERROR specified multiple times @@ -596,7 +595,7 @@ struct BE { } #[derive(Subdiagnostic)] -#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] +#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] struct BF { #[suggestion_part(code = "(")] first: Span, @@ -605,7 +604,7 @@ struct BF { } #[derive(Subdiagnostic)] -#[multipart_suggestion(parser::add_paren)] +#[multipart_suggestion(parser_add_paren)] struct BG { #[applicability] appl: Applicability, @@ -616,7 +615,7 @@ struct BG { } #[derive(Subdiagnostic)] -#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] +#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] struct BH { #[applicability] //~^ ERROR `#[applicability]` has no effect @@ -628,16 +627,37 @@ struct BH { } #[derive(Subdiagnostic)] -#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] +#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] struct BI { #[suggestion_part(code = "")] spans: Vec<Span>, } #[derive(Subdiagnostic)] -#[label(parser::add_paren)] +#[label(parser_add_paren)] struct BJ { #[primary_span] span: Span, r#type: String, } + +/// with a doc comment on the type.. +#[derive(Subdiagnostic)] +#[label(parser_add_paren)] +struct BK { + /// ..and the field + #[primary_span] + span: Span, +} + +/// with a doc comment on the type.. +#[derive(Subdiagnostic)] +enum BL { + /// ..and the variant.. + #[label(parser_add_paren)] + Foo { + /// ..and the field + #[primary_span] + span: Span, + } +} diff --git a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr index 171b89e657d..b21f9cc94a9 100644 --- a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr +++ b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr @@ -1,7 +1,7 @@ error: label without `#[primary_span]` field --> $DIR/subdiagnostic-derive.rs:47:1 | -LL | / #[label(parser::add_paren)] +LL | / #[label(parser_add_paren)] LL | | LL | | struct C { LL | | var: String, @@ -81,16 +81,16 @@ LL | #[label()] | ^^^^^^^^^^ error: `#[label(code = ...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:141:28 + --> $DIR/subdiagnostic-derive.rs:141:27 | -LL | #[label(parser::add_paren, code = "...")] - | ^^^^^^^^^^^^ +LL | #[label(parser_add_paren, code = "...")] + | ^^^^^^^^^^^^ error: `#[label(applicability = ...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:150:28 + --> $DIR/subdiagnostic-derive.rs:150:27 | -LL | #[label(parser::add_paren, applicability = "machine-applicable")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[label(parser_add_paren, applicability = "machine-applicable")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unsupported type attribute for subdiagnostic enum --> $DIR/subdiagnostic-derive.rs:159:1 @@ -134,22 +134,16 @@ error: diagnostic slug must be first argument of a `#[label(...)]` attribute LL | #[label(code = "...")] | ^^^^^^^^^^^^^^^^^^^^^^ -error: subdiagnostic kind not specified - --> $DIR/subdiagnostic-derive.rs:239:5 - | -LL | B { - | ^ - error: the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/subdiagnostic-derive.rs:251:5 + --> $DIR/subdiagnostic-derive.rs:250:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ error: label without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:248:1 + --> $DIR/subdiagnostic-derive.rs:247:1 | -LL | / #[label(parser::add_paren)] +LL | / #[label(parser_add_paren)] LL | | LL | | struct W { LL | | #[primary_span] @@ -159,13 +153,13 @@ LL | | } | |_^ error: `#[applicability]` is only valid on suggestions - --> $DIR/subdiagnostic-derive.rs:261:5 + --> $DIR/subdiagnostic-derive.rs:260:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: `#[bar]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:271:5 + --> $DIR/subdiagnostic-derive.rs:270:5 | LL | #[bar] | ^^^^^^ @@ -173,13 +167,13 @@ LL | #[bar] = help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes error: `#[bar = ...]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:282:5 + --> $DIR/subdiagnostic-derive.rs:281:5 | LL | #[bar = "..."] | ^^^^^^^^^^^^^^ error: `#[bar(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:293:5 + --> $DIR/subdiagnostic-derive.rs:292:5 | LL | #[bar("...")] | ^^^^^^^^^^^^^ @@ -187,7 +181,7 @@ LL | #[bar("...")] = help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes error: unexpected unsupported untagged union - --> $DIR/subdiagnostic-derive.rs:309:1 + --> $DIR/subdiagnostic-derive.rs:308:1 | LL | / union AC { LL | | @@ -196,78 +190,78 @@ LL | | b: u64 LL | | } | |_^ -error: `#[label(parser::add_paren)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:324:28 +error: `#[label(parser_add_paren)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:323:27 | -LL | #[label(parser::add_paren, parser::add_paren)] - | ^^^^^^^^^^^^^^^^^ +LL | #[label(parser_add_paren, parser_add_paren)] + | ^^^^^^^^^^^^^^^^ | = help: a diagnostic slug must be the first argument to the attribute error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:337:5 + --> $DIR/subdiagnostic-derive.rs:336:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:334:5 + --> $DIR/subdiagnostic-derive.rs:333:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ error: subdiagnostic kind not specified - --> $DIR/subdiagnostic-derive.rs:343:8 + --> $DIR/subdiagnostic-derive.rs:342:8 | LL | struct AG { | ^^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:380:47 + --> $DIR/subdiagnostic-derive.rs:379:46 | -LL | #[suggestion(parser::add_paren, code = "...", code = "...")] - | ^^^^^^^^^^^^ +LL | #[suggestion(parser_add_paren, code = "...", code = "...")] + | ^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:380:33 + --> $DIR/subdiagnostic-derive.rs:379:32 | -LL | #[suggestion(parser::add_paren, code = "...", code = "...")] - | ^^^^^^^^^^^^ +LL | #[suggestion(parser_add_paren, code = "...", code = "...")] + | ^^^^^^^^^^^^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:398:5 + --> $DIR/subdiagnostic-derive.rs:397:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:395:5 + --> $DIR/subdiagnostic-derive.rs:394:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: the `#[applicability]` attribute can only be applied to fields of type `Applicability` - --> $DIR/subdiagnostic-derive.rs:408:5 + --> $DIR/subdiagnostic-derive.rs:407:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: suggestion without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:421:1 + --> $DIR/subdiagnostic-derive.rs:420:1 | -LL | #[suggestion(parser::add_paren)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[suggestion(parser_add_paren)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid applicability - --> $DIR/subdiagnostic-derive.rs:431:46 + --> $DIR/subdiagnostic-derive.rs:430:45 | -LL | #[suggestion(parser::add_paren, code ="...", applicability = "foo")] - | ^^^^^^^^^^^^^^^^^^^^^ +LL | #[suggestion(parser_add_paren, code ="...", applicability = "foo")] + | ^^^^^^^^^^^^^^^^^^^^^ error: suggestion without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:449:1 + --> $DIR/subdiagnostic-derive.rs:448:1 | -LL | / #[suggestion(parser::add_paren, code = "...")] +LL | / #[suggestion(parser_add_paren, code = "...")] LL | | LL | | struct AR { LL | | var: String, @@ -275,25 +269,25 @@ LL | | } | |_^ error: unsupported type attribute for subdiagnostic enum - --> $DIR/subdiagnostic-derive.rs:463:1 + --> $DIR/subdiagnostic-derive.rs:462:1 | LL | #[label] | ^^^^^^^^ error: `var` doesn't refer to a field on this type - --> $DIR/subdiagnostic-derive.rs:483:39 + --> $DIR/subdiagnostic-derive.rs:482:38 | -LL | #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] - | ^^^^^^^ +LL | #[suggestion(parser_add_paren, code ="{var}", applicability = "machine-applicable")] + | ^^^^^^^ error: `var` doesn't refer to a field on this type - --> $DIR/subdiagnostic-derive.rs:502:43 + --> $DIR/subdiagnostic-derive.rs:501:42 | -LL | #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] - | ^^^^^^^ +LL | #[suggestion(parser_add_paren, code ="{var}", applicability = "machine-applicable")] + | ^^^^^^^ error: `#[suggestion_part]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:525:5 + --> $DIR/subdiagnostic-derive.rs:524:5 | LL | #[suggestion_part] | ^^^^^^^^^^^^^^^^^^ @@ -301,7 +295,7 @@ LL | #[suggestion_part] = help: `#[suggestion_part(...)]` is only valid in multipart suggestions, use `#[primary_span]` instead error: `#[suggestion_part(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:528:5 + --> $DIR/subdiagnostic-derive.rs:527:5 | LL | #[suggestion_part(code = "...")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -309,9 +303,9 @@ LL | #[suggestion_part(code = "...")] = help: `#[suggestion_part(...)]` is only valid in multipart suggestions error: suggestion without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:522:1 + --> $DIR/subdiagnostic-derive.rs:521:1 | -LL | / #[suggestion(parser::add_paren, code = "...")] +LL | / #[suggestion(parser_add_paren, code = "...")] LL | | LL | | struct BA { LL | | #[suggestion_part] @@ -321,17 +315,17 @@ LL | | } | |_^ error: `#[multipart_suggestion(code = ...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:537:43 + --> $DIR/subdiagnostic-derive.rs:536:42 | -LL | #[multipart_suggestion(parser::add_paren, code = "...", applicability = "machine-applicable")] - | ^^^^^^^^^^^^ +LL | #[multipart_suggestion(parser_add_paren, code = "...", applicability = "machine-applicable")] + | ^^^^^^^^^^^^ | = help: only `applicability` is a valid nested attributes error: multipart suggestion without any `#[suggestion_part(...)]` fields - --> $DIR/subdiagnostic-derive.rs:537:1 + --> $DIR/subdiagnostic-derive.rs:536:1 | -LL | / #[multipart_suggestion(parser::add_paren, code = "...", applicability = "machine-applicable")] +LL | / #[multipart_suggestion(parser_add_paren, code = "...", applicability = "machine-applicable")] LL | | LL | | LL | | struct BBa { @@ -340,19 +334,19 @@ LL | | } | |_^ error: `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:547:5 + --> $DIR/subdiagnostic-derive.rs:546:5 | LL | #[suggestion_part] | ^^^^^^^^^^^^^^^^^^ error: `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:555:5 + --> $DIR/subdiagnostic-derive.rs:554:5 | LL | #[suggestion_part()] | ^^^^^^^^^^^^^^^^^^^^ error: `#[primary_span]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:564:5 + --> $DIR/subdiagnostic-derive.rs:563:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ @@ -360,9 +354,9 @@ LL | #[primary_span] = help: multipart suggestions use one or more `#[suggestion_part]`s rather than one `#[primary_span]` error: multipart suggestion without any `#[suggestion_part(...)]` fields - --> $DIR/subdiagnostic-derive.rs:561:1 + --> $DIR/subdiagnostic-derive.rs:560:1 | -LL | / #[multipart_suggestion(parser::add_paren)] +LL | / #[multipart_suggestion(parser_add_paren)] LL | | LL | | struct BC { LL | | #[primary_span] @@ -372,19 +366,19 @@ LL | | } | |_^ error: `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:572:5 + --> $DIR/subdiagnostic-derive.rs:571:5 | LL | #[suggestion_part] | ^^^^^^^^^^^^^^^^^^ error: `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:575:5 + --> $DIR/subdiagnostic-derive.rs:574:5 | LL | #[suggestion_part()] | ^^^^^^^^^^^^^^^^^^^^ error: `#[suggestion_part(foo = ...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:578:23 + --> $DIR/subdiagnostic-derive.rs:577:23 | LL | #[suggestion_part(foo = "bar")] | ^^^^^^^^^^^ @@ -392,31 +386,31 @@ LL | #[suggestion_part(foo = "bar")] = help: `code` is the only valid nested attribute error: the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/subdiagnostic-derive.rs:581:5 + --> $DIR/subdiagnostic-derive.rs:580:5 | LL | #[suggestion_part(code = "...")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/subdiagnostic-derive.rs:584:5 + --> $DIR/subdiagnostic-derive.rs:583:5 | LL | #[suggestion_part()] | ^^^^^^^^^^^^^^^^^^^^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:592:37 + --> $DIR/subdiagnostic-derive.rs:591:37 | LL | #[suggestion_part(code = "...", code = ",,,")] | ^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:592:23 + --> $DIR/subdiagnostic-derive.rs:591:23 | LL | #[suggestion_part(code = "...", code = ",,,")] | ^^^^^^^^^^^^ error: `#[applicability]` has no effect if all `#[suggestion]`/`#[multipart_suggestion]` attributes have a static `applicability = "..."` - --> $DIR/subdiagnostic-derive.rs:621:5 + --> $DIR/subdiagnostic-derive.rs:620:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ @@ -458,19 +452,19 @@ LL | #[bar("...")] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:271:7 + --> $DIR/subdiagnostic-derive.rs:270:7 | LL | #[bar] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:282:7 + --> $DIR/subdiagnostic-derive.rs:281:7 | LL | #[bar = "..."] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:293:7 + --> $DIR/subdiagnostic-derive.rs:292:7 | LL | #[bar("...")] | ^^^ @@ -481,6 +475,6 @@ error[E0425]: cannot find value `slug` in module `rustc_errors::fluent` LL | #[label(slug)] | ^^^^ not found in `rustc_errors::fluent` -error: aborting due to 68 previous errors +error: aborting due to 67 previous errors For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/abi/abi-sysv64-register-usage.rs b/src/test/ui/abi/abi-sysv64-register-usage.rs index 9404e71d0fe..39330693677 100644 --- a/src/test/ui/abi/abi-sysv64-register-usage.rs +++ b/src/test/ui/abi/abi-sysv64-register-usage.rs @@ -6,20 +6,30 @@ // ignore-arm // ignore-aarch64 // needs-asm-support -#![feature(asm_sym)] #[cfg(target_arch = "x86_64")] -pub extern "sysv64" fn all_the_registers(rdi: i64, rsi: i64, rdx: i64, - rcx: i64, r8 : i64, r9 : i64, - xmm0: f32, xmm1: f32, xmm2: f32, - xmm3: f32, xmm4: f32, xmm5: f32, - xmm6: f32, xmm7: f32) -> i64 { +pub extern "sysv64" fn all_the_registers( + rdi: i64, + rsi: i64, + rdx: i64, + rcx: i64, + r8: i64, + r9: i64, + xmm0: f32, + xmm1: f32, + xmm2: f32, + xmm3: f32, + xmm4: f32, + xmm5: f32, + xmm6: f32, + xmm7: f32, +) -> i64 { assert_eq!(rdi, 1); assert_eq!(rsi, 2); assert_eq!(rdx, 3); assert_eq!(rcx, 4); - assert_eq!(r8, 5); - assert_eq!(r9, 6); + assert_eq!(r8, 5); + assert_eq!(r9, 6); assert_eq!(xmm0, 1.0f32); assert_eq!(xmm1, 2.0f32); assert_eq!(xmm2, 4.0f32); diff --git a/src/test/ui/alloc-error/default-alloc-error-hook.rs b/src/test/ui/alloc-error/default-alloc-error-hook.rs index 100e974977c..8be09500f4e 100644 --- a/src/test/ui/alloc-error/default-alloc-error-hook.rs +++ b/src/test/ui/alloc-error/default-alloc-error-hook.rs @@ -15,5 +15,14 @@ fn main() { let me = env::current_exe().unwrap(); let output = Command::new(&me).arg("next").output().unwrap(); assert!(!output.status.success(), "{:?} is a success", output.status); - assert_eq!(str::from_utf8(&output.stderr).unwrap(), "memory allocation of 42 bytes failed\n"); + + let mut stderr = str::from_utf8(&output.stderr).unwrap(); + + // When running inside QEMU user-mode emulation, there will be an extra message printed by QEMU + // in the stderr whenever a core dump happens. Remove it before the check. + stderr = stderr + .strip_suffix("qemu: uncaught target signal 6 (Aborted) - core dumped\n") + .unwrap_or(stderr); + + assert_eq!(stderr, "memory allocation of 42 bytes failed\n"); } diff --git a/src/test/ui/asm/aarch64/bad-reg.rs b/src/test/ui/asm/aarch64/bad-reg.rs index 2b6a9b71cd5..9ccb8ed6762 100644 --- a/src/test/ui/asm/aarch64/bad-reg.rs +++ b/src/test/ui/asm/aarch64/bad-reg.rs @@ -1,7 +1,7 @@ // only-aarch64 // compile-flags: -C target-feature=+neon -#![feature(asm_const, asm_sym)] +#![feature(asm_const)] use std::arch::asm; diff --git a/src/test/ui/asm/aarch64/may_unwind.rs b/src/test/ui/asm/aarch64/may_unwind.rs index dfd891b4212..6af8728bbaa 100644 --- a/src/test/ui/asm/aarch64/may_unwind.rs +++ b/src/test/ui/asm/aarch64/may_unwind.rs @@ -2,7 +2,7 @@ // run-pass // needs-asm-support -#![feature(asm_sym, asm_unwind)] +#![feature(asm_unwind)] use std::arch::asm; use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe}; diff --git a/src/test/ui/asm/aarch64/sym.rs b/src/test/ui/asm/aarch64/sym.rs index 3f659363cc8..6a6cdb00d51 100644 --- a/src/test/ui/asm/aarch64/sym.rs +++ b/src/test/ui/asm/aarch64/sym.rs @@ -3,7 +3,7 @@ // needs-asm-support // run-pass -#![feature(thread_local, asm_sym)] +#![feature(thread_local)] use std::arch::asm; diff --git a/src/test/ui/asm/aarch64/type-check-2-2.rs b/src/test/ui/asm/aarch64/type-check-2-2.rs index aa12d4aa4b4..0ce1f1d8f7f 100644 --- a/src/test/ui/asm/aarch64/type-check-2-2.rs +++ b/src/test/ui/asm/aarch64/type-check-2-2.rs @@ -1,6 +1,6 @@ // only-aarch64 -#![feature(repr_simd, never_type, asm_sym)] +#![feature(repr_simd, never_type)] use std::arch::{asm, global_asm}; diff --git a/src/test/ui/asm/aarch64/type-check-2.rs b/src/test/ui/asm/aarch64/type-check-2.rs index fdafe63c7b0..1c71c1185d4 100644 --- a/src/test/ui/asm/aarch64/type-check-2.rs +++ b/src/test/ui/asm/aarch64/type-check-2.rs @@ -1,6 +1,6 @@ // only-aarch64 -#![feature(repr_simd, never_type, asm_sym)] +#![feature(repr_simd, never_type)] use std::arch::{asm, global_asm}; diff --git a/src/test/ui/asm/generic-const.rs b/src/test/ui/asm/generic-const.rs index 55c5587804b..caa9b7dbce6 100644 --- a/src/test/ui/asm/generic-const.rs +++ b/src/test/ui/asm/generic-const.rs @@ -1,7 +1,7 @@ // needs-asm-support // build-pass -#![feature(asm_const, asm_sym)] +#![feature(asm_const)] use std::arch::asm; diff --git a/src/test/ui/asm/naked-functions.rs b/src/test/ui/asm/naked-functions.rs index 9e626f5711d..2f3716ca77f 100644 --- a/src/test/ui/asm/naked-functions.rs +++ b/src/test/ui/asm/naked-functions.rs @@ -4,7 +4,7 @@ // ignore-wasm32 #![feature(naked_functions)] -#![feature(asm_const, asm_sym, asm_unwind)] +#![feature(asm_const, asm_unwind)] #![crate_type = "lib"] use std::arch::asm; diff --git a/src/test/ui/asm/type-check-1.rs b/src/test/ui/asm/type-check-1.rs index 50b369ae045..59f7b36afcd 100644 --- a/src/test/ui/asm/type-check-1.rs +++ b/src/test/ui/asm/type-check-1.rs @@ -3,7 +3,7 @@ // ignore-spirv // ignore-wasm32 -#![feature(asm_const, asm_sym)] +#![feature(asm_const)] use std::arch::{asm, global_asm}; diff --git a/src/test/ui/asm/unpretty-expanded.rs b/src/test/ui/asm/unpretty-expanded.rs index 6128f49b89a..25cf1c3d730 100644 --- a/src/test/ui/asm/unpretty-expanded.rs +++ b/src/test/ui/asm/unpretty-expanded.rs @@ -1,3 +1,4 @@ +// needs-asm-support // check-pass // compile-flags: -Zunpretty=expanded core::arch::global_asm!("x: .byte 42"); diff --git a/src/test/ui/asm/unpretty-expanded.stdout b/src/test/ui/asm/unpretty-expanded.stdout index 15b60d1559c..ab1b5f45e5c 100644 --- a/src/test/ui/asm/unpretty-expanded.stdout +++ b/src/test/ui/asm/unpretty-expanded.stdout @@ -4,6 +4,7 @@ use ::std::prelude::rust_2015::*; #[macro_use] extern crate std; +// needs-asm-support // check-pass // compile-flags: -Zunpretty=expanded global_asm! ("x: .byte 42"); diff --git a/src/test/ui/asm/x86_64/bad-reg.rs b/src/test/ui/asm/x86_64/bad-reg.rs index a4f50a534a1..f5728079a6a 100644 --- a/src/test/ui/asm/x86_64/bad-reg.rs +++ b/src/test/ui/asm/x86_64/bad-reg.rs @@ -1,7 +1,7 @@ // only-x86_64 // compile-flags: -C target-feature=+avx2 -#![feature(asm_const, asm_sym)] +#![feature(asm_const)] use std::arch::asm; diff --git a/src/test/ui/asm/x86_64/issue-96797.rs b/src/test/ui/asm/x86_64/issue-96797.rs index d3e0906f37a..954f8c5ccc3 100644 --- a/src/test/ui/asm/x86_64/issue-96797.rs +++ b/src/test/ui/asm/x86_64/issue-96797.rs @@ -7,8 +7,6 @@ // regression test for #96797 -#![feature(asm_sym)] - use std::arch::global_asm; #[no_mangle] diff --git a/src/test/ui/asm/x86_64/may_unwind.rs b/src/test/ui/asm/x86_64/may_unwind.rs index 2f5d1a36024..c11f0938d0b 100644 --- a/src/test/ui/asm/x86_64/may_unwind.rs +++ b/src/test/ui/asm/x86_64/may_unwind.rs @@ -3,7 +3,7 @@ // needs-asm-support // needs-unwind -#![feature(asm_sym, asm_unwind)] +#![feature(asm_unwind)] use std::arch::asm; use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe}; diff --git a/src/test/ui/asm/x86_64/multiple-clobber-abi.rs b/src/test/ui/asm/x86_64/multiple-clobber-abi.rs index 513eb270e4f..06589431a44 100644 --- a/src/test/ui/asm/x86_64/multiple-clobber-abi.rs +++ b/src/test/ui/asm/x86_64/multiple-clobber-abi.rs @@ -4,8 +4,6 @@ // Checks that multiple clobber_abi options can be used -#![feature(asm_sym)] - use std::arch::asm; extern "sysv64" fn foo(x: i32) -> i32 { diff --git a/src/test/ui/asm/x86_64/sym.rs b/src/test/ui/asm/x86_64/sym.rs index 447e11e6eab..93ef4f09062 100644 --- a/src/test/ui/asm/x86_64/sym.rs +++ b/src/test/ui/asm/x86_64/sym.rs @@ -3,7 +3,7 @@ // needs-asm-support // run-pass -#![feature(thread_local, asm_sym)] +#![feature(thread_local)] use std::arch::asm; diff --git a/src/test/ui/asm/x86_64/type-check-2.rs b/src/test/ui/asm/x86_64/type-check-2.rs index 59d8cde3fb6..80b29ec870f 100644 --- a/src/test/ui/asm/x86_64/type-check-2.rs +++ b/src/test/ui/asm/x86_64/type-check-2.rs @@ -1,6 +1,6 @@ // only-x86_64 -#![feature(repr_simd, never_type, asm_sym)] +#![feature(repr_simd, never_type)] use std::arch::{asm, global_asm}; diff --git a/src/test/ui/asm/x86_64/type-check-4.rs b/src/test/ui/asm/x86_64/type-check-4.rs index da3b76c3d23..3d5d3807c53 100644 --- a/src/test/ui/asm/x86_64/type-check-4.rs +++ b/src/test/ui/asm/x86_64/type-check-4.rs @@ -1,14 +1,13 @@ // only-x86_64 // compile-flags: -C target-feature=+avx512f -#![feature(asm_const, asm_sym)] +#![feature(asm_const)] use std::arch::{asm, global_asm}; use std::arch::x86_64::{_mm256_setzero_ps, _mm_setzero_ps}; -fn main() { -} +fn main() {} // Constants must be... constant diff --git a/src/test/ui/asm/x86_64/type-check-4.stderr b/src/test/ui/asm/x86_64/type-check-4.stderr index 33f4638fb4b..3875bcc2112 100644 --- a/src/test/ui/asm/x86_64/type-check-4.stderr +++ b/src/test/ui/asm/x86_64/type-check-4.stderr @@ -1,5 +1,5 @@ error[E0013]: constants cannot refer to statics - --> $DIR/type-check-4.rs:22:25 + --> $DIR/type-check-4.rs:21:25 | LL | global_asm!("{}", const S); | ^ @@ -7,7 +7,7 @@ LL | global_asm!("{}", const S); = help: consider extracting the value of the `static` to a `const`, and referring to that error[E0013]: constants cannot refer to statics - --> $DIR/type-check-4.rs:25:35 + --> $DIR/type-check-4.rs:24:35 | LL | global_asm!("{}", const const_foo(S)); | ^ @@ -15,7 +15,7 @@ LL | global_asm!("{}", const const_foo(S)); = help: consider extracting the value of the `static` to a `const`, and referring to that error[E0013]: constants cannot refer to statics - --> $DIR/type-check-4.rs:28:35 + --> $DIR/type-check-4.rs:27:35 | LL | global_asm!("{}", const const_bar(S)); | ^ diff --git a/src/test/ui/asm/x86_64/type-check-5.rs b/src/test/ui/asm/x86_64/type-check-5.rs index 6190e0b52f4..8198df91095 100644 --- a/src/test/ui/asm/x86_64/type-check-5.rs +++ b/src/test/ui/asm/x86_64/type-check-5.rs @@ -1,6 +1,6 @@ // only-x86_64 -#![feature(repr_simd, never_type, asm_sym)] +#![feature(repr_simd, never_type)] use std::arch::asm; diff --git a/src/test/ui/associated-type-bounds/inside-adt.rs b/src/test/ui/associated-type-bounds/inside-adt.rs index f26037f0707..8eb8c44bb42 100644 --- a/src/test/ui/associated-type-bounds/inside-adt.rs +++ b/src/test/ui/associated-type-bounds/inside-adt.rs @@ -16,7 +16,7 @@ enum E2 { V(Box<dyn Iterator<Item: Copy>>) } //~^ ERROR associated type bounds are not allowed within structs, enums, or unions enum E3 { V(dyn Iterator<Item: 'static>) } //~^ ERROR associated type bounds are not allowed within structs, enums, or unions -//~| ERROR the size for values of type `(dyn Iterator<Item = impl Sized> + 'static)` +//~| ERROR the size for values of type `(dyn Iterator<Item = impl Sized + 'static> + 'static)` union U1 { f: ManuallyDrop<dyn Iterator<Item: Copy>> } //~^ ERROR associated type bounds are not allowed within structs, enums, or unions @@ -25,6 +25,6 @@ union U2 { f: ManuallyDrop<Box<dyn Iterator<Item: Copy>>> } //~^ ERROR associated type bounds are not allowed within structs, enums, or unions union U3 { f: ManuallyDrop<dyn Iterator<Item: 'static>> } //~^ ERROR associated type bounds are not allowed within structs, enums, or unions -//~| ERROR the size for values of type `(dyn Iterator<Item = impl Sized> + 'static)` +//~| ERROR the size for values of type `(dyn Iterator<Item = impl Sized + 'static> + 'static)` fn main() {} diff --git a/src/test/ui/associated-type-bounds/inside-adt.stderr b/src/test/ui/associated-type-bounds/inside-adt.stderr index 978390fa712..dbfcfa58063 100644 --- a/src/test/ui/associated-type-bounds/inside-adt.stderr +++ b/src/test/ui/associated-type-bounds/inside-adt.stderr @@ -70,13 +70,13 @@ help: the `Box` type always has a statically known size and allocates its conten LL | enum E1 { V(Box<dyn Iterator<Item: Copy>>) } | ++++ + -error[E0277]: the size for values of type `(dyn Iterator<Item = impl Sized> + 'static)` cannot be known at compilation time +error[E0277]: the size for values of type `(dyn Iterator<Item = impl Sized + 'static> + 'static)` cannot be known at compilation time --> $DIR/inside-adt.rs:17:13 | LL | enum E3 { V(dyn Iterator<Item: 'static>) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | - = help: the trait `Sized` is not implemented for `(dyn Iterator<Item = impl Sized> + 'static)` + = help: the trait `Sized` is not implemented for `(dyn Iterator<Item = impl Sized + 'static> + 'static)` = note: no field of an enum variant may have a dynamically sized type = help: change the field's type to have a statically known size help: borrowed types always have a statically known size @@ -107,14 +107,14 @@ help: the `Box` type always has a statically known size and allocates its conten LL | union U1 { f: Box<ManuallyDrop<dyn Iterator<Item: Copy>>> } | ++++ + -error[E0277]: the size for values of type `(dyn Iterator<Item = impl Sized> + 'static)` cannot be known at compilation time +error[E0277]: the size for values of type `(dyn Iterator<Item = impl Sized + 'static> + 'static)` cannot be known at compilation time --> $DIR/inside-adt.rs:26:15 | LL | union U3 { f: ManuallyDrop<dyn Iterator<Item: 'static>> } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | - = help: within `ManuallyDrop<(dyn Iterator<Item = impl Sized> + 'static)>`, the trait `Sized` is not implemented for `(dyn Iterator<Item = impl Sized> + 'static)` - = note: required because it appears within the type `ManuallyDrop<(dyn Iterator<Item = impl Sized> + 'static)>` + = help: within `ManuallyDrop<(dyn Iterator<Item = impl Sized + 'static> + 'static)>`, the trait `Sized` is not implemented for `(dyn Iterator<Item = impl Sized + 'static> + 'static)` + = note: required because it appears within the type `ManuallyDrop<(dyn Iterator<Item = impl Sized + 'static> + 'static)>` = note: no field of a union may have a dynamically sized type = help: change the field's type to have a statically known size help: borrowed types always have a statically known size diff --git a/src/test/ui/associated-types/issue-87261.rs b/src/test/ui/associated-types/issue-87261.rs index 384561f8ccd..e8548d402fa 100644 --- a/src/test/ui/associated-types/issue-87261.rs +++ b/src/test/ui/associated-types/issue-87261.rs @@ -77,10 +77,10 @@ where fn main() { accepts_trait(returns_opaque()); - //~^ ERROR type mismatch resolving `<impl Trait as Trait>::Associated == ()` + //~^ ERROR type mismatch resolving `<impl Trait + 'static as Trait>::Associated == ()` accepts_trait(returns_opaque_derived()); - //~^ ERROR type mismatch resolving `<impl DerivedTrait as Trait>::Associated == ()` + //~^ ERROR type mismatch resolving `<impl DerivedTrait + 'static as Trait>::Associated == ()` accepts_trait(returns_opaque_foo()); //~^ ERROR type mismatch resolving `<impl Trait + Foo as Trait>::Associated == ()` @@ -89,7 +89,7 @@ fn main() { //~^ ERROR type mismatch resolving `<impl DerivedTrait + Foo as Trait>::Associated == ()` accepts_generic_trait(returns_opaque_generic()); - //~^ ERROR type mismatch resolving `<impl GenericTrait<()> as GenericTrait<()>>::Associated == ()` + //~^ ERROR type mismatch resolving `<impl GenericTrait<()> + 'static as GenericTrait<()>>::Associated == ()` accepts_generic_trait(returns_opaque_generic_foo()); //~^ ERROR type mismatch resolving `<impl GenericTrait<()> + Foo as GenericTrait<()>>::Associated == ()` diff --git a/src/test/ui/associated-types/issue-87261.stderr b/src/test/ui/associated-types/issue-87261.stderr index f24423dd106..2cce6b94702 100644 --- a/src/test/ui/associated-types/issue-87261.stderr +++ b/src/test/ui/associated-types/issue-87261.stderr @@ -132,7 +132,7 @@ note: required by a bound in `accepts_generic_trait` LL | fn accepts_generic_trait<T: GenericTrait<(), Associated = ()>>(_: T) {} | ^^^^^^^^^^^^^^^ required by this bound in `accepts_generic_trait` -error[E0271]: type mismatch resolving `<impl Trait as Trait>::Associated == ()` +error[E0271]: type mismatch resolving `<impl Trait + 'static as Trait>::Associated == ()` --> $DIR/issue-87261.rs:79:19 | LL | fn returns_opaque() -> impl Trait + 'static { @@ -144,18 +144,18 @@ LL | accepts_trait(returns_opaque()); | required by a bound introduced by this call | = note: expected unit type `()` - found associated type `<impl Trait as Trait>::Associated` + found associated type `<impl Trait + 'static as Trait>::Associated` note: required by a bound in `accepts_trait` --> $DIR/issue-87261.rs:43:27 | LL | fn accepts_trait<T: Trait<Associated = ()>>(_: T) {} | ^^^^^^^^^^^^^^^ required by this bound in `accepts_trait` -help: consider constraining the associated type `<impl Trait as Trait>::Associated` to `()` +help: consider constraining the associated type `<impl Trait + 'static as Trait>::Associated` to `()` | LL | fn returns_opaque() -> impl Trait<Associated = ()> + 'static { | +++++++++++++++++ -error[E0271]: type mismatch resolving `<impl DerivedTrait as Trait>::Associated == ()` +error[E0271]: type mismatch resolving `<impl DerivedTrait + 'static as Trait>::Associated == ()` --> $DIR/issue-87261.rs:82:19 | LL | fn returns_opaque_derived() -> impl DerivedTrait + 'static { @@ -167,13 +167,13 @@ LL | accepts_trait(returns_opaque_derived()); | required by a bound introduced by this call | = note: expected unit type `()` - found associated type `<impl DerivedTrait as Trait>::Associated` + found associated type `<impl DerivedTrait + 'static as Trait>::Associated` note: required by a bound in `accepts_trait` --> $DIR/issue-87261.rs:43:27 | LL | fn accepts_trait<T: Trait<Associated = ()>>(_: T) {} | ^^^^^^^^^^^^^^^ required by this bound in `accepts_trait` -help: consider constraining the associated type `<impl DerivedTrait as Trait>::Associated` to `()` +help: consider constraining the associated type `<impl DerivedTrait + 'static as Trait>::Associated` to `()` | LL | fn returns_opaque_derived() -> impl DerivedTrait<Associated = ()> + 'static { | +++++++++++++++++ @@ -222,7 +222,7 @@ note: required by a bound in `accepts_trait` LL | fn accepts_trait<T: Trait<Associated = ()>>(_: T) {} | ^^^^^^^^^^^^^^^ required by this bound in `accepts_trait` -error[E0271]: type mismatch resolving `<impl GenericTrait<()> as GenericTrait<()>>::Associated == ()` +error[E0271]: type mismatch resolving `<impl GenericTrait<()> + 'static as GenericTrait<()>>::Associated == ()` --> $DIR/issue-87261.rs:91:27 | LL | fn returns_opaque_generic() -> impl GenericTrait<()> + 'static { @@ -234,13 +234,13 @@ LL | accepts_generic_trait(returns_opaque_generic()); | required by a bound introduced by this call | = note: expected unit type `()` - found associated type `<impl GenericTrait<()> as GenericTrait<()>>::Associated` + found associated type `<impl GenericTrait<()> + 'static as GenericTrait<()>>::Associated` note: required by a bound in `accepts_generic_trait` --> $DIR/issue-87261.rs:44:46 | LL | fn accepts_generic_trait<T: GenericTrait<(), Associated = ()>>(_: T) {} | ^^^^^^^^^^^^^^^ required by this bound in `accepts_generic_trait` -help: consider constraining the associated type `<impl GenericTrait<()> as GenericTrait<()>>::Associated` to `()` +help: consider constraining the associated type `<impl GenericTrait<()> + 'static as GenericTrait<()>>::Associated` to `()` | LL | fn returns_opaque_generic() -> impl GenericTrait<(), Associated = ()> + 'static { | +++++++++++++++++ diff --git a/src/test/ui/async-await/in-trait/issue-102310.rs b/src/test/ui/async-await/in-trait/issue-102310.rs new file mode 100644 index 00000000000..49c3e9feeb4 --- /dev/null +++ b/src/test/ui/async-await/in-trait/issue-102310.rs @@ -0,0 +1,15 @@ +// check-pass +// edition:2021 + +#![feature(async_fn_in_trait)] +#![allow(incomplete_features)] + +pub trait SpiDevice { + async fn transaction<F, R>(&mut self); +} + +impl SpiDevice for () { + async fn transaction<F, R>(&mut self) {} +} + +fn main() {} diff --git a/src/test/ui/async-await/issues/issue-72312.stderr b/src/test/ui/async-await/issues/issue-72312.stderr index aa947b69003..5e5a980adb9 100644 --- a/src/test/ui/async-await/issues/issue-72312.stderr +++ b/src/test/ui/async-await/issues/issue-72312.stderr @@ -1,5 +1,5 @@ error[E0521]: borrowed data escapes outside of associated function - --> $DIR/issue-72312.rs:12:9 + --> $DIR/issue-72312.rs:12:24 | LL | pub async fn start(&self) { | ----- @@ -7,16 +7,17 @@ LL | pub async fn start(&self) { | `self` is a reference that is only valid in the associated function body | let's call the lifetime of this reference `'1` ... -LL | / require_static(async move { +LL | require_static(async move { + | ________________________^ LL | | LL | | LL | | LL | | &self; LL | | }); - | | ^ - | | | - | |__________`self` escapes the associated function body here - | argument requires that `'1` must outlive `'static` + | | ^ + | | | + | |_________`self` escapes the associated function body here + | argument requires that `'1` must outlive `'static` error: aborting due to previous error diff --git a/src/test/ui/async-await/no-const-async.stderr b/src/test/ui/async-await/no-const-async.stderr index e6f6e9e9f65..c5bd520aaea 100644 --- a/src/test/ui/async-await/no-const-async.stderr +++ b/src/test/ui/async-await/no-const-async.stderr @@ -18,7 +18,7 @@ note: ...which requires borrow-checking `x`... | LL | pub const async fn x() {} | ^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing `x`... +note: ...which requires processing MIR for `x`... --> $DIR/no-const-async.rs:4:1 | LL | pub const async fn x() {} diff --git a/src/test/ui/attr-from-macro.rs b/src/test/ui/attr-from-macro.rs new file mode 100644 index 00000000000..bb3a5c94d41 --- /dev/null +++ b/src/test/ui/attr-from-macro.rs @@ -0,0 +1,20 @@ +// aux-build:attr-from-macro.rs +// run-pass + +extern crate attr_from_macro; + +attr_from_macro::creator! { + struct Foo; + enum Bar; + enum FooBar; +} + +fn main() { + // Checking the `repr(u32)` on the enum. + assert_eq!(4, std::mem::size_of::<Bar>()); + // Checking the `repr(u16)` on the enum. + assert_eq!(2, std::mem::size_of::<FooBar>()); + + // Checking the Debug impl on the types. + eprintln!("{:?} {:?} {:?}", Foo, Bar::A, FooBar::A); +} diff --git a/src/test/ui/attributes/unix_sigpipe/auxiliary/sigpipe-utils.rs b/src/test/ui/attributes/unix_sigpipe/auxiliary/sigpipe-utils.rs index e8b4fe7ae52..74fbae0350e 100644 --- a/src/test/ui/attributes/unix_sigpipe/auxiliary/sigpipe-utils.rs +++ b/src/test/ui/attributes/unix_sigpipe/auxiliary/sigpipe-utils.rs @@ -23,9 +23,11 @@ pub fn assert_sigpipe_handler(expected_handler: SignalHandler) { SignalHandler::Ignore => libc::SIG_IGN, SignalHandler::Default => libc::SIG_DFL, }; - assert_eq!(prev, expected); + assert_eq!(prev, expected, "expected sigpipe value matches actual value"); // Unlikely to matter, but restore the old value anyway - unsafe { libc::signal(libc::SIGPIPE, prev); }; + unsafe { + libc::signal(libc::SIGPIPE, prev); + }; } } diff --git a/src/test/ui/auxiliary/attr-from-macro.rs b/src/test/ui/auxiliary/attr-from-macro.rs new file mode 100644 index 00000000000..9b388675c80 --- /dev/null +++ b/src/test/ui/auxiliary/attr-from-macro.rs @@ -0,0 +1,15 @@ +#[macro_export] +macro_rules! creator { + (struct $name1:ident; enum $name2:ident; enum $name3:ident;) => { + #[derive(Debug)] + pub struct $name1; + + #[derive(Debug)] + #[repr(u32)] + pub enum $name2 { A } + + #[derive(Debug)] + #[repr(u16)] + pub enum $name3 { A } + } +} diff --git a/src/test/ui/binop/issue-77910-1.stderr b/src/test/ui/binop/issue-77910-1.stderr index 9c7bf6228be..263a35d9829 100644 --- a/src/test/ui/binop/issue-77910-1.stderr +++ b/src/test/ui/binop/issue-77910-1.stderr @@ -19,7 +19,7 @@ LL | assert_eq!(foo, y); | ^^^^^^^^^^^^^^^^^^ `for<'a> fn(&'a i32) -> &'a i32 {foo}` cannot be formatted using `{:?}` because it doesn't implement `Debug` | = help: the trait `Debug` is not implemented for fn item `for<'a> fn(&'a i32) -> &'a i32 {foo}` - = help: use parentheses to call the function: `foo(s)` + = help: use parentheses to call this function: `foo(/* &i32 */)` = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr index 15ac737606d..d2b845619c7 100644 --- a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr +++ b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr @@ -25,7 +25,10 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-mut-borrow-linear-errors.rs:12:30 | LL | _ => { addr.push(&mut x); } - | ^^^^^^ `x` was mutably borrowed here in the previous iteration of the loop + | ----------^^^^^^- + | | | + | | `x` was mutably borrowed here in the previous iteration of the loop + | first borrow used here, in later iteration of loop error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/issue-103250.rs b/src/test/ui/borrowck/issue-103250.rs new file mode 100644 index 00000000000..46565f61ca9 --- /dev/null +++ b/src/test/ui/borrowck/issue-103250.rs @@ -0,0 +1,37 @@ +// edition:2021 + +type TranslateFn = Box<dyn Fn(String, String) -> String>; + +pub struct DeviceCluster { + devices: Vec<Device>, +} + +impl DeviceCluster { + pub async fn do_something(&mut self) -> Result<String, Box<dyn std::error::Error>> { + let mut last_error: Box<dyn std::error::Error>; + + for device in &mut self.devices { + match device.do_something().await { + Ok(info) => { + return Ok(info); + } + Err(e) => {} + } + } + + Err(last_error) + //~^ ERROR used binding `last_error` isn't initialized + } +} + +pub struct Device { + translate_fn: Option<TranslateFn>, +} + +impl Device { + pub async fn do_something(&mut self) -> Result<String, Box<dyn std::error::Error>> { + Ok(String::from("")) + } +} + +fn main() {} diff --git a/src/test/ui/borrowck/issue-103250.stderr b/src/test/ui/borrowck/issue-103250.stderr new file mode 100644 index 00000000000..4a237835222 --- /dev/null +++ b/src/test/ui/borrowck/issue-103250.stderr @@ -0,0 +1,17 @@ +error[E0381]: used binding `last_error` isn't initialized + --> $DIR/issue-103250.rs:22:13 + | +LL | let mut last_error: Box<dyn std::error::Error>; + | -------------- binding declared here but left uninitialized +... +LL | Err(last_error) + | ^^^^^^^^^^ `last_error` used here but it isn't initialized + | +help: consider assigning a value + | +LL | let mut last_error: Box<dyn std::error::Error> = todo!(); + | +++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/issues/issue-23338-params-outlive-temps-of-body.rs b/src/test/ui/borrowck/issue-23338-params-outlive-temps-of-body.rs index d45aaa843fb..d45aaa843fb 100644 --- a/src/test/ui/issues/issue-23338-params-outlive-temps-of-body.rs +++ b/src/test/ui/borrowck/issue-23338-params-outlive-temps-of-body.rs diff --git a/src/test/ui/borrowck/two-phase-across-loop.stderr b/src/test/ui/borrowck/two-phase-across-loop.stderr index 95896c6bbf9..22f9b39dfee 100644 --- a/src/test/ui/borrowck/two-phase-across-loop.stderr +++ b/src/test/ui/borrowck/two-phase-across-loop.stderr @@ -2,7 +2,10 @@ error[E0499]: cannot borrow `foo` as mutable more than once at a time --> $DIR/two-phase-across-loop.rs:17:22 | LL | strings.push(foo.get_string()); - | ^^^^^^^^^^^^^^^^ `foo` was mutably borrowed here in the previous iteration of the loop + | -------------^^^^^^^^^^^^^^^^- + | | | + | | `foo` was mutably borrowed here in the previous iteration of the loop + | first borrow used here, in later iteration of loop error: aborting due to previous error diff --git a/src/test/ui/closures/closure-bounds-subtype.stderr b/src/test/ui/closures/closure-bounds-subtype.stderr index 1a40326d986..8ad8273fc2b 100644 --- a/src/test/ui/closures/closure-bounds-subtype.stderr +++ b/src/test/ui/closures/closure-bounds-subtype.stderr @@ -11,6 +11,10 @@ note: required by a bound in `take_const_owned` | LL | fn take_const_owned<F>(_: F) where F: FnOnce() + Sync + Send { | ^^^^ required by this bound in `take_const_owned` +help: use parentheses to call this type parameter + | +LL | take_const_owned(f()); + | ++ help: consider further restricting this bound | LL | fn give_owned<F>(f: F) where F: FnOnce() + Send + std::marker::Sync { diff --git a/src/test/ui/closures/issue-97607.rs b/src/test/ui/closures/issue-97607.rs new file mode 100644 index 00000000000..74c910ad0bb --- /dev/null +++ b/src/test/ui/closures/issue-97607.rs @@ -0,0 +1,12 @@ +// check-pass +#[allow(unused)] + +fn test<T, F, U>(f: F) -> Box<dyn Fn(T) -> U + 'static> +where + F: 'static + Fn(T) -> U, + for<'a> U: 'a, // < This is the problematic line, see #97607 +{ + Box::new(move |t| f(t)) +} + +fn main() {} diff --git a/src/test/ui/command/command-current-dir.rs b/src/test/ui/command/command-current-dir.rs index 69a0b486d68..5d06fcdebc6 100644 --- a/src/test/ui/command/command-current-dir.rs +++ b/src/test/ui/command/command-current-dir.rs @@ -1,6 +1,7 @@ // run-pass // ignore-emscripten no processes // ignore-sgx no processes +// ignore-fuchsia Needs directory creation privilege use std::env; use std::fs; diff --git a/src/test/ui/const-generics/generic_const_exprs/closures.stderr b/src/test/ui/const-generics/generic_const_exprs/closures.stderr index a15dd2016e9..a7d891d7790 100644 --- a/src/test/ui/const-generics/generic_const_exprs/closures.stderr +++ b/src/test/ui/const-generics/generic_const_exprs/closures.stderr @@ -1,4 +1,4 @@ -error[E0391]: cycle detected when building an abstract representation for test::{constant#0} +error[E0391]: cycle detected when building an abstract representation for `test::{constant#0}` --> $DIR/closures.rs:3:35 | LL | fn test<const N: usize>() -> [u8; N + (|| 42)()] {} @@ -14,7 +14,7 @@ note: ...which requires type-checking `test::{constant#0}`... | LL | fn test<const N: usize>() -> [u8; N + (|| 42)()] {} | ^^^^^^^^^^^^^ - = note: ...which again requires building an abstract representation for test::{constant#0}, completing the cycle + = note: ...which again requires building an abstract representation for `test::{constant#0}`, completing the cycle note: cycle used when checking that `test` is well-formed --> $DIR/closures.rs:3:1 | diff --git a/src/test/ui/const-generics/generic_const_exprs/dependence_lint.full.stderr b/src/test/ui/const-generics/generic_const_exprs/dependence_lint.full.stderr index 828f0988a03..d674e3acdff 100644 --- a/src/test/ui/const-generics/generic_const_exprs/dependence_lint.full.stderr +++ b/src/test/ui/const-generics/generic_const_exprs/dependence_lint.full.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/dependence_lint.rs:13:32 + --> $DIR/dependence_lint.rs:14:32 | LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce | ^ cannot perform const operation using `T` @@ -8,7 +8,7 @@ LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/dependence_lint.rs:20:37 + --> $DIR/dependence_lint.rs:21:37 | LL | let _: [u8; if true { size_of::<T>() } else { 3 }]; // error on stable, error with gce | ^ cannot perform const operation using `T` @@ -17,7 +17,7 @@ LL | let _: [u8; if true { size_of::<T>() } else { 3 }]; // error on stable, = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions warning: cannot use constants which depend on generic parameters in types - --> $DIR/dependence_lint.rs:9:9 + --> $DIR/dependence_lint.rs:10:9 | LL | [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_exprs` | ^^^^^^^^^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL | [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_ = note: `#[warn(const_evaluatable_unchecked)]` on by default warning: cannot use constants which depend on generic parameters in types - --> $DIR/dependence_lint.rs:16:9 + --> $DIR/dependence_lint.rs:17:9 | LL | [0; if false { size_of::<T>() } else { 3 }]; // lint on stable, error with gce | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr b/src/test/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr index b13bcdb2c47..74111ef1d38 100644 --- a/src/test/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr +++ b/src/test/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr @@ -1,5 +1,5 @@ error: overly complex generic constant - --> $DIR/dependence_lint.rs:16:9 + --> $DIR/dependence_lint.rs:17:9 | LL | [0; if false { size_of::<T>() } else { 3 }]; // lint on stable, error with gce | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ control flow is not supported in generic constants @@ -7,7 +7,7 @@ LL | [0; if false { size_of::<T>() } else { 3 }]; // lint on stable, error w = help: consider moving this anonymous constant into a `const` function error: overly complex generic constant - --> $DIR/dependence_lint.rs:20:17 + --> $DIR/dependence_lint.rs:21:17 | LL | let _: [u8; if true { size_of::<T>() } else { 3 }]; // error on stable, error with gce | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ control flow is not supported in generic constants @@ -15,7 +15,7 @@ LL | let _: [u8; if true { size_of::<T>() } else { 3 }]; // error on stable, = help: consider moving this anonymous constant into a `const` function error: unconstrained generic constant - --> $DIR/dependence_lint.rs:13:12 + --> $DIR/dependence_lint.rs:14:12 | LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce = help: try adding a `where` bound using this expression: `where [(); size_of::<*mut T>()]:` error: unconstrained generic constant - --> $DIR/dependence_lint.rs:9:9 + --> $DIR/dependence_lint.rs:10:9 | LL | [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_exprs` | ^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/generic_const_exprs/dependence_lint.rs b/src/test/ui/const-generics/generic_const_exprs/dependence_lint.rs index dcdfd75def9..b715e07f8fa 100644 --- a/src/test/ui/const-generics/generic_const_exprs/dependence_lint.rs +++ b/src/test/ui/const-generics/generic_const_exprs/dependence_lint.rs @@ -1,4 +1,5 @@ // revisions: full gce +// compile-flags: -Zdeduplicate-diagnostics=yes #![cfg_attr(gce, feature(generic_const_exprs))] #![allow(incomplete_features)] diff --git a/src/test/ui/const-generics/generic_const_exprs/function-call.rs b/src/test/ui/const-generics/generic_const_exprs/function-call.rs index b5de66621c5..3c866333d60 100644 --- a/src/test/ui/const-generics/generic_const_exprs/function-call.rs +++ b/src/test/ui/const-generics/generic_const_exprs/function-call.rs @@ -1,4 +1,5 @@ // check-pass +// compile-flags: -Zdeduplicate-diagnostics=yes const fn foo<T>() -> usize { // We might instead branch on `std::mem::size_of::<*mut T>() < 8` here, diff --git a/src/test/ui/const-generics/generic_const_exprs/function-call.stderr b/src/test/ui/const-generics/generic_const_exprs/function-call.stderr index 796dc01043c..84abfe57876 100644 --- a/src/test/ui/const-generics/generic_const_exprs/function-call.stderr +++ b/src/test/ui/const-generics/generic_const_exprs/function-call.stderr @@ -1,5 +1,5 @@ warning: cannot use constants which depend on generic parameters in types - --> $DIR/function-call.rs:14:17 + --> $DIR/function-call.rs:15:17 | LL | let _ = [0; foo::<T>()]; | ^^^^^^^^^^ diff --git a/src/test/ui/const-generics/min_const_generics/complex-expression.rs b/src/test/ui/const-generics/min_const_generics/complex-expression.rs index 7840989cb08..8e667aebaad 100644 --- a/src/test/ui/const-generics/min_const_generics/complex-expression.rs +++ b/src/test/ui/const-generics/min_const_generics/complex-expression.rs @@ -1,3 +1,4 @@ +// compile-flags: -Zdeduplicate-diagnostics=yes use std::mem::size_of; fn test<const N: usize>() {} diff --git a/src/test/ui/const-generics/min_const_generics/complex-expression.stderr b/src/test/ui/const-generics/min_const_generics/complex-expression.stderr index 0b051c6131b..deabd05a6d5 100644 --- a/src/test/ui/const-generics/min_const_generics/complex-expression.stderr +++ b/src/test/ui/const-generics/min_const_generics/complex-expression.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/complex-expression.rs:9:38 + --> $DIR/complex-expression.rs:10:38 | LL | struct Break0<const N: usize>([u8; { N + 1 }]); | ^ cannot perform const operation using `N` @@ -8,7 +8,7 @@ LL | struct Break0<const N: usize>([u8; { N + 1 }]); = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/complex-expression.rs:12:40 + --> $DIR/complex-expression.rs:13:40 | LL | struct Break1<const N: usize>([u8; { { N } }]); | ^ cannot perform const operation using `N` @@ -17,7 +17,7 @@ LL | struct Break1<const N: usize>([u8; { { N } }]); = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/complex-expression.rs:16:17 + --> $DIR/complex-expression.rs:17:17 | LL | let _: [u8; N + 1]; | ^ cannot perform const operation using `N` @@ -26,7 +26,7 @@ LL | let _: [u8; N + 1]; = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/complex-expression.rs:21:17 + --> $DIR/complex-expression.rs:22:17 | LL | let _ = [0; N + 1]; | ^ cannot perform const operation using `N` @@ -35,7 +35,7 @@ LL | let _ = [0; N + 1]; = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/complex-expression.rs:25:45 + --> $DIR/complex-expression.rs:26:45 | LL | struct BreakTy0<T>(T, [u8; { size_of::<*mut T>() }]); | ^ cannot perform const operation using `T` @@ -44,7 +44,7 @@ LL | struct BreakTy0<T>(T, [u8; { size_of::<*mut T>() }]); = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/complex-expression.rs:28:47 + --> $DIR/complex-expression.rs:29:47 | LL | struct BreakTy1<T>(T, [u8; { { size_of::<*mut T>() } }]); | ^ cannot perform const operation using `T` @@ -53,7 +53,7 @@ LL | struct BreakTy1<T>(T, [u8; { { size_of::<*mut T>() } }]); = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/complex-expression.rs:32:32 + --> $DIR/complex-expression.rs:33:32 | LL | let _: [u8; size_of::<*mut T>() + 1]; | ^ cannot perform const operation using `T` @@ -62,7 +62,7 @@ LL | let _: [u8; size_of::<*mut T>() + 1]; = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions warning: cannot use constants which depend on generic parameters in types - --> $DIR/complex-expression.rs:37:17 + --> $DIR/complex-expression.rs:38:17 | LL | let _ = [0; size_of::<*mut T>() + 1]; | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/min_const_generics/const-evaluatable-unchecked.rs b/src/test/ui/const-generics/min_const_generics/const-evaluatable-unchecked.rs index 71d13ca61c9..e9d868093e7 100644 --- a/src/test/ui/const-generics/min_const_generics/const-evaluatable-unchecked.rs +++ b/src/test/ui/const-generics/min_const_generics/const-evaluatable-unchecked.rs @@ -1,4 +1,5 @@ // check-pass +// compile-flags: -Zdeduplicate-diagnostics=yes #![allow(dead_code)] fn foo<T>() { diff --git a/src/test/ui/const-generics/min_const_generics/const-evaluatable-unchecked.stderr b/src/test/ui/const-generics/min_const_generics/const-evaluatable-unchecked.stderr index f0ba7a39d1e..8003dfa4071 100644 --- a/src/test/ui/const-generics/min_const_generics/const-evaluatable-unchecked.stderr +++ b/src/test/ui/const-generics/min_const_generics/const-evaluatable-unchecked.stderr @@ -1,5 +1,5 @@ warning: cannot use constants which depend on generic parameters in types - --> $DIR/const-evaluatable-unchecked.rs:5:9 + --> $DIR/const-evaluatable-unchecked.rs:6:9 | LL | [0; std::mem::size_of::<*mut T>()]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | [0; std::mem::size_of::<*mut T>()]; = note: `#[warn(const_evaluatable_unchecked)]` on by default warning: cannot use constants which depend on generic parameters in types - --> $DIR/const-evaluatable-unchecked.rs:16:21 + --> $DIR/const-evaluatable-unchecked.rs:17:21 | LL | let _ = [0; Self::ASSOC]; | ^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | let _ = [0; Self::ASSOC]; = note: for more information, see issue #76200 <https://github.com/rust-lang/rust/issues/76200> warning: cannot use constants which depend on generic parameters in types - --> $DIR/const-evaluatable-unchecked.rs:28:21 + --> $DIR/const-evaluatable-unchecked.rs:29:21 | LL | let _ = [0; Self::ASSOC]; | ^^^^^^^^^^^ diff --git a/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr b/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr index 168fa0ad0f0..12244450e7f 100644 --- a/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr +++ b/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr @@ -10,16 +10,6 @@ note: the trait `PartialEq<_>` is implemented for `*const i32`, but that impleme | LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; | ^^ - = help: the following other types implement trait `PartialEq<Rhs>`: - f32 - f64 - i128 - i16 - i32 - i64 - i8 - isize - and 6 others error[E0277]: can't compare `*const i32` with `_` in const contexts --> $DIR/const_raw_ptr_ops.rs:6:44 @@ -33,16 +23,6 @@ note: the trait `PartialEq<_>` is implemented for `*const i32`, but that impleme | LL | const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; | ^^ - = help: the following other types implement trait `PartialEq<Rhs>`: - f32 - f64 - i128 - i16 - i32 - i64 - i8 - isize - and 6 others error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/issue-25826.stderr b/src/test/ui/consts/issue-25826.stderr index b80befa26f6..905c5ee6eb4 100644 --- a/src/test/ui/consts/issue-25826.stderr +++ b/src/test/ui/consts/issue-25826.stderr @@ -10,10 +10,6 @@ note: the trait `PartialOrd` is implemented for `*const ()`, but that implementa | LL | const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () }; | ^ -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | fn main() where *const (): ~const PartialOrd { - | ++++++++++++++++++++++++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/consts/issue-94675.stderr b/src/test/ui/consts/issue-94675.stderr index 7ae293ffbf8..f4683f7f536 100644 --- a/src/test/ui/consts/issue-94675.stderr +++ b/src/test/ui/consts/issue-94675.stderr @@ -23,10 +23,6 @@ note: the trait `IndexMut<usize>` is implemented for `Vec<usize>`, but that impl | LL | self.bar[0] = baz.len(); | ^^^^^^^^^^^ -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | impl<'a> Foo<'a> where Vec<usize>: ~const IndexMut<usize> { - | ++++++++++++++++++++++++++++++++++++++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/deriving/deriving-all-codegen.rs b/src/test/ui/deriving/deriving-all-codegen.rs index aef79ae8a5b..ba7809413bd 100644 --- a/src/test/ui/deriving/deriving-all-codegen.rs +++ b/src/test/ui/deriving/deriving-all-codegen.rs @@ -85,7 +85,7 @@ enum Mixed { P, Q, R(u32), - S { d1: u32, d2: u32 }, + S { d1: Option<u32>, d2: Option<i32> }, } // An enum with no fieldless variants. Note that `Default` cannot be derived diff --git a/src/test/ui/deriving/deriving-all-codegen.stdout b/src/test/ui/deriving/deriving-all-codegen.stdout index 65f7dec8408..92fce6888c0 100644 --- a/src/test/ui/deriving/deriving-all-codegen.stdout +++ b/src/test/ui/deriving/deriving-all-codegen.stdout @@ -46,13 +46,15 @@ impl ::core::default::Default for Empty { impl ::core::hash::Hash for Empty { fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {} } -impl ::core::marker::StructuralPartialEq for Empty {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Empty { } #[automatically_derived] impl ::core::cmp::PartialEq for Empty { #[inline] fn eq(&self, other: &Empty) -> bool { true } } -impl ::core::marker::StructuralEq for Empty {} +#[automatically_derived] +impl ::core::marker::StructuralEq for Empty { } #[automatically_derived] impl ::core::cmp::Eq for Empty { #[inline] @@ -115,7 +117,8 @@ impl ::core::hash::Hash for Point { ::core::hash::Hash::hash(&self.y, state) } } -impl ::core::marker::StructuralPartialEq for Point {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Point { } #[automatically_derived] impl ::core::cmp::PartialEq for Point { #[inline] @@ -123,7 +126,8 @@ impl ::core::cmp::PartialEq for Point { self.x == other.x && self.y == other.y } } -impl ::core::marker::StructuralEq for Point {} +#[automatically_derived] +impl ::core::marker::StructuralEq for Point { } #[automatically_derived] impl ::core::cmp::Eq for Point { #[inline] @@ -225,7 +229,8 @@ impl ::core::hash::Hash for Big { ::core::hash::Hash::hash(&self.b8, state) } } -impl ::core::marker::StructuralPartialEq for Big {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Big { } #[automatically_derived] impl ::core::cmp::PartialEq for Big { #[inline] @@ -236,7 +241,8 @@ impl ::core::cmp::PartialEq for Big { self.b8 == other.b8 } } -impl ::core::marker::StructuralEq for Big {} +#[automatically_derived] +impl ::core::marker::StructuralEq for Big { } #[automatically_derived] impl ::core::cmp::Eq for Big { #[inline] @@ -345,13 +351,15 @@ impl ::core::hash::Hash for Unsized { ::core::hash::Hash::hash(&self.0, state) } } -impl ::core::marker::StructuralPartialEq for Unsized {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Unsized { } #[automatically_derived] impl ::core::cmp::PartialEq for Unsized { #[inline] fn eq(&self, other: &Unsized) -> bool { self.0 == other.0 } } -impl ::core::marker::StructuralEq for Unsized {} +#[automatically_derived] +impl ::core::marker::StructuralEq for Unsized { } #[automatically_derived] impl ::core::cmp::Eq for Unsized { #[inline] @@ -410,13 +418,15 @@ impl ::core::hash::Hash for PackedCopy { ::core::hash::Hash::hash(&{ self.0 }, state) } } -impl ::core::marker::StructuralPartialEq for PackedCopy {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for PackedCopy { } #[automatically_derived] impl ::core::cmp::PartialEq for PackedCopy { #[inline] fn eq(&self, other: &PackedCopy) -> bool { { self.0 } == { other.0 } } } -impl ::core::marker::StructuralEq for PackedCopy {} +#[automatically_derived] +impl ::core::marker::StructuralEq for PackedCopy { } #[automatically_derived] impl ::core::cmp::Eq for PackedCopy { #[inline] @@ -479,7 +489,8 @@ impl ::core::hash::Hash for PackedNonCopy { ::core::hash::Hash::hash(__self_0_0, state) } } -impl ::core::marker::StructuralPartialEq for PackedNonCopy {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for PackedNonCopy { } #[automatically_derived] impl ::core::cmp::PartialEq for PackedNonCopy { #[inline] @@ -489,7 +500,8 @@ impl ::core::cmp::PartialEq for PackedNonCopy { *__self_0_0 == *__self_1_0 } } -impl ::core::marker::StructuralEq for PackedNonCopy {} +#[automatically_derived] +impl ::core::marker::StructuralEq for PackedNonCopy { } #[automatically_derived] impl ::core::cmp::Eq for PackedNonCopy { #[inline] @@ -540,7 +552,8 @@ impl ::core::hash::Hash for Enum0 { unsafe { ::core::intrinsics::unreachable() } } } -impl ::core::marker::StructuralPartialEq for Enum0 {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Enum0 { } #[automatically_derived] impl ::core::cmp::PartialEq for Enum0 { #[inline] @@ -548,7 +561,8 @@ impl ::core::cmp::PartialEq for Enum0 { unsafe { ::core::intrinsics::unreachable() } } } -impl ::core::marker::StructuralEq for Enum0 {} +#[automatically_derived] +impl ::core::marker::StructuralEq for Enum0 { } #[automatically_derived] impl ::core::cmp::Eq for Enum0 { #[inline] @@ -607,7 +621,8 @@ impl ::core::hash::Hash for Enum1 { } } } -impl ::core::marker::StructuralPartialEq for Enum1 {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Enum1 { } #[automatically_derived] impl ::core::cmp::PartialEq for Enum1 { #[inline] @@ -618,7 +633,8 @@ impl ::core::cmp::PartialEq for Enum1 { } } } -impl ::core::marker::StructuralEq for Enum1 {} +#[automatically_derived] +impl ::core::marker::StructuralEq for Enum1 { } #[automatically_derived] impl ::core::cmp::Eq for Enum1 { #[inline] @@ -676,13 +692,15 @@ impl ::core::default::Default for Fieldless1 { impl ::core::hash::Hash for Fieldless1 { fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {} } -impl ::core::marker::StructuralPartialEq for Fieldless1 {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Fieldless1 { } #[automatically_derived] impl ::core::cmp::PartialEq for Fieldless1 { #[inline] fn eq(&self, other: &Fieldless1) -> bool { true } } -impl ::core::marker::StructuralEq for Fieldless1 {} +#[automatically_derived] +impl ::core::marker::StructuralEq for Fieldless1 { } #[automatically_derived] impl ::core::cmp::Eq for Fieldless1 { #[inline] @@ -743,7 +761,8 @@ impl ::core::hash::Hash for Fieldless { ::core::hash::Hash::hash(&__self_tag, state) } } -impl ::core::marker::StructuralPartialEq for Fieldless {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Fieldless { } #[automatically_derived] impl ::core::cmp::PartialEq for Fieldless { #[inline] @@ -753,7 +772,8 @@ impl ::core::cmp::PartialEq for Fieldless { __self_tag == __arg1_tag } } -impl ::core::marker::StructuralEq for Fieldless {} +#[automatically_derived] +impl ::core::marker::StructuralEq for Fieldless { } #[automatically_derived] impl ::core::cmp::Eq for Fieldless { #[inline] @@ -789,8 +809,8 @@ enum Mixed { Q, R(u32), S { - d1: u32, - d2: u32, + d1: Option<u32>, + d2: Option<i32>, }, } #[automatically_derived] @@ -798,6 +818,8 @@ impl ::core::clone::Clone for Mixed { #[inline] fn clone(&self) -> Mixed { let _: ::core::clone::AssertParamIsClone<u32>; + let _: ::core::clone::AssertParamIsClone<Option<u32>>; + let _: ::core::clone::AssertParamIsClone<Option<i32>>; *self } } @@ -838,7 +860,8 @@ impl ::core::hash::Hash for Mixed { } } } -impl ::core::marker::StructuralPartialEq for Mixed {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Mixed { } #[automatically_derived] impl ::core::cmp::PartialEq for Mixed { #[inline] @@ -856,7 +879,8 @@ impl ::core::cmp::PartialEq for Mixed { } } } -impl ::core::marker::StructuralEq for Mixed {} +#[automatically_derived] +impl ::core::marker::StructuralEq for Mixed { } #[automatically_derived] impl ::core::cmp::Eq for Mixed { #[inline] @@ -864,6 +888,8 @@ impl ::core::cmp::Eq for Mixed { #[no_coverage] fn assert_receiver_is_total_eq(&self) -> () { let _: ::core::cmp::AssertParamIsEq<u32>; + let _: ::core::cmp::AssertParamIsEq<Option<u32>>; + let _: ::core::cmp::AssertParamIsEq<Option<i32>>; } } #[automatically_derived] @@ -963,7 +989,8 @@ impl ::core::hash::Hash for Fielded { } } } -impl ::core::marker::StructuralPartialEq for Fielded {} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Fielded { } #[automatically_derived] impl ::core::cmp::PartialEq for Fielded { #[inline] @@ -982,7 +1009,8 @@ impl ::core::cmp::PartialEq for Fielded { } } } -impl ::core::marker::StructuralEq for Fielded {} +#[automatically_derived] +impl ::core::marker::StructuralEq for Fielded { } #[automatically_derived] impl ::core::cmp::Eq for Fielded { #[inline] diff --git a/src/test/ui/deriving/deriving-hash.rs b/src/test/ui/deriving/deriving-hash.rs index 8b51370bca5..16738ec4ae4 100644 --- a/src/test/ui/deriving/deriving-hash.rs +++ b/src/test/ui/deriving/deriving-hash.rs @@ -44,6 +44,17 @@ fn fake_hash<A: Hash>(v: &mut Vec<u8>, a: A) { a.hash(&mut FakeHasher(v)); } +struct OnlyOneByteHasher; +impl Hasher for OnlyOneByteHasher { + fn finish(&self) -> u64 { + unreachable!() + } + + fn write(&mut self, bytes: &[u8]) { + assert_eq!(bytes.len(), 1); + } +} + fn main() { let person1 = Person { id: 5, @@ -73,4 +84,13 @@ fn main() { let mut v = vec![]; fake_hash(&mut v, SingleVariantEnum::A(17)); assert_eq!(vec![17], v); + + // issue #39137 + #[repr(u8)] + #[derive(Hash)] + enum E { + A, + B, + } + E::A.hash(&mut OnlyOneByteHasher); } diff --git a/src/test/ui/deriving/issue-103157.rs b/src/test/ui/deriving/issue-103157.rs new file mode 100644 index 00000000000..52b4c7898d8 --- /dev/null +++ b/src/test/ui/deriving/issue-103157.rs @@ -0,0 +1,12 @@ +// check-fail + +#[derive(PartialEq, Eq)] +pub enum Value { + Boolean(Option<bool>), + Float(Option<f64>), //~ ERROR the trait bound `f64: Eq` is not satisfied +} + +fn main() { + let a = Value::Float(Some(f64::NAN)); + assert!(a == a); +} diff --git a/src/test/ui/deriving/issue-103157.stderr b/src/test/ui/deriving/issue-103157.stderr new file mode 100644 index 00000000000..ee3528fe106 --- /dev/null +++ b/src/test/ui/deriving/issue-103157.stderr @@ -0,0 +1,30 @@ +error[E0277]: the trait bound `f64: Eq` is not satisfied + --> $DIR/issue-103157.rs:6:11 + | +LL | #[derive(PartialEq, Eq)] + | -- in this derive macro expansion +... +LL | Float(Option<f64>), + | ^^^^^^^^^^^ the trait `Eq` is not implemented for `f64` + | + = help: the following other types implement trait `Eq`: + i128 + i16 + i32 + i64 + i8 + isize + u128 + u16 + and 4 others + = note: required for `Option<f64>` to implement `Eq` +note: required by a bound in `AssertParamIsEq` + --> $SRC_DIR/core/src/cmp.rs:LL:COL + | +LL | pub struct AssertParamIsEq<T: Eq + ?Sized> { + | ^^ required by this bound in `AssertParamIsEq` + = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/drop/drop_order.rs b/src/test/ui/drop/drop_order.rs index ba1ac53aa7c..42385216ae7 100644 --- a/src/test/ui/drop/drop_order.rs +++ b/src/test/ui/drop/drop_order.rs @@ -129,10 +129,10 @@ impl DropOrderCollector { // take the "else" branch if self.option_loud_drop(6).is_some() // 2 && self.option_loud_drop(5).is_some() // 1 - && let None = self.option_loud_drop(7) { // 3 + && let None = self.option_loud_drop(8) { // 4 unreachable!(); } else { - self.print(8); // 4 + self.print(7); // 3 } // let exprs interspersed diff --git a/src/test/ui/drop/issue-100276.rs b/src/test/ui/drop/issue-100276.rs new file mode 100644 index 00000000000..6401a8d1481 --- /dev/null +++ b/src/test/ui/drop/issue-100276.rs @@ -0,0 +1,12 @@ +// check-pass +// compile-flags: -Z validate-mir +#![feature(let_chains)] + +fn let_chains(entry: std::io::Result<std::fs::DirEntry>) { + if let Ok(entry) = entry + && let Some(s) = entry.file_name().to_str() + && s.contains("") + {} +} + +fn main() {} diff --git a/src/test/ui/issues/issue-23338-ensure-param-drop-order.rs b/src/test/ui/drop/issue-23338-ensure-param-drop-order.rs index a99f260dde3..a99f260dde3 100644 --- a/src/test/ui/issues/issue-23338-ensure-param-drop-order.rs +++ b/src/test/ui/drop/issue-23338-ensure-param-drop-order.rs diff --git a/src/test/ui/issues/issue-24805-dropck-itemless.rs b/src/test/ui/dropck/issue-24805-dropck-itemless.rs index 45761b61c3e..45761b61c3e 100644 --- a/src/test/ui/issues/issue-24805-dropck-itemless.rs +++ b/src/test/ui/dropck/issue-24805-dropck-itemless.rs diff --git a/src/test/ui/empty_global_asm.rs b/src/test/ui/empty_global_asm.rs index dbcc7be0578..af13762d118 100644 --- a/src/test/ui/empty_global_asm.rs +++ b/src/test/ui/empty_global_asm.rs @@ -1,21 +1,8 @@ +// needs-asm-support // run-pass -#[allow(unused_imports)] use std::arch::global_asm; -#[cfg(target_arch = "x86")] -global_asm!(""); - -#[cfg(target_arch = "x86_64")] -global_asm!(""); - -#[cfg(target_arch = "arm")] -global_asm!(""); - -#[cfg(target_arch = "aarch64")] -global_asm!(""); - -#[cfg(target_arch = "mips")] global_asm!(""); fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-asm_sym.rs b/src/test/ui/feature-gates/feature-gate-asm_sym.rs deleted file mode 100644 index 0de6b3abb18..00000000000 --- a/src/test/ui/feature-gates/feature-gate-asm_sym.rs +++ /dev/null @@ -1,19 +0,0 @@ -// only-x86_64 - -use std::arch::asm; - -fn bar<const N: usize>() {} - -fn foo<const N: usize>() { - unsafe { - asm!("mov eax, {}", sym bar::<N>); - //~^ ERROR sym operands for inline assembly are unstable - } -} - -fn main() { - unsafe { - asm!("mov eax, {}", sym foo::<0>); - //~^ ERROR sym operands for inline assembly are unstable - } -} diff --git a/src/test/ui/feature-gates/feature-gate-asm_sym.stderr b/src/test/ui/feature-gates/feature-gate-asm_sym.stderr deleted file mode 100644 index d4b16f60b0b..00000000000 --- a/src/test/ui/feature-gates/feature-gate-asm_sym.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0658]: sym operands for inline assembly are unstable - --> $DIR/feature-gate-asm_sym.rs:9:29 - | -LL | asm!("mov eax, {}", sym bar::<N>); - | ^^^^^^^^^^^^ - | - = note: see issue #93333 <https://github.com/rust-lang/rust/issues/93333> for more information - = help: add `#![feature(asm_sym)]` to the crate attributes to enable - -error[E0658]: sym operands for inline assembly are unstable - --> $DIR/feature-gate-asm_sym.rs:16:29 - | -LL | asm!("mov eax, {}", sym foo::<0>); - | ^^^^^^^^^^^^ - | - = note: see issue #93333 <https://github.com/rust-lang/rust/issues/93333> for more information - = help: add `#![feature(asm_sym)]` to the crate attributes to enable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/generic-associated-types/bugs/issue-89008.stderr b/src/test/ui/generic-associated-types/bugs/issue-89008.stderr deleted file mode 100644 index 3f72734efa1..00000000000 --- a/src/test/ui/generic-associated-types/bugs/issue-89008.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0271]: type mismatch resolving `<Empty<_> as Stream>::Item == Repr` - --> $DIR/issue-89008.rs:38:43 - | -LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> { - | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Empty<_> as Stream>::Item == Repr` - | | - | this type parameter - | -note: expected this to be `()` - --> $DIR/issue-89008.rs:17:17 - | -LL | type Item = (); - | ^^ - = note: expected unit type `()` - found type parameter `Repr` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/generic-associated-types/bugs/issue-91762.rs b/src/test/ui/generic-associated-types/bugs/issue-91762.rs index 796935cc06f..dec668bec10 100644 --- a/src/test/ui/generic-associated-types/bugs/issue-91762.rs +++ b/src/test/ui/generic-associated-types/bugs/issue-91762.rs @@ -1,7 +1,7 @@ // check-fail // known-bug -// We almost certaintly want this to pass, but +// We almost certainly want this to pass, but // it's particularly difficult currently, because we need a way of specifying // that `<Self::Base as Functor>::With<T> = Self` without using that when we have // a `U`. See `https://github.com/rust-lang/rust/pull/92728` for a (hacky) diff --git a/src/test/ui/generic-associated-types/bugs/issue-89008.rs b/src/test/ui/generic-associated-types/issue-89008.rs index 012aa8df2fc..669dbafb5d5 100644 --- a/src/test/ui/generic-associated-types/bugs/issue-89008.rs +++ b/src/test/ui/generic-associated-types/issue-89008.rs @@ -1,42 +1,36 @@ -// check-fail +// check-pass // edition:2021 -// known-bug: #88908 - -// This should pass, but seems to run into a TAIT bug. #![feature(type_alias_impl_trait)] use std::future::Future; +use std::marker::PhantomData; trait Stream { type Item; } -struct Empty<T>(T); -impl<T> Stream for Empty<T> { - type Item = (); +struct Empty<T> { + _phantom: PhantomData<T>, } -fn empty<T>() -> Empty<T> { - todo!() + +impl<T> Stream for Empty<T> { + type Item = T; } trait X { type LineStream<'a, Repr>: Stream<Item = Repr> where Self: 'a; - - type LineStreamFut<'a,Repr>: Future<Output = Self::LineStream<'a, Repr>> where Self: 'a; - - fn line_stream<'a,Repr>(&'a self) -> Self::LineStreamFut<'a,Repr>; + type LineStreamFut<'a, Repr>: Future<Output = Self::LineStream<'a, Repr>> where Self: 'a; + fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr>; } struct Y; impl X for Y { type LineStream<'a, Repr> = impl Stream<Item = Repr>; - - type LineStreamFut<'a, Repr> = impl Future<Output = Self::LineStream<'a, Repr>> ; - + type LineStreamFut<'a, Repr> = impl Future<Output = Self::LineStream<'a, Repr>>; fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> { - async {empty()} + async { Empty { _phantom: PhantomData } } } } diff --git a/src/test/ui/higher-rank-trait-bounds/issue-100689.rs b/src/test/ui/higher-rank-trait-bounds/issue-100689.rs new file mode 100644 index 00000000000..2db7f8a354c --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/issue-100689.rs @@ -0,0 +1,29 @@ +// check-pass + +struct Foo<'a> { + foo: &'a mut usize, +} + +trait Bar<'a> { + type FooRef<'b> + where + 'a: 'b; + fn uwu(foo: Foo<'a>, f: impl for<'b> FnMut(Self::FooRef<'b>)); +} +impl<'a> Bar<'a> for () { + type FooRef<'b> + = + &'b Foo<'a> + where + 'a : 'b, + ; + + fn uwu( + foo: Foo<'a>, + mut f: impl for<'b> FnMut(&'b Foo<'a>), //relevant part + ) { + f(&foo); + } +} + +fn main() {} diff --git a/src/test/ui/higher-rank-trait-bounds/issue-102899.rs b/src/test/ui/higher-rank-trait-bounds/issue-102899.rs new file mode 100644 index 00000000000..952b81584f3 --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/issue-102899.rs @@ -0,0 +1,32 @@ +// check-pass + +pub trait BufferTrait<'buffer> { + type Subset<'channel> + where + 'buffer: 'channel; + + fn for_each_subset<F>(&self, f: F) + where + F: for<'channel> Fn(Self::Subset<'channel>); +} + +pub struct SomeBuffer<'buffer> { + samples: &'buffer [()], +} + +impl<'buffer> BufferTrait<'buffer> for SomeBuffer<'buffer> { + type Subset<'subset> = Subset<'subset> where 'buffer: 'subset; + + fn for_each_subset<F>(&self, _f: F) + where + F: for<'subset> Fn(Subset<'subset>), + { + todo!() + } +} + +pub struct Subset<'subset> { + buffer: &'subset [()], +} + +fn main() {} diff --git a/src/test/ui/hygiene/globs.stderr b/src/test/ui/hygiene/globs.stderr index bcfcc28adf7..1f2a96a4c41 100644 --- a/src/test/ui/hygiene/globs.stderr +++ b/src/test/ui/hygiene/globs.stderr @@ -1,9 +1,16 @@ error[E0425]: cannot find function `f` in this scope --> $DIR/globs.rs:22:9 | +LL | pub fn g() {} + | ---------- similarly named function `g` defined here +... LL | f(); - | ^ not found in this scope + | ^ + | +help: a function with a similar name exists | +LL | g(); + | ~ help: consider importing this function | LL | use foo::f; @@ -12,8 +19,11 @@ LL | use foo::f; error[E0425]: cannot find function `g` in this scope --> $DIR/globs.rs:15:5 | +LL | pub fn f() {} + | ---------- similarly named function `f` defined here +... LL | g(); - | ^ not found in this scope + | ^ ... LL | / m! { LL | | use bar::*; @@ -23,6 +33,10 @@ LL | | } | |_____- in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) +help: a function with a similar name exists + | +LL | f(); + | ~ help: consider importing this function | LL | use bar::g; diff --git a/src/test/ui/hygiene/rustc-macro-transparency.stderr b/src/test/ui/hygiene/rustc-macro-transparency.stderr index 17d05dd0963..1d2a1e12498 100644 --- a/src/test/ui/hygiene/rustc-macro-transparency.stderr +++ b/src/test/ui/hygiene/rustc-macro-transparency.stderr @@ -19,14 +19,8 @@ LL | semitransparent; error[E0423]: expected value, found macro `opaque` --> $DIR/rustc-macro-transparency.rs:30:5 | -LL | struct Opaque; - | -------------- similarly named unit struct `Opaque` defined here -... LL | opaque; - | ^^^^^^ - | | - | not a value - | help: a unit struct with a similar name exists (notice the capitalization): `Opaque` + | ^^^^^^ not a value error: aborting due to 3 previous errors diff --git a/src/test/ui/impl-trait/auto-trait-leak.stderr b/src/test/ui/impl-trait/auto-trait-leak.stderr index b6e28364768..feedfc40aaf 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.stderr +++ b/src/test/ui/impl-trait/auto-trait-leak.stderr @@ -9,12 +9,12 @@ note: ...which requires borrow-checking `cycle1`... | LL | fn cycle1() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing `cycle1`... +note: ...which requires processing MIR for `cycle1`... --> $DIR/auto-trait-leak.rs:12:1 | LL | fn cycle1() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing MIR for `cycle1`... +note: ...which requires preparing `cycle1` for borrow checking... --> $DIR/auto-trait-leak.rs:12:1 | LL | fn cycle1() -> impl Clone { @@ -50,12 +50,12 @@ note: ...which requires borrow-checking `cycle2`... | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing `cycle2`... +note: ...which requires processing MIR for `cycle2`... --> $DIR/auto-trait-leak.rs:19:1 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing MIR for `cycle2`... +note: ...which requires preparing `cycle2` for borrow checking... --> $DIR/auto-trait-leak.rs:19:1 | LL | fn cycle2() -> impl Clone { diff --git a/src/test/ui/impl-trait/hidden-lifetimes.stderr b/src/test/ui/impl-trait/hidden-lifetimes.stderr index efc228de58b..de06ded7acd 100644 --- a/src/test/ui/impl-trait/hidden-lifetimes.stderr +++ b/src/test/ui/impl-trait/hidden-lifetimes.stderr @@ -1,4 +1,4 @@ -error[E0700]: hidden type for `impl Swap` captures lifetime that does not appear in bounds +error[E0700]: hidden type for `impl Swap + 'a` captures lifetime that does not appear in bounds --> $DIR/hidden-lifetimes.rs:29:5 | LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a { @@ -11,7 +11,7 @@ help: to declare that the `impl Trait` captures `'b`, you can add an explicit `' LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a + 'b { | ++++ -error[E0700]: hidden type for `impl Swap` captures lifetime that does not appear in bounds +error[E0700]: hidden type for `impl Swap + 'a` captures lifetime that does not appear in bounds --> $DIR/hidden-lifetimes.rs:46:5 | LL | fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a { diff --git a/src/test/ui/impl-trait/in-trait/default-body-type-err-2.rs b/src/test/ui/impl-trait/in-trait/default-body-type-err-2.rs new file mode 100644 index 00000000000..45ae2b8ad3a --- /dev/null +++ b/src/test/ui/impl-trait/in-trait/default-body-type-err-2.rs @@ -0,0 +1,13 @@ +// edition:2021 + +#![allow(incomplete_features)] +#![feature(async_fn_in_trait)] + +pub trait Foo { + async fn woopsie_async(&self) -> String { + 42 + //~^ ERROR mismatched types + } +} + +fn main() {} diff --git a/src/test/ui/impl-trait/in-trait/default-body-type-err-2.stderr b/src/test/ui/impl-trait/in-trait/default-body-type-err-2.stderr new file mode 100644 index 00000000000..142b1bff1a4 --- /dev/null +++ b/src/test/ui/impl-trait/in-trait/default-body-type-err-2.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/default-body-type-err-2.rs:8:9 + | +LL | 42 + | ^^- help: try using a conversion method: `.to_string()` + | | + | expected struct `String`, found integer + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/impl-trait/in-trait/default-body-type-err.rs b/src/test/ui/impl-trait/in-trait/default-body-type-err.rs new file mode 100644 index 00000000000..ac9baf91cae --- /dev/null +++ b/src/test/ui/impl-trait/in-trait/default-body-type-err.rs @@ -0,0 +1,13 @@ +#![allow(incomplete_features)] +#![feature(return_position_impl_trait_in_trait)] + +use std::ops::Deref; + +pub trait Foo { + fn lol(&self) -> impl Deref<Target = String> { + //~^ type mismatch resolving `<&i32 as Deref>::Target == String` + &1i32 + } +} + +fn main() {} diff --git a/src/test/ui/impl-trait/in-trait/default-body-type-err.stderr b/src/test/ui/impl-trait/in-trait/default-body-type-err.stderr new file mode 100644 index 00000000000..461247a3e3f --- /dev/null +++ b/src/test/ui/impl-trait/in-trait/default-body-type-err.stderr @@ -0,0 +1,12 @@ +error[E0271]: type mismatch resolving `<&i32 as Deref>::Target == String` + --> $DIR/default-body-type-err.rs:7:22 + | +LL | fn lol(&self) -> impl Deref<Target = String> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found struct `String` +LL | +LL | &1i32 + | ----- return type was inferred to be `&i32` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/impl-trait/in-trait/default-body-with-rpit.rs b/src/test/ui/impl-trait/in-trait/default-body-with-rpit.rs index f0d407cd527..ad3cc7c2524 100644 --- a/src/test/ui/impl-trait/in-trait/default-body-with-rpit.rs +++ b/src/test/ui/impl-trait/in-trait/default-body-with-rpit.rs @@ -1,4 +1,4 @@ -// known-bug: #102688 +// check-pass // edition:2021 #![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] diff --git a/src/test/ui/impl-trait/in-trait/default-body-with-rpit.stderr b/src/test/ui/impl-trait/in-trait/default-body-with-rpit.stderr deleted file mode 100644 index 4529d301f9e..00000000000 --- a/src/test/ui/impl-trait/in-trait/default-body-with-rpit.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0720]: cannot resolve opaque type - --> $DIR/default-body-with-rpit.rs:10:28 - | -LL | async fn baz(&self) -> impl Debug { - | ^^^^^^^^^^ cannot resolve opaque type - | - = note: these returned values have a concrete "never" type - = help: this error will resolve once the item's body returns a concrete type - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0720`. diff --git a/src/test/ui/impl-trait/in-trait/issue-102301.rs b/src/test/ui/impl-trait/in-trait/issue-102301.rs new file mode 100644 index 00000000000..a93714a658e --- /dev/null +++ b/src/test/ui/impl-trait/in-trait/issue-102301.rs @@ -0,0 +1,18 @@ +// check-pass + +#![feature(return_position_impl_trait_in_trait)] +#![allow(incomplete_features)] + +trait Foo<T> { + fn foo<F2: Foo<T>>(self) -> impl Foo<T>; +} + +struct Bar; + +impl Foo<u8> for Bar { + fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> { + self + } +} + +fn main() {} diff --git a/src/test/ui/impl-trait/issue-103181-1.rs b/src/test/ui/impl-trait/issue-103181-1.rs new file mode 100644 index 00000000000..197aedf9d98 --- /dev/null +++ b/src/test/ui/impl-trait/issue-103181-1.rs @@ -0,0 +1,85 @@ +// edition:2021 + +mod hyper { + use std::{fmt::Debug, future::Future, marker::PhantomData, pin::Pin, task::Poll}; + + pub trait HttpBody { + type Error; + } + impl HttpBody for () { + //~^ ERROR not all trait items implemented, missing: `Error` + // don't implement `Error` here for the ICE + } + + pub struct Server<I, S>(I, S); + + pub fn serve<I, S>(_: S) -> Server<I, S> { + todo!() + } + + impl<S, B> Future for Server<(), S> + where + S: MakeServiceRef<(), (), ResBody = B>, + B: HttpBody, + B::Error: Debug, + { + type Output = (); + + fn poll(self: Pin<&mut Self>, _: &mut std::task::Context<'_>) -> Poll<Self::Output> { + todo!() + } + } + + pub trait MakeServiceRef<Target, ReqBody> { + type ResBody; + } + + impl<T, S> MakeServiceRef<(), ()> for T + where + T: for<'a> Service<&'a (), Response = S>, + S: Service<()>, + { + type ResBody = (); + } + + pub struct MakeServiceFn<F>(pub F); + pub struct ServiceFn<F, R>(pub PhantomData<(F, R)>); + + pub trait Service<Request> { + type Response; + } + + impl<'t, F, Ret, Target, Svc> Service<&'t Target> for MakeServiceFn<F> + where + F: Fn() -> Ret, + Ret: Future<Output = Result<Svc, ()>>, + { + type Response = Svc; + } + + impl<F, ReqBody, Ret, ResBody, E> Service<ReqBody> for ServiceFn<F, ReqBody> + where + F: Fn() -> Ret, + Ret: Future<Output = Result<ResBody, E>>, + { + type Response = ResBody; + } +} + +async fn smarvice() -> Result<(), ()> { + Ok(()) +} + +fn service_fn<F, R, S>(f: F) -> hyper::ServiceFn<F, R> +where + F: Fn() -> S, +{ + hyper::ServiceFn(std::marker::PhantomData) +} + +async fn iceice() { + let service = hyper::MakeServiceFn(|| async { Ok::<_, ()>(service_fn(|| smarvice())) }); + hyper::serve::<(), _>(service).await; +} + +fn main() {} diff --git a/src/test/ui/impl-trait/issue-103181-1.stderr b/src/test/ui/impl-trait/issue-103181-1.stderr new file mode 100644 index 00000000000..cd026607d52 --- /dev/null +++ b/src/test/ui/impl-trait/issue-103181-1.stderr @@ -0,0 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `Error` + --> $DIR/issue-103181-1.rs:9:5 + | +LL | type Error; + | ---------- `Error` from trait +LL | } +LL | impl HttpBody for () { + | ^^^^^^^^^^^^^^^^^^^^ missing `Error` in implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/src/test/ui/impl-trait/issue-103181-2.rs b/src/test/ui/impl-trait/issue-103181-2.rs new file mode 100644 index 00000000000..b43ac45075e --- /dev/null +++ b/src/test/ui/impl-trait/issue-103181-2.rs @@ -0,0 +1,29 @@ +// edition:2021 + +trait SendFuture: Send { + type Output; +} + +impl<Fut: Send> SendFuture for Fut { + type Output = (); +} + +async fn broken_fut() { + ident_error; + //~^ ERROR cannot find value `ident_error` in this scope +} + +// triggers normalization of `<Fut as SendFuture>::Output`, +// which requires `Fut: Send`. +fn normalize<Fut: SendFuture>(_: Fut, _: Fut::Output) {} + +async fn iceice<A, B>() +// <- async fn is necessary +where + A: Send, + B: Send, // <- a second bound +{ + normalize(broken_fut(), ()); +} + +fn main() {} diff --git a/src/test/ui/impl-trait/issue-103181-2.stderr b/src/test/ui/impl-trait/issue-103181-2.stderr new file mode 100644 index 00000000000..5eb2dd9184b --- /dev/null +++ b/src/test/ui/impl-trait/issue-103181-2.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find value `ident_error` in this scope + --> $DIR/issue-103181-2.rs:12:5 + | +LL | ident_error; + | ^^^^^^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/impl-trait/issue-86465.rs b/src/test/ui/impl-trait/issue-86465.rs index a79bb6474d8..8c7b41d73b7 100644 --- a/src/test/ui/impl-trait/issue-86465.rs +++ b/src/test/ui/impl-trait/issue-86465.rs @@ -1,6 +1,10 @@ #![feature(type_alias_impl_trait)] -type X<'a, 'b> = impl std::fmt::Debug; +pub trait Captures<'a> {} + +impl<'a, T: ?Sized> Captures<'a> for T {} + +type X<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>; fn f<'t, 'u>(a: &'t u32, b: &'u u32) -> (X<'t, 'u>, X<'u, 't>) { (a, a) diff --git a/src/test/ui/impl-trait/issue-86465.stderr b/src/test/ui/impl-trait/issue-86465.stderr index 90d6904ed61..b949b2b4245 100644 --- a/src/test/ui/impl-trait/issue-86465.stderr +++ b/src/test/ui/impl-trait/issue-86465.stderr @@ -1,5 +1,5 @@ error: concrete type differs from previous defining opaque type use - --> $DIR/issue-86465.rs:6:5 + --> $DIR/issue-86465.rs:10:5 | LL | (a, a) | ^^^^^^ diff --git a/src/test/ui/impl-trait/nested-rpit-with-anonymous-lifetimes.rs b/src/test/ui/impl-trait/nested-rpit-with-anonymous-lifetimes.rs new file mode 100644 index 00000000000..287a030cf87 --- /dev/null +++ b/src/test/ui/impl-trait/nested-rpit-with-anonymous-lifetimes.rs @@ -0,0 +1,23 @@ +// check-pass + +pub struct VecNumber<'s> { + pub vec_number: Vec<Number<'s>>, + pub auxiliary_object: &'s Vec<usize>, +} + +pub struct Number<'s> { + pub number: &'s usize, +} + +impl<'s> VecNumber<'s> { + pub fn vec_number_iterable_per_item_in_auxiliary_object( + &self, + ) -> impl Iterator<Item = (&'s usize, impl Iterator<Item = &Number<'s>>)> { + self.auxiliary_object.iter().map(move |n| { + let iter_number = self.vec_number.iter(); + (n, iter_number) + }) + } +} + +fn main() {} diff --git a/src/test/ui/inference/char-as-str-single.fixed b/src/test/ui/inference/char-as-str-single.fixed index e401492a830..bab1854dc51 100644 --- a/src/test/ui/inference/char-as-str-single.fixed +++ b/src/test/ui/inference/char-as-str-single.fixed @@ -8,4 +8,5 @@ fn main() { let _: char = 'a'; //~ ERROR mismatched types let _: char = '人'; //~ ERROR mismatched types + let _: char = '\''; //~ ERROR mismatched types } diff --git a/src/test/ui/inference/char-as-str-single.rs b/src/test/ui/inference/char-as-str-single.rs index 4f23cea5354..736920643b2 100644 --- a/src/test/ui/inference/char-as-str-single.rs +++ b/src/test/ui/inference/char-as-str-single.rs @@ -8,4 +8,5 @@ fn main() { let _: char = "a"; //~ ERROR mismatched types let _: char = "人"; //~ ERROR mismatched types + let _: char = "'"; //~ ERROR mismatched types } diff --git a/src/test/ui/inference/char-as-str-single.stderr b/src/test/ui/inference/char-as-str-single.stderr index 29075c15414..3375ec6ac32 100644 --- a/src/test/ui/inference/char-as-str-single.stderr +++ b/src/test/ui/inference/char-as-str-single.stderr @@ -24,6 +24,19 @@ help: if you meant to write a `char` literal, use single quotes LL | let _: char = '人'; | ~~~~ -error: aborting due to 2 previous errors +error[E0308]: mismatched types + --> $DIR/char-as-str-single.rs:11:19 + | +LL | let _: char = "'"; + | ---- ^^^ expected `char`, found `&str` + | | + | expected due to this + | +help: if you meant to write a `char` literal, use single quotes + | +LL | let _: char = '\''; + | ~~~~ + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/issues/issue-36053.rs b/src/test/ui/inference/issue-36053.rs index 5c6d0780416..5c6d0780416 100644 --- a/src/test/ui/issues/issue-36053.rs +++ b/src/test/ui/inference/issue-36053.rs diff --git a/src/test/ui/inference/need_type_info/issue-103053.rs b/src/test/ui/inference/need_type_info/issue-103053.rs new file mode 100644 index 00000000000..05169666f83 --- /dev/null +++ b/src/test/ui/inference/need_type_info/issue-103053.rs @@ -0,0 +1,18 @@ +trait TypeMapper { + type MapType; +} + +type Mapped<T> = <T as TypeMapper>::MapType; + +struct Test {} + +impl TypeMapper for () { + type MapType = Test; +} + +fn test() { + Mapped::<()> {}; + None; //~ ERROR type annotations needed +} + +fn main() {} diff --git a/src/test/ui/inference/need_type_info/issue-103053.stderr b/src/test/ui/inference/need_type_info/issue-103053.stderr new file mode 100644 index 00000000000..84f0475d8cd --- /dev/null +++ b/src/test/ui/inference/need_type_info/issue-103053.stderr @@ -0,0 +1,14 @@ +error[E0282]: type annotations needed + --> $DIR/issue-103053.rs:15:5 + | +LL | None; + | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option` + | +help: consider specifying the generic argument + | +LL | None::<T>; + | +++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/inference/str-as-char.fixed b/src/test/ui/inference/str-as-char.fixed index 09f3dec5a17..6aea809cbdb 100644 --- a/src/test/ui/inference/str-as-char.fixed +++ b/src/test/ui/inference/str-as-char.fixed @@ -4,5 +4,7 @@ // run-rustfix fn main() { - let _: &str = "a"; //~ ERROR mismatched types + let _: &str = "a"; //~ ERROR mismatched types + let _: &str = "\"\"\""; //~ ERROR character literal may only contain one codepoint + let _: &str = "\"\"\""; //~ ERROR character literal may only contain one codepoint } diff --git a/src/test/ui/inference/str-as-char.rs b/src/test/ui/inference/str-as-char.rs index 7092a612442..eaa8d788c34 100644 --- a/src/test/ui/inference/str-as-char.rs +++ b/src/test/ui/inference/str-as-char.rs @@ -4,5 +4,7 @@ // run-rustfix fn main() { - let _: &str = 'a'; //~ ERROR mismatched types + let _: &str = 'a'; //~ ERROR mismatched types + let _: &str = '"""'; //~ ERROR character literal may only contain one codepoint + let _: &str = '\"\"\"'; //~ ERROR character literal may only contain one codepoint } diff --git a/src/test/ui/inference/str-as-char.stderr b/src/test/ui/inference/str-as-char.stderr index ebbe7c80f77..2c84dac8e0c 100644 --- a/src/test/ui/inference/str-as-char.stderr +++ b/src/test/ui/inference/str-as-char.stderr @@ -1,3 +1,25 @@ +error: character literal may only contain one codepoint + --> $DIR/str-as-char.rs:8:19 + | +LL | let _: &str = '"""'; + | ^^^^^ + | +help: if you meant to write a `str` literal, use double quotes + | +LL | let _: &str = "\"\"\""; + | ~~~~~~~~ + +error: character literal may only contain one codepoint + --> $DIR/str-as-char.rs:9:19 + | +LL | let _: &str = '\"\"\"'; + | ^^^^^^^^ + | +help: if you meant to write a `str` literal, use double quotes + | +LL | let _: &str = "\"\"\""; + | ~~~~~~~~ + error[E0308]: mismatched types --> $DIR/str-as-char.rs:7:19 | @@ -11,6 +33,6 @@ help: if you meant to write a `str` literal, use double quotes LL | let _: &str = "a"; | ~~~ -error: aborting due to previous error +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/issues/issue-30490.rs b/src/test/ui/issues/issue-30490.rs index 47c17e362ae..68d9c4de4d1 100644 --- a/src/test/ui/issues/issue-30490.rs +++ b/src/test/ui/issues/issue-30490.rs @@ -1,6 +1,7 @@ // run-pass // ignore-emscripten no processes // ignore-sgx no processes +// ignore-fuchsia Child I/O swaps not privileged // Previously libstd would set stdio descriptors of a child process // by `dup`ing the requested descriptors to inherit directly into the diff --git a/src/test/ui/issues/issue-35241.stderr b/src/test/ui/issues/issue-35241.stderr index 9ee7654a088..42a78ed97e0 100644 --- a/src/test/ui/issues/issue-35241.stderr +++ b/src/test/ui/issues/issue-35241.stderr @@ -11,7 +11,7 @@ LL | fn test() -> Foo { Foo } | = note: expected struct `Foo` found fn item `fn(u32) -> Foo {Foo}` -help: use parentheses to instantiate this tuple struct +help: use parentheses to construct this tuple struct | LL | fn test() -> Foo { Foo(/* u32 */) } | +++++++++++ diff --git a/src/test/ui/issues/issue-59488.stderr b/src/test/ui/issues/issue-59488.stderr index 08fe0b35eb7..f9846b62a72 100644 --- a/src/test/ui/issues/issue-59488.stderr +++ b/src/test/ui/issues/issue-59488.stderr @@ -99,7 +99,7 @@ LL | assert_eq!(Foo::Bar, i); extern "C" fn(A, B, C, D) -> Ret extern "C" fn(A, B, C, D, ...) -> Ret extern "C" fn(A, B, C, D, E) -> Ret - and 68 others + and 118 others = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `fn(usize) -> Foo {Foo::Bar}` doesn't implement `Debug` @@ -118,7 +118,7 @@ LL | assert_eq!(Foo::Bar, i); extern "C" fn(A, B, C, D) -> Ret extern "C" fn(A, B, C, D, ...) -> Ret extern "C" fn(A, B, C, D, E) -> Ret - and 68 others + and 118 others = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 10 previous errors diff --git a/src/test/ui/issues/issue-6458-3.stderr b/src/test/ui/issues/issue-6458-3.stderr index 2c3ec1a331f..520efccae51 100644 --- a/src/test/ui/issues/issue-6458-3.stderr +++ b/src/test/ui/issues/issue-6458-3.stderr @@ -2,12 +2,12 @@ error[E0282]: type annotations needed --> $DIR/issue-6458-3.rs:4:5 | LL | mem::transmute(0); - | ^^^^^^^^^^^^^^ cannot infer type of the type parameter `U` declared on the function `transmute` + | ^^^^^^^^^^^^^^ cannot infer type of the type parameter `Dst` declared on the function `transmute` | help: consider specifying the generic arguments | -LL | mem::transmute::<i32, U>(0); - | ++++++++++ +LL | mem::transmute::<i32, Dst>(0); + | ++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr b/src/test/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr index 7f29709ce50..b30bcfb776c 100644 --- a/src/test/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr +++ b/src/test/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr @@ -29,7 +29,7 @@ LL | assert_eq!(a, 0); | ^^^^^^^^^^^^^^^^ `fn() -> i32 {a}` cannot be formatted using `{:?}` because it doesn't implement `Debug` | = help: the trait `Debug` is not implemented for fn item `fn() -> i32 {a}` - = help: use parentheses to call the function: `a()` + = help: use parentheses to call this function: `a()` = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/src/test/ui/let-else/let-else-non-diverging.rs b/src/test/ui/let-else/let-else-non-diverging.rs index 58d2c09776f..a5442dd82f0 100644 --- a/src/test/ui/let-else/let-else-non-diverging.rs +++ b/src/test/ui/let-else/let-else-non-diverging.rs @@ -11,7 +11,7 @@ fn main() { // Ensure that uninhabited types do not "diverge". // This might be relaxed in the future, but when it is, - // it should be an explicitly wanted descision. + // it should be an explicitly wanted decision. let Some(x) = Some(1) else { foo::<Uninhabited>() }; //~ ERROR does not diverge } diff --git a/src/test/ui/lexical-scopes.stderr b/src/test/ui/lexical-scopes.stderr index 08e4be2c0c3..53598545223 100644 --- a/src/test/ui/lexical-scopes.stderr +++ b/src/test/ui/lexical-scopes.stderr @@ -1,6 +1,8 @@ error[E0574]: expected struct, variant or union type, found type parameter `T` --> $DIR/lexical-scopes.rs:3:13 | +LL | struct T { i: i32 } + | ------------------- you might have meant to refer to this struct LL | fn f<T>() { | - found this type parameter LL | let t = T { i: 0 }; diff --git a/src/test/ui/lifetimes/elided-lifetime-in-param-pat.rs b/src/test/ui/lifetimes/elided-lifetime-in-param-pat.rs new file mode 100644 index 00000000000..c1425fa4243 --- /dev/null +++ b/src/test/ui/lifetimes/elided-lifetime-in-param-pat.rs @@ -0,0 +1,11 @@ +// check-pass + +struct S<T> { + _t: T, +} + +fn f(S::<&i8> { .. }: S<&i8>) {} + +fn main() { + f(S { _t: &42_i8 }); +} diff --git a/src/test/ui/lint/invalid_value.rs b/src/test/ui/lint/invalid_value.rs index 946a0e38861..57d8cbe7c93 100644 --- a/src/test/ui/lint/invalid_value.rs +++ b/src/test/ui/lint/invalid_value.rs @@ -44,6 +44,10 @@ enum TwoUninhabited { B(Void), } +#[rustc_layout_scalar_valid_range_start(254)] +#[rustc_layout_scalar_valid_range_end(1)] +pub(crate) struct WrapAroundRange(u8); + #[allow(unused)] fn generic<T: 'static>() { unsafe { @@ -131,6 +135,9 @@ fn main() { let _val: *const [()] = mem::zeroed(); let _val: *const [()] = mem::uninitialized(); //~ ERROR: does not permit being left uninitialized + let _val: WrapAroundRange = mem::zeroed(); + let _val: WrapAroundRange = mem::uninitialized(); //~ ERROR: does not permit being left uninitialized + // Things where 0 is okay due to rustc implementation details, // but that are not guaranteed to keep working. let _val: Result<i32, i32> = mem::zeroed(); diff --git a/src/test/ui/lint/invalid_value.stderr b/src/test/ui/lint/invalid_value.stderr index 3901692001a..76afb765f0f 100644 --- a/src/test/ui/lint/invalid_value.stderr +++ b/src/test/ui/lint/invalid_value.stderr @@ -1,5 +1,5 @@ error: the type `&T` does not permit zero-initialization - --> $DIR/invalid_value.rs:50:32 + --> $DIR/invalid_value.rs:54:32 | LL | let _val: &'static T = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | #![deny(invalid_value)] | ^^^^^^^^^^^^^ error: the type `&T` does not permit being left uninitialized - --> $DIR/invalid_value.rs:51:32 + --> $DIR/invalid_value.rs:55:32 | LL | let _val: &'static T = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | let _val: &'static T = mem::uninitialized(); = note: references must be non-null error: the type `Wrap<&T>` does not permit zero-initialization - --> $DIR/invalid_value.rs:53:38 + --> $DIR/invalid_value.rs:57:38 | LL | let _val: Wrap<&'static T> = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | struct Wrap<T> { wrapped: T } | ^^^^^^^^^^ error: the type `Wrap<&T>` does not permit being left uninitialized - --> $DIR/invalid_value.rs:54:38 + --> $DIR/invalid_value.rs:58:38 | LL | let _val: Wrap<&'static T> = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | struct Wrap<T> { wrapped: T } | ^^^^^^^^^^ error: the type `!` does not permit zero-initialization - --> $DIR/invalid_value.rs:61:23 + --> $DIR/invalid_value.rs:65:23 | LL | let _val: ! = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | let _val: ! = mem::zeroed(); = note: the `!` type has no valid value error: the type `!` does not permit being left uninitialized - --> $DIR/invalid_value.rs:62:23 + --> $DIR/invalid_value.rs:66:23 | LL | let _val: ! = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -78,7 +78,7 @@ LL | let _val: ! = mem::uninitialized(); = note: the `!` type has no valid value error: the type `(i32, !)` does not permit zero-initialization - --> $DIR/invalid_value.rs:64:30 + --> $DIR/invalid_value.rs:68:30 | LL | let _val: (i32, !) = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | let _val: (i32, !) = mem::zeroed(); = note: the `!` type has no valid value error: the type `(i32, !)` does not permit being left uninitialized - --> $DIR/invalid_value.rs:65:30 + --> $DIR/invalid_value.rs:69:30 | LL | let _val: (i32, !) = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | let _val: (i32, !) = mem::uninitialized(); = note: integers must not be uninitialized error: the type `Void` does not permit zero-initialization - --> $DIR/invalid_value.rs:67:26 + --> $DIR/invalid_value.rs:71:26 | LL | let _val: Void = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -115,7 +115,7 @@ LL | enum Void {} | ^^^^^^^^^ error: the type `Void` does not permit being left uninitialized - --> $DIR/invalid_value.rs:68:26 + --> $DIR/invalid_value.rs:72:26 | LL | let _val: Void = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -130,7 +130,7 @@ LL | enum Void {} | ^^^^^^^^^ error: the type `&i32` does not permit zero-initialization - --> $DIR/invalid_value.rs:70:34 + --> $DIR/invalid_value.rs:74:34 | LL | let _val: &'static i32 = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -141,7 +141,7 @@ LL | let _val: &'static i32 = mem::zeroed(); = note: references must be non-null error: the type `&i32` does not permit being left uninitialized - --> $DIR/invalid_value.rs:71:34 + --> $DIR/invalid_value.rs:75:34 | LL | let _val: &'static i32 = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -152,7 +152,7 @@ LL | let _val: &'static i32 = mem::uninitialized(); = note: references must be non-null error: the type `Ref` does not permit zero-initialization - --> $DIR/invalid_value.rs:73:25 + --> $DIR/invalid_value.rs:77:25 | LL | let _val: Ref = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -167,7 +167,7 @@ LL | struct Ref(&'static i32); | ^^^^^^^^^^^^ error: the type `Ref` does not permit being left uninitialized - --> $DIR/invalid_value.rs:74:25 + --> $DIR/invalid_value.rs:78:25 | LL | let _val: Ref = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -182,7 +182,7 @@ LL | struct Ref(&'static i32); | ^^^^^^^^^^^^ error: the type `fn()` does not permit zero-initialization - --> $DIR/invalid_value.rs:76:26 + --> $DIR/invalid_value.rs:80:26 | LL | let _val: fn() = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -193,7 +193,7 @@ LL | let _val: fn() = mem::zeroed(); = note: function pointers must be non-null error: the type `fn()` does not permit being left uninitialized - --> $DIR/invalid_value.rs:77:26 + --> $DIR/invalid_value.rs:81:26 | LL | let _val: fn() = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -204,7 +204,7 @@ LL | let _val: fn() = mem::uninitialized(); = note: function pointers must be non-null error: the type `Wrap<fn()>` does not permit zero-initialization - --> $DIR/invalid_value.rs:79:32 + --> $DIR/invalid_value.rs:83:32 | LL | let _val: Wrap<fn()> = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -219,7 +219,7 @@ LL | struct Wrap<T> { wrapped: T } | ^^^^^^^^^^ error: the type `Wrap<fn()>` does not permit being left uninitialized - --> $DIR/invalid_value.rs:80:32 + --> $DIR/invalid_value.rs:84:32 | LL | let _val: Wrap<fn()> = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -234,7 +234,7 @@ LL | struct Wrap<T> { wrapped: T } | ^^^^^^^^^^ error: the type `WrapEnum<fn()>` does not permit zero-initialization - --> $DIR/invalid_value.rs:82:36 + --> $DIR/invalid_value.rs:86:36 | LL | let _val: WrapEnum<fn()> = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -249,7 +249,7 @@ LL | enum WrapEnum<T> { Wrapped(T) } | ^ error: the type `WrapEnum<fn()>` does not permit being left uninitialized - --> $DIR/invalid_value.rs:83:36 + --> $DIR/invalid_value.rs:87:36 | LL | let _val: WrapEnum<fn()> = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -264,7 +264,7 @@ LL | enum WrapEnum<T> { Wrapped(T) } | ^ error: the type `Wrap<(RefPair, i32)>` does not permit zero-initialization - --> $DIR/invalid_value.rs:85:42 + --> $DIR/invalid_value.rs:89:42 | LL | let _val: Wrap<(RefPair, i32)> = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -279,7 +279,7 @@ LL | struct RefPair((&'static i32, i32)); | ^^^^^^^^^^^^^^^^^^^ error: the type `Wrap<(RefPair, i32)>` does not permit being left uninitialized - --> $DIR/invalid_value.rs:86:42 + --> $DIR/invalid_value.rs:90:42 | LL | let _val: Wrap<(RefPair, i32)> = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -294,7 +294,7 @@ LL | struct RefPair((&'static i32, i32)); | ^^^^^^^^^^^^^^^^^^^ error: the type `NonNull<i32>` does not permit zero-initialization - --> $DIR/invalid_value.rs:88:34 + --> $DIR/invalid_value.rs:92:34 | LL | let _val: NonNull<i32> = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -305,7 +305,7 @@ LL | let _val: NonNull<i32> = mem::zeroed(); = note: `std::ptr::NonNull<i32>` must be non-null error: the type `NonNull<i32>` does not permit being left uninitialized - --> $DIR/invalid_value.rs:89:34 + --> $DIR/invalid_value.rs:93:34 | LL | let _val: NonNull<i32> = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -316,7 +316,7 @@ LL | let _val: NonNull<i32> = mem::uninitialized(); = note: `std::ptr::NonNull<i32>` must be non-null error: the type `(NonZeroU32, i32)` does not permit zero-initialization - --> $DIR/invalid_value.rs:91:39 + --> $DIR/invalid_value.rs:95:39 | LL | let _val: (NonZeroU32, i32) = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -327,7 +327,7 @@ LL | let _val: (NonZeroU32, i32) = mem::zeroed(); = note: `std::num::NonZeroU32` must be non-null error: the type `(NonZeroU32, i32)` does not permit being left uninitialized - --> $DIR/invalid_value.rs:92:39 + --> $DIR/invalid_value.rs:96:39 | LL | let _val: (NonZeroU32, i32) = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -338,7 +338,7 @@ LL | let _val: (NonZeroU32, i32) = mem::uninitialized(); = note: `std::num::NonZeroU32` must be non-null error: the type `*const dyn Send` does not permit zero-initialization - --> $DIR/invalid_value.rs:94:37 + --> $DIR/invalid_value.rs:98:37 | LL | let _val: *const dyn Send = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -349,7 +349,7 @@ LL | let _val: *const dyn Send = mem::zeroed(); = note: the vtable of a wide raw pointer must be non-null error: the type `*const dyn Send` does not permit being left uninitialized - --> $DIR/invalid_value.rs:95:37 + --> $DIR/invalid_value.rs:99:37 | LL | let _val: *const dyn Send = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -360,7 +360,7 @@ LL | let _val: *const dyn Send = mem::uninitialized(); = note: the vtable of a wide raw pointer must be non-null error: the type `[fn(); 2]` does not permit zero-initialization - --> $DIR/invalid_value.rs:97:31 + --> $DIR/invalid_value.rs:101:31 | LL | let _val: [fn(); 2] = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -371,7 +371,7 @@ LL | let _val: [fn(); 2] = mem::zeroed(); = note: function pointers must be non-null error: the type `[fn(); 2]` does not permit being left uninitialized - --> $DIR/invalid_value.rs:98:31 + --> $DIR/invalid_value.rs:102:31 | LL | let _val: [fn(); 2] = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -382,7 +382,7 @@ LL | let _val: [fn(); 2] = mem::uninitialized(); = note: function pointers must be non-null error: the type `TwoUninhabited` does not permit zero-initialization - --> $DIR/invalid_value.rs:100:36 + --> $DIR/invalid_value.rs:104:36 | LL | let _val: TwoUninhabited = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -397,7 +397,7 @@ LL | enum TwoUninhabited { | ^^^^^^^^^^^^^^^^^^^ error: the type `TwoUninhabited` does not permit being left uninitialized - --> $DIR/invalid_value.rs:101:36 + --> $DIR/invalid_value.rs:105:36 | LL | let _val: TwoUninhabited = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -412,7 +412,7 @@ LL | enum TwoUninhabited { | ^^^^^^^^^^^^^^^^^^^ error: the type `OneFruitNonZero` does not permit zero-initialization - --> $DIR/invalid_value.rs:103:37 + --> $DIR/invalid_value.rs:107:37 | LL | let _val: OneFruitNonZero = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -427,7 +427,7 @@ LL | Banana(NonZeroU32), | ^^^^^^^^^^ error: the type `OneFruitNonZero` does not permit being left uninitialized - --> $DIR/invalid_value.rs:104:37 + --> $DIR/invalid_value.rs:108:37 | LL | let _val: OneFruitNonZero = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -442,7 +442,7 @@ LL | Banana(NonZeroU32), | ^^^^^^^^^^ error: the type `bool` does not permit being left uninitialized - --> $DIR/invalid_value.rs:108:26 + --> $DIR/invalid_value.rs:112:26 | LL | let _val: bool = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -453,7 +453,7 @@ LL | let _val: bool = mem::uninitialized(); = note: booleans must be either `true` or `false` error: the type `Wrap<char>` does not permit being left uninitialized - --> $DIR/invalid_value.rs:111:32 + --> $DIR/invalid_value.rs:115:32 | LL | let _val: Wrap<char> = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -468,7 +468,7 @@ LL | struct Wrap<T> { wrapped: T } | ^^^^^^^^^^ error: the type `NonBig` does not permit being left uninitialized - --> $DIR/invalid_value.rs:114:28 + --> $DIR/invalid_value.rs:118:28 | LL | let _val: NonBig = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -479,7 +479,7 @@ LL | let _val: NonBig = mem::uninitialized(); = note: `NonBig` must be initialized inside its custom valid range error: the type `Fruit` does not permit being left uninitialized - --> $DIR/invalid_value.rs:117:27 + --> $DIR/invalid_value.rs:121:27 | LL | let _val: Fruit = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -494,7 +494,7 @@ LL | enum Fruit { | ^^^^^^^^^^ error: the type `[bool; 2]` does not permit being left uninitialized - --> $DIR/invalid_value.rs:120:31 + --> $DIR/invalid_value.rs:124:31 | LL | let _val: [bool; 2] = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -505,7 +505,7 @@ LL | let _val: [bool; 2] = mem::uninitialized(); = note: booleans must be either `true` or `false` error: the type `i32` does not permit being left uninitialized - --> $DIR/invalid_value.rs:123:25 + --> $DIR/invalid_value.rs:127:25 | LL | let _val: i32 = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -516,7 +516,7 @@ LL | let _val: i32 = mem::uninitialized(); = note: integers must not be uninitialized error: the type `f32` does not permit being left uninitialized - --> $DIR/invalid_value.rs:126:25 + --> $DIR/invalid_value.rs:130:25 | LL | let _val: f32 = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -527,7 +527,7 @@ LL | let _val: f32 = mem::uninitialized(); = note: floats must not be uninitialized error: the type `*const ()` does not permit being left uninitialized - --> $DIR/invalid_value.rs:129:31 + --> $DIR/invalid_value.rs:133:31 | LL | let _val: *const () = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -538,7 +538,7 @@ LL | let _val: *const () = mem::uninitialized(); = note: raw pointers must not be uninitialized error: the type `*const [()]` does not permit being left uninitialized - --> $DIR/invalid_value.rs:132:33 + --> $DIR/invalid_value.rs:136:33 | LL | let _val: *const [()] = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -548,8 +548,19 @@ LL | let _val: *const [()] = mem::uninitialized(); | = note: raw pointers must not be uninitialized +error: the type `WrapAroundRange` does not permit being left uninitialized + --> $DIR/invalid_value.rs:139:37 + | +LL | let _val: WrapAroundRange = mem::uninitialized(); + | ^^^^^^^^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done + | + = note: `WrapAroundRange` must be initialized inside its custom valid range + error: the type `Result<i32, i32>` does not permit being left uninitialized - --> $DIR/invalid_value.rs:137:38 + --> $DIR/invalid_value.rs:144:38 | LL | let _val: Result<i32, i32> = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -564,7 +575,7 @@ LL | pub enum Result<T, E> { | ^^^^^^^^^^^^^^^^^^^^^ error: the type `&i32` does not permit zero-initialization - --> $DIR/invalid_value.rs:145:34 + --> $DIR/invalid_value.rs:152:34 | LL | let _val: &'static i32 = mem::transmute(0usize); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -575,7 +586,7 @@ LL | let _val: &'static i32 = mem::transmute(0usize); = note: references must be non-null error: the type `&[i32]` does not permit zero-initialization - --> $DIR/invalid_value.rs:146:36 + --> $DIR/invalid_value.rs:153:36 | LL | let _val: &'static [i32] = mem::transmute((0usize, 0usize)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -586,7 +597,7 @@ LL | let _val: &'static [i32] = mem::transmute((0usize, 0usize)); = note: references must be non-null error: the type `NonZeroU32` does not permit zero-initialization - --> $DIR/invalid_value.rs:147:32 + --> $DIR/invalid_value.rs:154:32 | LL | let _val: NonZeroU32 = mem::transmute(0); | ^^^^^^^^^^^^^^^^^ @@ -597,7 +608,7 @@ LL | let _val: NonZeroU32 = mem::transmute(0); = note: `std::num::NonZeroU32` must be non-null error: the type `NonNull<i32>` does not permit zero-initialization - --> $DIR/invalid_value.rs:150:34 + --> $DIR/invalid_value.rs:157:34 | LL | let _val: NonNull<i32> = MaybeUninit::zeroed().assume_init(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -608,7 +619,7 @@ LL | let _val: NonNull<i32> = MaybeUninit::zeroed().assume_init(); = note: `std::ptr::NonNull<i32>` must be non-null error: the type `NonNull<i32>` does not permit being left uninitialized - --> $DIR/invalid_value.rs:151:34 + --> $DIR/invalid_value.rs:158:34 | LL | let _val: NonNull<i32> = MaybeUninit::uninit().assume_init(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -619,7 +630,7 @@ LL | let _val: NonNull<i32> = MaybeUninit::uninit().assume_init(); = note: `std::ptr::NonNull<i32>` must be non-null error: the type `bool` does not permit being left uninitialized - --> $DIR/invalid_value.rs:152:26 + --> $DIR/invalid_value.rs:159:26 | LL | let _val: bool = MaybeUninit::uninit().assume_init(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -629,5 +640,5 @@ LL | let _val: bool = MaybeUninit::uninit().assume_init(); | = note: booleans must be either `true` or `false` -error: aborting due to 50 previous errors +error: aborting due to 51 previous errors diff --git a/src/test/ui/lint/lint-incoherent-auto-trait-objects.stderr b/src/test/ui/lint/lint-incoherent-auto-trait-objects.stderr index 3f366bedbf3..2cc4d382d9d 100644 --- a/src/test/ui/lint/lint-incoherent-auto-trait-objects.stderr +++ b/src/test/ui/lint/lint-incoherent-auto-trait-objects.stderr @@ -37,3 +37,45 @@ LL | impl Foo for dyn Send + Sync + Send {} error: aborting due to 3 previous errors +Future incompatibility report: Future breakage diagnostic: +error: conflicting implementations of trait `Foo` for type `(dyn std::marker::Send + 'static)`: (E0119) + --> $DIR/lint-incoherent-auto-trait-objects.rs:5:1 + | +LL | impl Foo for dyn Send {} + | --------------------- first implementation here +LL | +LL | impl Foo for dyn Send + Send {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + 'static)` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> + = note: `#[deny(order_dependent_trait_objects)]` on by default + +Future breakage diagnostic: +error: conflicting implementations of trait `Foo` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) + --> $DIR/lint-incoherent-auto-trait-objects.rs:11:1 + | +LL | impl Foo for dyn Send + Sync {} + | ---------------------------- first implementation here +LL | +LL | impl Foo for dyn Sync + Send {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> + = note: `#[deny(order_dependent_trait_objects)]` on by default + +Future breakage diagnostic: +error: conflicting implementations of trait `Foo` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) + --> $DIR/lint-incoherent-auto-trait-objects.rs:15:1 + | +LL | impl Foo for dyn Sync + Send {} + | ---------------------------- first implementation here +... +LL | impl Foo for dyn Send + Sync + Send {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> + = note: `#[deny(order_dependent_trait_objects)]` on by default + diff --git a/src/test/ui/lint/unused/unused-supertrait.rs b/src/test/ui/lint/unused/unused-supertrait.rs new file mode 100644 index 00000000000..64a8e520457 --- /dev/null +++ b/src/test/ui/lint/unused/unused-supertrait.rs @@ -0,0 +1,11 @@ +#![deny(unused_must_use)] + +fn it() -> impl ExactSizeIterator<Item = ()> { + let x: Box<dyn ExactSizeIterator<Item = ()>> = todo!(); + x +} + +fn main() { + it(); + //~^ ERROR unused implementer of `Iterator` that must be used +} diff --git a/src/test/ui/lint/unused/unused-supertrait.stderr b/src/test/ui/lint/unused/unused-supertrait.stderr new file mode 100644 index 00000000000..d2f8c007848 --- /dev/null +++ b/src/test/ui/lint/unused/unused-supertrait.stderr @@ -0,0 +1,15 @@ +error: unused implementer of `Iterator` that must be used + --> $DIR/unused-supertrait.rs:9:5 + | +LL | it(); + | ^^^^^ + | + = note: iterators are lazy and do nothing unless consumed +note: the lint level is defined here + --> $DIR/unused-supertrait.rs:1:9 + | +LL | #![deny(unused_must_use)] + | ^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/macros/macro-context.stderr b/src/test/ui/macros/macro-context.stderr index 2a2e0c6c66a..f597c398b7c 100644 --- a/src/test/ui/macros/macro-context.stderr +++ b/src/test/ui/macros/macro-context.stderr @@ -57,7 +57,7 @@ error[E0425]: cannot find value `i` in this scope --> $DIR/macro-context.rs:3:13 | LL | () => ( i ; typeof ); - | ^ help: a local variable with a similar name exists: `a` + | ^ not found in this scope ... LL | let i = m!(); | ---- in this macro invocation diff --git a/src/test/ui/methods/issues/issue-90315.rs b/src/test/ui/methods/issues/issue-90315.rs index 01bf9f48402..79cdc41959a 100644 --- a/src/test/ui/methods/issues/issue-90315.rs +++ b/src/test/ui/methods/issues/issue-90315.rs @@ -1,7 +1,76 @@ +#![allow(unused)] fn main() { - let arr = &[0,1,2,3]; - for _i in 0..arr.len().rev() { //~ERROR not an iterator - // The above error used to say “the method `rev` exists for type `usize`”. - // This regression test ensures it doesn't say that any more. - } + let arr = &[0, 1, 2, 3]; + for _i in 0..arr.len().rev() { + //~^ ERROR can't call method + //~| surround the range in parentheses + // The above error used to say “the method `rev` exists for type `usize`”. + // This regression test ensures it doesn't say that any more. + } + + // Test for #102396 + for i in 1..11.rev() { + //~^ ERROR can't call method + //~| HELP surround the range in parentheses + } + + let end: usize = 10; + for i in 1..end.rev() { + //~^ ERROR can't call method + //~| HELP surround the range in parentheses + } + + for i in 1..(end + 1).rev() { + //~^ ERROR can't call method + //~| HELP surround the range in parentheses + } + + if 1..(end + 1).is_empty() { + //~^ ERROR can't call method + //~| ERROR mismatched types [E0308] + //~| HELP surround the range in parentheses + } + + if 1..(end + 1).is_sorted() { + //~^ ERROR mismatched types [E0308] + //~| ERROR can't call method + //~| HELP surround the range in parentheses + } + + let _res: i32 = 3..6.take(2).sum(); + //~^ ERROR can't call method + //~| ERROR mismatched types [E0308] + //~| HELP surround the range in parentheses + + let _sum: i32 = 3..6.sum(); + //~^ ERROR can't call method + //~| ERROR mismatched types [E0308] + //~| HELP surround the range in parentheses + + let a = 1 as usize; + let b = 10 as usize; + + for _a in a..=b.rev() { + //~^ ERROR can't call method + //~| HELP surround the range in parentheses + } + + let _res = ..10.contains(3); + //~^ ERROR can't call method + //~| HELP surround the range in parentheses + + if 1..end.error_method() { + //~^ ERROR no method named `error_method` + //~| ERROR mismatched types [E0308] + // Won't suggest + } + + let _res = b.take(1)..a; + //~^ ERROR `usize` is not an iterator + + let _res: i32 = ..6.take(2).sum(); + //~^ can't call method `take` on ambiguous numeric type + //~| ERROR mismatched types [E0308] + //~| HELP you must specify a concrete type for this numeric value + // Won't suggest because `RangeTo` dest not implemented `take` } diff --git a/src/test/ui/methods/issues/issue-90315.stderr b/src/test/ui/methods/issues/issue-90315.stderr index c6a76c9e790..070cd305436 100644 --- a/src/test/ui/methods/issues/issue-90315.stderr +++ b/src/test/ui/methods/issues/issue-90315.stderr @@ -1,13 +1,201 @@ +error[E0689]: can't call method `rev` on type `usize` + --> $DIR/issue-90315.rs:4:28 + | +LL | for _i in 0..arr.len().rev() { + | ^^^ can't call method `rev` on type `usize` + | +help: you must surround the range in parentheses to call its `rev` function + | +LL | for _i in (0..arr.len()).rev() { + | + + + +error[E0689]: can't call method `rev` on type `{integer}` + --> $DIR/issue-90315.rs:12:20 + | +LL | for i in 1..11.rev() { + | ^^^ can't call method `rev` on type `{integer}` + | +help: you must surround the range in parentheses to call its `rev` function + | +LL | for i in (1..11).rev() { + | + + + +error[E0689]: can't call method `rev` on type `usize` + --> $DIR/issue-90315.rs:18:21 + | +LL | for i in 1..end.rev() { + | ^^^ can't call method `rev` on type `usize` + | +help: you must surround the range in parentheses to call its `rev` function + | +LL | for i in (1..end).rev() { + | + + + +error[E0689]: can't call method `rev` on type `usize` + --> $DIR/issue-90315.rs:23:27 + | +LL | for i in 1..(end + 1).rev() { + | ^^^ can't call method `rev` on type `usize` + | +help: you must surround the range in parentheses to call its `rev` function + | +LL | for i in (1..(end + 1)).rev() { + | + + + +error[E0689]: can't call method `is_empty` on type `usize` + --> $DIR/issue-90315.rs:28:21 + | +LL | if 1..(end + 1).is_empty() { + | ^^^^^^^^ can't call method `is_empty` on type `usize` + | +help: you must surround the range in parentheses to call its `is_empty` function + | +LL | if (1..(end + 1)).is_empty() { + | + + + +error[E0308]: mismatched types + --> $DIR/issue-90315.rs:28:8 + | +LL | if 1..(end + 1).is_empty() { + | ^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found struct `std::ops::Range` + | + = note: expected type `bool` + found struct `std::ops::Range<{integer}>` + +error[E0689]: can't call method `is_sorted` on type `usize` + --> $DIR/issue-90315.rs:34:21 + | +LL | if 1..(end + 1).is_sorted() { + | ^^^^^^^^^ can't call method `is_sorted` on type `usize` + | +help: you must surround the range in parentheses to call its `is_sorted` function + | +LL | if (1..(end + 1)).is_sorted() { + | + + + +error[E0308]: mismatched types + --> $DIR/issue-90315.rs:34:8 + | +LL | if 1..(end + 1).is_sorted() { + | ^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found struct `std::ops::Range` + | + = note: expected type `bool` + found struct `std::ops::Range<{integer}>` + +error[E0689]: can't call method `take` on type `{integer}` + --> $DIR/issue-90315.rs:40:26 + | +LL | let _res: i32 = 3..6.take(2).sum(); + | ^^^^ can't call method `take` on type `{integer}` + | +help: you must surround the range in parentheses to call its `take` function + | +LL | let _res: i32 = (3..6).take(2).sum(); + | + + + +error[E0308]: mismatched types + --> $DIR/issue-90315.rs:40:21 + | +LL | let _res: i32 = 3..6.take(2).sum(); + | --- ^^^^^^^^^^^^^^^^^^ expected `i32`, found struct `std::ops::Range` + | | + | expected due to this + | + = note: expected type `i32` + found struct `std::ops::Range<{integer}>` + +error[E0689]: can't call method `sum` on type `{integer}` + --> $DIR/issue-90315.rs:45:26 + | +LL | let _sum: i32 = 3..6.sum(); + | ^^^ can't call method `sum` on type `{integer}` + | +help: you must surround the range in parentheses to call its `sum` function + | +LL | let _sum: i32 = (3..6).sum(); + | + + + +error[E0308]: mismatched types + --> $DIR/issue-90315.rs:45:21 + | +LL | let _sum: i32 = 3..6.sum(); + | --- ^^^^^^^^^^ expected `i32`, found struct `std::ops::Range` + | | + | expected due to this + | + = note: expected type `i32` + found struct `std::ops::Range<{integer}>` + +error[E0689]: can't call method `rev` on type `usize` + --> $DIR/issue-90315.rs:53:21 + | +LL | for _a in a..=b.rev() { + | ^^^ can't call method `rev` on type `usize` + | +help: you must surround the range in parentheses to call its `rev` function + | +LL | for _a in (a..=b).rev() { + | + + + +error[E0689]: can't call method `contains` on type `{integer}` + --> $DIR/issue-90315.rs:58:21 + | +LL | let _res = ..10.contains(3); + | ^^^^^^^^ can't call method `contains` on type `{integer}` + | +help: you must surround the range in parentheses to call its `contains` function + | +LL | let _res = (..10).contains(3); + | + + + +error[E0599]: no method named `error_method` found for type `usize` in the current scope + --> $DIR/issue-90315.rs:62:15 + | +LL | if 1..end.error_method() { + | ^^^^^^^^^^^^ method not found in `usize` + +error[E0308]: mismatched types + --> $DIR/issue-90315.rs:62:8 + | +LL | if 1..end.error_method() { + | ^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found struct `std::ops::Range` + | + = note: expected type `bool` + found struct `std::ops::Range<{integer}>` + error[E0599]: `usize` is not an iterator - --> $DIR/issue-90315.rs:3:26 + --> $DIR/issue-90315.rs:68:18 | -LL | for _i in 0..arr.len().rev() { - | ^^^ `usize` is not an iterator +LL | let _res = b.take(1)..a; + | ^^^^ `usize` is not an iterator | = note: the following trait bounds were not satisfied: `usize: Iterator` which is required by `&mut usize: Iterator` -error: aborting due to previous error +error[E0689]: can't call method `take` on ambiguous numeric type `{integer}` + --> $DIR/issue-90315.rs:71:25 + | +LL | let _res: i32 = ..6.take(2).sum(); + | ^^^^ + | +help: you must specify a concrete type for this numeric value, like `i32` + | +LL | let _res: i32 = ..6_i32.take(2).sum(); + | ~~~~~ + +error[E0308]: mismatched types + --> $DIR/issue-90315.rs:71:21 + | +LL | let _res: i32 = ..6.take(2).sum(); + | --- ^^^^^^^^^^^^^^^^^ expected `i32`, found struct `RangeTo` + | | + | expected due to this + | + = note: expected type `i32` + found struct `RangeTo<_>` + +error: aborting due to 19 previous errors -For more information about this error, try `rustc --explain E0599`. +Some errors have detailed explanations: E0308, E0599, E0689. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/mir/mir_let_chains_drop_order.rs b/src/test/ui/mir/mir_let_chains_drop_order.rs index 536a84a352a..6471553e93f 100644 --- a/src/test/ui/mir/mir_let_chains_drop_order.rs +++ b/src/test/ui/mir/mir_let_chains_drop_order.rs @@ -12,7 +12,7 @@ use std::panic; pub struct DropLogger<'a, T> { extra: T, id: usize, - log: &'a panic::AssertUnwindSafe<RefCell<Vec<usize>>> + log: &'a panic::AssertUnwindSafe<RefCell<Vec<usize>>>, } impl<'a, T> Drop for DropLogger<'a, T> { @@ -55,9 +55,9 @@ fn main() { else { // 10 is not constructed d(10, None) - } + }, ); - assert_eq!(get(), vec![3, 8, 7, 1, 2]); + assert_eq!(get(), vec![8, 7, 1, 3, 2]); } assert_eq!(get(), vec![0, 4, 6, 9, 5]); @@ -89,5 +89,5 @@ fn main() { panic::panic_any(InjectedFailure) ); }); - assert_eq!(get(), vec![14, 19, 20, 17, 15, 11, 18, 16, 12, 13]); + assert_eq!(get(), vec![20, 17, 15, 11, 19, 18, 16, 12, 14, 13]); } diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr index 01293379700..da4bc499c7e 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr @@ -53,15 +53,14 @@ LL | fn case2() { error[E0597]: `a` does not live long enough --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:30:26 | -LL | let cell = Cell::new(&a); - | ^^ borrowed value does not live long enough +LL | let cell = Cell::new(&a); + | ----------^^- + | | | + | | borrowed value does not live long enough + | argument requires that `a` is borrowed for `'static` ... -LL | / foo(cell, |cell_a, cell_x| { -LL | | cell_x.set(cell_a.get()); // forces 'a: 'x, implies 'a = 'static -> borrow error -LL | | }) - | |______- argument requires that `a` is borrowed for `'static` -LL | } - | - `a` dropped here while still borrowed +LL | } + | - `a` dropped here while still borrowed error: aborting due to 2 previous errors diff --git a/src/test/ui/nll/closures-in-loops.stderr b/src/test/ui/nll/closures-in-loops.stderr index 2be0460df1f..1c1a31d356d 100644 --- a/src/test/ui/nll/closures-in-loops.stderr +++ b/src/test/ui/nll/closures-in-loops.stderr @@ -13,17 +13,21 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/closures-in-loops.rs:13:16 | LL | v.push(|| x = String::new()); - | ^^ - borrows occur due to use of `x` in closure - | | - | `x` was mutably borrowed here in the previous iteration of the loop + | -------^^------------------- + | | | | + | | | borrows occur due to use of `x` in closure + | | `x` was mutably borrowed here in the previous iteration of the loop + | first borrow used here, in later iteration of loop error[E0524]: two closures require unique access to `x` at the same time --> $DIR/closures-in-loops.rs:20:16 | LL | v.push(|| *x = String::new()); - | ^^ -- borrows occur due to use of `x` in closure - | | - | closures are constructed here in different iterations of loop + | -------^^-------------------- + | | | | + | | | borrows occur due to use of `x` in closure + | | closures are constructed here in different iterations of loop + | first borrow used here, in later iteration of loop error: aborting due to 3 previous errors diff --git a/src/test/ui/nll/user-annotations/adt-nullary-enums.stderr b/src/test/ui/nll/user-annotations/adt-nullary-enums.stderr index 3326fa521fc..bb703412228 100644 --- a/src/test/ui/nll/user-annotations/adt-nullary-enums.stderr +++ b/src/test/ui/nll/user-annotations/adt-nullary-enums.stderr @@ -1,14 +1,14 @@ error[E0597]: `c` does not live long enough --> $DIR/adt-nullary-enums.rs:33:41 | -LL | / combine( -LL | | SomeEnum::SomeVariant(Cell::new(&c)), - | | ^^ borrowed value does not live long enough -LL | | SomeEnum::SomeOtherVariant::<Cell<&'static u32>>, -LL | | ); - | |_____- argument requires that `c` is borrowed for `'static` -LL | } - | - `c` dropped here while still borrowed +LL | SomeEnum::SomeVariant(Cell::new(&c)), + | ----------^^- + | | | + | | borrowed value does not live long enough + | argument requires that `c` is borrowed for `'static` +... +LL | } + | - `c` dropped here while still borrowed error[E0597]: `c` does not live long enough --> $DIR/adt-nullary-enums.rs:41:41 diff --git a/src/test/ui/parser/fn-header-semantic-fail.stderr b/src/test/ui/parser/fn-header-semantic-fail.stderr index 800b5a43a00..038fdfb2d51 100644 --- a/src/test/ui/parser/fn-header-semantic-fail.stderr +++ b/src/test/ui/parser/fn-header-semantic-fail.stderr @@ -199,7 +199,7 @@ note: ...which requires borrow-checking `main::ff5`... | LL | const async unsafe extern "C" fn ff5() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing `main::ff5`... +note: ...which requires processing MIR for `main::ff5`... --> $DIR/fn-header-semantic-fail.rs:12:5 | LL | const async unsafe extern "C" fn ff5() {} @@ -235,7 +235,7 @@ note: ...which requires borrow-checking `main::<impl at $DIR/fn-header-semantic- | LL | const async unsafe extern "C" fn ft5() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 28:17>::ft5`... +note: ...which requires processing MIR for `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 28:17>::ft5`... --> $DIR/fn-header-semantic-fail.rs:33:9 | LL | const async unsafe extern "C" fn ft5() {} @@ -271,7 +271,7 @@ note: ...which requires borrow-checking `main::<impl at $DIR/fn-header-semantic- | LL | const async unsafe extern "C" fn fi5() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 40:11>::fi5`... +note: ...which requires processing MIR for `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 40:11>::fi5`... --> $DIR/fn-header-semantic-fail.rs:45:9 | LL | const async unsafe extern "C" fn fi5() {} diff --git a/src/test/ui/parser/issues/issue-93282.rs b/src/test/ui/parser/issues/issue-93282.rs index 261fcb5f918..274245f1a46 100644 --- a/src/test/ui/parser/issues/issue-93282.rs +++ b/src/test/ui/parser/issues/issue-93282.rs @@ -12,4 +12,5 @@ fn foo() { let x = 1; bar('y, x); //~^ ERROR expected + //~| ERROR mismatched types } diff --git a/src/test/ui/parser/issues/issue-93282.stderr b/src/test/ui/parser/issues/issue-93282.stderr index ee554784b3a..c6140bb821e 100644 --- a/src/test/ui/parser/issues/issue-93282.stderr +++ b/src/test/ui/parser/issues/issue-93282.stderr @@ -3,6 +3,11 @@ error: expected `while`, `for`, `loop` or `{` after a label | LL | f<'a,> | ^ expected `while`, `for`, `loop` or `{` after a label + | +help: add `'` to close the char literal + | +LL | f<'a',> + | + error: expected one of `.`, `:`, `;`, `?`, `for`, `loop`, `while`, `}`, or an operator, found `,` --> $DIR/issue-93282.rs:2:9 @@ -20,6 +25,26 @@ error: expected `while`, `for`, `loop` or `{` after a label | LL | bar('y, x); | ^ expected `while`, `for`, `loop` or `{` after a label + | +help: add `'` to close the char literal + | +LL | bar('y', x); + | + + +error[E0308]: mismatched types + --> $DIR/issue-93282.rs:13:9 + | +LL | bar('y, x); + | --- ^^ expected `usize`, found `char` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/issue-93282.rs:7:4 + | +LL | fn bar(a: usize, b: usize) -> usize { + | ^^^ -------- -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/parser/label-is-actually-char.rs b/src/test/ui/parser/label-is-actually-char.rs new file mode 100644 index 00000000000..183da603da4 --- /dev/null +++ b/src/test/ui/parser/label-is-actually-char.rs @@ -0,0 +1,16 @@ +fn main() { + let c = 'a; + //~^ ERROR expected `while`, `for`, `loop` or `{` after a label + //~| HELP add `'` to close the char literal + match c { + 'a'..='b => {} + //~^ ERROR unexpected token: `'b` + //~| HELP add `'` to close the char literal + _ => {} + } + let x = ['a, 'b]; + //~^ ERROR expected `while`, `for`, `loop` or `{` after a label + //~| ERROR expected `while`, `for`, `loop` or `{` after a label + //~| HELP add `'` to close the char literal + //~| HELP add `'` to close the char literal +} diff --git a/src/test/ui/parser/label-is-actually-char.stderr b/src/test/ui/parser/label-is-actually-char.stderr new file mode 100644 index 00000000000..28c8d2ada3a --- /dev/null +++ b/src/test/ui/parser/label-is-actually-char.stderr @@ -0,0 +1,46 @@ +error: expected `while`, `for`, `loop` or `{` after a label + --> $DIR/label-is-actually-char.rs:2:15 + | +LL | let c = 'a; + | ^ expected `while`, `for`, `loop` or `{` after a label + | +help: add `'` to close the char literal + | +LL | let c = 'a'; + | + + +error: unexpected token: `'b` + --> $DIR/label-is-actually-char.rs:6:15 + | +LL | 'a'..='b => {} + | ^^ + | +help: add `'` to close the char literal + | +LL | 'a'..='b' => {} + | + + +error: expected `while`, `for`, `loop` or `{` after a label + --> $DIR/label-is-actually-char.rs:11:16 + | +LL | let x = ['a, 'b]; + | ^ expected `while`, `for`, `loop` or `{` after a label + | +help: add `'` to close the char literal + | +LL | let x = ['a', 'b]; + | + + +error: expected `while`, `for`, `loop` or `{` after a label + --> $DIR/label-is-actually-char.rs:11:20 + | +LL | let x = ['a, 'b]; + | ^ expected `while`, `for`, `loop` or `{` after a label + | +help: add `'` to close the char literal + | +LL | let x = ['a, 'b']; + | + + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/parser/numeric-lifetime.stderr b/src/test/ui/parser/numeric-lifetime.stderr index 73a828952b2..7c1bcb72631 100644 --- a/src/test/ui/parser/numeric-lifetime.stderr +++ b/src/test/ui/parser/numeric-lifetime.stderr @@ -1,3 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/numeric-lifetime.rs:6:20 + | +LL | let x: usize = ""; + | ----- ^^ expected `usize`, found `&str` + | | + | expected due to this + error: lifetimes cannot start with a number --> $DIR/numeric-lifetime.rs:1:10 | @@ -10,14 +18,6 @@ error: lifetimes cannot start with a number LL | struct S<'1> { s: &'1 usize } | ^^ -error[E0308]: mismatched types - --> $DIR/numeric-lifetime.rs:6:20 - | -LL | let x: usize = ""; - | ----- ^^ expected `usize`, found `&str` - | | - | expected due to this - error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/parser/require-parens-for-chained-comparison.rs b/src/test/ui/parser/require-parens-for-chained-comparison.rs index f29fd7a5472..5b90e905a64 100644 --- a/src/test/ui/parser/require-parens-for-chained-comparison.rs +++ b/src/test/ui/parser/require-parens-for-chained-comparison.rs @@ -23,11 +23,13 @@ fn main() { //~^ ERROR expected one of //~| HELP use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments //~| ERROR expected + //~| HELP add `'` to close the char literal f<'_>(); //~^ comparison operators cannot be chained //~| HELP use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments //~| ERROR expected + //~| HELP add `'` to close the char literal let _ = f<u8>; //~^ ERROR comparison operators cannot be chained diff --git a/src/test/ui/parser/require-parens-for-chained-comparison.stderr b/src/test/ui/parser/require-parens-for-chained-comparison.stderr index 0bf52854ec2..52e201c435c 100644 --- a/src/test/ui/parser/require-parens-for-chained-comparison.stderr +++ b/src/test/ui/parser/require-parens-for-chained-comparison.stderr @@ -58,6 +58,11 @@ error: expected `while`, `for`, `loop` or `{` after a label | LL | let _ = f<'_, i8>(); | ^ expected `while`, `for`, `loop` or `{` after a label + | +help: add `'` to close the char literal + | +LL | let _ = f<'_', i8>(); + | + error: expected one of `.`, `:`, `;`, `?`, `else`, `for`, `loop`, `while`, or an operator, found `,` --> $DIR/require-parens-for-chained-comparison.rs:22:17 @@ -71,13 +76,18 @@ LL | let _ = f::<'_, i8>(); | ++ error: expected `while`, `for`, `loop` or `{` after a label - --> $DIR/require-parens-for-chained-comparison.rs:27:9 + --> $DIR/require-parens-for-chained-comparison.rs:28:9 | LL | f<'_>(); | ^ expected `while`, `for`, `loop` or `{` after a label + | +help: add `'` to close the char literal + | +LL | f<'_'>(); + | + error: comparison operators cannot be chained - --> $DIR/require-parens-for-chained-comparison.rs:27:6 + --> $DIR/require-parens-for-chained-comparison.rs:28:6 | LL | f<'_>(); | ^ ^ @@ -88,7 +98,7 @@ LL | f::<'_>(); | ++ error: comparison operators cannot be chained - --> $DIR/require-parens-for-chained-comparison.rs:32:14 + --> $DIR/require-parens-for-chained-comparison.rs:34:14 | LL | let _ = f<u8>; | ^ ^ diff --git a/src/test/ui/parser/semi-after-closure-in-macro.rs b/src/test/ui/parser/semi-after-closure-in-macro.rs new file mode 100644 index 00000000000..14efb6100b0 --- /dev/null +++ b/src/test/ui/parser/semi-after-closure-in-macro.rs @@ -0,0 +1,14 @@ +// check-pass + +// Checks that the fix in #103222 doesn't also disqualify semicolons after +// closures within parentheses *in macros*, where they're totally allowed. + +macro_rules! m { + (($expr:expr ; )) => { + $expr + }; +} + +fn main() { + let x = m!(( ||() ; )); +} diff --git a/src/test/ui/privacy/access_levels.rs b/src/test/ui/privacy/access_levels.rs index bf94d980678..42c9975bedb 100644 --- a/src/test/ui/privacy/access_levels.rs +++ b/src/test/ui/privacy/access_levels.rs @@ -1,44 +1,44 @@ #![feature(rustc_attrs)] #[rustc_effective_visibility] -mod outer { //~ ERROR Public: pub(self), Exported: pub(self), Reachable: pub(self), ReachableFromImplTrait: pub(self) +mod outer { //~ ERROR Public: pub(crate), Exported: pub(crate), Reachable: pub(crate), ReachableFromImplTrait: pub(crate) #[rustc_effective_visibility] - pub mod inner1 { //~ ERROR Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + pub mod inner1 { //~ ERROR Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub #[rustc_effective_visibility] - extern "C" {} //~ ERROR Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + extern "C" {} //~ ERROR Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub #[rustc_effective_visibility] - pub trait PubTrait { //~ ERROR Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + pub trait PubTrait { //~ ERROR Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub #[rustc_effective_visibility] - const A: i32; //~ ERROR Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + const A: i32; //~ ERROR Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub #[rustc_effective_visibility] - type B; //~ ERROR Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + type B; //~ ERROR Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub } #[rustc_effective_visibility] struct PrivStruct; //~ ERROR Public: pub(self), Exported: pub(self), Reachable: pub(self), ReachableFromImplTrait: pub(self) #[rustc_effective_visibility] - pub union PubUnion { //~ ERROR Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + pub union PubUnion { //~ ERROR Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub #[rustc_effective_visibility] a: u8, //~ ERROR Public: pub(self), Exported: pub(self), Reachable: pub(self), ReachableFromImplTrait: pub(self) #[rustc_effective_visibility] - pub b: u8, //~ ERROR Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + pub b: u8, //~ ERROR Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub } #[rustc_effective_visibility] - pub enum Enum { //~ ERROR Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + pub enum Enum { //~ ERROR Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub #[rustc_effective_visibility] - A( //~ ERROR Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + A( //~ ERROR Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub #[rustc_effective_visibility] - PubUnion, //~ ERROR Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + PubUnion, //~ ERROR Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub ), } } #[rustc_effective_visibility] - macro_rules! none_macro { //~ Public: pub(self), Exported: pub(self), Reachable: pub(self), ReachableFromImplTrait: pub(self) + macro_rules! none_macro { //~ Public: pub(crate), Exported: pub(crate), Reachable: pub(crate), ReachableFromImplTrait: pub(crate) () => {}; } @@ -49,9 +49,9 @@ mod outer { //~ ERROR Public: pub(self), Exported: pub(self), Reachable: pub(sel } #[rustc_effective_visibility] - pub struct ReachableStruct { //~ ERROR Public: pub(self), Exported: pub(self), Reachable: pub, ReachableFromImplTrait: pub + pub struct ReachableStruct { //~ ERROR Public: pub(crate), Exported: pub(crate), Reachable: pub, ReachableFromImplTrait: pub #[rustc_effective_visibility] - pub a: u8, //~ ERROR Public: pub(self), Exported: pub(self), Reachable: pub, ReachableFromImplTrait: pub + pub a: u8, //~ ERROR Public: pub(crate), Exported: pub(crate), Reachable: pub, ReachableFromImplTrait: pub } } @@ -62,14 +62,14 @@ pub fn foo() -> outer::ReachableStruct { outer::ReachableStruct {a: 0} } mod half_public_import { #[rustc_effective_visibility] - pub type HalfPublicImport = u8; //~ ERROR Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + pub type HalfPublicImport = u8; //~ ERROR Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub #[rustc_effective_visibility] #[allow(non_upper_case_globals)] - pub(crate) const HalfPublicImport: u8 = 0; //~ ERROR Public: pub(self), Exported: pub(self), Reachable: pub(self), ReachableFromImplTrait: pub(self) + pub(crate) const HalfPublicImport: u8 = 0; //~ ERROR Public: pub(crate), Exported: pub(crate), Reachable: pub(crate), ReachableFromImplTrait: pub(crate) } #[rustc_effective_visibility] pub use half_public_import::HalfPublicImport; //~ ERROR Public: pub, Exported: pub, Reachable: pub, ReachableFromImplTrait: pub - //~^ ERROR Public: pub(self), Exported: pub(self), Reachable: pub(self), ReachableFromImplTrait: pub(self) + //~^ ERROR Public: pub, Exported: pub, Reachable: pub, ReachableFromImplTrait: pub fn main() {} diff --git a/src/test/ui/privacy/access_levels.stderr b/src/test/ui/privacy/access_levels.stderr index 81514d1fbab..111e02bc329 100644 --- a/src/test/ui/privacy/access_levels.stderr +++ b/src/test/ui/privacy/access_levels.stderr @@ -1,22 +1,22 @@ -error: Public: pub(self), Exported: pub(self), Reachable: pub(self), ReachableFromImplTrait: pub(self) +error: Public: pub(crate), Exported: pub(crate), Reachable: pub(crate), ReachableFromImplTrait: pub(crate) --> $DIR/access_levels.rs:4:1 | LL | mod outer { | ^^^^^^^^^ -error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub +error: Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub --> $DIR/access_levels.rs:6:5 | LL | pub mod inner1 { | ^^^^^^^^^^^^^^ -error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub +error: Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub --> $DIR/access_levels.rs:9:9 | LL | extern "C" {} | ^^^^^^^^^^^^^ -error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub +error: Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub --> $DIR/access_levels.rs:12:9 | LL | pub trait PubTrait { @@ -28,7 +28,7 @@ error: Public: pub(self), Exported: pub(self), Reachable: pub(self), ReachableFr LL | struct PrivStruct; | ^^^^^^^^^^^^^^^^^ -error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub +error: Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub --> $DIR/access_levels.rs:23:9 | LL | pub union PubUnion { @@ -40,31 +40,31 @@ error: Public: pub(self), Exported: pub(self), Reachable: pub(self), ReachableFr LL | a: u8, | ^^^^^ -error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub +error: Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub --> $DIR/access_levels.rs:27:13 | LL | pub b: u8, | ^^^^^^^^^ -error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub +error: Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub --> $DIR/access_levels.rs:31:9 | LL | pub enum Enum { | ^^^^^^^^^^^^^ -error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub +error: Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub --> $DIR/access_levels.rs:33:13 | LL | A( | ^ -error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub +error: Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub --> $DIR/access_levels.rs:35:17 | LL | PubUnion, | ^^^^^^^^ -error: Public: pub(self), Exported: pub(self), Reachable: pub(self), ReachableFromImplTrait: pub(self) +error: Public: pub(crate), Exported: pub(crate), Reachable: pub(crate), ReachableFromImplTrait: pub(crate) --> $DIR/access_levels.rs:41:5 | LL | macro_rules! none_macro { @@ -76,13 +76,13 @@ error: Public: pub, Exported: pub, Reachable: pub, ReachableFromImplTrait: pub LL | macro_rules! public_macro { | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: Public: pub(self), Exported: pub(self), Reachable: pub, ReachableFromImplTrait: pub +error: Public: pub(crate), Exported: pub(crate), Reachable: pub, ReachableFromImplTrait: pub --> $DIR/access_levels.rs:52:5 | LL | pub struct ReachableStruct { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: Public: pub(self), Exported: pub(self), Reachable: pub, ReachableFromImplTrait: pub +error: Public: pub(crate), Exported: pub(crate), Reachable: pub, ReachableFromImplTrait: pub --> $DIR/access_levels.rs:54:9 | LL | pub a: u8, @@ -94,13 +94,13 @@ error: Public: pub, Exported: pub, Reachable: pub, ReachableFromImplTrait: pub LL | pub use outer::inner1; | ^^^^^^^^^^^^^ -error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub +error: Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub --> $DIR/access_levels.rs:65:5 | LL | pub type HalfPublicImport = u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: Public: pub(self), Exported: pub(self), Reachable: pub(self), ReachableFromImplTrait: pub(self) +error: Public: pub(crate), Exported: pub(crate), Reachable: pub(crate), ReachableFromImplTrait: pub(crate) --> $DIR/access_levels.rs:68:5 | LL | pub(crate) const HalfPublicImport: u8 = 0; @@ -112,19 +112,19 @@ error: Public: pub, Exported: pub, Reachable: pub, ReachableFromImplTrait: pub LL | pub use half_public_import::HalfPublicImport; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: Public: pub(self), Exported: pub(self), Reachable: pub(self), ReachableFromImplTrait: pub(self) +error: Public: pub, Exported: pub, Reachable: pub, ReachableFromImplTrait: pub --> $DIR/access_levels.rs:72:9 | LL | pub use half_public_import::HalfPublicImport; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub +error: Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub --> $DIR/access_levels.rs:14:13 | LL | const A: i32; | ^^^^^^^^^^^^ -error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub +error: Public: pub(crate), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub --> $DIR/access_levels.rs:16:13 | LL | type B; diff --git a/src/test/ui/proc-macro/gen-macro-rules-hygiene.stderr b/src/test/ui/proc-macro/gen-macro-rules-hygiene.stderr index 6060f872f22..df7c4f72eb0 100644 --- a/src/test/ui/proc-macro/gen-macro-rules-hygiene.stderr +++ b/src/test/ui/proc-macro/gen-macro-rules-hygiene.stderr @@ -13,7 +13,7 @@ error[E0425]: cannot find value `local_use` in this scope --> $DIR/gen-macro-rules-hygiene.rs:12:1 | LL | gen_macro_rules!(); - | ^^^^^^^^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^^^^^^ help: a local variable with a similar name exists: `local_def` ... LL | generated!(); | ------------ in this macro invocation @@ -24,7 +24,7 @@ error[E0425]: cannot find value `local_def` in this scope --> $DIR/gen-macro-rules-hygiene.rs:21:9 | LL | local_def; - | ^^^^^^^^^ not found in this scope + | ^^^^^^^^^ help: a local variable with a similar name exists: `local_use` error: aborting due to 3 previous errors diff --git a/src/test/ui/proc-macro/mixed-site-span.stderr b/src/test/ui/proc-macro/mixed-site-span.stderr index eab4317ded8..13786080124 100644 --- a/src/test/ui/proc-macro/mixed-site-span.stderr +++ b/src/test/ui/proc-macro/mixed-site-span.stderr @@ -10,7 +10,7 @@ error[E0425]: cannot find value `local_use` in this scope --> $DIR/mixed-site-span.rs:13:9 | LL | proc_macro_rules!(); - | ^^^^^^^^^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^^^^^^^ help: a local variable with a similar name exists: `local_def` | = note: this error originates in the macro `proc_macro_rules` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -18,7 +18,7 @@ error[E0425]: cannot find value `local_def` in this scope --> $DIR/mixed-site-span.rs:17:9 | LL | local_def; - | ^^^^^^^^^ not found in this scope + | ^^^^^^^^^ help: a local variable with a similar name exists: `local_use` error[E0412]: cannot find type `ItemUse` in crate `$crate` --> $DIR/mixed-site-span.rs:24:1 diff --git a/src/test/ui/process/process-spawn-with-unicode-params.rs b/src/test/ui/process/process-spawn-with-unicode-params.rs index 6e9229b6293..16dba6292db 100644 --- a/src/test/ui/process/process-spawn-with-unicode-params.rs +++ b/src/test/ui/process/process-spawn-with-unicode-params.rs @@ -9,6 +9,7 @@ // ignore-emscripten no processes // ignore-sgx no processes +// ignore-fuchsia Filesystem manipulation privileged use std::io::prelude::*; use std::io; diff --git a/src/test/ui/query-visibility.rs b/src/test/ui/query-visibility.rs new file mode 100644 index 00000000000..09a289d85da --- /dev/null +++ b/src/test/ui/query-visibility.rs @@ -0,0 +1,9 @@ +// check-pass +// Check that it doesn't panic when `Input` gets its visibility checked. + +#![crate_type = "lib"] + +pub trait Layer< + /// Hello. + Input, +> {} diff --git a/src/test/ui/resolve/issue-103202.rs b/src/test/ui/resolve/issue-103202.rs new file mode 100644 index 00000000000..469d9d7c860 --- /dev/null +++ b/src/test/ui/resolve/issue-103202.rs @@ -0,0 +1,7 @@ +struct S {} + +impl S { + fn f(self: &S::x) {} //~ ERROR ambiguous associated type +} + +fn main() {} diff --git a/src/test/ui/resolve/issue-103202.stderr b/src/test/ui/resolve/issue-103202.stderr new file mode 100644 index 00000000000..880389371ef --- /dev/null +++ b/src/test/ui/resolve/issue-103202.stderr @@ -0,0 +1,9 @@ +error[E0223]: ambiguous associated type + --> $DIR/issue-103202.rs:4:17 + | +LL | fn f(self: &S::x) {} + | ^^^^ help: use fully-qualified syntax: `<S as Trait>::x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0223`. diff --git a/src/test/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr b/src/test/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr index af9f4612ab3..eb26cd9cabb 100644 --- a/src/test/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr +++ b/src/test/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr @@ -1,11 +1,16 @@ error[E0574]: expected struct, variant or union type, found type parameter `Baz` --> $DIR/point-at-type-parameter-shadowing-another-type.rs:16:13 | -LL | impl<Baz> Foo<Baz> for Bar { - | --- found this type parameter +LL | / struct Baz { +LL | | num: usize, +LL | | } + | |_- you might have meant to refer to this struct +LL | +LL | impl<Baz> Foo<Baz> for Bar { + | --- found this type parameter ... -LL | Baz { num } => num, - | ^^^ not a struct, variant or union type +LL | Baz { num } => num, + | ^^^ not a struct, variant or union type error: aborting due to previous error diff --git a/src/test/ui/resolve/privacy-enum-ctor.stderr b/src/test/ui/resolve/privacy-enum-ctor.stderr index a369dc6db52..82a4211f08a 100644 --- a/src/test/ui/resolve/privacy-enum-ctor.stderr +++ b/src/test/ui/resolve/privacy-enum-ctor.stderr @@ -327,7 +327,7 @@ LL | let _: Z = Z::Fn; | = note: expected enum `Z` found fn item `fn(u8) -> Z {Z::Fn}` -help: use parentheses to instantiate this tuple variant +help: use parentheses to construct this tuple variant | LL | let _: Z = Z::Fn(/* u8 */); | ++++++++++ @@ -362,7 +362,7 @@ LL | let _: E = m::E::Fn; | = note: expected enum `E` found fn item `fn(u8) -> E {E::Fn}` -help: use parentheses to instantiate this tuple variant +help: use parentheses to construct this tuple variant | LL | let _: E = m::E::Fn(/* u8 */); | ++++++++++ @@ -397,7 +397,7 @@ LL | let _: E = E::Fn; | = note: expected enum `E` found fn item `fn(u8) -> E {E::Fn}` -help: use parentheses to instantiate this tuple variant +help: use parentheses to construct this tuple variant | LL | let _: E = E::Fn(/* u8 */); | ++++++++++ diff --git a/src/test/ui/issues/issue-64620.rs b/src/test/ui/return/issue-64620.rs index a62e5bf8d3c..a62e5bf8d3c 100644 --- a/src/test/ui/issues/issue-64620.rs +++ b/src/test/ui/return/issue-64620.rs diff --git a/src/test/ui/issues/issue-64620.stderr b/src/test/ui/return/issue-64620.stderr index f40ac4de32d..f40ac4de32d 100644 --- a/src/test/ui/issues/issue-64620.stderr +++ b/src/test/ui/return/issue-64620.stderr diff --git a/src/test/ui/rfc-1937-termination-trait/issue-103052-1.rs b/src/test/ui/rfc-1937-termination-trait/issue-103052-1.rs new file mode 100644 index 00000000000..a75c91cc90d --- /dev/null +++ b/src/test/ui/rfc-1937-termination-trait/issue-103052-1.rs @@ -0,0 +1,11 @@ +// Check that we don't blindly emit a diagnostic claiming that "`main` has an invalid return type" +// if we encounter a type that doesn't implement `std::process::Termination` and is not actually +// the return type of the program entry `main`. + +fn receive(_: impl std::process::Termination) {} + +struct Something; + +fn main() { + receive(Something); //~ ERROR the trait bound `Something: Termination` is not satisfied +} diff --git a/src/test/ui/rfc-1937-termination-trait/issue-103052-1.stderr b/src/test/ui/rfc-1937-termination-trait/issue-103052-1.stderr new file mode 100644 index 00000000000..409dede1a90 --- /dev/null +++ b/src/test/ui/rfc-1937-termination-trait/issue-103052-1.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `Something: Termination` is not satisfied + --> $DIR/issue-103052-1.rs:10:13 + | +LL | receive(Something); + | ------- ^^^^^^^^^ the trait `Termination` is not implemented for `Something` + | | + | required by a bound introduced by this call + | +note: required by a bound in `receive` + --> $DIR/issue-103052-1.rs:5:20 + | +LL | fn receive(_: impl std::process::Termination) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `receive` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/rfc-1937-termination-trait/issue-103052-2.rs b/src/test/ui/rfc-1937-termination-trait/issue-103052-2.rs new file mode 100644 index 00000000000..fa9182b6dee --- /dev/null +++ b/src/test/ui/rfc-1937-termination-trait/issue-103052-2.rs @@ -0,0 +1,18 @@ +#![feature(return_position_impl_trait_in_trait)] +#![allow(incomplete_features)] + +mod child { + trait Main { + fn main() -> impl std::process::Termination; + } + + struct Something; + + impl Main for () { + fn main() -> Something { //~ ERROR the trait bound `Something: Termination` is not satisfied + Something + } + } +} + +fn main() {} diff --git a/src/test/ui/rfc-1937-termination-trait/issue-103052-2.stderr b/src/test/ui/rfc-1937-termination-trait/issue-103052-2.stderr new file mode 100644 index 00000000000..a700c72ea68 --- /dev/null +++ b/src/test/ui/rfc-1937-termination-trait/issue-103052-2.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `Something: Termination` is not satisfied + --> $DIR/issue-103052-2.rs:12:22 + | +LL | fn main() -> Something { + | ^^^^^^^^^ the trait `Termination` is not implemented for `Something` + | +note: required by a bound in `Main::main::{opaque#0}` + --> $DIR/issue-103052-2.rs:6:27 + | +LL | fn main() -> impl std::process::Termination; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Main::main::{opaque#0}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr index 7c1390cdc64..6ee32314607 100644 --- a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr @@ -1,4 +1,4 @@ -error[E0277]: `main` has invalid return type `f32` +error[E0277]: the trait bound `f32: Termination` is not satisfied --> $DIR/termination-trait-test-wrong-type.rs:6:1 | LL | #[test] @@ -6,9 +6,8 @@ LL | #[test] LL | / fn can_parse_zero_as_f32() -> Result<f32, ParseFloatError> { LL | | "0".parse() LL | | } - | |_^ `main` can only return types that implement `Termination` + | |_^ the trait `Termination` is not implemented for `f32` | - = help: the trait `Termination` is not implemented for `f32` = note: required for `Result<f32, ParseFloatError>` to implement `Termination` note: required by a bound in `assert_test_result` --> $SRC_DIR/test/src/lib.rs:LL:COL diff --git a/src/test/ui/rfc-2632-const-trait-impl/assoc-type.stderr b/src/test/ui/rfc-2632-const-trait-impl/assoc-type.stderr index ce2425010ad..89177b0f1ac 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/assoc-type.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/assoc-type.stderr @@ -15,10 +15,6 @@ note: required by a bound in `Foo::Bar` | LL | type Bar: ~const std::ops::Add; | ^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo::Bar` -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | impl const Foo for NonConstAdd where NonConstAdd: ~const Add { - | +++++++++++++++++++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr b/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr index d9ad8043153..7350909ba8e 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr @@ -9,10 +9,6 @@ note: the trait `Plus` is implemented for `u32`, but that implementation is not | LL | a.plus(b) | ^^^^ -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | pub const fn add_u32(a: u32, b: u32) -> u32 where u32: ~const Plus { - | ++++++++++++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-fail.stderr b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-fail.stderr index 83d395dda19..31e6dbdab22 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-fail.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-fail.stderr @@ -9,7 +9,6 @@ note: the trait `PartialEq<_>` is implemented for `T`, but that implementation i | LL | *t == *t | ^^ - = help: the trait `PartialEq<&B>` is implemented for `&A` error: aborting due to previous error diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-default-method-bodies.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-default-method-bodies.stderr index fddc8d37f2f..c64930db9be 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-default-method-bodies.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/const-default-method-bodies.stderr @@ -11,10 +11,6 @@ note: the trait `ConstDefaultFn` is implemented for `NonConstImpl`, but that imp | LL | NonConstImpl.a(); | ^^^^^^^^^^^^ -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | const fn test() where NonConstImpl: ~const ConstDefaultFn { - | +++++++++++++++++++++++++++++++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr index ddf0e2d91c0..796c0d388ea 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr @@ -45,34 +45,55 @@ note: required by a bound in `check` LL | const fn check<T: ~const Destruct>(_: T) {} | ^^^^^^^^^^^^^^^ required by this bound in `check` -error[E0277]: the trait bound `ConstDropImplWithBounds<NonTrivialDrop>: ~const Destruct` is not satisfied +error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied + --> $DIR/const-drop-fail.rs:48:47 + | +LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), + | ----------------------------------------- ^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` + | | + | required by a bound introduced by this call + | +note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` + --> $DIR/const-drop-fail.rs:48:47 + | +LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), + | ^^^^^^^^^^^ +note: required by a bound in `ConstDropImplWithBounds` + --> $DIR/const-drop-fail.rs:27:35 + | +LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); + | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` + +error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied + --> $DIR/const-drop-fail.rs:48:5 + | +LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` + | +note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` --> $DIR/const-drop-fail.rs:48:5 | -LL | const _: () = check($exp); - | ----- required by a bound introduced by this call -... LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `ConstDropImplWithBounds<NonTrivialDrop>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `ConstDropImplWithBounds` + --> $DIR/const-drop-fail.rs:27:35 | -note: required for `ConstDropImplWithBounds<NonTrivialDrop>` to implement `~const Destruct` - --> $DIR/const-drop-fail.rs:29:25 +LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); + | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` + +error[E0367]: `Drop` impl requires `T: ~const A` but the struct it is implemented for does not + --> $DIR/const-drop-fail.rs:55:9 | -LL | impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> { - | ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: 1 redundant requirement hidden - = note: required for `ConstDropImplWithBounds<NonTrivialDrop>` to implement `~const Destruct` -note: required by a bound in `check` - --> $DIR/const-drop-fail.rs:35:19 +LL | impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> { + | ^^^^^^^^ | -LL | const fn check<T: ~const Destruct>(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` -help: consider borrowing here +note: the implementor must specify the same requirement + --> $DIR/const-drop-fail.rs:53:1 | -LL | &ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), - | + -LL | &mut ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), - | ++++ +LL | struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0277, E0367. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.rs b/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.rs index 565e2c77ac5..d36c7f81ced 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.rs @@ -24,7 +24,7 @@ trait A { fn a() { } } impl A for NonTrivialDrop {} -struct ConstDropImplWithBounds<T: A>(PhantomData<T>); +struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> { fn drop(&mut self) { @@ -47,6 +47,16 @@ check_all! { //~^ ERROR can't drop ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), //~^ ERROR the trait bound + //~| ERROR the trait bound +} + +struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>); + +impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> { +//~^ ERROR `Drop` impl requires `T: ~const A` but the struct it is implemented for does not + fn drop(&mut self) { + T::a(); + } } fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr index ddf0e2d91c0..796c0d388ea 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr @@ -45,34 +45,55 @@ note: required by a bound in `check` LL | const fn check<T: ~const Destruct>(_: T) {} | ^^^^^^^^^^^^^^^ required by this bound in `check` -error[E0277]: the trait bound `ConstDropImplWithBounds<NonTrivialDrop>: ~const Destruct` is not satisfied +error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied + --> $DIR/const-drop-fail.rs:48:47 + | +LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), + | ----------------------------------------- ^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` + | | + | required by a bound introduced by this call + | +note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` + --> $DIR/const-drop-fail.rs:48:47 + | +LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), + | ^^^^^^^^^^^ +note: required by a bound in `ConstDropImplWithBounds` + --> $DIR/const-drop-fail.rs:27:35 + | +LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); + | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` + +error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied + --> $DIR/const-drop-fail.rs:48:5 + | +LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` + | +note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` --> $DIR/const-drop-fail.rs:48:5 | -LL | const _: () = check($exp); - | ----- required by a bound introduced by this call -... LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `ConstDropImplWithBounds<NonTrivialDrop>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `ConstDropImplWithBounds` + --> $DIR/const-drop-fail.rs:27:35 | -note: required for `ConstDropImplWithBounds<NonTrivialDrop>` to implement `~const Destruct` - --> $DIR/const-drop-fail.rs:29:25 +LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); + | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` + +error[E0367]: `Drop` impl requires `T: ~const A` but the struct it is implemented for does not + --> $DIR/const-drop-fail.rs:55:9 | -LL | impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> { - | ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: 1 redundant requirement hidden - = note: required for `ConstDropImplWithBounds<NonTrivialDrop>` to implement `~const Destruct` -note: required by a bound in `check` - --> $DIR/const-drop-fail.rs:35:19 +LL | impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> { + | ^^^^^^^^ | -LL | const fn check<T: ~const Destruct>(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` -help: consider borrowing here +note: the implementor must specify the same requirement + --> $DIR/const-drop-fail.rs:53:1 | -LL | &ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), - | + -LL | &mut ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), - | ++++ +LL | struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0277, E0367. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-drop.rs b/src/test/ui/rfc-2632-const-trait-impl/const-drop.rs index 8b4c4065815..b0fc3adf984 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-drop.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/const-drop.rs @@ -60,7 +60,7 @@ mod t { fn foo() {} } - pub struct ConstDropWithBound<T: SomeTrait>(pub core::marker::PhantomData<T>); + pub struct ConstDropWithBound<T: ~const SomeTrait>(pub core::marker::PhantomData<T>); impl<T: ~const SomeTrait> const Drop for ConstDropWithBound<T> { fn drop(&mut self) { diff --git a/src/test/ui/rfc-2632-const-trait-impl/cross-crate.gatednc.stderr b/src/test/ui/rfc-2632-const-trait-impl/cross-crate.gatednc.stderr index d4fa44b4bfc..925ae53e324 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/cross-crate.gatednc.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/cross-crate.gatednc.stderr @@ -11,10 +11,6 @@ note: the trait `cross_crate::MyTrait` is implemented for `cross_crate::NonConst | LL | NonConst.func(); | ^^^^^^^^ -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | const fn const_context() where cross_crate::NonConst: ~const cross_crate::MyTrait { - | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/rfc-2632-const-trait-impl/cross-crate.stocknc.stderr b/src/test/ui/rfc-2632-const-trait-impl/cross-crate.stocknc.stderr index 71ecd9b0694..11db0c2b8f2 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/cross-crate.stocknc.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/cross-crate.stocknc.stderr @@ -11,10 +11,6 @@ note: the trait `cross_crate::MyTrait` is implemented for `cross_crate::NonConst | LL | NonConst.func(); | ^^^^^^^^ -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | const fn const_context() where cross_crate::NonConst: ~const cross_crate::MyTrait { - | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr b/src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr index d102956cd2e..a244ab10cab 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr @@ -14,10 +14,6 @@ note: required by a bound in `foo` | LL | const fn foo<T>() where T: ~const Tr {} | ^^^^^^^^^ required by this bound in `foo` -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | pub trait Foo where (): ~const Tr { - | +++++++++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr b/src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr index 85285ba8497..c2c16921c2e 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr @@ -11,10 +11,6 @@ note: the trait `Tr` is implemented for `()`, but that implementation is not `co | LL | ().a() | ^^ -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | pub trait Tr where (): ~const Tr { - | +++++++++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/rfc-2632-const-trait-impl/issue-90052.rs b/src/test/ui/rfc-2632-const-trait-impl/issue-90052.rs new file mode 100644 index 00000000000..21ddf4ab4e5 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/issue-90052.rs @@ -0,0 +1,9 @@ +#![feature(const_trait_impl)] + +#[const_trait] +trait Bar {} + +fn foo<T>() where T: ~const Bar {} +//~^ ERROR `~const` is not allowed + +fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/issue-90052.stderr b/src/test/ui/rfc-2632-const-trait-impl/issue-90052.stderr new file mode 100644 index 00000000000..b2a9365378b --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/issue-90052.stderr @@ -0,0 +1,14 @@ +error: `~const` is not allowed here + --> $DIR/issue-90052.rs:6:22 + | +LL | fn foo<T>() where T: ~const Bar {} + | ^^^^^^^^^^ + | +note: this function is not `const`, so it cannot have `~const` trait bounds + --> $DIR/issue-90052.rs:6:4 + | +LL | fn foo<T>() where T: ~const Bar {} + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/rfc-2632-const-trait-impl/super-traits-fail.stderr b/src/test/ui/rfc-2632-const-trait-impl/super-traits-fail.stderr index 9787792ab13..1f8f312df01 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/super-traits-fail.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/super-traits-fail.stderr @@ -14,10 +14,6 @@ note: required by a bound in `Bar` | LL | trait Bar: ~const Foo {} | ^^^^^^^^^^ required by this bound in `Bar` -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | impl const Bar for S where S: ~const Foo {} - | +++++++++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs b/src/test/ui/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs index b29b633cff6..78a64b9018a 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs @@ -1,4 +1,3 @@ -// check-pass #![feature(const_trait_impl)] #![feature(generic_arg_infer)] #![feature(generic_const_exprs)] @@ -24,6 +23,7 @@ impl const Add42 for () { } fn bar<A: ~const Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> { + //~^ ERROR `~const` is not allowed here Foo } diff --git a/src/test/ui/rfc-2632-const-trait-impl/tilde-const-and-const-params.stderr b/src/test/ui/rfc-2632-const-trait-impl/tilde-const-and-const-params.stderr new file mode 100644 index 00000000000..aae72f36e57 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/tilde-const-and-const-params.stderr @@ -0,0 +1,14 @@ +error: `~const` is not allowed here + --> $DIR/tilde-const-and-const-params.rs:25:11 + | +LL | fn bar<A: ~const Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> { + | ^^^^^^^^^^^^ + | +note: this function is not `const`, so it cannot have `~const` trait bounds + --> $DIR/tilde-const-and-const-params.rs:25:4 + | +LL | fn bar<A: ~const Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> { + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr b/src/test/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr index 5d213315634..84867cb4a53 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr @@ -4,7 +4,7 @@ error: `~const` is not allowed here LL | fn rpit() -> impl ~const T { S } | ^^^^^^^^ | - = note: only allowed on bounds on functions, traits' associated types and functions, const impls and its associated functions + = note: `impl Trait`s cannot have `~const` trait bounds error: `~const` is not allowed here --> $DIR/tilde-const-invalid-places.rs:12:17 @@ -12,7 +12,7 @@ error: `~const` is not allowed here LL | fn apit(_: impl ~const T) {} | ^^^^^^^^ | - = note: only allowed on bounds on functions, traits' associated types and functions, const impls and its associated functions + = note: `impl Trait`s cannot have `~const` trait bounds error: `~const` is not allowed here --> $DIR/tilde-const-invalid-places.rs:15:50 @@ -20,7 +20,7 @@ error: `~const` is not allowed here LL | fn rpit_assoc_bound() -> impl IntoIterator<Item: ~const T> { Some(S) } | ^^^^^^^^ | - = note: only allowed on bounds on functions, traits' associated types and functions, const impls and its associated functions + = note: `impl Trait`s cannot have `~const` trait bounds error: `~const` is not allowed here --> $DIR/tilde-const-invalid-places.rs:18:48 @@ -28,7 +28,7 @@ error: `~const` is not allowed here LL | fn apit_assoc_bound(_: impl IntoIterator<Item: ~const T>) {} | ^^^^^^^^ | - = note: only allowed on bounds on functions, traits' associated types and functions, const impls and its associated functions + = note: `impl Trait`s cannot have `~const` trait bounds error: `~const` and `?` are mutually exclusive --> $DIR/tilde-const-invalid-places.rs:21:25 diff --git a/src/test/ui/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.rs b/src/test/ui/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.rs new file mode 100644 index 00000000000..285cef571f3 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.rs @@ -0,0 +1,17 @@ +// check-pass +#![feature(const_trait_impl)] + +#[const_trait] +trait Foo { + fn foo(&self) {} +} + +struct Bar<T>(T); + +impl<T: ~const Foo> Bar<T> { + const fn foo(&self) { + self.0.foo() + } +} + +fn main() {} diff --git a/src/test/ui/runtime/rt-explody-panic-payloads.rs b/src/test/ui/runtime/rt-explody-panic-payloads.rs index e2221e5df8e..755d3df42de 100644 --- a/src/test/ui/runtime/rt-explody-panic-payloads.rs +++ b/src/test/ui/runtime/rt-explody-panic-payloads.rs @@ -22,7 +22,12 @@ fn main() { }.expect("running the command should have succeeded"); println!("{:#?}", output); let stderr = std::str::from_utf8(&output.stderr); - assert!(stderr.map(|v| { - v.ends_with("fatal runtime error: drop of the panic payload panicked\n") - }).unwrap_or(false)); + assert!(stderr + .map(|v| { + // When running inside QEMU user-mode emulation, there will be an extra message printed + // by QEMU in the stderr whenever a core dump happens. Remove it before the check. + v.strip_suffix("qemu: uncaught target signal 6 (Aborted) - core dumped\n").unwrap_or(v) + }) + .map(|v| { v.ends_with("fatal runtime error: drop of the panic payload panicked\n") }) + .unwrap_or(false)); } diff --git a/src/test/ui/single-use-lifetime/derive-eq.rs b/src/test/ui/single-use-lifetime/derive-eq.rs new file mode 100644 index 00000000000..e5bdfc55dd6 --- /dev/null +++ b/src/test/ui/single-use-lifetime/derive-eq.rs @@ -0,0 +1,11 @@ +// check-pass + +#![deny(single_use_lifetimes)] + +#[derive(PartialEq, Eq)] +struct Foo<'a, T> { + /// a reference to the underlying secret data that will be derefed + pub data: &'a mut T, +} + +fn main() {} diff --git a/src/test/ui/stability-attribute/stability-attribute-trait-impl.rs b/src/test/ui/stability-attribute/stability-attribute-trait-impl.rs index ce2726ffde4..0c771ae8795 100644 --- a/src/test/ui/stability-attribute/stability-attribute-trait-impl.rs +++ b/src/test/ui/stability-attribute/stability-attribute-trait-impl.rs @@ -1,4 +1,4 @@ -#![feature(staged_api)] +#![feature(staged_api, never_type, c_unwind)] //~^ ERROR module has missing stability attribute #[stable(feature = "a", since = "1")] @@ -23,7 +23,21 @@ impl StableTrait for UnstableType {} impl UnstableTrait for StableType {} #[unstable(feature = "h", issue = "none")] +impl StableTrait for ! {} + +// Note: If C-unwind is stabilized, switch this to another (unstable) ABI. +#[unstable(feature = "i", issue = "none")] +impl StableTrait for extern "C-unwind" fn() {} + +#[unstable(feature = "j", issue = "none")] //~^ ERROR an `#[unstable]` annotation here has no effect [ineffective_unstable_trait_impl] impl StableTrait for StableType {} +#[unstable(feature = "k", issue = "none")] +//~^ ERROR an `#[unstable]` annotation here has no effect [ineffective_unstable_trait_impl] +impl StableTrait for fn() -> ! {} + +#[unstable(feature = "l", issue = "none")] +impl StableTrait for fn() -> UnstableType {} + fn main() {} diff --git a/src/test/ui/stability-attribute/stability-attribute-trait-impl.stderr b/src/test/ui/stability-attribute/stability-attribute-trait-impl.stderr index 7645f3c7ef5..b91a1d2e11a 100644 --- a/src/test/ui/stability-attribute/stability-attribute-trait-impl.stderr +++ b/src/test/ui/stability-attribute/stability-attribute-trait-impl.stderr @@ -1,16 +1,24 @@ error: an `#[unstable]` annotation here has no effect - --> $DIR/stability-attribute-trait-impl.rs:25:1 + --> $DIR/stability-attribute-trait-impl.rs:32:1 | -LL | #[unstable(feature = "h", issue = "none")] +LL | #[unstable(feature = "j", issue = "none")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #55436 <https://github.com/rust-lang/rust/issues/55436> for more information = note: `#[deny(ineffective_unstable_trait_impl)]` on by default +error: an `#[unstable]` annotation here has no effect + --> $DIR/stability-attribute-trait-impl.rs:36:1 + | +LL | #[unstable(feature = "k", issue = "none")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #55436 <https://github.com/rust-lang/rust/issues/55436> for more information + error: module has missing stability attribute --> $DIR/stability-attribute-trait-impl.rs:1:1 | -LL | / #![feature(staged_api)] +LL | / #![feature(staged_api, never_type, c_unwind)] LL | | LL | | LL | | #[stable(feature = "a", since = "1")] @@ -19,5 +27,5 @@ LL | | LL | | fn main() {} | |____________^ -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors diff --git a/src/test/ui/issues/issue-2718-a.rs b/src/test/ui/structs-enums/issue-2718-a.rs index 6c491584540..6c491584540 100644 --- a/src/test/ui/issues/issue-2718-a.rs +++ b/src/test/ui/structs-enums/issue-2718-a.rs diff --git a/src/test/ui/issues/issue-2718-a.stderr b/src/test/ui/structs-enums/issue-2718-a.stderr index 7ea620f386a..7ea620f386a 100644 --- a/src/test/ui/issues/issue-2718-a.stderr +++ b/src/test/ui/structs-enums/issue-2718-a.stderr diff --git a/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr b/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr index bfd506c9f6e..8ed62f854f0 100644 --- a/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr +++ b/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr @@ -1,9 +1,6 @@ error[E0277]: `fn() -> impl Future<Output = ()> {foo}` is not a future --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:10:9 | -LL | async fn foo() {} - | --- consider calling this function -... LL | bar(foo); | --- ^^^ `fn() -> impl Future<Output = ()> {foo}` is not a future | | @@ -16,7 +13,7 @@ note: required by a bound in `bar` | LL | fn bar(f: impl Future<Output=()>) {} | ^^^^^^^^^^^^^^^^^ required by this bound in `bar` -help: use parentheses to call the function +help: use parentheses to call this function | LL | bar(foo()); | ++ @@ -24,8 +21,6 @@ LL | bar(foo()); error[E0277]: `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33]` is not a future --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:12:9 | -LL | let async_closure = async || (); - | -------- consider calling this closure LL | bar(async_closure); | --- ^^^^^^^^^^^^^ `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33]` is not a future | | @@ -38,7 +33,7 @@ note: required by a bound in `bar` | LL | fn bar(f: impl Future<Output=()>) {} | ^^^^^^^^^^^^^^^^^ required by this bound in `bar` -help: use parentheses to call the closure +help: use parentheses to call this closure | LL | bar(async_closure()); | ++ diff --git a/src/test/ui/suggestions/call-on-unimplemented-ctor.rs b/src/test/ui/suggestions/call-on-unimplemented-ctor.rs new file mode 100644 index 00000000000..5f811044eb3 --- /dev/null +++ b/src/test/ui/suggestions/call-on-unimplemented-ctor.rs @@ -0,0 +1,17 @@ +fn main() { + insert_resource(Marker); + insert_resource(Time); + //~^ ERROR the trait bound `fn(u32) -> Time {Time}: Resource` is not satisfied + //~| HELP use parentheses to construct this tuple struct +} + +trait Resource {} + +fn insert_resource<R: Resource>(resource: R) {} + +struct Marker; +impl Resource for Marker {} + +struct Time(u32); + +impl Resource for Time {} diff --git a/src/test/ui/suggestions/call-on-unimplemented-ctor.stderr b/src/test/ui/suggestions/call-on-unimplemented-ctor.stderr new file mode 100644 index 00000000000..58612cbfb23 --- /dev/null +++ b/src/test/ui/suggestions/call-on-unimplemented-ctor.stderr @@ -0,0 +1,21 @@ +error[E0277]: the trait bound `fn(u32) -> Time {Time}: Resource` is not satisfied + --> $DIR/call-on-unimplemented-ctor.rs:3:21 + | +LL | insert_resource(Time); + | --------------- ^^^^ the trait `Resource` is not implemented for fn item `fn(u32) -> Time {Time}` + | | + | required by a bound introduced by this call + | +note: required by a bound in `insert_resource` + --> $DIR/call-on-unimplemented-ctor.rs:10:23 + | +LL | fn insert_resource<R: Resource>(resource: R) {} + | ^^^^^^^^ required by this bound in `insert_resource` +help: use parentheses to construct this tuple struct + | +LL | insert_resource(Time(/* u32 */)); + | +++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/suggestions/call-on-unimplemented-fn-ptr.rs b/src/test/ui/suggestions/call-on-unimplemented-fn-ptr.rs new file mode 100644 index 00000000000..86490c724e0 --- /dev/null +++ b/src/test/ui/suggestions/call-on-unimplemented-fn-ptr.rs @@ -0,0 +1,15 @@ +struct Foo; + +trait Bar {} + +impl Bar for Foo {} + +fn needs_bar<T: Bar>(_: T) {} + +fn blah(f: fn() -> Foo) { + needs_bar(f); + //~^ ERROR the trait bound `fn() -> Foo: Bar` is not satisfied + //~| HELP use parentheses to call this function pointer +} + +fn main() {} diff --git a/src/test/ui/suggestions/call-on-unimplemented-fn-ptr.stderr b/src/test/ui/suggestions/call-on-unimplemented-fn-ptr.stderr new file mode 100644 index 00000000000..167f7e592a9 --- /dev/null +++ b/src/test/ui/suggestions/call-on-unimplemented-fn-ptr.stderr @@ -0,0 +1,21 @@ +error[E0277]: the trait bound `fn() -> Foo: Bar` is not satisfied + --> $DIR/call-on-unimplemented-fn-ptr.rs:10:15 + | +LL | needs_bar(f); + | --------- ^ the trait `Bar` is not implemented for `fn() -> Foo` + | | + | required by a bound introduced by this call + | +note: required by a bound in `needs_bar` + --> $DIR/call-on-unimplemented-fn-ptr.rs:7:17 + | +LL | fn needs_bar<T: Bar>(_: T) {} + | ^^^ required by this bound in `needs_bar` +help: use parentheses to call this function pointer + | +LL | needs_bar(f()); + | ++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr b/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr index fe603b67575..955148315ba 100644 --- a/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr +++ b/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr @@ -1,9 +1,6 @@ error[E0277]: the trait bound `fn() -> impl T<O = ()> {foo}: T` is not satisfied --> $DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:17:9 | -LL | fn foo() -> impl T<O=()> { S } - | --- consider calling this function -... LL | bar(foo); | --- ^^^ the trait `T` is not implemented for fn item `fn() -> impl T<O = ()> {foo}` | | @@ -14,7 +11,7 @@ note: required by a bound in `bar` | LL | fn bar(f: impl T<O=()>) {} | ^^^^^^^ required by this bound in `bar` -help: use parentheses to call the function +help: use parentheses to call this function | LL | bar(foo()); | ++ @@ -22,8 +19,6 @@ LL | bar(foo()); error[E0277]: the trait bound `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:21]: T` is not satisfied --> $DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:19:9 | -LL | let closure = || S; - | -- consider calling this closure LL | bar(closure); | --- ^^^^^^^ the trait `T` is not implemented for closure `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:21]` | | @@ -34,7 +29,7 @@ note: required by a bound in `bar` | LL | fn bar(f: impl T<O=()>) {} | ^^^^^^^ required by this bound in `bar` -help: use parentheses to call the closure +help: use parentheses to call this closure | LL | bar(closure()); | ++ diff --git a/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr b/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr index f05dba1d4ca..597dc61c3f7 100644 --- a/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr +++ b/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr @@ -49,7 +49,7 @@ LL | let _: S = S; | = note: expected struct `S` found fn item `fn(usize, usize) -> S {S}` -help: use parentheses to instantiate this tuple struct +help: use parentheses to construct this tuple struct | LL | let _: S = S(/* usize */, /* usize */); | ++++++++++++++++++++++++++ @@ -85,7 +85,7 @@ LL | let _: V = V; | = note: expected struct `V` found fn item `fn() -> V {V}` -help: use parentheses to instantiate this tuple struct +help: use parentheses to construct this tuple struct | LL | let _: V = V(); | ++ @@ -139,7 +139,7 @@ LL | let _: E = E::A; | = note: expected enum `E` found fn item `fn(usize) -> E {E::A}` -help: use parentheses to instantiate this tuple variant +help: use parentheses to construct this tuple variant | LL | let _: E = E::A(/* usize */); | +++++++++++++ diff --git a/src/test/ui/suggestions/issue-103112.rs b/src/test/ui/suggestions/issue-103112.rs new file mode 100644 index 00000000000..111ae7c7308 --- /dev/null +++ b/src/test/ui/suggestions/issue-103112.rs @@ -0,0 +1,4 @@ +fn main() { + std::process::abort!(); + //~^ ERROR: failed to resolve +} diff --git a/src/test/ui/suggestions/issue-103112.stderr b/src/test/ui/suggestions/issue-103112.stderr new file mode 100644 index 00000000000..4ca7fdf9b5a --- /dev/null +++ b/src/test/ui/suggestions/issue-103112.stderr @@ -0,0 +1,15 @@ +error[E0433]: failed to resolve: could not find `abort` in `process` + --> $DIR/issue-103112.rs:2:19 + | +LL | std::process::abort!(); + | ^^^^^ could not find `abort` in `process` + | +help: std::process::abort is not a macro, but a function, try to remove `!` + | +LL - std::process::abort!(); +LL + std::process::abort(); + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/suggestions/suggest-let-for-assignment.fixed b/src/test/ui/suggestions/suggest-let-for-assignment.fixed new file mode 100644 index 00000000000..3a25e25eede --- /dev/null +++ b/src/test/ui/suggestions/suggest-let-for-assignment.fixed @@ -0,0 +1,17 @@ +// run-rustfix + +fn main() { + let demo = 1; //~ ERROR cannot find value `demo` in this scope + dbg!(demo); //~ ERROR cannot find value `demo` in this scope + + let x = "x"; //~ ERROR cannot find value `x` in this scope + println!("x: {}", x); //~ ERROR cannot find value `x` in this scope + + if x == "x" { + //~^ ERROR cannot find value `x` in this scope + println!("x is 1"); + } + + let y = 1 + 2; //~ ERROR cannot find value `y` in this scope + println!("y: {}", y); //~ ERROR cannot find value `y` in this scope +} diff --git a/src/test/ui/suggestions/suggest-let-for-assignment.rs b/src/test/ui/suggestions/suggest-let-for-assignment.rs new file mode 100644 index 00000000000..67705fe063a --- /dev/null +++ b/src/test/ui/suggestions/suggest-let-for-assignment.rs @@ -0,0 +1,17 @@ +// run-rustfix + +fn main() { + demo = 1; //~ ERROR cannot find value `demo` in this scope + dbg!(demo); //~ ERROR cannot find value `demo` in this scope + + x = "x"; //~ ERROR cannot find value `x` in this scope + println!("x: {}", x); //~ ERROR cannot find value `x` in this scope + + if x == "x" { + //~^ ERROR cannot find value `x` in this scope + println!("x is 1"); + } + + y = 1 + 2; //~ ERROR cannot find value `y` in this scope + println!("y: {}", y); //~ ERROR cannot find value `y` in this scope +} diff --git a/src/test/ui/suggestions/suggest-let-for-assignment.stderr b/src/test/ui/suggestions/suggest-let-for-assignment.stderr new file mode 100644 index 00000000000..3f6a3da4be2 --- /dev/null +++ b/src/test/ui/suggestions/suggest-let-for-assignment.stderr @@ -0,0 +1,60 @@ +error[E0425]: cannot find value `demo` in this scope + --> $DIR/suggest-let-for-assignment.rs:4:5 + | +LL | demo = 1; + | ^^^^ + | +help: you might have meant to introduce a new binding + | +LL | let demo = 1; + | +++ + +error[E0425]: cannot find value `demo` in this scope + --> $DIR/suggest-let-for-assignment.rs:5:10 + | +LL | dbg!(demo); + | ^^^^ not found in this scope + +error[E0425]: cannot find value `x` in this scope + --> $DIR/suggest-let-for-assignment.rs:7:5 + | +LL | x = "x"; + | ^ + | +help: you might have meant to introduce a new binding + | +LL | let x = "x"; + | +++ + +error[E0425]: cannot find value `x` in this scope + --> $DIR/suggest-let-for-assignment.rs:8:23 + | +LL | println!("x: {}", x); + | ^ not found in this scope + +error[E0425]: cannot find value `x` in this scope + --> $DIR/suggest-let-for-assignment.rs:10:8 + | +LL | if x == "x" { + | ^ not found in this scope + +error[E0425]: cannot find value `y` in this scope + --> $DIR/suggest-let-for-assignment.rs:15:5 + | +LL | y = 1 + 2; + | ^ + | +help: you might have meant to introduce a new binding + | +LL | let y = 1 + 2; + | +++ + +error[E0425]: cannot find value `y` in this scope + --> $DIR/suggest-let-for-assignment.rs:16:23 + | +LL | println!("y: {}", y); + | ^ not found in this scope + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/test-attrs/test-fn-signature-verification-for-explicit-return-type.rs b/src/test/ui/test-attrs/test-fn-signature-verification-for-explicit-return-type.rs index ff62d84925f..585874e273d 100644 --- a/src/test/ui/test-attrs/test-fn-signature-verification-for-explicit-return-type.rs +++ b/src/test/ui/test-attrs/test-fn-signature-verification-for-explicit-return-type.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind (#73509) #![feature(test)] diff --git a/src/test/ui/test-attrs/test-thread-capture.rs b/src/test/ui/test-attrs/test-thread-capture.rs index edc972837a3..53acca34133 100644 --- a/src/test/ui/test-attrs/test-thread-capture.rs +++ b/src/test/ui/test-attrs/test-thread-capture.rs @@ -5,6 +5,7 @@ // exec-env:RUST_BACKTRACE=0 // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // ignore-emscripten no threads support +// needs-unwind #[test] fn thready_pass() { diff --git a/src/test/ui/test-attrs/test-thread-capture.run.stdout b/src/test/ui/test-attrs/test-thread-capture.run.stdout index 487cfb55eb4..c712a78afb0 100644 --- a/src/test/ui/test-attrs/test-thread-capture.run.stdout +++ b/src/test/ui/test-attrs/test-thread-capture.run.stdout @@ -10,7 +10,7 @@ fee fie foe fum -thread 'main' panicked at 'explicit panic', $DIR/test-thread-capture.rs:31:5 +thread 'main' panicked at 'explicit panic', $DIR/test-thread-capture.rs:32:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/src/test/ui/test-attrs/test-thread-nocapture.rs b/src/test/ui/test-attrs/test-thread-nocapture.rs index 8e8e9bbfdf0..2b57eb8aae1 100644 --- a/src/test/ui/test-attrs/test-thread-nocapture.rs +++ b/src/test/ui/test-attrs/test-thread-nocapture.rs @@ -5,6 +5,7 @@ // exec-env:RUST_BACKTRACE=0 // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // ignore-emscripten no threads support +// needs-unwind #[test] fn thready_pass() { diff --git a/src/test/ui/test-attrs/test-thread-nocapture.run.stderr b/src/test/ui/test-attrs/test-thread-nocapture.run.stderr index 06495681b3e..0a12a052819 100644 --- a/src/test/ui/test-attrs/test-thread-nocapture.run.stderr +++ b/src/test/ui/test-attrs/test-thread-nocapture.run.stderr @@ -1,2 +1,2 @@ -thread 'main' panicked at 'explicit panic', $DIR/test-thread-nocapture.rs:31:5 +thread 'main' panicked at 'explicit panic', $DIR/test-thread-nocapture.rs:32:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/src/test/ui/threads-sendsync/sync-send-in-std.rs b/src/test/ui/threads-sendsync/sync-send-in-std.rs index b8ae214dc09..6d1fba64e42 100644 --- a/src/test/ui/threads-sendsync/sync-send-in-std.rs +++ b/src/test/ui/threads-sendsync/sync-send-in-std.rs @@ -2,6 +2,7 @@ // ignore-wasm32-bare networking not available // ignore-sgx ToSocketAddrs cannot be used for DNS Resolution +// ignore-fuchsia Req. test-harness networking privileges use std::net::ToSocketAddrs; diff --git a/src/test/ui/traits/issue-33140-hack-boundaries.stderr b/src/test/ui/traits/issue-33140-hack-boundaries.stderr index 62cfca545b2..58286648d4f 100644 --- a/src/test/ui/traits/issue-33140-hack-boundaries.stderr +++ b/src/test/ui/traits/issue-33140-hack-boundaries.stderr @@ -66,3 +66,20 @@ error: aborting due to 8 previous errors Some errors have detailed explanations: E0119, E0751. For more information about an error, try `rustc --explain E0119`. +Future incompatibility report: Future breakage diagnostic: +warning: conflicting implementations of trait `Trait0` for type `(dyn std::marker::Send + 'static)`: (E0119) + --> $DIR/issue-33140-hack-boundaries.rs:10:1 + | +LL | impl Trait0 for dyn Send {} + | ------------------------ first implementation here +LL | impl Trait0 for dyn Send {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + 'static)` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> +note: the lint level is defined here + --> $DIR/issue-33140-hack-boundaries.rs:2:10 + | +LL | #![allow(order_dependent_trait_objects)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/src/test/ui/traits/object/issue-33140-traitobject-crate.stderr b/src/test/ui/traits/object/issue-33140-traitobject-crate.stderr index 4ab777bd4df..0af4df2aecb 100644 --- a/src/test/ui/traits/object/issue-33140-traitobject-crate.stderr +++ b/src/test/ui/traits/object/issue-33140-traitobject-crate.stderr @@ -40,3 +40,56 @@ LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send + Sync { } warning: 3 warnings emitted +Future incompatibility report: Future breakage diagnostic: +warning: conflicting implementations of trait `Trait` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) + --> $DIR/issue-33140-traitobject-crate.rs:86:1 + | +LL | unsafe impl Trait for dyn (::std::marker::Send) + Sync { } + | ------------------------------------------------------ first implementation here +LL | unsafe impl Trait for dyn (::std::marker::Send) + Send + Sync { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> +note: the lint level is defined here + --> $DIR/issue-33140-traitobject-crate.rs:3:9 + | +LL | #![warn(order_dependent_trait_objects)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Future breakage diagnostic: +warning: conflicting implementations of trait `Trait` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) + --> $DIR/issue-33140-traitobject-crate.rs:89:1 + | +LL | unsafe impl Trait for dyn (::std::marker::Send) + Send + Sync { } + | ------------------------------------------------------------- first implementation here +... +LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> +note: the lint level is defined here + --> $DIR/issue-33140-traitobject-crate.rs:3:9 + | +LL | #![warn(order_dependent_trait_objects)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Future breakage diagnostic: +warning: conflicting implementations of trait `Trait` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) + --> $DIR/issue-33140-traitobject-crate.rs:93:1 + | +LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send { } + | ------------------------------------------------------ first implementation here +... +LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send + Sync { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> +note: the lint level is defined here + --> $DIR/issue-33140-traitobject-crate.rs:3:9 + | +LL | #![warn(order_dependent_trait_objects)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/src/test/ui/traits/trait-upcasting/multiple-occurence-ambiguousity.rs b/src/test/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.rs index 6986ad62172..6986ad62172 100644 --- a/src/test/ui/traits/trait-upcasting/multiple-occurence-ambiguousity.rs +++ b/src/test/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.rs diff --git a/src/test/ui/traits/trait-upcasting/multiple-occurence-ambiguousity.stderr b/src/test/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.stderr index e9670ad7def..9564813512c 100644 --- a/src/test/ui/traits/trait-upcasting/multiple-occurence-ambiguousity.stderr +++ b/src/test/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/multiple-occurence-ambiguousity.rs:21:26 + --> $DIR/multiple-occurrence-ambiguousity.rs:21:26 | LL | let t: &dyn Bar<_> = s; | ----------- ^ expected trait `Bar`, found trait `Foo` diff --git a/src/test/ui/treat-err-as-bug/delay_span_bug.rs b/src/test/ui/treat-err-as-bug/delay_span_bug.rs index d4d44049c91..832afddf891 100644 --- a/src/test/ui/treat-err-as-bug/delay_span_bug.rs +++ b/src/test/ui/treat-err-as-bug/delay_span_bug.rs @@ -1,7 +1,7 @@ // compile-flags: -Ztreat-err-as-bug // failure-status: 101 // error-pattern: aborting due to `-Z treat-err-as-bug=1` -// error-pattern: [trigger_delay_span_bug] trigger a delay span bug +// error-pattern: [trigger_delay_span_bug] triggering a delay span bug // normalize-stderr-test "note: .*\n\n" -> "" // normalize-stderr-test "thread 'rustc' panicked.*\n" -> "" // rustc-env:RUST_BACKTRACE=0 diff --git a/src/test/ui/treat-err-as-bug/delay_span_bug.stderr b/src/test/ui/treat-err-as-bug/delay_span_bug.stderr index c23c2b81b97..e9457c8faff 100644 --- a/src/test/ui/treat-err-as-bug/delay_span_bug.stderr +++ b/src/test/ui/treat-err-as-bug/delay_span_bug.stderr @@ -7,5 +7,5 @@ LL | fn main() {} error: internal compiler error: unexpected panic query stack during panic: -#0 [trigger_delay_span_bug] trigger a delay span bug +#0 [trigger_delay_span_bug] triggering a delay span bug end of query stack diff --git a/src/test/ui/type-alias-impl-trait/different_lifetimes_defining_uses.rs b/src/test/ui/type-alias-impl-trait/different_lifetimes_defining_uses.rs index 4f424b8c665..5f75fdc716e 100644 --- a/src/test/ui/type-alias-impl-trait/different_lifetimes_defining_uses.rs +++ b/src/test/ui/type-alias-impl-trait/different_lifetimes_defining_uses.rs @@ -1,7 +1,11 @@ #![feature(type_alias_impl_trait)] #![allow(dead_code)] -type OneLifetime<'a, 'b> = impl std::fmt::Debug; +pub trait Captures<'a> {} + +impl<'a, T: ?Sized> Captures<'a> for T {} + +type OneLifetime<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>; fn foo<'a, 'b>(a: &'a u32, b: &'b u32) -> OneLifetime<'a, 'b> { a diff --git a/src/test/ui/type-alias-impl-trait/different_lifetimes_defining_uses.stderr b/src/test/ui/type-alias-impl-trait/different_lifetimes_defining_uses.stderr index 0c50a84e894..546598e8a5c 100644 --- a/src/test/ui/type-alias-impl-trait/different_lifetimes_defining_uses.stderr +++ b/src/test/ui/type-alias-impl-trait/different_lifetimes_defining_uses.stderr @@ -1,11 +1,11 @@ error: concrete type differs from previous defining opaque type use - --> $DIR/different_lifetimes_defining_uses.rs:11:5 + --> $DIR/different_lifetimes_defining_uses.rs:15:5 | LL | b | ^ expected `&'a u32`, got `&'b u32` | note: previous use here - --> $DIR/different_lifetimes_defining_uses.rs:7:5 + --> $DIR/different_lifetimes_defining_uses.rs:11:5 | LL | a | ^ diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs index c9b9e128f88..9d938a61600 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs @@ -2,8 +2,11 @@ fn main() {} -type Two<'a, 'b> = impl std::fmt::Debug; +pub trait Captures<'a> {} +impl<'a, T: ?Sized> Captures<'a> for T {} + +type Two<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>; fn one<'a>(t: &'a ()) -> Two<'a, 'a> { t diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr index 222aaea78d9..72e1ef4b492 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr @@ -1,13 +1,13 @@ error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_lifetime_param.rs:9:5 + --> $DIR/generic_duplicate_lifetime_param.rs:12:5 | LL | t | ^ | note: lifetime used multiple times - --> $DIR/generic_duplicate_lifetime_param.rs:5:10 + --> $DIR/generic_duplicate_lifetime_param.rs:9:10 | -LL | type Two<'a, 'b> = impl std::fmt::Debug; +LL | type Two<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>; | ^^ ^^ error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs index 093c1c23186..80462f8ac04 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs @@ -7,7 +7,12 @@ fn main() {} // test that unused generic parameters are ok type TwoTys<T, U> = impl Debug; -type TwoLifetimes<'a, 'b> = impl Debug; + +pub trait Captures<'a> {} + +impl<'a, T: ?Sized> Captures<'a> for T {} + +type TwoLifetimes<'a, 'b> = impl Debug + Captures<'a> + Captures<'b>; type TwoConsts<const X: usize, const Y: usize> = impl Debug; diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr index b2edcc5526a..98e4bfea10d 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr @@ -1,5 +1,5 @@ error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_param_use.rs:16:5 + --> $DIR/generic_duplicate_param_use.rs:21:5 | LL | t | ^ @@ -11,25 +11,25 @@ LL | type TwoTys<T, U> = impl Debug; | ^ ^ error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_param_use.rs:21:5 + --> $DIR/generic_duplicate_param_use.rs:26:5 | LL | t | ^ | note: lifetime used multiple times - --> $DIR/generic_duplicate_param_use.rs:10:19 + --> $DIR/generic_duplicate_param_use.rs:15:19 | -LL | type TwoLifetimes<'a, 'b> = impl Debug; +LL | type TwoLifetimes<'a, 'b> = impl Debug + Captures<'a> + Captures<'b>; | ^^ ^^ error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_param_use.rs:26:5 + --> $DIR/generic_duplicate_param_use.rs:31:5 | LL | t | ^ | note: constant used multiple times - --> $DIR/generic_duplicate_param_use.rs:12:16 + --> $DIR/generic_duplicate_param_use.rs:17:16 | LL | type TwoConsts<const X: usize, const Y: usize> = impl Debug; | ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^ diff --git a/src/test/ui/type-alias-impl-trait/generic_lifetime_param.rs b/src/test/ui/type-alias-impl-trait/generic_lifetime_param.rs index e109c38c986..106efefbaf2 100644 --- a/src/test/ui/type-alias-impl-trait/generic_lifetime_param.rs +++ b/src/test/ui/type-alias-impl-trait/generic_lifetime_param.rs @@ -1,10 +1,11 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass #![feature(type_alias_impl_trait)] fn main() {} -type Region<'a> = impl std::fmt::Debug; +type Region<'a> = impl std::fmt::Debug + 'a; + fn region<'b>(a: &'b ()) -> Region<'b> { a diff --git a/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs b/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs index 6e5b8f491ea..07f825aea50 100644 --- a/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs +++ b/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs @@ -1,7 +1,7 @@ #![feature(type_alias_impl_trait)] mod test_lifetime_param { - type Ty<'a> = impl Sized; + type Ty<'a> = impl Sized + 'a; fn defining(a: &str) -> Ty<'_> { a } fn assert_static<'a: 'static>() {} //~^ WARN: unnecessary lifetime parameter `'a` @@ -10,7 +10,7 @@ mod test_lifetime_param { } mod test_higher_kinded_lifetime_param { - type Ty<'a> = impl Sized; + type Ty<'a> = impl Sized + 'a; fn defining(a: &str) -> Ty<'_> { a } fn assert_static<'a: 'static>() {} //~^ WARN: unnecessary lifetime parameter `'a` diff --git a/src/test/ui/type-alias-impl-trait/issue-89686.rs b/src/test/ui/type-alias-impl-trait/issue-89686.rs index de070fc9deb..058417bdb80 100644 --- a/src/test/ui/type-alias-impl-trait/issue-89686.rs +++ b/src/test/ui/type-alias-impl-trait/issue-89686.rs @@ -4,7 +4,7 @@ use std::future::Future; -type G<'a, T> = impl Future<Output = ()>; +type G<'a, T> = impl Future<Output = ()> + 'a; trait Trait { type F: Future<Output = ()>; diff --git a/src/test/ui/type-alias-impl-trait/issue-89686.stderr b/src/test/ui/type-alias-impl-trait/issue-89686.stderr index b636ada8b75..3b95a575ac2 100644 --- a/src/test/ui/type-alias-impl-trait/issue-89686.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-89686.stderr @@ -6,7 +6,7 @@ LL | async move { self.f().await } | help: consider restricting type parameter `T` | -LL | type G<'a, T: Trait> = impl Future<Output = ()>; +LL | type G<'a, T: Trait> = impl Future<Output = ()> + 'a; | +++++++ error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/missing_lifetime_bound.rs b/src/test/ui/type-alias-impl-trait/missing_lifetime_bound.rs new file mode 100644 index 00000000000..428194058c3 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/missing_lifetime_bound.rs @@ -0,0 +1,7 @@ +#![feature(type_alias_impl_trait)] + +type Opaque<'a, T> = impl Sized; +fn defining<'a, T>(x: &'a i32) -> Opaque<T> { x } +//~^ ERROR: non-defining opaque type use in defining scope + +fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/missing_lifetime_bound.stderr b/src/test/ui/type-alias-impl-trait/missing_lifetime_bound.stderr new file mode 100644 index 00000000000..df2b3ed1911 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/missing_lifetime_bound.stderr @@ -0,0 +1,8 @@ +error: non-defining opaque type use in defining scope + --> $DIR/missing_lifetime_bound.rs:4:47 + | +LL | fn defining<'a, T>(x: &'a i32) -> Opaque<T> { x } + | ^ lifetime `'a` is part of concrete type but not used in parameter list of the `impl Trait` type alias + +error: aborting due to previous error + diff --git a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs index 3f122f10609..65eb2952e0f 100644 --- a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs +++ b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs @@ -1,6 +1,10 @@ #![feature(type_alias_impl_trait)] -type Foo<'a, 'b> = impl std::fmt::Debug; +pub trait Captures<'a> {} + +impl<'a, T: ?Sized> Captures<'a> for T {} + +type Foo<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>; fn foo<'x, 'y>(i: &'x i32, j: &'y i32) -> (Foo<'x, 'y>, Foo<'y, 'x>) { (i, i) //~ ERROR concrete type differs from previous diff --git a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr index 81e603e2355..d7676b8e9b1 100644 --- a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr +++ b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr @@ -1,5 +1,5 @@ error: concrete type differs from previous defining opaque type use - --> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:6:5 + --> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:10:5 | LL | (i, i) | ^^^^^^ diff --git a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs index 83fd9a1da45..21fca047a3c 100644 --- a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs +++ b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs @@ -7,7 +7,11 @@ fn f<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<A, B>) (a.clone(), a) } -type Foo<'a, 'b> = impl std::fmt::Debug; +pub trait Captures<'a> {} + +impl<'a, T: ?Sized> Captures<'a> for T {} + +type Foo<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>; fn foo<'x, 'y>(i: &'x i32, j: &'y i32) -> (Foo<'x, 'y>, Foo<'y, 'x>) { (i, j) diff --git a/src/test/ui/typeck/issue-87181/empty-tuple-method.stderr b/src/test/ui/typeck/issue-87181/empty-tuple-method.stderr index a18c54a29b5..23e7b7cc363 100644 --- a/src/test/ui/typeck/issue-87181/empty-tuple-method.stderr +++ b/src/test/ui/typeck/issue-87181/empty-tuple-method.stderr @@ -4,7 +4,7 @@ error[E0599]: no method named `foo` found for fn item `fn() -> Foo {Foo}` in the LL | thing.bar.foo(); | ^^^ method not found in `fn() -> Foo {Foo}` | -help: use parentheses to instantiate this tuple struct +help: use parentheses to construct this tuple struct | LL | (thing.bar)().foo(); | + +++ diff --git a/src/test/ui/typeck/issue-87181/enum-variant.stderr b/src/test/ui/typeck/issue-87181/enum-variant.stderr index 90641410d8e..2247ea27021 100644 --- a/src/test/ui/typeck/issue-87181/enum-variant.stderr +++ b/src/test/ui/typeck/issue-87181/enum-variant.stderr @@ -4,7 +4,7 @@ error[E0599]: no method named `foo` found for fn item `fn() -> Foo {Foo::Tup}` i LL | thing.bar.foo(); | ^^^ method not found in `fn() -> Foo {Foo::Tup}` | -help: use parentheses to instantiate this tuple variant +help: use parentheses to construct this tuple variant | LL | (thing.bar)().foo(); | + +++ diff --git a/src/test/ui/typeck/issue-87181/tuple-field.stderr b/src/test/ui/typeck/issue-87181/tuple-field.stderr index c1ca26ee9af..0a7d30b615a 100644 --- a/src/test/ui/typeck/issue-87181/tuple-field.stderr +++ b/src/test/ui/typeck/issue-87181/tuple-field.stderr @@ -4,7 +4,7 @@ error[E0609]: no field `0` on type `fn(char, u16) -> Foo {Foo}` LL | thing.bar.0; | ^ | -help: use parentheses to instantiate this tuple struct +help: use parentheses to construct this tuple struct | LL | (thing.bar)(/* char */, /* u16 */).0; | + ++++++++++++++++++++++++ diff --git a/src/test/ui/typeck/slow-lhs-suggestion.rs b/src/test/ui/typeck/slow-lhs-suggestion.rs new file mode 100644 index 00000000000..80dfd683524 --- /dev/null +++ b/src/test/ui/typeck/slow-lhs-suggestion.rs @@ -0,0 +1,26 @@ +fn main() { + 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + //~^ ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment + //~| ERROR invalid left-hand side of assignment +} diff --git a/src/test/ui/typeck/slow-lhs-suggestion.stderr b/src/test/ui/typeck/slow-lhs-suggestion.stderr new file mode 100644 index 00000000000..c5bf795eeee --- /dev/null +++ b/src/test/ui/typeck/slow-lhs-suggestion.stderr @@ -0,0 +1,187 @@ +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:95 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:91 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:87 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:83 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:79 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:75 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:71 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:67 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:63 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:59 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:55 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:51 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:47 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:43 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:39 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:35 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:31 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:27 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:23 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:19 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:15 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:11 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error[E0070]: invalid left-hand side of assignment + --> $DIR/slow-lhs-suggestion.rs:2:7 + | +LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1; + | - ^ + | | + | cannot assign to this expression + +error: aborting due to 23 previous errors + +For more information about this error, try `rustc --explain E0070`. |
