diff options
Diffstat (limited to 'src/test')
174 files changed, 1807 insertions, 618 deletions
diff --git a/src/test/codegen/slice-iter-len-eq-zero.rs b/src/test/codegen/slice-iter-len-eq-zero.rs index fd19e624cdd..1124028253d 100644 --- a/src/test/codegen/slice-iter-len-eq-zero.rs +++ b/src/test/codegen/slice-iter-len-eq-zero.rs @@ -1,5 +1,6 @@ // no-system-llvm // compile-flags: -O +// ignore-debug: the debug assertions add extra comparisons #![crate_type = "lib"] type Demo = [u8; 3]; @@ -12,3 +13,16 @@ pub fn slice_iter_len_eq_zero(y: std::slice::Iter<'_, Demo>) -> bool { // CHECK: ret i1 %2 y.len() == 0 } + +// CHECK-LABEL: @array_into_iter_len_eq_zero +#[no_mangle] +pub fn array_into_iter_len_eq_zero(y: std::array::IntoIter<Demo, 123>) -> bool { + // This should be able to just check that the indexes are equal, and not + // need any subtractions or comparisons to handle `start > end`. + + // CHECK-NOT: icmp + // CHECK-NOT: sub + // CHECK: %1 = icmp eq {{i16|i32|i64}} + // CHECK: ret i1 %1 + y.len() == 0 +} diff --git a/src/test/codegen/slice_as_from_ptr_range.rs b/src/test/codegen/slice_as_from_ptr_range.rs new file mode 100644 index 00000000000..0e3fefd9728 --- /dev/null +++ b/src/test/codegen/slice_as_from_ptr_range.rs @@ -0,0 +1,23 @@ +// compile-flags: -O +// only-64bit (because we're using [ui]size) +// ignore-debug (because the assertions get in the way) +// min-llvm-version: 15.0 (because this is a relatively new instcombine) + +#![crate_type = "lib"] +#![feature(slice_from_ptr_range)] + +// This is intentionally using a non-power-of-two array length, +// as that's where the optimization differences show up + +// CHECK-LABEL: @flatten_via_ptr_range +#[no_mangle] +pub fn flatten_via_ptr_range(slice_of_arrays: &[[i32; 13]]) -> &[i32] { + // CHECK-NOT: lshr + // CHECK-NOT: udiv + // CHECK: mul nuw nsw i64 %{{.+}}, 13 + // CHECK-NOT: lshr + // CHECK-NOT: udiv + let r = slice_of_arrays.as_ptr_range(); + let r = r.start.cast()..r.end.cast(); + unsafe { core::slice::from_ptr_range(r) } +} diff --git a/src/test/mir-opt/issue-101867.rs b/src/test/mir-opt/issue-101867.rs new file mode 100644 index 00000000000..931396e2171 --- /dev/null +++ b/src/test/mir-opt/issue-101867.rs @@ -0,0 +1,9 @@ +#![cfg_attr(bootstrap, feature(let_else))] + +// EMIT_MIR issue_101867.main.mir_map.0.mir +fn main() { + let x: Option<u8> = Some(1); + let Some(y) = x else { + panic!(); + }; +} diff --git a/src/test/mir-opt/issue-101973.rs b/src/test/mir-opt/issue-101973.rs new file mode 100644 index 00000000000..216659a235e --- /dev/null +++ b/src/test/mir-opt/issue-101973.rs @@ -0,0 +1,20 @@ +// compile-flags: -O -C debug-assertions=on +// This needs inlining followed by ConstProp to reproduce, so we cannot use "unit-test". + +#[inline] +pub fn imm8(x: u32) -> u32 { + let mut out = 0u32; + out |= (x >> 0) & 0xff; + out +} + +// EMIT_MIR issue_101973.inner.ConstProp.diff +#[inline(never)] +pub fn inner(fields: u32) -> i64 { + imm8(fields).rotate_right(((fields >> 8) & 0xf) << 1) as i32 as i64 +} + +fn main() { + let val = inner(0xe32cf20f); + assert_eq!(val as u64, 0xfffffffff0000000); +} diff --git a/src/test/mir-opt/issue_101867.main.mir_map.0.mir b/src/test/mir-opt/issue_101867.main.mir_map.0.mir new file mode 100644 index 00000000000..98501ac8c9d --- /dev/null +++ b/src/test/mir-opt/issue_101867.main.mir_map.0.mir @@ -0,0 +1,75 @@ +// MIR for `main` 0 mir_map + +| User Type Annotations +| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option<u8>) }, span: $DIR/issue-101867.rs:5:12: 5:22, inferred_ty: std::option::Option<u8> +| 1: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option<u8>) }, span: $DIR/issue-101867.rs:5:12: 5:22, inferred_ty: std::option::Option<u8> +| +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue-101867.rs:+0:11: +0:11 + let _1: std::option::Option<u8> as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/issue-101867.rs:+1:9: +1:10 + let mut _2: !; // in scope 0 at $DIR/issue-101867.rs:+2:26: +4:6 + let _3: (); // in scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL + let mut _4: !; // in scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL + let mut _6: isize; // in scope 0 at $DIR/issue-101867.rs:+2:9: +2:16 + scope 1 { + debug x => _1; // in scope 1 at $DIR/issue-101867.rs:+1:9: +1:10 + let _5: u8; // in scope 1 at $DIR/issue-101867.rs:+2:14: +2:15 + scope 2 { + debug y => _5; // in scope 2 at $DIR/issue-101867.rs:+2:14: +2:15 + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/issue-101867.rs:+1:9: +1:10 + _1 = Option::<u8>::Some(const 1_u8); // scope 0 at $DIR/issue-101867.rs:+1:25: +1:32 + FakeRead(ForLet(None), _1); // scope 0 at $DIR/issue-101867.rs:+1:9: +1:10 + AscribeUserType(_1, o, UserTypeProjection { base: UserType(1), projs: [] }); // scope 0 at $DIR/issue-101867.rs:+1:12: +1:22 + StorageLive(_5); // scope 1 at $DIR/issue-101867.rs:+2:14: +2:15 + FakeRead(ForMatchedPlace(None), _1); // scope 1 at $DIR/issue-101867.rs:+2:19: +2:20 + _6 = discriminant(_1); // scope 1 at $DIR/issue-101867.rs:+2:19: +2:20 + switchInt(move _6) -> [1_isize: bb4, otherwise: bb3]; // scope 1 at $DIR/issue-101867.rs:+2:9: +2:16 + } + + bb1: { + StorageLive(_3); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL + StorageLive(_4); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL + _4 = begin_panic::<&str>(const "explicit panic") -> bb7; // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/std/src/panic.rs:LL:COL + // + literal: Const { ty: fn(&str) -> ! {begin_panic::<&str>}, val: Value(<ZST>) } + // mir::Constant + // + span: $SRC_DIR/std/src/panic.rs:LL:COL + // + literal: Const { ty: &str, val: Value(Slice(..)) } + } + + bb2: { + StorageDead(_4); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL + StorageDead(_3); // scope 1 at $DIR/issue-101867.rs:+3:16: +3:17 + unreachable; // scope 1 at $DIR/issue-101867.rs:+2:26: +4:6 + } + + bb3: { + goto -> bb6; // scope 1 at $DIR/issue-101867.rs:+2:19: +2:20 + } + + bb4: { + falseEdge -> [real: bb5, imaginary: bb3]; // scope 1 at $DIR/issue-101867.rs:+2:9: +2:16 + } + + bb5: { + _5 = ((_1 as Some).0: u8); // scope 1 at $DIR/issue-101867.rs:+2:14: +2:15 + _0 = const (); // scope 0 at $DIR/issue-101867.rs:+0:11: +5:2 + StorageDead(_5); // scope 1 at $DIR/issue-101867.rs:+5:1: +5:2 + StorageDead(_1); // scope 0 at $DIR/issue-101867.rs:+5:1: +5:2 + return; // scope 0 at $DIR/issue-101867.rs:+5:2: +5:2 + } + + bb6: { + StorageDead(_5); // scope 1 at $DIR/issue-101867.rs:+5:1: +5:2 + goto -> bb1; // scope 0 at $DIR/issue-101867.rs:+0:11: +5:2 + } + + bb7 (cleanup): { + resume; // scope 0 at $DIR/issue-101867.rs:+0:1: +5:2 + } +} diff --git a/src/test/mir-opt/issue_101973.inner.ConstProp.diff b/src/test/mir-opt/issue_101973.inner.ConstProp.diff new file mode 100644 index 00000000000..89733a9a2cb --- /dev/null +++ b/src/test/mir-opt/issue_101973.inner.ConstProp.diff @@ -0,0 +1,100 @@ +- // MIR for `inner` before ConstProp ++ // MIR for `inner` after ConstProp + + fn inner(_1: u32) -> i64 { + debug fields => _1; // in scope 0 at $DIR/issue-101973.rs:+0:14: +0:20 + let mut _0: i64; // return place in scope 0 at $DIR/issue-101973.rs:+0:30: +0:33 + let mut _2: i32; // in scope 0 at $DIR/issue-101973.rs:+1:5: +1:65 + let mut _3: u32; // in scope 0 at $DIR/issue-101973.rs:+1:5: +1:58 + let mut _4: u32; // in scope 0 at $DIR/issue-101973.rs:+1:5: +1:17 + let mut _5: u32; // in scope 0 at $DIR/issue-101973.rs:+1:10: +1:16 + let mut _6: u32; // in scope 0 at $DIR/issue-101973.rs:+1:31: +1:57 + let mut _7: u32; // in scope 0 at $DIR/issue-101973.rs:+1:31: +1:52 + let mut _8: u32; // in scope 0 at $DIR/issue-101973.rs:+1:32: +1:45 + let mut _9: u32; // in scope 0 at $DIR/issue-101973.rs:+1:33: +1:39 + let mut _10: (u32, bool); // in scope 0 at $DIR/issue-101973.rs:+1:32: +1:45 + let mut _11: (u32, bool); // in scope 0 at $DIR/issue-101973.rs:+1:31: +1:57 + scope 1 (inlined imm8) { // at $DIR/issue-101973.rs:14:5: 14:17 + debug x => _5; // in scope 1 at $DIR/issue-101973.rs:5:13: 5:14 + let mut _12: u32; // in scope 1 at $DIR/issue-101973.rs:7:12: 7:27 + let mut _13: u32; // in scope 1 at $DIR/issue-101973.rs:7:12: 7:20 + let mut _14: u32; // in scope 1 at $DIR/issue-101973.rs:7:13: 7:14 + let mut _15: (u32, bool); // in scope 1 at $DIR/issue-101973.rs:7:12: 7:20 + scope 2 { + debug out => _4; // in scope 2 at $DIR/issue-101973.rs:6:9: 6:16 + } + } + scope 3 (inlined core::num::<impl u32>::rotate_right) { // at $DIR/issue-101973.rs:14:5: 14:58 + debug self => _4; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug n => _6; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + let mut _16: u32; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + let mut _17: u32; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/issue-101973.rs:+1:5: +1:65 + StorageLive(_3); // scope 0 at $DIR/issue-101973.rs:+1:5: +1:58 + StorageLive(_4); // scope 0 at $DIR/issue-101973.rs:+1:5: +1:17 + StorageLive(_5); // scope 0 at $DIR/issue-101973.rs:+1:10: +1:16 + _5 = _1; // scope 0 at $DIR/issue-101973.rs:+1:10: +1:16 + _4 = const 0_u32; // scope 1 at $DIR/issue-101973.rs:6:19: 6:23 + StorageLive(_12); // scope 2 at $DIR/issue-101973.rs:7:12: 7:27 + StorageLive(_13); // scope 2 at $DIR/issue-101973.rs:7:12: 7:20 + StorageLive(_14); // scope 2 at $DIR/issue-101973.rs:7:13: 7:14 + _14 = _5; // scope 2 at $DIR/issue-101973.rs:7:13: 7:14 + _15 = CheckedShr(_14, const 0_i32); // scope 2 at $DIR/issue-101973.rs:7:12: 7:20 + assert(!move (_15.1: bool), "attempt to shift right by `{}`, which would overflow", const 0_i32) -> bb3; // scope 2 at $DIR/issue-101973.rs:7:12: 7:20 + } + + bb1: { + _8 = move (_10.0: u32); // scope 0 at $DIR/issue-101973.rs:+1:32: +1:45 + StorageDead(_9); // scope 0 at $DIR/issue-101973.rs:+1:44: +1:45 + _7 = BitAnd(move _8, const 15_u32); // scope 0 at $DIR/issue-101973.rs:+1:31: +1:52 + StorageDead(_8); // scope 0 at $DIR/issue-101973.rs:+1:51: +1:52 + _11 = CheckedShl(_7, const 1_i32); // scope 0 at $DIR/issue-101973.rs:+1:31: +1:57 + assert(!move (_11.1: bool), "attempt to shift left by `{}`, which would overflow", const 1_i32) -> bb2; // scope 0 at $DIR/issue-101973.rs:+1:31: +1:57 + } + + bb2: { + _6 = move (_11.0: u32); // scope 0 at $DIR/issue-101973.rs:+1:31: +1:57 + StorageDead(_7); // scope 0 at $DIR/issue-101973.rs:+1:56: +1:57 + StorageLive(_16); // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _16 = _4; // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageLive(_17); // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _17 = _6; // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _3 = rotate_right::<u32>(move _16, move _17) -> bb4; // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + // + literal: Const { ty: extern "rust-intrinsic" fn(u32, u32) -> u32 {rotate_right::<u32>}, val: Value(<ZST>) } + } + + bb3: { + _13 = move (_15.0: u32); // scope 2 at $DIR/issue-101973.rs:7:12: 7:20 + StorageDead(_14); // scope 2 at $DIR/issue-101973.rs:7:19: 7:20 + _12 = BitAnd(move _13, const 255_u32); // scope 2 at $DIR/issue-101973.rs:7:12: 7:27 + StorageDead(_13); // scope 2 at $DIR/issue-101973.rs:7:26: 7:27 + _4 = BitOr(_4, move _12); // scope 2 at $DIR/issue-101973.rs:7:5: 7:27 + StorageDead(_12); // scope 2 at $DIR/issue-101973.rs:7:26: 7:27 + StorageDead(_5); // scope 0 at $DIR/issue-101973.rs:+1:16: +1:17 + StorageLive(_6); // scope 0 at $DIR/issue-101973.rs:+1:31: +1:57 + StorageLive(_7); // scope 0 at $DIR/issue-101973.rs:+1:31: +1:52 + StorageLive(_8); // scope 0 at $DIR/issue-101973.rs:+1:32: +1:45 + StorageLive(_9); // scope 0 at $DIR/issue-101973.rs:+1:33: +1:39 + _9 = _1; // scope 0 at $DIR/issue-101973.rs:+1:33: +1:39 + _10 = CheckedShr(_9, const 8_i32); // scope 0 at $DIR/issue-101973.rs:+1:32: +1:45 + assert(!move (_10.1: bool), "attempt to shift right by `{}`, which would overflow", const 8_i32) -> bb1; // scope 0 at $DIR/issue-101973.rs:+1:32: +1:45 + } + + bb4: { + StorageDead(_17); // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageDead(_16); // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageDead(_6); // scope 0 at $DIR/issue-101973.rs:+1:57: +1:58 + StorageDead(_4); // scope 0 at $DIR/issue-101973.rs:+1:57: +1:58 + _2 = move _3 as i32 (Misc); // scope 0 at $DIR/issue-101973.rs:+1:5: +1:65 + StorageDead(_3); // scope 0 at $DIR/issue-101973.rs:+1:64: +1:65 + _0 = move _2 as i64 (Misc); // scope 0 at $DIR/issue-101973.rs:+1:5: +1:72 + StorageDead(_2); // scope 0 at $DIR/issue-101973.rs:+1:71: +1:72 + return; // scope 0 at $DIR/issue-101973.rs:+2:2: +2:2 + } + } + diff --git a/src/test/run-make-fulldeps/alloc-no-rc/Makefile b/src/test/run-make-fulldeps/alloc-no-rc/Makefile new file mode 100644 index 00000000000..5f7ae70fa02 --- /dev/null +++ b/src/test/run-make-fulldeps/alloc-no-rc/Makefile @@ -0,0 +1,4 @@ +include ../tools.mk + +all: + $(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../../library/alloc/src/lib.rs --cfg no_rc diff --git a/src/test/run-make-fulldeps/alloc-no-sync/Makefile b/src/test/run-make-fulldeps/alloc-no-sync/Makefile new file mode 100644 index 00000000000..6a258a2ddfd --- /dev/null +++ b/src/test/run-make-fulldeps/alloc-no-sync/Makefile @@ -0,0 +1,4 @@ +include ../tools.mk + +all: + $(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../../library/alloc/src/lib.rs --cfg no_sync diff --git a/src/test/run-make/native-link-modifier-verbatim-linker/Makefile b/src/test/run-make/native-link-modifier-verbatim-linker/Makefile new file mode 100644 index 00000000000..e56e1e94ec5 --- /dev/null +++ b/src/test/run-make/native-link-modifier-verbatim-linker/Makefile @@ -0,0 +1,15 @@ +# ignore-cross-compile +# ignore-macos + +include ../../run-make-fulldeps/tools.mk + +all: + # Verbatim allows specify precise name. + $(RUSTC) local_native_dep.rs --crate-type=staticlib -o $(TMPDIR)/local_some_strange_name.ext + $(RUSTC) main.rs -Zunstable-options -l static:+verbatim=local_some_strange_name.ext + + # With verbatim any other name cannot be used (local). + $(RUSTC) local_native_dep.rs --crate-type=staticlib -o $(TMPDIR)/liblocal_native_dep.a + $(RUSTC) local_native_dep.rs --crate-type=staticlib -o $(TMPDIR)/local_native_dep.a + $(RUSTC) local_native_dep.rs --crate-type=staticlib -o $(TMPDIR)/local_native_dep.lib + $(RUSTC) main.rs -Zunstable-options -l static:+verbatim=local_native_dep 2>&1 | $(CGREP) "local_native_dep" diff --git a/src/test/run-make/native-link-modifier-verbatim-linker/local_native_dep.rs b/src/test/run-make/native-link-modifier-verbatim-linker/local_native_dep.rs new file mode 100644 index 00000000000..59b6c92d293 --- /dev/null +++ b/src/test/run-make/native-link-modifier-verbatim-linker/local_native_dep.rs @@ -0,0 +1,4 @@ +#[no_mangle] +pub fn local_native_f() -> i32 { + return 0; +} diff --git a/src/test/run-make/native-link-modifier-verbatim-linker/main.rs b/src/test/run-make/native-link-modifier-verbatim-linker/main.rs new file mode 100644 index 00000000000..71b73a489c7 --- /dev/null +++ b/src/test/run-make/native-link-modifier-verbatim-linker/main.rs @@ -0,0 +1,9 @@ +extern "C" { + fn local_native_f() -> i32; +} + +pub fn main() { + unsafe { + assert!(local_native_f() == 0); + }; +} diff --git a/src/test/run-make/native-link-modifier-verbatim-rustc/Makefile b/src/test/run-make/native-link-modifier-verbatim-rustc/Makefile new file mode 100644 index 00000000000..1093b1cd369 --- /dev/null +++ b/src/test/run-make/native-link-modifier-verbatim-rustc/Makefile @@ -0,0 +1,12 @@ +include ../../run-make-fulldeps/tools.mk + +all: + # Verbatim allows specify precise name. + $(RUSTC) upstream_native_dep.rs --crate-type=staticlib -o $(TMPDIR)/upstream_some_strange_name.ext + $(RUSTC) rust_dep.rs -Zunstable-options -l static:+verbatim=upstream_some_strange_name.ext --crate-type rlib + + # With verbatim any other name cannot be used (upstream). + $(RUSTC) upstream_native_dep.rs --crate-type=staticlib -o $(TMPDIR)/libupstream_native_dep.a + $(RUSTC) upstream_native_dep.rs --crate-type=staticlib -o $(TMPDIR)/upstream_native_dep.a + $(RUSTC) upstream_native_dep.rs --crate-type=staticlib -o $(TMPDIR)/upstream_native_dep.lib + $(RUSTC) rust_dep.rs -Zunstable-options -l static:+verbatim=upstream_native_dep --crate-type rlib 2>&1 | $(CGREP) "upstream_native_dep" diff --git a/src/test/run-make/native-link-modifier-verbatim-rustc/rust_dep.rs b/src/test/run-make/native-link-modifier-verbatim-rustc/rust_dep.rs new file mode 100644 index 00000000000..e9517218e0d --- /dev/null +++ b/src/test/run-make/native-link-modifier-verbatim-rustc/rust_dep.rs @@ -0,0 +1,9 @@ +extern "C" { + fn upstream_native_f() -> i32; +} + +pub fn rust_dep() { + unsafe { + assert!(upstream_native_f() == 0); + } +} diff --git a/src/test/run-make/native-link-modifier-verbatim-rustc/upstream_native_dep.rs b/src/test/run-make/native-link-modifier-verbatim-rustc/upstream_native_dep.rs new file mode 100644 index 00000000000..8396862333d --- /dev/null +++ b/src/test/run-make/native-link-modifier-verbatim-rustc/upstream_native_dep.rs @@ -0,0 +1,4 @@ +#[no_mangle] +pub fn upstream_native_f() -> i32 { + return 0; +} diff --git a/src/test/rustdoc-gui/check-code-blocks-margin.goml b/src/test/rustdoc-gui/check-code-blocks-margin.goml index f6266eba75d..f2fc3e9afc2 100644 --- a/src/test/rustdoc-gui/check-code-blocks-margin.goml +++ b/src/test/rustdoc-gui/check-code-blocks-margin.goml @@ -1,6 +1,6 @@ // This test ensures that the docblock elements have the appropriate left margin. goto: file://|DOC_PATH|/test_docs/fn.foo.html // The top docblock elements shouldn't have left margin... -assert-css: ("#main-content .docblock.item-decl", {"margin-left": "0px"}) +assert-css: ("#main-content .item-decl", {"margin-left": "0px"}) // ... but all the others should! -assert-css: ("#main-content .docblock:not(.item-decl)", {"margin-left": "24px"}) +assert-css: ("#main-content .docblock", {"margin-left": "24px"}) diff --git a/src/test/rustdoc-gui/check-stab-in-docblock.goml b/src/test/rustdoc-gui/check-stab-in-docblock.goml new file mode 100644 index 00000000000..7f965ada594 --- /dev/null +++ b/src/test/rustdoc-gui/check-stab-in-docblock.goml @@ -0,0 +1,21 @@ +// This test checks that using `.stab` attributes in `.docblock` elements doesn't +// create scrollable paragraphs. +goto: file://|DOC_PATH|/test_docs/index.html +// Needs the text to be display to check for scrollable content. +show-text: true +size: (786, 600) +// Confirms that there 3 paragraphs. +assert-count: (".top-doc .docblock p", 3) +// Checking that there is no scrollable content. +assert-property: ( + ".top-doc .docblock p:nth-of-type(1)", + {"scrollHeight": "120", "clientHeight": "120", "scrollWidth": "502", "clientWidth": "502"}, +) +assert-property: ( + ".top-doc .docblock p:nth-of-type(2)", + {"scrollHeight": "48", "clientHeight": "48", "scrollWidth": "502", "clientWidth": "502"}, +) +assert-property: ( + ".top-doc .docblock p:nth-of-type(3)", + {"scrollHeight": "48", "clientHeight": "48", "scrollWidth": "502", "clientWidth": "502"}, +) diff --git a/src/test/rustdoc-gui/docblock-details.goml b/src/test/rustdoc-gui/docblock-details.goml index f6287ade2f2..c0c4d1b43aa 100644 --- a/src/test/rustdoc-gui/docblock-details.goml +++ b/src/test/rustdoc-gui/docblock-details.goml @@ -14,7 +14,7 @@ assert-css: ( // We now check that the `<summary>` doesn't have a bottom border and has the correct display. assert-css: ( ".top-doc .docblock summary h4", - {"border-bottom": "0px none rgb(210, 210, 210)"}, + {"border-bottom-width": "0px"}, ) // This allows to ensure that summary is on one line only! assert-property: (".top-doc .docblock summary h4", {"offsetHeight": "33"}) diff --git a/src/test/rustdoc-gui/font-weight.goml b/src/test/rustdoc-gui/font-weight.goml index 5f29fde6689..13e8ec9fb16 100644 --- a/src/test/rustdoc-gui/font-weight.goml +++ b/src/test/rustdoc-gui/font-weight.goml @@ -1,6 +1,6 @@ // This test checks that the font weight is correctly applied. goto: file://|DOC_PATH|/lib2/struct.Foo.html -assert-css: ("//*[@class='docblock item-decl']//a[text()='Alias']", {"font-weight": "400"}) +assert-css: ("//*[@class='item-decl']//a[text()='Alias']", {"font-weight": "400"}) assert-css: ( "//*[@class='structfield small-section-header']//a[text()='Alias']", {"font-weight": "400"}, @@ -19,7 +19,7 @@ goto: file://|DOC_PATH|/lib2/trait.Trait.html // This is a complex selector, so here's how it works: // -// * //*[@class='docblock item-decl'] — selects element of any tag with classes docblock and item-decl +// * //*[@class='item-decl'] — selects element of any tag with classes docblock and item-decl // * /pre[@class='rust trait'] — selects immediate child with tag pre and classes rust and trait // * /code — selects immediate child with tag code // * /a[@class='constant'] — selects immediate child with tag a and class constant @@ -29,11 +29,11 @@ goto: file://|DOC_PATH|/lib2/trait.Trait.html // This uses '/parent::*' as a proxy for the style of the text node. // We can't just select the '<a>' because intermediate tags could be added. assert-count: ( - "//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", + "//*[@class='item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", 1, ) assert-css: ( - "//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", + "//*[@class='item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", {"font-weight": "400"}, ) diff --git a/src/test/rustdoc-gui/headings.goml b/src/test/rustdoc-gui/headings.goml index ed07e777b18..53308e13480 100644 --- a/src/test/rustdoc-gui/headings.goml +++ b/src/test/rustdoc-gui/headings.goml @@ -168,19 +168,19 @@ assert-css: ( ) assert-css: ( ".top-doc .docblock h5", - {"color": "rgb(0, 0, 0)", "border-bottom": "0px none rgb(221, 221, 221)"}, + {"color": "rgb(0, 0, 0)", "border-bottom-width": "0px"}, ) assert-css: ( "#implementations-list .docblock h4", - {"color": "rgb(0, 0, 0)", "border-bottom": "0px none rgb(221, 221, 221)"}, + {"color": "rgb(0, 0, 0)", "border-bottom-width": "0px"}, ) assert-css: ( "#implementations-list .docblock h5", - {"color": "rgb(0, 0, 0)", "border-bottom": "0px none rgb(221, 221, 221)"}, + {"color": "rgb(0, 0, 0)", "border-bottom-width": "0px"}, ) assert-css: ( "#implementations-list .docblock h6", - {"color": "rgb(0, 0, 0)", "border-bottom": "0px none rgb(221, 221, 221)"}, + {"color": "rgb(0, 0, 0)", "border-bottom-width": "0px"}, ) local-storage: {"rustdoc-theme": "dark"} @@ -199,19 +199,19 @@ assert-css: ( ) assert-css: ( ".top-doc .docblock h5", - {"color": "rgb(221, 221, 221)", "border-bottom": "0px none rgb(210, 210, 210)"}, + {"color": "rgb(221, 221, 221)", "border-bottom-width": "0px"}, ) assert-css: ( "#implementations-list .docblock h4", - {"color": "rgb(221, 221, 221)", "border-bottom": "0px none rgb(210, 210, 210)"}, + {"color": "rgb(221, 221, 221)", "border-bottom-width": "0px"}, ) assert-css: ( "#implementations-list .docblock h5", - {"color": "rgb(221, 221, 221)", "border-bottom": "0px none rgb(210, 210, 210)"}, + {"color": "rgb(221, 221, 221)", "border-bottom-width": "0px"}, ) assert-css: ( "#implementations-list .docblock h6", - {"color": "rgb(221, 221, 221)", "border-bottom": "0px none rgb(210, 210, 210)"}, + {"color": "rgb(221, 221, 221)", "border-bottom-width": "0px"}, ) local-storage: {"rustdoc-theme": "ayu"} @@ -230,19 +230,19 @@ assert-css: ( ) assert-css: ( ".top-doc .docblock h5", - {"color": "rgb(197, 197, 197)", "border-bottom": "0px none rgb(92, 103, 115)"}, + {"color": "rgb(197, 197, 197)", "border-bottom-width": "0px"}, ) assert-css: ( "#implementations-list .docblock h4", - {"color": "rgb(255, 255, 255)", "border-bottom": "0px none rgb(92, 103, 115)"}, + {"color": "rgb(255, 255, 255)", "border-bottom-width": "0px"}, ) assert-css: ( "#implementations-list .docblock h5", - {"color": "rgb(197, 197, 197)", "border-bottom": "0px none rgb(92, 103, 115)"}, + {"color": "rgb(197, 197, 197)", "border-bottom-width": "0px"}, ) assert-css: ( "#implementations-list .docblock h6", - {"color": "rgb(197, 197, 197)", "border-bottom": "0px none rgb(92, 103, 115)"}, + {"color": "rgb(197, 197, 197)", "border-bottom-width": "0px"}, ) local-storage: {"rustdoc-theme": "light"} diff --git a/src/test/rustdoc-gui/item-info-overflow.goml b/src/test/rustdoc-gui/item-info-overflow.goml index b7095a3c532..17478da4fea 100644 --- a/src/test/rustdoc-gui/item-info-overflow.goml +++ b/src/test/rustdoc-gui/item-info-overflow.goml @@ -3,7 +3,7 @@ goto: file://|DOC_PATH|/lib2/struct.LongItemInfo.html // We set a fixed size so there is no chance of "random" resize. size: (1200, 870) // Logically, the "item-decl" and the "item-info" should have the same scroll width. -compare-elements-property: (".docblock.item-decl", ".item-info", ["scrollWidth"]) +compare-elements-property: (".item-decl", ".item-info", ["scrollWidth"]) assert-property: (".item-info", {"scrollWidth": "890"}) // Just to be sure we're comparing the correct "item-info": assert-text: ( diff --git a/src/test/rustdoc-gui/notable-trait.goml b/src/test/rustdoc-gui/notable-trait.goml new file mode 100644 index 00000000000..69088a0774f --- /dev/null +++ b/src/test/rustdoc-gui/notable-trait.goml @@ -0,0 +1,91 @@ +// This test checks the position of the `i` for the notable traits. +goto: file://|DOC_PATH|/test_docs/struct.NotableStructWithLongName.html +show-text: true +// We start with a wide screen. +size: (1100, 600) +// Checking they have the same y position. +compare-elements-position: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("y"), +) +// Checking they don't have the same x position. +compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("x"), +) +// The `i` should be *after* the type. +assert-position: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + {"x": 692}, +) +assert-position: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + {"x": 966}, +) + + +// Now only the `i` should be on the next line. +size: (1055, 600) +compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("y", "x"), +) + +// Now both the `i` and the struct name should be on the next line. +size: (980, 600) +// Checking they have the same y position. +compare-elements-position: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("y"), +) +// Checking they don't have the same x position. +compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("x"), +) +// The `i` should be *after* the type. +assert-position: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + {"x": 245}, +) +assert-position: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + {"x": 519}, +) + +// Checking on mobile now. +size: (650, 600) +// Checking they have the same y position. +compare-elements-position: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("y"), +) +// Checking they don't have the same x position. +compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("x"), +) +// The `i` should be *after* the type. +assert-position: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + {"x": 15}, +) +assert-position: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + {"x": 289}, +) + +// Checking on very small mobile. The `i` should be on its own line. +size: (410, 600) +compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("y", "x"), +) diff --git a/src/test/rustdoc-gui/src/test_docs/lib.rs b/src/test/rustdoc-gui/src/test_docs/lib.rs index 4eedf7f15c3..1c066206c1f 100644 --- a/src/test/rustdoc-gui/src/test_docs/lib.rs +++ b/src/test/rustdoc-gui/src/test_docs/lib.rs @@ -6,6 +6,24 @@ #![feature(rustdoc_internals)] #![feature(doc_cfg)] +/*! +Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy +this crate even more! +Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy +this crate even more! +Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy +this crate even more! + +Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>. +Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>. +Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>. + +Finally, you can use `quz` only on <span class="stab portability"><code>Unix or x86-64</code> +</span>. +Finally, you can use `quz` only on <span class="stab portability"><code>Unix or x86-64</code> +</span>. +*/ + use std::convert::AsRef; use std::fmt; @@ -325,3 +343,15 @@ pub mod doc_block_table { } } + +pub struct NotableStructWithLongName<R>(R); + +impl<R: std::io::Read> NotableStructWithLongName<R> { + pub fn create_an_iterator_from_read(r: R) -> NotableStructWithLongName<R> { Self(r) } +} + +impl<R: std::io::Read> std::iter::Iterator for NotableStructWithLongName<R> { + type Item = (); + + fn next(&mut self) -> Option<Self::Item> { () } +} diff --git a/src/test/rustdoc-ui/normalize-overflow.rs b/src/test/rustdoc-ui/normalize-overflow.rs index 0cdcc88e314..3698fe70e7f 100644 --- a/src/test/rustdoc-ui/normalize-overflow.rs +++ b/src/test/rustdoc-ui/normalize-overflow.rs @@ -1,3 +1,5 @@ // aux-crate:overflow=overflow.rs // check-pass // Regression test for <https://github.com/rust-lang/rust/issues/79506>. + +extern crate overflow; diff --git a/src/test/rustdoc/attribute-rendering.rs b/src/test/rustdoc/attribute-rendering.rs index 6777871846e..36e10923c85 100644 --- a/src/test/rustdoc/attribute-rendering.rs +++ b/src/test/rustdoc/attribute-rendering.rs @@ -1,7 +1,7 @@ #![crate_name = "foo"] // @has 'foo/fn.f.html' -// @has - //*[@'class="docblock item-decl"]' '#[export_name = "f"] pub fn f()' +// @has - //*[@'class="item-decl"]' '#[export_name = "f"] pub fn f()' #[export_name = "\ f"] pub fn f() {} diff --git a/src/test/rustdoc/attributes.rs b/src/test/rustdoc/attributes.rs index 1c7f4b72418..a36dadced87 100644 --- a/src/test/rustdoc/attributes.rs +++ b/src/test/rustdoc/attributes.rs @@ -8,6 +8,6 @@ pub extern "C" fn f() {} #[export_name = "bar"] pub extern "C" fn g() {} -// @has foo/struct.Repr.html '//*[@class="docblock item-decl"]' '#[repr(C, align(8))]' +// @has foo/struct.Repr.html '//*[@class="item-decl"]' '#[repr(C, align(8))]' #[repr(C, align(8))] pub struct Repr; diff --git a/src/test/rustdoc/const-value-display.rs b/src/test/rustdoc/const-value-display.rs index 5b2f3c48d57..8d95f0de9d0 100644 --- a/src/test/rustdoc/const-value-display.rs +++ b/src/test/rustdoc/const-value-display.rs @@ -1,9 +1,9 @@ #![crate_name = "foo"] // @has 'foo/constant.HOUR_IN_SECONDS.html' -// @has - '//*[@class="docblock item-decl"]//code' 'pub const HOUR_IN_SECONDS: u64 = _; // 3_600u64' +// @has - '//*[@class="item-decl"]//code' 'pub const HOUR_IN_SECONDS: u64 = _; // 3_600u64' pub const HOUR_IN_SECONDS: u64 = 60 * 60; // @has 'foo/constant.NEGATIVE.html' -// @has - '//*[@class="docblock item-decl"]//code' 'pub const NEGATIVE: i64 = _; // -3_600i64' +// @has - '//*[@class="item-decl"]//code' 'pub const NEGATIVE: i64 = _; // -3_600i64' pub const NEGATIVE: i64 = -60 * 60; diff --git a/src/test/rustdoc/decl-trailing-whitespace.rs b/src/test/rustdoc/decl-trailing-whitespace.rs index 46a2307abef..e47edc13218 100644 --- a/src/test/rustdoc/decl-trailing-whitespace.rs +++ b/src/test/rustdoc/decl-trailing-whitespace.rs @@ -7,7 +7,7 @@ pub struct Error; // @has 'foo/trait.Write.html' pub trait Write { - // @snapshot 'declaration' - '//*[@class="docblock item-decl"]//code' + // @snapshot 'declaration' - '//*[@class="item-decl"]//code' fn poll_write( self: Option<String>, cx: &mut Option<String>, diff --git a/src/test/rustdoc/macro-higher-kinded-function.rs b/src/test/rustdoc/macro-higher-kinded-function.rs index 02a4305644e..b8c52b7b791 100644 --- a/src/test/rustdoc/macro-higher-kinded-function.rs +++ b/src/test/rustdoc/macro-higher-kinded-function.rs @@ -11,8 +11,8 @@ macro_rules! gen { } // @has 'foo/struct.Providers.html' -// @has - '//*[@class="docblock item-decl"]//code' "pub a: for<'tcx> fn(_: TyCtxt<'tcx>, _: u8) -> i8," -// @has - '//*[@class="docblock item-decl"]//code' "pub b: for<'tcx> fn(_: TyCtxt<'tcx>, _: u16) -> i16," +// @has - '//*[@class="item-decl"]//code' "pub a: for<'tcx> fn(_: TyCtxt<'tcx>, _: u8) -> i8," +// @has - '//*[@class="item-decl"]//code' "pub b: for<'tcx> fn(_: TyCtxt<'tcx>, _: u16) -> i16," // @has - '//*[@id="structfield.a"]/code' "a: for<'tcx> fn(_: TyCtxt<'tcx>, _: u8) -> i8" // @has - '//*[@id="structfield.b"]/code' "b: for<'tcx> fn(_: TyCtxt<'tcx>, _: u16) -> i16" gen! { diff --git a/src/test/rustdoc/reexport-dep-foreign-fn.rs b/src/test/rustdoc/reexport-dep-foreign-fn.rs index 6e1dc453982..6694c91d104 100644 --- a/src/test/rustdoc/reexport-dep-foreign-fn.rs +++ b/src/test/rustdoc/reexport-dep-foreign-fn.rs @@ -8,5 +8,5 @@ extern crate all_item_types; // @has 'foo/fn.foo_ffn.html' -// @has - '//*[@class="docblock item-decl"]//code' 'pub unsafe extern "C" fn foo_ffn()' +// @has - '//*[@class="item-decl"]//code' 'pub unsafe extern "C" fn foo_ffn()' pub use all_item_types::foo_ffn; diff --git a/src/test/rustdoc/reexports-priv.rs b/src/test/rustdoc/reexports-priv.rs index aea9b9f2b39..11364e7f707 100644 --- a/src/test/rustdoc/reexports-priv.rs +++ b/src/test/rustdoc/reexports-priv.rs @@ -5,7 +5,7 @@ extern crate reexports; -// @has 'foo/macro.addr_of.html' '//*[@class="docblock item-decl"]' 'pub macro addr_of($place:expr) {' +// @has 'foo/macro.addr_of.html' '//*[@class="item-decl"]' 'pub macro addr_of($place:expr) {' pub use reexports::addr_of; // @!has 'foo/macro.addr_of_crate.html' pub(crate) use reexports::addr_of_crate; @@ -14,7 +14,7 @@ pub(self) use reexports::addr_of_self; // @!has 'foo/macro.addr_of_local.html' use reexports::addr_of_local; -// @has 'foo/struct.Foo.html' '//*[@class="docblock item-decl"]' 'pub struct Foo;' +// @has 'foo/struct.Foo.html' '//*[@class="item-decl"]' 'pub struct Foo;' pub use reexports::Foo; // @!has 'foo/struct.FooCrate.html' pub(crate) use reexports::FooCrate; @@ -23,7 +23,7 @@ pub(self) use reexports::FooSelf; // @!has 'foo/struct.FooLocal.html' use reexports::FooLocal; -// @has 'foo/enum.Bar.html' '//*[@class="docblock item-decl"]' 'pub enum Bar {' +// @has 'foo/enum.Bar.html' '//*[@class="item-decl"]' 'pub enum Bar {' pub use reexports::Bar; // @!has 'foo/enum.BarCrate.html' pub(crate) use reexports::BarCrate; @@ -50,7 +50,7 @@ pub(self) use reexports::TypeSelf; // @!has 'foo/type.TypeLocal.html' use reexports::TypeLocal; -// @has 'foo/union.Union.html' '//*[@class="docblock item-decl"]' 'pub union Union {' +// @has 'foo/union.Union.html' '//*[@class="item-decl"]' 'pub union Union {' pub use reexports::Union; // @!has 'foo/union.UnionCrate.html' pub(crate) use reexports::UnionCrate; @@ -61,33 +61,33 @@ use reexports::UnionLocal; pub mod outer { pub mod inner { - // @has 'foo/outer/inner/macro.addr_of.html' '//*[@class="docblock item-decl"]' 'pub macro addr_of($place:expr) {' + // @has 'foo/outer/inner/macro.addr_of.html' '//*[@class="item-decl"]' 'pub macro addr_of($place:expr) {' pub use reexports::addr_of; - // @has 'foo/outer/inner/macro.addr_of_crate.html' '//*[@class="docblock item-decl"]' 'pub(crate) macro addr_of_crate($place:expr) {' + // @has 'foo/outer/inner/macro.addr_of_crate.html' '//*[@class="item-decl"]' 'pub(crate) macro addr_of_crate($place:expr) {' pub(crate) use reexports::addr_of_crate; - // @has 'foo/outer/inner/macro.addr_of_super.html' '//*[@class="docblock item-decl"]' 'pub(in outer) macro addr_of_super($place:expr) {' + // @has 'foo/outer/inner/macro.addr_of_super.html' '//*[@class="item-decl"]' 'pub(in outer) macro addr_of_super($place:expr) {' pub(super) use reexports::addr_of_super; // @!has 'foo/outer/inner/macro.addr_of_self.html' pub(self) use reexports::addr_of_self; // @!has 'foo/outer/inner/macro.addr_of_local.html' use reexports::addr_of_local; - // @has 'foo/outer/inner/struct.Foo.html' '//*[@class="docblock item-decl"]' 'pub struct Foo;' + // @has 'foo/outer/inner/struct.Foo.html' '//*[@class="item-decl"]' 'pub struct Foo;' pub use reexports::Foo; - // @has 'foo/outer/inner/struct.FooCrate.html' '//*[@class="docblock item-decl"]' 'pub(crate) struct FooCrate;' + // @has 'foo/outer/inner/struct.FooCrate.html' '//*[@class="item-decl"]' 'pub(crate) struct FooCrate;' pub(crate) use reexports::FooCrate; - // @has 'foo/outer/inner/struct.FooSuper.html' '//*[@class="docblock item-decl"]' 'pub(in outer) struct FooSuper;' + // @has 'foo/outer/inner/struct.FooSuper.html' '//*[@class="item-decl"]' 'pub(in outer) struct FooSuper;' pub(super) use reexports::FooSuper; // @!has 'foo/outer/inner/struct.FooSelf.html' pub(self) use reexports::FooSelf; // @!has 'foo/outer/inner/struct.FooLocal.html' use reexports::FooLocal; - // @has 'foo/outer/inner/enum.Bar.html' '//*[@class="docblock item-decl"]' 'pub enum Bar {' + // @has 'foo/outer/inner/enum.Bar.html' '//*[@class="item-decl"]' 'pub enum Bar {' pub use reexports::Bar; - // @has 'foo/outer/inner/enum.BarCrate.html' '//*[@class="docblock item-decl"]' 'pub(crate) enum BarCrate {' + // @has 'foo/outer/inner/enum.BarCrate.html' '//*[@class="item-decl"]' 'pub(crate) enum BarCrate {' pub(crate) use reexports::BarCrate; - // @has 'foo/outer/inner/enum.BarSuper.html' '//*[@class="docblock item-decl"]' 'pub(in outer) enum BarSuper {' + // @has 'foo/outer/inner/enum.BarSuper.html' '//*[@class="item-decl"]' 'pub(in outer) enum BarSuper {' pub(super) use reexports::BarSuper; // @!has 'foo/outer/inner/enum.BarSelf.html' pub(self) use reexports::BarSelf; @@ -116,11 +116,11 @@ pub mod outer { // @!has 'foo/outer/inner/type.TypeLocal.html' use reexports::TypeLocal; - // @has 'foo/outer/inner/union.Union.html' '//*[@class="docblock item-decl"]' 'pub union Union {' + // @has 'foo/outer/inner/union.Union.html' '//*[@class="item-decl"]' 'pub union Union {' pub use reexports::Union; - // @has 'foo/outer/inner/union.UnionCrate.html' '//*[@class="docblock item-decl"]' 'pub(crate) union UnionCrate {' + // @has 'foo/outer/inner/union.UnionCrate.html' '//*[@class="item-decl"]' 'pub(crate) union UnionCrate {' pub(crate) use reexports::UnionCrate; - // @has 'foo/outer/inner/union.UnionSuper.html' '//*[@class="docblock item-decl"]' 'pub(in outer) union UnionSuper {' + // @has 'foo/outer/inner/union.UnionSuper.html' '//*[@class="item-decl"]' 'pub(in outer) union UnionSuper {' pub(super) use reexports::UnionSuper; // @!has 'foo/outer/inner/union.UnionSelf.html' pub(self) use reexports::UnionSelf; diff --git a/src/test/rustdoc/reexports.rs b/src/test/rustdoc/reexports.rs index 7abcbfb6181..9aa6d7224ba 100644 --- a/src/test/rustdoc/reexports.rs +++ b/src/test/rustdoc/reexports.rs @@ -4,7 +4,7 @@ extern crate reexports; -// @has 'foo/macro.addr_of.html' '//*[@class="docblock item-decl"]' 'pub macro addr_of($place:expr) {' +// @has 'foo/macro.addr_of.html' '//*[@class="item-decl"]' 'pub macro addr_of($place:expr) {' pub use reexports::addr_of; // @!has 'foo/macro.addr_of_crate.html' pub(crate) use reexports::addr_of_crate; @@ -13,7 +13,7 @@ pub(self) use reexports::addr_of_self; // @!has 'foo/macro.addr_of_local.html' use reexports::addr_of_local; -// @has 'foo/struct.Foo.html' '//*[@class="docblock item-decl"]' 'pub struct Foo;' +// @has 'foo/struct.Foo.html' '//*[@class="item-decl"]' 'pub struct Foo;' pub use reexports::Foo; // @!has 'foo/struct.FooCrate.html' pub(crate) use reexports::FooCrate; @@ -22,7 +22,7 @@ pub(self) use reexports::FooSelf; // @!has 'foo/struct.FooLocal.html' use reexports::FooLocal; -// @has 'foo/enum.Bar.html' '//*[@class="docblock item-decl"]' 'pub enum Bar {' +// @has 'foo/enum.Bar.html' '//*[@class="item-decl"]' 'pub enum Bar {' pub use reexports::Bar; // @!has 'foo/enum.BarCrate.html' pub(crate) use reexports::BarCrate; @@ -49,7 +49,7 @@ pub(self) use reexports::TypeSelf; // @!has 'foo/type.TypeLocal.html' use reexports::TypeLocal; -// @has 'foo/union.Union.html' '//*[@class="docblock item-decl"]' 'pub union Union {' +// @has 'foo/union.Union.html' '//*[@class="item-decl"]' 'pub union Union {' pub use reexports::Union; // @!has 'foo/union.UnionCrate.html' pub(crate) use reexports::UnionCrate; @@ -60,7 +60,7 @@ use reexports::UnionLocal; pub mod outer { pub mod inner { - // @has 'foo/outer/inner/macro.addr_of.html' '//*[@class="docblock item-decl"]' 'pub macro addr_of($place:expr) {' + // @has 'foo/outer/inner/macro.addr_of.html' '//*[@class="item-decl"]' 'pub macro addr_of($place:expr) {' pub use reexports::addr_of; // @!has 'foo/outer/inner/macro.addr_of_crate.html' pub(crate) use reexports::addr_of_crate; @@ -71,7 +71,7 @@ pub mod outer { // @!has 'foo/outer/inner/macro.addr_of_local.html' use reexports::addr_of_local; - // @has 'foo/outer/inner/struct.Foo.html' '//*[@class="docblock item-decl"]' 'pub struct Foo;' + // @has 'foo/outer/inner/struct.Foo.html' '//*[@class="item-decl"]' 'pub struct Foo;' pub use reexports::Foo; // @!has 'foo/outer/inner/struct.FooCrate.html' pub(crate) use reexports::FooCrate; @@ -82,7 +82,7 @@ pub mod outer { // @!has 'foo/outer/inner/struct.FooLocal.html' use reexports::FooLocal; - // @has 'foo/outer/inner/enum.Bar.html' '//*[@class="docblock item-decl"]' 'pub enum Bar {' + // @has 'foo/outer/inner/enum.Bar.html' '//*[@class="item-decl"]' 'pub enum Bar {' pub use reexports::Bar; // @!has 'foo/outer/inner/enum.BarCrate.html' pub(crate) use reexports::BarCrate; @@ -115,7 +115,7 @@ pub mod outer { // @!has 'foo/outer/inner/type.TypeLocal.html' use reexports::TypeLocal; - // @has 'foo/outer/inner/union.Union.html' '//*[@class="docblock item-decl"]' 'pub union Union {' + // @has 'foo/outer/inner/union.Union.html' '//*[@class="item-decl"]' 'pub union Union {' pub use reexports::Union; // @!has 'foo/outer/inner/union.UnionCrate.html' pub(crate) use reexports::UnionCrate; diff --git a/src/test/rustdoc/sidebar-all-page.rs b/src/test/rustdoc/sidebar-all-page.rs new file mode 100644 index 00000000000..e74b981de64 --- /dev/null +++ b/src/test/rustdoc/sidebar-all-page.rs @@ -0,0 +1,35 @@ +#![crate_name = "foo"] + +#![feature(rustdoc_internals)] + +// @has 'foo/all.html' +// @has - '//*[@class="sidebar-elems"]//li' 'Structs' +// @has - '//*[@class="sidebar-elems"]//li' 'Enums' +// @has - '//*[@class="sidebar-elems"]//li' 'Unions' +// @has - '//*[@class="sidebar-elems"]//li' 'Functions' +// @has - '//*[@class="sidebar-elems"]//li' 'Traits' +// @has - '//*[@class="sidebar-elems"]//li' 'Macros' +// @has - '//*[@class="sidebar-elems"]//li' 'Type Definitions' +// @has - '//*[@class="sidebar-elems"]//li' 'Constants' +// @has - '//*[@class="sidebar-elems"]//li' 'Statics' +// @has - '//*[@class="sidebar-elems"]//li' 'Primitive Types' + +pub struct Foo; +pub enum Enum { + A, +} +pub union Bar { + a: u8, + b: u16, +} +pub fn foo() {} +pub trait Trait {} +#[macro_export] +macro_rules! foo { + () => {} +} +pub type Type = u8; +pub const FOO: u8 = 0; +pub static BAR: u8 = 0; +#[doc(primitive = "u8")] +mod u8 {} diff --git a/src/test/rustdoc/toggle-item-contents.rs b/src/test/rustdoc/toggle-item-contents.rs index dbaf195e1a9..47a1d62f5a7 100644 --- a/src/test/rustdoc/toggle-item-contents.rs +++ b/src/test/rustdoc/toggle-item-contents.rs @@ -55,7 +55,7 @@ pub union Union { // @has 'toggle_item_contents/struct.PrivStruct.html' // @count - '//details[@class="rustdoc-toggle type-contents-toggle"]' 0 -// @has - '//div[@class="docblock item-decl"]' '/* private fields */' +// @has - '//div[@class="item-decl"]' '/* private fields */' pub struct PrivStruct { a: usize, b: usize, diff --git a/src/test/rustdoc/trait_alias.rs b/src/test/rustdoc/trait_alias.rs index a0c657d9a05..791c099cc52 100644 --- a/src/test/rustdoc/trait_alias.rs +++ b/src/test/rustdoc/trait_alias.rs @@ -14,13 +14,13 @@ use std::fmt::Debug; // @has foo/index.html '//a[@class="traitalias"]' 'Foo' // @has foo/traitalias.CopyAlias.html -// @has - '//section[@id="main-content"]/div[@class="docblock item-decl"]/pre' 'trait CopyAlias = Copy;' +// @has - '//section[@id="main-content"]/div[@class="item-decl"]/pre' 'trait CopyAlias = Copy;' pub trait CopyAlias = Copy; // @has foo/traitalias.Alias2.html -// @has - '//section[@id="main-content"]/div[@class="docblock item-decl"]/pre' 'trait Alias2 = Copy + Debug;' +// @has - '//section[@id="main-content"]/div[@class="item-decl"]/pre' 'trait Alias2 = Copy + Debug;' pub trait Alias2 = Copy + Debug; // @has foo/traitalias.Foo.html -// @has - '//section[@id="main-content"]/div[@class="docblock item-decl"]/pre' 'trait Foo<T> = Into<T> + Debug;' +// @has - '//section[@id="main-content"]/div[@class="item-decl"]/pre' 'trait Foo<T> = Into<T> + Debug;' pub trait Foo<T> = Into<T> + Debug; // @has foo/fn.bar.html '//a[@href="traitalias.Alias2.html"]' 'Alias2' pub fn bar<T>() where T: Alias2 {} diff --git a/src/test/rustdoc/where.SWhere_Simd_item-decl.html b/src/test/rustdoc/where.SWhere_Simd_item-decl.html index 0133bcaeb66..6c1b5d31513 100644 --- a/src/test/rustdoc/where.SWhere_Simd_item-decl.html +++ b/src/test/rustdoc/where.SWhere_Simd_item-decl.html @@ -1 +1 @@ -<div class="docblock item-decl"><pre class="rust struct"><code>pub struct Simd<T>(_) <br /><span class="where">where<br />    T: <a class="trait" href="trait.MyTrait.html" title="trait foo::MyTrait">MyTrait</a></span>;</code></pre></div> \ No newline at end of file +<div class="item-decl"><pre class="rust struct"><code>pub struct Simd<T>(_)<br /><span class="where">where<br />    T: <a class="trait" href="trait.MyTrait.html" title="trait foo::MyTrait">MyTrait</a></span>;</code></pre></div> \ No newline at end of file diff --git a/src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html b/src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html index 54026ff034e..0fbdc0c9cd1 100644 --- a/src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html +++ b/src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html @@ -1,3 +1,3 @@ -<div class="docblock item-decl"><pre class="rust trait"><code>pub trait TraitWhere { - type <a href="#associatedtype.Item" class="associatedtype">Item</a><'a><br />    <span class="where">where<br />        Self: 'a</span>; +<div class="item-decl"><pre class="rust trait"><code>pub trait TraitWhere { + type <a href="#associatedtype.Item" class="associatedtype">Item</a><'a><br />   <span class="where">where<br />        Self: 'a</span>; }</code></pre></div> \ No newline at end of file diff --git a/src/test/rustdoc/where.rs b/src/test/rustdoc/where.rs index b1034c707f5..8818d74ddd0 100644 --- a/src/test/rustdoc/where.rs +++ b/src/test/rustdoc/where.rs @@ -20,13 +20,13 @@ impl<D> Delta<D> where D: MyTrait { pub struct Echo<E>(E); // @has 'foo/struct.Simd.html' -// @snapshot SWhere_Simd_item-decl - '//div[@class="docblock item-decl"]' +// @snapshot SWhere_Simd_item-decl - '//div[@class="item-decl"]' pub struct Simd<T>([T; 1]) where T: MyTrait; // @has 'foo/trait.TraitWhere.html' -// @snapshot SWhere_TraitWhere_item-decl - '//div[@class="docblock item-decl"]' +// @snapshot SWhere_TraitWhere_item-decl - '//div[@class="item-decl"]' pub trait TraitWhere { type Item<'a> where Self: 'a; } diff --git a/src/test/rustdoc/whitespace-after-where-clause.enum.html b/src/test/rustdoc/whitespace-after-where-clause.enum.html index 9e5bf45ae7d..c74866f4a10 100644 --- a/src/test/rustdoc/whitespace-after-where-clause.enum.html +++ b/src/test/rustdoc/whitespace-after-where-clause.enum.html @@ -1,4 +1,4 @@ -<div class="docblock item-decl"><pre class="rust enum"><code>pub enum Cow<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a> <span class="where fmt-newline">where<br />    B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>>, </span>{ +<div class="item-decl"><pre class="rust enum"><code>pub enum Cow<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a><span class="where fmt-newline">where<br />    B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>>,</span>{ Borrowed(<a class="primitive" href="{{channel}}/std/primitive.reference.html">&'a </a>B), Whatever(<a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a>), -}</code></pre></div> +}</code></pre></div> \ No newline at end of file diff --git a/src/test/rustdoc/whitespace-after-where-clause.enum2.html b/src/test/rustdoc/whitespace-after-where-clause.enum2.html index 6bc47beaed1..ac7d7759821 100644 --- a/src/test/rustdoc/whitespace-after-where-clause.enum2.html +++ b/src/test/rustdoc/whitespace-after-where-clause.enum2.html @@ -1,4 +1,4 @@ -<div class="docblock item-decl"><pre class="rust enum"><code>pub enum Cow2<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> + 'a> { +<div class="item-decl"><pre class="rust enum"><code>pub enum Cow2<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> + 'a> { Borrowed(<a class="primitive" href="{{channel}}/std/primitive.reference.html">&'a </a>B), Whatever(<a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a>), -}</code></pre></div> +}</code></pre></div> \ No newline at end of file diff --git a/src/test/rustdoc/whitespace-after-where-clause.rs b/src/test/rustdoc/whitespace-after-where-clause.rs index c36386a2aa2..4b740b970fc 100644 --- a/src/test/rustdoc/whitespace-after-where-clause.rs +++ b/src/test/rustdoc/whitespace-after-where-clause.rs @@ -4,7 +4,7 @@ #![crate_name = "foo"] // @has 'foo/trait.ToOwned.html' -// @snapshot trait - '//*[@class="docblock item-decl"]' +// @snapshot trait - '//*[@class="item-decl"]' pub trait ToOwned<T> where T: Clone { @@ -14,7 +14,7 @@ where T: Clone } // @has 'foo/trait.ToOwned2.html' -// @snapshot trait2 - '//*[@class="docblock item-decl"]' +// @snapshot trait2 - '//*[@class="item-decl"]' // There should be a whitespace before `{` in this case! pub trait ToOwned2<T: Clone> { type Owned; @@ -23,7 +23,7 @@ pub trait ToOwned2<T: Clone> { } // @has 'foo/enum.Cow.html' -// @snapshot enum - '//*[@class="docblock item-decl"]' +// @snapshot enum - '//*[@class="item-decl"]' pub enum Cow<'a, B: ?Sized + 'a> where B: ToOwned<Clone>, @@ -33,7 +33,7 @@ where } // @has 'foo/enum.Cow2.html' -// @snapshot enum2 - '//*[@class="docblock item-decl"]' +// @snapshot enum2 - '//*[@class="item-decl"]' // There should be a whitespace before `{` in this case! pub enum Cow2<'a, B: ?Sized + ToOwned<Clone> + 'a> { Borrowed(&'a B), @@ -41,7 +41,7 @@ pub enum Cow2<'a, B: ?Sized + ToOwned<Clone> + 'a> { } // @has 'foo/struct.Struct.html' -// @snapshot struct - '//*[@class="docblock item-decl"]' +// @snapshot struct - '//*[@class="item-decl"]' pub struct Struct<'a, B: ?Sized + 'a> where B: ToOwned<Clone>, @@ -51,7 +51,7 @@ where } // @has 'foo/struct.Struct2.html' -// @snapshot struct2 - '//*[@class="docblock item-decl"]' +// @snapshot struct2 - '//*[@class="item-decl"]' // There should be a whitespace before `{` in this case! pub struct Struct2<'a, B: ?Sized + ToOwned<Clone> + 'a> { pub a: &'a B, @@ -59,7 +59,7 @@ pub struct Struct2<'a, B: ?Sized + ToOwned<Clone> + 'a> { } // @has 'foo/union.Union.html' -// @snapshot union - '//*[@class="docblock item-decl"]' +// @snapshot union - '//*[@class="item-decl"]' pub union Union<'a, B: ?Sized + 'a> where B: ToOwned<Clone>, @@ -69,7 +69,7 @@ where } // @has 'foo/union.Union2.html' -// @snapshot union2 - '//*[@class="docblock item-decl"]' +// @snapshot union2 - '//*[@class="item-decl"]' // There should be a whitespace before `{` in this case! pub union Union2<'a, B: ?Sized + ToOwned<Clone> + 'a> { a: &'a B, diff --git a/src/test/rustdoc/whitespace-after-where-clause.struct.html b/src/test/rustdoc/whitespace-after-where-clause.struct.html index 236cc3b30d0..1ba1367d20f 100644 --- a/src/test/rustdoc/whitespace-after-where-clause.struct.html +++ b/src/test/rustdoc/whitespace-after-where-clause.struct.html @@ -1,4 +1,4 @@ -<div class="docblock item-decl"><pre class="rust struct"><code>pub struct Struct<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a> <span class="where fmt-newline">where<br />    B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>>, </span>{ +<div class="item-decl"><pre class="rust struct"><code>pub struct Struct<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a><span class="where fmt-newline">where<br />    B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>>,</span>{ pub a: <a class="primitive" href="{{channel}}/std/primitive.reference.html">&'a </a>B, pub b: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a>, -}</code></pre></div> +}</code></pre></div> \ No newline at end of file diff --git a/src/test/rustdoc/whitespace-after-where-clause.struct2.html b/src/test/rustdoc/whitespace-after-where-clause.struct2.html index 47f5c6ba9c8..fb06b0f77c5 100644 --- a/src/test/rustdoc/whitespace-after-where-clause.struct2.html +++ b/src/test/rustdoc/whitespace-after-where-clause.struct2.html @@ -1,4 +1,4 @@ -<div class="docblock item-decl"><pre class="rust struct"><code>pub struct Struct2<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> + 'a> { +<div class="item-decl"><pre class="rust struct"><code>pub struct Struct2<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> + 'a> { pub a: <a class="primitive" href="{{channel}}/std/primitive.reference.html">&'a </a>B, pub b: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a>, -}</code></pre></div> +}</code></pre></div> \ No newline at end of file diff --git a/src/test/rustdoc/whitespace-after-where-clause.trait.html b/src/test/rustdoc/whitespace-after-where-clause.trait.html index 98f03b837b5..16b55823703 100644 --- a/src/test/rustdoc/whitespace-after-where-clause.trait.html +++ b/src/test/rustdoc/whitespace-after-where-clause.trait.html @@ -1,6 +1,6 @@ -<div class="docblock item-decl"><pre class="rust trait"><code>pub trait ToOwned<T> <span class="where fmt-newline">where<br />    T: <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>, </span>{ +<div class="item-decl"><pre class="rust trait"><code>pub trait ToOwned<T><span class="where fmt-newline">where<br />    T: <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</span>{ type <a href="#associatedtype.Owned" class="associatedtype">Owned</a>; fn <a href="#tymethod.to_owned" class="fnname">to_owned</a>(&self) -> Self::<a class="associatedtype" href="trait.ToOwned.html#associatedtype.Owned" title="type foo::ToOwned::Owned">Owned</a>; <span class="item-spacer" /> fn <a href="#tymethod.whatever" class="fnname">whatever</a>(&self) -> T; -}</code></pre></div> +}</code></pre></div> \ No newline at end of file diff --git a/src/test/rustdoc/whitespace-after-where-clause.trait2.html b/src/test/rustdoc/whitespace-after-where-clause.trait2.html index 35052869e76..eeca6e1f500 100644 --- a/src/test/rustdoc/whitespace-after-where-clause.trait2.html +++ b/src/test/rustdoc/whitespace-after-where-clause.trait2.html @@ -1,6 +1,6 @@ -<div class="docblock item-decl"><pre class="rust trait"><code>pub trait ToOwned2<T: <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> { +<div class="item-decl"><pre class="rust trait"><code>pub trait ToOwned2<T: <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> { type <a href="#associatedtype.Owned" class="associatedtype">Owned</a>; fn <a href="#tymethod.to_owned" class="fnname">to_owned</a>(&self) -> Self::<a class="associatedtype" href="trait.ToOwned2.html#associatedtype.Owned" title="type foo::ToOwned2::Owned">Owned</a>; <span class="item-spacer" /> fn <a href="#tymethod.whatever" class="fnname">whatever</a>(&self) -> T; -}</code></pre></div> +}</code></pre></div> \ No newline at end of file diff --git a/src/test/rustdoc/whitespace-after-where-clause.union.html b/src/test/rustdoc/whitespace-after-where-clause.union.html index 97e1bbcf339..0dfb6407d45 100644 --- a/src/test/rustdoc/whitespace-after-where-clause.union.html +++ b/src/test/rustdoc/whitespace-after-where-clause.union.html @@ -1,3 +1,3 @@ -<div class="docblock item-decl"><pre class="rust union"><code>pub union Union<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a> <span class="where fmt-newline">where<br />    B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>>, </span>{ +<div class="item-decl"><pre class="rust union"><code>pub union Union<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a><span class="where fmt-newline">where<br />    B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>>,</span>{ /* private fields */ -}</code></pre></div> +}</code></pre></div> \ No newline at end of file diff --git a/src/test/rustdoc/whitespace-after-where-clause.union2.html b/src/test/rustdoc/whitespace-after-where-clause.union2.html index 6c752a8b4c5..0d237df53c7 100644 --- a/src/test/rustdoc/whitespace-after-where-clause.union2.html +++ b/src/test/rustdoc/whitespace-after-where-clause.union2.html @@ -1,3 +1,3 @@ -<div class="docblock item-decl"><pre class="rust union"><code>pub union Union2<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> + 'a> { +<div class="item-decl"><pre class="rust union"><code>pub union Union2<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> + 'a> { /* private fields */ -}</code></pre></div> +}</code></pre></div> \ No newline at end of file diff --git a/src/test/ui-fulldeps/internal-lints/diagnostics.rs b/src/test/ui-fulldeps/internal-lints/diagnostics.rs index e9e809fa416..18e39108eca 100644 --- a/src/test/ui-fulldeps/internal-lints/diagnostics.rs +++ b/src/test/ui-fulldeps/internal-lints/diagnostics.rs @@ -12,55 +12,55 @@ extern crate rustc_session; extern crate rustc_span; use rustc_errors::{ - AddSubdiagnostic, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, Handler, fluent + AddToDiagnostic, IntoDiagnostic, Diagnostic, DiagnosticBuilder, + ErrorGuaranteed, Handler, fluent }; -use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic}; -use rustc_session::SessionDiagnostic; +use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::Span; -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(parser::expect_path)] -struct DeriveSessionDiagnostic { +struct DeriveDiagnostic { #[primary_span] span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[note(parser::add_paren)] struct Note { #[primary_span] span: Span, } -pub struct UntranslatableInSessionDiagnostic; +pub struct UntranslatableInIntoDiagnostic; -impl<'a> SessionDiagnostic<'a, ErrorGuaranteed> for UntranslatableInSessionDiagnostic { +impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for UntranslatableInIntoDiagnostic { fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> { handler.struct_err("untranslatable diagnostic") //~^ ERROR diagnostics should be created using translatable messages } } -pub struct TranslatableInSessionDiagnostic; +pub struct TranslatableInIntoDiagnostic; -impl<'a> SessionDiagnostic<'a, ErrorGuaranteed> for TranslatableInSessionDiagnostic { +impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for TranslatableInIntoDiagnostic { fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> { handler.struct_err(fluent::parser::expect_path) } } -pub struct UntranslatableInAddSubdiagnostic; +pub struct UntranslatableInAddToDiagnostic; -impl AddSubdiagnostic for UntranslatableInAddSubdiagnostic { +impl AddToDiagnostic for UntranslatableInAddToDiagnostic { fn add_to_diagnostic(self, diag: &mut Diagnostic) { diag.note("untranslatable diagnostic"); //~^ ERROR diagnostics should be created using translatable messages } } -pub struct TranslatableInAddSubdiagnostic; +pub struct TranslatableInAddToDiagnostic; -impl AddSubdiagnostic for TranslatableInAddSubdiagnostic { +impl AddToDiagnostic for TranslatableInAddToDiagnostic { fn add_to_diagnostic(self, diag: &mut Diagnostic) { diag.note(fluent::typeck::note); } @@ -68,10 +68,10 @@ impl AddSubdiagnostic for TranslatableInAddSubdiagnostic { pub fn make_diagnostics<'a>(handler: &'a Handler) { let _diag = handler.struct_err(fluent::parser::expect_path); - //~^ ERROR diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls + //~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls let _diag = handler.struct_err("untranslatable diagnostic"); - //~^ ERROR diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls + //~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls //~^^ ERROR diagnostics should be created using translatable messages } diff --git a/src/test/ui-fulldeps/internal-lints/diagnostics.stderr b/src/test/ui-fulldeps/internal-lints/diagnostics.stderr index e5c5bc2e998..9219d09e9b4 100644 --- a/src/test/ui-fulldeps/internal-lints/diagnostics.stderr +++ b/src/test/ui-fulldeps/internal-lints/diagnostics.stderr @@ -16,7 +16,7 @@ error: diagnostics should be created using translatable messages LL | diag.note("untranslatable diagnostic"); | ^^^^ -error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls +error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls --> $DIR/diagnostics.rs:70:25 | LL | let _diag = handler.struct_err(fluent::parser::expect_path); @@ -28,7 +28,7 @@ note: the lint level is defined here LL | #![deny(rustc::diagnostic_outside_of_impl)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls +error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls --> $DIR/diagnostics.rs:73:25 | LL | let _diag = handler.struct_err("untranslatable diagnostic"); diff --git a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs index c1c109ac1ea..80ea9082881 100644 --- a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs +++ b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs @@ -1,10 +1,10 @@ // check-fail -// Tests error conditions for specifying diagnostics using #[derive(SessionDiagnostic)] +// Tests error conditions for specifying diagnostics using #[derive(Diagnostic)] // normalize-stderr-test "the following other types implement trait `IntoDiagnosticArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr" // normalize-stderr-test "diagnostic_builder\.rs:[0-9]+:[0-9]+" -> "diagnostic_builder.rs:LL:CC" // The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly, -// changing the output of this test. Since SessionDiagnostic is strictly internal to the compiler +// changing the output of this test. Since Diagnostic is strictly internal to the compiler // the test is just ignored on stable and beta: // ignore-beta // ignore-stable @@ -17,7 +17,7 @@ use rustc_span::symbol::Ident; use rustc_span::Span; extern crate rustc_macros; -use rustc_macros::{SessionDiagnostic, LintDiagnostic, SessionSubdiagnostic}; +use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; extern crate rustc_middle; use rustc_middle::ty::Ty; @@ -27,70 +27,70 @@ use rustc_errors::{Applicability, MultiSpan}; extern crate rustc_session; -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct Hello {} -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct HelloWarn {} -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] -//~^ ERROR `#[derive(SessionDiagnostic)]` can only be used on structs -enum SessionDiagnosticOnEnum { +//~^ ERROR `#[derive(Diagnostic)]` can only be used on structs +enum DiagnosticOnEnum { Foo, Bar, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] #[diag = "E0123"] //~^ ERROR `#[diag = ...]` is not a valid attribute struct WrongStructAttrStyle {} -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[nonsense(typeck::ambiguous_lifetime_bound, code = "E0123")] //~^ ERROR `#[nonsense(...)]` is not a valid attribute //~^^ ERROR diagnostic slug not specified //~^^^ ERROR cannot find attribute `nonsense` in this scope struct InvalidStructAttr {} -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag("E0123")] //~^ ERROR `#[diag("...")]` is not a valid attribute //~^^ ERROR diagnostic slug not specified struct InvalidLitNestedAttr {} -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(nonsense, code = "E0123")] //~^ ERROR cannot find value `nonsense` in module `rustc_errors::fluent` struct InvalidNestedStructAttr {} -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(nonsense("foo"), code = "E0123", slug = "foo")] //~^ ERROR `#[diag(nonsense(...))]` is not a valid attribute //~^^ ERROR diagnostic slug not specified struct InvalidNestedStructAttr1 {} -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(nonsense = "...", code = "E0123", slug = "foo")] //~^ ERROR `#[diag(nonsense = ...)]` is not a valid attribute //~^^ ERROR diagnostic slug not specified struct InvalidNestedStructAttr2 {} -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(nonsense = 4, code = "E0123", slug = "foo")] //~^ ERROR `#[diag(nonsense = ...)]` is not a valid attribute //~^^ ERROR diagnostic slug not specified struct InvalidNestedStructAttr3 {} -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123", slug = "foo")] //~^ ERROR `#[diag(slug = ...)]` is not a valid attribute struct InvalidNestedStructAttr4 {} -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct WrongPlaceField { #[suggestion = "bar"] @@ -98,36 +98,36 @@ struct WrongPlaceField { sp: Span, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] #[diag(typeck::ambiguous_lifetime_bound, code = "E0456")] //~^ ERROR specified multiple times //~^^ ERROR specified multiple times struct DiagSpecifiedTwice {} -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0456", code = "E0457")] //~^ ERROR specified multiple times struct CodeSpecifiedTwice {} -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, typeck::ambiguous_lifetime_bound, code = "E0456")] //~^ ERROR `#[diag(typeck::ambiguous_lifetime_bound)]` is not a valid attribute struct SlugSpecifiedTwice {} -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] struct KindNotProvided {} //~ ERROR diagnostic slug not specified -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(code = "E0456")] //~^ ERROR diagnostic slug not specified struct SlugNotProvided {} -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound)] struct CodeNotProvided {} -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct MessageWrongType { #[primary_span] @@ -135,7 +135,7 @@ struct MessageWrongType { foo: String, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct InvalidPathFieldAttr { #[nonsense] @@ -144,7 +144,7 @@ struct InvalidPathFieldAttr { foo: String, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct ErrorWithField { name: String, @@ -152,7 +152,7 @@ struct ErrorWithField { span: Span, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct ErrorWithMessageAppliedToField { #[label(typeck::label)] @@ -160,7 +160,7 @@ struct ErrorWithMessageAppliedToField { name: String, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct ErrorWithNonexistentField { #[suggestion(typeck::suggestion, code = "{name}")] @@ -168,7 +168,7 @@ struct ErrorWithNonexistentField { suggestion: (Span, Applicability), } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] //~^ ERROR invalid format string: expected `'}'` #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct ErrorMissingClosingBrace { @@ -178,7 +178,7 @@ struct ErrorMissingClosingBrace { val: usize, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] //~^ ERROR invalid format string: unmatched `}` #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct ErrorMissingOpeningBrace { @@ -188,14 +188,14 @@ struct ErrorMissingOpeningBrace { val: usize, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct LabelOnSpan { #[label(typeck::label)] sp: Span, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct LabelOnNonSpan { #[label(typeck::label)] @@ -203,7 +203,7 @@ struct LabelOnNonSpan { id: u32, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct Suggest { #[suggestion(typeck::suggestion, code = "This is the suggested code")] @@ -213,14 +213,14 @@ struct Suggest { suggestion: (Span, Applicability), } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct SuggestWithoutCode { #[suggestion(typeck::suggestion)] suggestion: (Span, Applicability), } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct SuggestWithBadKey { #[suggestion(nonsense = "bar")] @@ -228,7 +228,7 @@ struct SuggestWithBadKey { suggestion: (Span, Applicability), } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct SuggestWithShorthandMsg { #[suggestion(msg = "bar")] @@ -236,21 +236,21 @@ struct SuggestWithShorthandMsg { suggestion: (Span, Applicability), } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct SuggestWithoutMsg { #[suggestion(code = "bar")] suggestion: (Span, Applicability), } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct SuggestWithTypesSwapped { #[suggestion(typeck::suggestion, code = "This is suggested code")] suggestion: (Applicability, Span), } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct SuggestWithWrongTypeApplicabilityOnly { #[suggestion(typeck::suggestion, code = "This is suggested code")] @@ -258,14 +258,14 @@ struct SuggestWithWrongTypeApplicabilityOnly { suggestion: Applicability, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct SuggestWithSpanOnly { #[suggestion(typeck::suggestion, code = "This is suggested code")] suggestion: Span, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct SuggestWithDuplicateSpanAndApplicability { #[suggestion(typeck::suggestion, code = "This is suggested code")] @@ -273,7 +273,7 @@ struct SuggestWithDuplicateSpanAndApplicability { suggestion: (Span, Span, Applicability), } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct SuggestWithDuplicateApplicabilityAndSpan { #[suggestion(typeck::suggestion, code = "This is suggested code")] @@ -281,7 +281,7 @@ struct SuggestWithDuplicateApplicabilityAndSpan { suggestion: (Applicability, Applicability, Span), } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct WrongKindOfAnnotation { #[label = "bar"] @@ -289,7 +289,7 @@ struct WrongKindOfAnnotation { z: Span, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct OptionsInErrors { #[label(typeck::label)] @@ -298,7 +298,7 @@ struct OptionsInErrors { opt_sugg: Option<(Span, Applicability)>, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0456")] struct MoveOutOfBorrowError<'tcx> { name: Ident, @@ -312,7 +312,7 @@ struct MoveOutOfBorrowError<'tcx> { opt_sugg: Option<(Span, Applicability)>, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct ErrorWithLifetime<'a> { #[label(typeck::label)] @@ -320,7 +320,7 @@ struct ErrorWithLifetime<'a> { name: &'a str, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct ErrorWithDefaultLabelAttr<'a> { #[label] @@ -328,7 +328,7 @@ struct ErrorWithDefaultLabelAttr<'a> { name: &'a str, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] //~^ ERROR the trait bound `Hello: IntoDiagnosticArg` is not satisfied #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct ArgFieldWithoutSkip { @@ -337,7 +337,7 @@ struct ArgFieldWithoutSkip { other: Hello, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct ArgFieldWithSkip { #[primary_span] @@ -348,91 +348,91 @@ struct ArgFieldWithSkip { other: Hello, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct ErrorWithSpannedNote { #[note] span: Span, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct ErrorWithSpannedNoteCustom { #[note(typeck::note)] span: Span, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] #[note] struct ErrorWithNote { val: String, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] #[note(typeck::note)] struct ErrorWithNoteCustom { val: String, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct ErrorWithSpannedHelp { #[help] span: Span, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct ErrorWithSpannedHelpCustom { #[help(typeck::help)] span: Span, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] #[help] struct ErrorWithHelp { val: String, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] #[help(typeck::help)] struct ErrorWithHelpCustom { val: String, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[help] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct ErrorWithHelpWrongOrder { val: String, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[help(typeck::help)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct ErrorWithHelpCustomWrongOrder { val: String, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[note] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct ErrorWithNoteWrongOrder { val: String, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[note(typeck::note)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct ErrorWithNoteCustomWrongOrder { val: String, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct ApplicabilityInBoth { #[suggestion(typeck::suggestion, code = "...", applicability = "maybe-incorrect")] @@ -440,7 +440,7 @@ struct ApplicabilityInBoth { suggestion: (Span, Applicability), } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct InvalidApplicability { #[suggestion(typeck::suggestion, code = "...", applicability = "batman")] @@ -448,32 +448,32 @@ struct InvalidApplicability { suggestion: Span, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct ValidApplicability { #[suggestion(typeck::suggestion, code = "...", applicability = "maybe-incorrect")] suggestion: Span, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct NoApplicability { #[suggestion(typeck::suggestion, code = "...")] suggestion: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[note(parser::add_paren)] struct Note; -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound)] struct Subdiagnostic { #[subdiagnostic] note: Note, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct VecField { #[primary_span] @@ -481,7 +481,7 @@ struct VecField { spans: Vec<Span>, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct UnitField { #[primary_span] @@ -492,7 +492,7 @@ struct UnitField { bar: (), } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct OptUnitField { #[primary_span] @@ -503,7 +503,7 @@ struct OptUnitField { bar: Option<()>, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct LabelWithTrailingPath { #[label(typeck::label, foo)] @@ -511,7 +511,7 @@ struct LabelWithTrailingPath { span: Span, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct LabelWithTrailingNameValue { #[label(typeck::label, foo = "...")] @@ -519,7 +519,7 @@ struct LabelWithTrailingNameValue { span: Span, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct LabelWithTrailingList { #[label(typeck::label, foo("..."))] @@ -540,35 +540,35 @@ struct PrimarySpanOnLint { span: Span, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] struct ErrorWithMultiSpan { #[primary_span] span: MultiSpan, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] #[warning] struct ErrorWithWarn { val: String, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[error(typeck::ambiguous_lifetime_bound, 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(SessionDiagnostic)] +#[derive(Diagnostic)] #[warn_(typeck::ambiguous_lifetime_bound, 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(SessionDiagnostic)] +#[derive(Diagnostic)] #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")] //~^ ERROR `#[lint(...)]` is not a valid attribute //~| ERROR diagnostic slug not specified diff --git a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr index ab5c28fe473..c3972beb512 100644 --- a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr +++ b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -1,9 +1,9 @@ -error: `#[derive(SessionDiagnostic)]` can only be used on structs +error: `#[derive(Diagnostic)]` can only be used on structs --> $DIR/diagnostic-derive.rs:39:1 | LL | / #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] LL | | -LL | | enum SessionDiagnosticOnEnum { +LL | | enum DiagnosticOnEnum { LL | | Foo, LL | | Bar, LL | | } @@ -214,22 +214,22 @@ LL | #[suggestion(typeck::suggestion, code = "{name}")] error: invalid format string: expected `'}'` but string was terminated --> $DIR/diagnostic-derive.rs:171:16 | -LL | #[derive(SessionDiagnostic)] +LL | #[derive(Diagnostic)] | - ^ expected `'}'` in format string | | | because of this opening brace | = note: if you intended to print `{`, you can escape it using `{{` - = note: this error originates in the derive macro `SessionDiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) error: invalid format string: unmatched `}` found --> $DIR/diagnostic-derive.rs:181:15 | -LL | #[derive(SessionDiagnostic)] +LL | #[derive(Diagnostic)] | ^ unmatched `}` in format string | = note: if you intended to print `}`, you can escape it using `}}` - = note: this error originates in the derive macro `SessionDiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) error: the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` --> $DIR/diagnostic-derive.rs:201:5 @@ -448,8 +448,8 @@ LL | #[diag(nonsense, code = "E0123")] error[E0277]: the trait bound `Hello: IntoDiagnosticArg` is not satisfied --> $DIR/diagnostic-derive.rs:331:10 | -LL | #[derive(SessionDiagnostic)] - | ^^^^^^^^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `Hello` +LL | #[derive(Diagnostic)] + | ^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `Hello` | = help: normalized in stderr note: required by a bound in `DiagnosticBuilder::<'a, G>::set_arg` @@ -457,7 +457,7 @@ note: required by a bound in `DiagnosticBuilder::<'a, G>::set_arg` | LL | arg: impl IntoDiagnosticArg, | ^^^^^^^^^^^^^^^^^ required by this bound in `DiagnosticBuilder::<'a, G>::set_arg` - = note: this error originates in the derive macro `SessionDiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 55 previous errors diff --git a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs index 812ca0c72bd..9fbe7b1f4c8 100644 --- a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs +++ b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs @@ -1,8 +1,8 @@ // check-fail -// Tests error conditions for specifying subdiagnostics using #[derive(SessionSubdiagnostic)] +// Tests error conditions for specifying subdiagnostics using #[derive(Subdiagnostic)] // The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly, -// changing the output of this test. Since SessionSubdiagnostic is strictly internal to the compiler +// changing the output of this test. Since Subdiagnostic is strictly internal to the compiler // the test is just ignored on stable and beta: // ignore-beta // ignore-stable @@ -17,9 +17,9 @@ extern crate rustc_macros; use rustc_errors::Applicability; use rustc_span::Span; -use rustc_macros::SessionSubdiagnostic; +use rustc_macros::Subdiagnostic; -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren)] struct A { #[primary_span] @@ -27,7 +27,7 @@ struct A { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum B { #[label(parser::add_paren)] A { @@ -43,14 +43,14 @@ enum B { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren)] //~^ ERROR label without `#[primary_span]` field struct C { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label] //~^ ERROR `#[label]` is not a valid attribute struct D { @@ -59,7 +59,7 @@ struct D { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[foo] //~^ ERROR `#[foo]` is not a valid attribute //~^^ ERROR cannot find attribute `foo` in this scope @@ -69,7 +69,7 @@ struct E { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label = "..."] //~^ ERROR `#[label = ...]` is not a valid attribute struct F { @@ -78,7 +78,7 @@ struct F { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(bug = "...")] //~^ ERROR `#[label(bug = ...)]` is not a valid attribute struct G { @@ -87,7 +87,7 @@ struct G { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label("...")] //~^ ERROR `#[label("...")]` is not a valid attribute struct H { @@ -96,7 +96,7 @@ struct H { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(slug = 4)] //~^ ERROR `#[label(slug = ...)]` is not a valid attribute struct J { @@ -105,7 +105,7 @@ struct J { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(slug("..."))] //~^ ERROR `#[label(slug(...))]` is not a valid attribute struct K { @@ -114,7 +114,7 @@ struct K { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(slug)] //~^ ERROR cannot find value `slug` in module `rustc_errors::fluent` //~^^ NOTE not found in `rustc_errors::fluent` @@ -124,7 +124,7 @@ struct L { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label()] //~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute struct M { @@ -133,7 +133,7 @@ struct M { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren, code = "...")] //~^ ERROR `code` is not a valid nested attribute of a `label` attribute struct N { @@ -142,7 +142,7 @@ struct N { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren, applicability = "machine-applicable")] //~^ ERROR `applicability` is not a valid nested attribute of a `label` attribute struct O { @@ -151,7 +151,7 @@ struct O { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[foo] //~^ ERROR cannot find attribute `foo` in this scope //~^^ ERROR unsupported type attribute for subdiagnostic enum @@ -164,7 +164,7 @@ enum P { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum Q { #[bar] //~^ ERROR `#[bar]` is not a valid attribute @@ -176,7 +176,7 @@ enum Q { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum R { #[bar = "..."] //~^ ERROR `#[bar = ...]` is not a valid attribute @@ -188,7 +188,7 @@ enum R { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum S { #[bar = 4] //~^ ERROR `#[bar = ...]` is not a valid attribute @@ -200,7 +200,7 @@ enum S { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum T { #[bar("...")] //~^ ERROR `#[bar(...)]` is not a valid attribute @@ -212,7 +212,7 @@ enum T { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum U { #[label(code = "...")] //~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute @@ -223,7 +223,7 @@ enum U { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum V { #[label(parser::add_paren)] A { @@ -239,7 +239,7 @@ enum V { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren)] //~^ ERROR label without `#[primary_span]` field struct W { @@ -248,7 +248,7 @@ struct W { span: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren)] struct X { #[primary_span] @@ -258,7 +258,7 @@ struct X { applicability: Applicability, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren)] struct Y { #[primary_span] @@ -269,7 +269,7 @@ struct Y { bar: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren)] struct Z { #[primary_span] @@ -280,7 +280,7 @@ struct Z { bar: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren)] struct AA { #[primary_span] @@ -291,7 +291,7 @@ struct AA { bar: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren)] struct AB { #[primary_span] @@ -300,14 +300,14 @@ struct AB { z: Z } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] union AC { //~^ ERROR unexpected unsupported untagged union span: u32, b: u64 } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren)] #[label(parser::add_paren)] struct AD { @@ -315,7 +315,7 @@ struct AD { span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren, parser::add_paren)] //~^ ERROR `#[label(parser::add_paren)]` is not a valid attribute struct AE { @@ -323,7 +323,7 @@ struct AE { span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(parser::add_paren)] struct AF { #[primary_span] @@ -334,14 +334,14 @@ struct AF { span_b: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] struct AG { //~^ ERROR subdiagnostic kind not specified #[primary_span] span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code = "...")] struct AH { #[primary_span] @@ -351,7 +351,7 @@ struct AH { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum AI { #[suggestion(parser::add_paren, code = "...")] A { @@ -371,7 +371,7 @@ enum AI { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code = "...", code = "...")] //~^ ERROR specified multiple times //~^^ NOTE previously specified here @@ -382,7 +382,7 @@ struct AJ { applicability: Applicability, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code = "...")] struct AK { #[primary_span] @@ -395,7 +395,7 @@ struct AK { applicability_b: Applicability, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code = "...")] struct AL { #[primary_span] @@ -405,14 +405,14 @@ struct AL { applicability: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code = "...")] struct AM { #[primary_span] span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren)] //~^ ERROR suggestion without `code = "..."` struct AN { @@ -422,7 +422,7 @@ struct AN { applicability: Applicability, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code ="...", applicability = "foo")] //~^ ERROR invalid applicability struct AO { @@ -430,31 +430,31 @@ struct AO { span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[help(parser::add_paren)] struct AP { var: String } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[note(parser::add_paren)] struct AQ; -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code = "...")] //~^ ERROR suggestion without `#[primary_span]` field struct AR { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code ="...", applicability = "machine-applicable")] struct AS { #[primary_span] span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label] //~^ ERROR unsupported type attribute for subdiagnostic enum enum AT { @@ -466,7 +466,7 @@ enum AT { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] struct AU { #[primary_span] @@ -474,7 +474,7 @@ struct AU { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] //~^ ERROR `var` doesn't refer to a field on this type struct AV { @@ -482,7 +482,7 @@ struct AV { span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum AW { #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] A { @@ -492,7 +492,7 @@ enum AW { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum AX { #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] //~^ ERROR `var` doesn't refer to a field on this type @@ -502,18 +502,18 @@ enum AX { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[warning(parser::add_paren)] struct AY {} -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[warning(parser::add_paren)] struct AZ { #[primary_span] span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[suggestion(parser::add_paren, code = "...")] //~^ ERROR suggestion without `#[primary_span]` field struct BA { @@ -528,7 +528,7 @@ struct BA { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[multipart_suggestion(parser::add_paren, code = "...", applicability = "machine-applicable")] //~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields //~| ERROR `code` is not a valid nested attribute of a `multipart_suggestion` attribute @@ -536,7 +536,7 @@ struct BBa { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] struct BBb { #[suggestion_part] @@ -544,7 +544,7 @@ struct BBb { span1: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] struct BBc { #[suggestion_part()] @@ -552,7 +552,7 @@ struct BBc { span1: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[multipart_suggestion(parser::add_paren)] //~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields struct BC { @@ -561,7 +561,7 @@ struct BC { span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[multipart_suggestion(parser::add_paren)] struct BD { #[suggestion_part] @@ -581,7 +581,7 @@ struct BD { s2: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] struct BE { #[suggestion_part(code = "...", code = ",,,")] @@ -590,7 +590,7 @@ struct BE { span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] struct BF { #[suggestion_part(code = "(")] @@ -599,7 +599,7 @@ struct BF { second: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[multipart_suggestion(parser::add_paren)] struct BG { #[applicability] @@ -610,7 +610,7 @@ struct BG { second: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] //~^ NOTE previously specified here struct BH { @@ -623,7 +623,7 @@ struct BH { second: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] struct BI { #[suggestion_part(code = "")] diff --git a/src/test/ui/abi/segfault-no-out-of-stack.rs b/src/test/ui/abi/segfault-no-out-of-stack.rs index ad4faf95a0f..ab2b3089485 100644 --- a/src/test/ui/abi/segfault-no-out-of-stack.rs +++ b/src/test/ui/abi/segfault-no-out-of-stack.rs @@ -3,6 +3,7 @@ #![allow(unused_imports)] // ignore-emscripten can't run commands // ignore-sgx no processes +// ignore-fuchsia must translate zircon signal to SIGSEGV/SIGBUS, FIXME (#58590) #![feature(rustc_private)] extern crate libc; diff --git a/src/test/ui/abi/stack-probes-lto.rs b/src/test/ui/abi/stack-probes-lto.rs index 90df1f3f53e..74b5e843f77 100644 --- a/src/test/ui/abi/stack-probes-lto.rs +++ b/src/test/ui/abi/stack-probes-lto.rs @@ -12,6 +12,7 @@ // ignore-sgx no processes // ignore-musl FIXME #31506 // ignore-pretty +// ignore-fuchsia no exception handler registered for segfault // compile-flags: -C lto // no-prefer-dynamic diff --git a/src/test/ui/abi/stack-probes.rs b/src/test/ui/abi/stack-probes.rs index e998dd0f83e..b497af7abad 100644 --- a/src/test/ui/abi/stack-probes.rs +++ b/src/test/ui/abi/stack-probes.rs @@ -10,6 +10,7 @@ // ignore-wasm // ignore-emscripten no processes // ignore-sgx no processes +// ignore-fuchsia no exception handler registered for segfault use std::env; use std::mem::MaybeUninit; diff --git a/src/test/ui/async-await/async-fn-size-moved-locals.rs b/src/test/ui/async-await/async-fn-size-moved-locals.rs index 15566256600..9e3794b0484 100644 --- a/src/test/ui/async-await/async-fn-size-moved-locals.rs +++ b/src/test/ui/async-await/async-fn-size-moved-locals.rs @@ -8,6 +8,7 @@ // See issue #59123 for a full explanation. // ignore-emscripten (sizes don't match) +// needs-unwind Size of Futures change on panic=abort // run-pass // edition:2018 diff --git a/src/test/ui/async-await/async-fn-size-uninit-locals.rs b/src/test/ui/async-await/async-fn-size-uninit-locals.rs index 31a086ba975..54617269354 100644 --- a/src/test/ui/async-await/async-fn-size-uninit-locals.rs +++ b/src/test/ui/async-await/async-fn-size-uninit-locals.rs @@ -5,6 +5,7 @@ // being reflected in the size. // ignore-emscripten (sizes don't match) +// needs-unwind Size of Futures change on panic=abort // run-pass // edition:2018 @@ -67,9 +68,7 @@ async fn joined() { let c = Big::new(); fut().await; - noop(); joiner = Joiner { a: Some(a), b: Some(b), c: Some(c) }; - noop(); } async fn joined_with_noop() { @@ -97,7 +96,7 @@ async fn join_retval() -> Joiner { fn main() { assert_eq!(2, std::mem::size_of_val(&single())); assert_eq!(3, std::mem::size_of_val(&single_with_noop())); - assert_eq!(3078, std::mem::size_of_val(&joined())); + assert_eq!(3074, std::mem::size_of_val(&joined())); assert_eq!(3078, std::mem::size_of_val(&joined_with_noop())); assert_eq!(3074, std::mem::size_of_val(&join_retval())); } diff --git a/src/test/ui/backtrace.rs b/src/test/ui/backtrace.rs index e2ac43fffc9..dd73dd9886a 100644 --- a/src/test/ui/backtrace.rs +++ b/src/test/ui/backtrace.rs @@ -4,6 +4,7 @@ // ignore-openbsd no support for libbacktrace without filename // ignore-sgx no processes // ignore-msvc see #62897 and `backtrace-debuginfo.rs` test +// ignore-fuchsia Backtraces not symbolized // compile-flags:-g // compile-flags:-Cstrip=none diff --git a/src/test/ui/command/command-exec.rs b/src/test/ui/command/command-exec.rs index 0af87214f95..032dad1840d 100644 --- a/src/test/ui/command/command-exec.rs +++ b/src/test/ui/command/command-exec.rs @@ -5,6 +5,7 @@ // ignore-pretty issue #37199 // ignore-emscripten no processes // ignore-sgx no processes +// ignore-fuchsia no execvp syscall provided #![feature(process_exec)] diff --git a/src/test/ui/const-generics/const_trait_fn-issue-88433.rs b/src/test/ui/const-generics/const_trait_fn-issue-88433.rs index 8724fa69825..6e04cfaec31 100644 --- a/src/test/ui/const-generics/const_trait_fn-issue-88433.rs +++ b/src/test/ui/const-generics/const_trait_fn-issue-88433.rs @@ -2,6 +2,7 @@ #![feature(const_trait_impl)] +#[const_trait] trait Func<T> { type Output; diff --git a/src/test/ui/const-generics/issue-93647.rs b/src/test/ui/const-generics/issue-93647.rs index c1a6bf6e34d..806540e1775 100644 --- a/src/test/ui/const-generics/issue-93647.rs +++ b/src/test/ui/const-generics/issue-93647.rs @@ -1,6 +1,6 @@ struct X<const N: usize = { (||1usize)() - //~^ ERROR cannot call + //~^ ERROR cannot call non-const closure }>; fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-88119.rs b/src/test/ui/const-generics/issues/issue-88119.rs index 70dfa7f708b..647b0eea86d 100644 --- a/src/test/ui/const-generics/issues/issue-88119.rs +++ b/src/test/ui/const-generics/issues/issue-88119.rs @@ -3,6 +3,7 @@ #![allow(incomplete_features)] #![feature(const_trait_impl, generic_const_exprs)] +#[const_trait] trait ConstName { const NAME_BYTES: &'static [u8]; } diff --git a/src/test/ui/const-generics/issues/issue-98629.rs b/src/test/ui/const-generics/issues/issue-98629.rs index fc8666bbcdb..1d2d3012a6e 100644 --- a/src/test/ui/const-generics/issues/issue-98629.rs +++ b/src/test/ui/const-generics/issues/issue-98629.rs @@ -1,5 +1,6 @@ #![feature(const_trait_impl)] +#[const_trait] trait Trait { const N: usize; } diff --git a/src/test/ui/const-generics/issues/issue-98629.stderr b/src/test/ui/const-generics/issues/issue-98629.stderr index 53570220882..4a248be76a9 100644 --- a/src/test/ui/const-generics/issues/issue-98629.stderr +++ b/src/test/ui/const-generics/issues/issue-98629.stderr @@ -1,5 +1,5 @@ error[E0046]: not all trait items implemented, missing: `N` - --> $DIR/issue-98629.rs:7:1 + --> $DIR/issue-98629.rs:8:1 | LL | const N: usize; | -------------- `N` from trait diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr index 0e6be6d01ed..c685922c456 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr @@ -4,13 +4,13 @@ error[E0308]: mismatched types LL | = [0; (i8::MAX + 1u8) as usize]; | ^^^ expected `i8`, found `u8` -error[E0277]: cannot add `u8` to `i8` +error[E0277]: cannot add `u8` to `i8` in const contexts --> $DIR/const-eval-overflow-3b.rs:16:20 | LL | = [0; (i8::MAX + 1u8) as usize]; | ^ no implementation for `i8 + u8` | - = help: the trait `Add<u8>` is not implemented for `i8` + = help: the trait `~const Add<u8>` is not implemented for `i8` = help: the following other types implement trait `Add<Rhs>`: <&'a f32 as Add<f32>> <&'a f64 as Add<f64>> diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr index 4fa017e04e9..b396079240a 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr @@ -4,13 +4,13 @@ error[E0308]: mismatched types LL | : [u32; (i8::MAX as i8 + 1u8) as usize] | ^^^ expected `i8`, found `u8` -error[E0277]: cannot add `u8` to `i8` +error[E0277]: cannot add `u8` to `i8` in const contexts --> $DIR/const-eval-overflow-4b.rs:9:28 | LL | : [u32; (i8::MAX as i8 + 1u8) as usize] | ^ no implementation for `i8 + u8` | - = help: the trait `Add<u8>` is not implemented for `i8` + = help: the trait `~const Add<u8>` is not implemented for `i8` = help: the following other types implement trait `Add<Rhs>`: <&'a f32 as Add<f32>> <&'a f64 as Add<f64>> diff --git a/src/test/ui/consts/const-fn-error.rs b/src/test/ui/consts/const-fn-error.rs index abe68c17a0d..50b7ce1f8c0 100644 --- a/src/test/ui/consts/const-fn-error.rs +++ b/src/test/ui/consts/const-fn-error.rs @@ -3,10 +3,10 @@ const X : usize = 2; const fn f(x: usize) -> usize { let mut sum = 0; for i in 0..x { - //~^ ERROR mutable references - //~| ERROR cannot convert - //~| ERROR cannot call non-const fn + //~^ ERROR cannot convert //~| ERROR `for` is not allowed in a `const fn` + //~| ERROR mutable references are not allowed in constant functions + //~| ERROR cannot call non-const fn sum += i; } sum diff --git a/src/test/ui/consts/const-for.rs b/src/test/ui/consts/const-for.rs index 58bcb5f74cc..8db24853558 100644 --- a/src/test/ui/consts/const-for.rs +++ b/src/test/ui/consts/const-for.rs @@ -3,8 +3,8 @@ const _: () = { for _ in 0..5 {} - //~^ error: cannot convert - //~| error: cannot call non-const fn + //~^ error: cannot call + //~| error: cannot convert }; fn main() {} diff --git a/src/test/ui/consts/issue-56164.rs b/src/test/ui/consts/issue-56164.rs index 094ca377e03..fd02d215480 100644 --- a/src/test/ui/consts/issue-56164.rs +++ b/src/test/ui/consts/issue-56164.rs @@ -1,11 +1,11 @@ const fn foo() { (||{})() } //~^ ERROR cannot call non-const closure -//~| ERROR erroneous constant used [const_err] -//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +//~| ERROR erroneous constant +//~| WARN this was previously accepted const fn bad(input: fn()) { input() - //~^ ERROR function pointer + //~^ ERROR function pointer calls are not allowed } fn main() { diff --git a/src/test/ui/consts/issue-94675.rs b/src/test/ui/consts/issue-94675.rs index 0604aab3bcd..ce21ebdb9ac 100644 --- a/src/test/ui/consts/issue-94675.rs +++ b/src/test/ui/consts/issue-94675.rs @@ -7,9 +7,8 @@ struct Foo<'a> { impl<'a> Foo<'a> { const fn spam(&mut self, baz: &mut Vec<u32>) { self.bar[0] = baz.len(); - //~^ ERROR cannot call non-const fn `Vec::<u32>::len` in constant functions - //~| ERROR the trait bound `Vec<usize>: ~const IndexMut<usize>` is not satisfied - //~| ERROR cannot call non-const operator in constant functions + //~^ the trait bound `Vec<usize>: ~const Index<_>` is not satisfied + //~| the trait bound `Vec<usize>: ~const IndexMut<usize>` is not satisfied } } diff --git a/src/test/ui/consts/issue-94675.stderr b/src/test/ui/consts/issue-94675.stderr index 6665e42835b..7ae293ffbf8 100644 --- a/src/test/ui/consts/issue-94675.stderr +++ b/src/test/ui/consts/issue-94675.stderr @@ -1,10 +1,15 @@ -error[E0015]: cannot call non-const fn `Vec::<u32>::len` in constant functions - --> $DIR/issue-94675.rs:9:27 +error[E0277]: the trait bound `Vec<usize>: ~const Index<_>` is not satisfied + --> $DIR/issue-94675.rs:9:9 | LL | self.bar[0] = baz.len(); - | ^^^^^ + | ^^^^^^^^^^^ vector indices are of type `usize` or ranges of `usize` + | + = help: the trait `~const Index<_>` is not implemented for `Vec<usize>` +note: the trait `Index<_>` is implemented for `Vec<usize>`, but that implementation is not `const` + --> $DIR/issue-94675.rs:9:9 | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +LL | self.bar[0] = baz.len(); + | ^^^^^^^^^^^ error[E0277]: the trait bound `Vec<usize>: ~const IndexMut<usize>` is not satisfied --> $DIR/issue-94675.rs:9:9 @@ -18,21 +23,11 @@ note: the trait `IndexMut<usize>` is implemented for `Vec<usize>`, but that impl | LL | self.bar[0] = baz.len(); | ^^^^^^^^^^^ - -error[E0015]: cannot call non-const operator in constant functions - --> $DIR/issue-94675.rs:9:9 - | -LL | self.bar[0] = baz.len(); - | ^^^^^^^^^^^ - | -note: impl defined here, but it is not `const` - --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement | -LL | impl<T, I: SliceIndex<[T]>, A: Allocator> IndexMut<I> for Vec<T, A> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +LL | impl<'a> Foo<'a> where Vec<usize>: ~const IndexMut<usize> { + | ++++++++++++++++++++++++++++++++++++++++ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/consts/unstable-const-fn-in-libcore.rs b/src/test/ui/consts/unstable-const-fn-in-libcore.rs index 16b36c8d56d..b9e7e1405f9 100644 --- a/src/test/ui/consts/unstable-const-fn-in-libcore.rs +++ b/src/test/ui/consts/unstable-const-fn-in-libcore.rs @@ -4,7 +4,7 @@ // gate was not enabled in libcore. #![stable(feature = "core", since = "1.6.0")] -#![feature(staged_api)] +#![feature(staged_api, const_trait_impl)] enum Opt<T> { Some(T), @@ -14,12 +14,12 @@ enum Opt<T> { impl<T> Opt<T> { #[rustc_const_unstable(feature = "foo", issue = "none")] #[stable(feature = "rust1", since = "1.0.0")] - const fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T { + const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T { //~^ ERROR destructors cannot be evaluated at compile-time //~| ERROR destructors cannot be evaluated at compile-time match self { Opt::Some(t) => t, - Opt::None => f(), //~ ERROR E0015 + Opt::None => f(), } } } diff --git a/src/test/ui/consts/unstable-const-fn-in-libcore.stderr b/src/test/ui/consts/unstable-const-fn-in-libcore.stderr index 180f9f10cc6..fee74bd0a6c 100644 --- a/src/test/ui/consts/unstable-const-fn-in-libcore.stderr +++ b/src/test/ui/consts/unstable-const-fn-in-libcore.stderr @@ -1,34 +1,21 @@ -error[E0015]: cannot call non-const closure in constant functions - --> $DIR/unstable-const-fn-in-libcore.rs:22:26 - | -LL | Opt::None => f(), - | ^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -help: consider further restricting this bound - | -LL | const fn unwrap_or_else<F: FnOnce() -> T + ~const std::ops::FnOnce<()>>(self, f: F) -> T { - | +++++++++++++++++++++++++++++ - error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/unstable-const-fn-in-libcore.rs:17:53 + --> $DIR/unstable-const-fn-in-libcore.rs:17:60 | -LL | const fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T { - | ^ constant functions cannot evaluate destructors +LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T { + | ^ constant functions cannot evaluate destructors ... LL | } | - value is dropped here error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/unstable-const-fn-in-libcore.rs:17:47 + --> $DIR/unstable-const-fn-in-libcore.rs:17:54 | -LL | const fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T { - | ^^^^ constant functions cannot evaluate destructors +LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T { + | ^^^^ constant functions cannot evaluate destructors ... LL | } | - value is dropped here -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0015, E0493. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0493`. diff --git a/src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.fixed b/src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.fixed index 87debfeceaa..e566ed488c9 100644 --- a/src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.fixed +++ b/src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.fixed @@ -2,4 +2,9 @@ fn main() { let _x = !1; //~ ERROR cannot be used as a unary operator + let _y = !1; //~ ERROR unexpected `1` after identifier + let _z = !false; //~ ERROR unexpected keyword `false` after identifier + let _a = !true; //~ ERROR unexpected keyword `true` after identifier + let v = 1 + 2; + let _v = !v; //~ ERROR unexpected `v` after identifier } diff --git a/src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.rs b/src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.rs index 015a8edcea3..1708a80505d 100644 --- a/src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.rs +++ b/src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.rs @@ -2,4 +2,9 @@ fn main() { let _x = ~1; //~ ERROR cannot be used as a unary operator + let _y = not 1; //~ ERROR unexpected `1` after identifier + let _z = not false; //~ ERROR unexpected keyword `false` after identifier + let _a = not true; //~ ERROR unexpected keyword `true` after identifier + let v = 1 + 2; + let _v = not v; //~ ERROR unexpected `v` after identifier } diff --git a/src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.stderr b/src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.stderr index 84b81d561e9..2a3242abea4 100644 --- a/src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.stderr +++ b/src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.stderr @@ -4,5 +4,37 @@ error: `~` cannot be used as a unary operator LL | let _x = ~1; | ^ help: use `!` to perform bitwise not -error: aborting due to previous error +error: unexpected `1` after identifier + --> $DIR/issue-41679-tilde-bitwise-negation-attempt.rs:5:18 + | +LL | let _y = not 1; + | ----^ + | | + | help: use `!` to perform bitwise not + +error: unexpected keyword `false` after identifier + --> $DIR/issue-41679-tilde-bitwise-negation-attempt.rs:6:18 + | +LL | let _z = not false; + | ----^^^^^ + | | + | help: use `!` to perform logical negation + +error: unexpected keyword `true` after identifier + --> $DIR/issue-41679-tilde-bitwise-negation-attempt.rs:7:18 + | +LL | let _a = not true; + | ----^^^^ + | | + | help: use `!` to perform logical negation + +error: unexpected `v` after identifier + --> $DIR/issue-41679-tilde-bitwise-negation-attempt.rs:9:18 + | +LL | let _v = not v; + | ----^ + | | + | help: use `!` to perform logical negation or bitwise not + +error: aborting due to 5 previous errors diff --git a/src/test/ui/did_you_mean/issue-46836-identifier-not-instead-of-negation.stderr b/src/test/ui/did_you_mean/issue-46836-identifier-not-instead-of-negation.stderr index 3ccc14bba54..14918ba8953 100644 --- a/src/test/ui/did_you_mean/issue-46836-identifier-not-instead-of-negation.stderr +++ b/src/test/ui/did_you_mean/issue-46836-identifier-not-instead-of-negation.stderr @@ -4,7 +4,7 @@ error: unexpected `for_you` after identifier LL | if not for_you { | ----^^^^^^^ | | - | help: use `!` to perform logical negation + | help: use `!` to perform logical negation or bitwise not error: unexpected `the_worst` after identifier --> $DIR/issue-46836-identifier-not-instead-of-negation.rs:11:15 @@ -12,13 +12,13 @@ error: unexpected `the_worst` after identifier LL | while not the_worst { | ----^^^^^^^^^ | | - | help: use `!` to perform logical negation + | help: use `!` to perform logical negation or bitwise not error: unexpected `println` after identifier --> $DIR/issue-46836-identifier-not-instead-of-negation.rs:20:9 | LL | if not // lack of braces is [sic] - | ----- help: use `!` to perform logical negation + | ----- help: use `!` to perform logical negation or bitwise not LL | println!("Then when?"); | ^^^^^^^ @@ -42,7 +42,7 @@ error: unexpected `2` after identifier LL | let resource = not 2; | ----^ | | - | help: use `!` to perform logical negation + | help: use `!` to perform bitwise not error: unexpected `be_smothered_out_before` after identifier --> $DIR/issue-46836-identifier-not-instead-of-negation.rs:32:27 @@ -50,7 +50,7 @@ error: unexpected `be_smothered_out_before` after identifier LL | let young_souls = not be_smothered_out_before; | ----^^^^^^^^^^^^^^^^^^^^^^^ | | - | help: use `!` to perform logical negation + | help: use `!` to perform logical negation or bitwise not error: aborting due to 6 previous errors diff --git a/src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr b/src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr index 26986684f0c..81f3f269432 100644 --- a/src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr +++ b/src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr @@ -15,13 +15,13 @@ help: Unicode character '−' (Minus Sign) looks like '-' (Minus/Hyphen), but it LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e-11; // m³⋅kg⁻¹⋅s⁻² | ~ -error[E0277]: cannot subtract `{integer}` from `{float}` +error[E0277]: cannot subtract `{integer}` from `{float}` in const contexts --> $DIR/issue-49746-unicode-confusable-in-float-literal-expt.rs:1:53 | LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e−11; // m³⋅kg⁻¹⋅s⁻² | ^ no implementation for `{float} - {integer}` | - = help: the trait `Sub<{integer}>` is not implemented for `{float}` + = help: the trait `~const Sub<{integer}>` is not implemented for `{float}` = help: the following other types implement trait `Sub<Rhs>`: <&'a f32 as Sub<f32>> <&'a f64 as Sub<f64>> diff --git a/src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.stderr b/src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.stderr index 528c62f501e..cbe59e8e0af 100644 --- a/src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.stderr +++ b/src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.stderr @@ -4,7 +4,7 @@ error: `and` is not a logical operator LL | let _ = a and b; | ^^^ help: use `&&` to perform logical conjunction | - = note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators + = note: unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators error: `and` is not a logical operator --> $DIR/issue-54109-and_instead_of_ampersands.rs:9:10 @@ -12,7 +12,7 @@ error: `and` is not a logical operator LL | if a and b { | ^^^ help: use `&&` to perform logical conjunction | - = note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators + = note: unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators error: `or` is not a logical operator --> $DIR/issue-54109-and_instead_of_ampersands.rs:20:15 @@ -20,7 +20,7 @@ error: `or` is not a logical operator LL | let _ = a or b; | ^^ help: use `||` to perform logical disjunction | - = note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators + = note: unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators error: `or` is not a logical operator --> $DIR/issue-54109-and_instead_of_ampersands.rs:22:10 @@ -28,7 +28,7 @@ error: `or` is not a logical operator LL | if a or b { | ^^ help: use `||` to perform logical disjunction | - = note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators + = note: unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators error: `and` is not a logical operator --> $DIR/issue-54109-and_instead_of_ampersands.rs:30:11 @@ -36,7 +36,7 @@ error: `and` is not a logical operator LL | if (a and b) { | ^^^ help: use `&&` to perform logical conjunction | - = note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators + = note: unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators error: `or` is not a logical operator --> $DIR/issue-54109-and_instead_of_ampersands.rs:38:11 @@ -44,7 +44,7 @@ error: `or` is not a logical operator LL | if (a or b) { | ^^ help: use `||` to perform logical disjunction | - = note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators + = note: unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators error: `and` is not a logical operator --> $DIR/issue-54109-and_instead_of_ampersands.rs:46:13 @@ -52,7 +52,7 @@ error: `and` is not a logical operator LL | while a and b { | ^^^ help: use `&&` to perform logical conjunction | - = note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators + = note: unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators error: `or` is not a logical operator --> $DIR/issue-54109-and_instead_of_ampersands.rs:54:13 @@ -60,7 +60,7 @@ error: `or` is not a logical operator LL | while a or b { | ^^ help: use `||` to perform logical disjunction | - = note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators + = note: unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators error[E0308]: mismatched types --> $DIR/issue-54109-and_instead_of_ampersands.rs:13:33 diff --git a/src/test/ui/did_you_mean/issue-54109-without-witness.stderr b/src/test/ui/did_you_mean/issue-54109-without-witness.stderr index 0350890c1fd..6455b0863f8 100644 --- a/src/test/ui/did_you_mean/issue-54109-without-witness.stderr +++ b/src/test/ui/did_you_mean/issue-54109-without-witness.stderr @@ -4,7 +4,7 @@ error: `and` is not a logical operator LL | let _ = a and b; | ^^^ help: use `&&` to perform logical conjunction | - = note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators + = note: unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators error: `and` is not a logical operator --> $DIR/issue-54109-without-witness.rs:15:10 @@ -12,7 +12,7 @@ error: `and` is not a logical operator LL | if a and b { | ^^^ help: use `&&` to perform logical conjunction | - = note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators + = note: unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators error: `or` is not a logical operator --> $DIR/issue-54109-without-witness.rs:24:15 @@ -20,7 +20,7 @@ error: `or` is not a logical operator LL | let _ = a or b; | ^^ help: use `||` to perform logical disjunction | - = note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators + = note: unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators error: `or` is not a logical operator --> $DIR/issue-54109-without-witness.rs:26:10 @@ -28,7 +28,7 @@ error: `or` is not a logical operator LL | if a or b { | ^^ help: use `||` to perform logical disjunction | - = note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators + = note: unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators error: `and` is not a logical operator --> $DIR/issue-54109-without-witness.rs:34:11 @@ -36,7 +36,7 @@ error: `and` is not a logical operator LL | if (a and b) { | ^^^ help: use `&&` to perform logical conjunction | - = note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators + = note: unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators error: `or` is not a logical operator --> $DIR/issue-54109-without-witness.rs:42:11 @@ -44,7 +44,7 @@ error: `or` is not a logical operator LL | if (a or b) { | ^^ help: use `||` to perform logical disjunction | - = note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators + = note: unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators error: `and` is not a logical operator --> $DIR/issue-54109-without-witness.rs:50:13 @@ -52,7 +52,7 @@ error: `and` is not a logical operator LL | while a and b { | ^^^ help: use `&&` to perform logical conjunction | - = note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators + = note: unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators error: `or` is not a logical operator --> $DIR/issue-54109-without-witness.rs:58:13 @@ -60,7 +60,7 @@ error: `or` is not a logical operator LL | while a or b { | ^^ help: use `||` to perform logical disjunction | - = note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators + = note: unlike in e.g., Python and PHP, `&&` and `||` are used for logical operators error: aborting due to 8 previous errors diff --git a/src/test/ui/expr/malformed_closure/ruby_style_closure.stderr b/src/test/ui/expr/malformed_closure/ruby_style_closure.stderr index 9db9cfc7ff0..759d79493a9 100644 --- a/src/test/ui/expr/malformed_closure/ruby_style_closure.stderr +++ b/src/test/ui/expr/malformed_closure/ruby_style_closure.stderr @@ -14,7 +14,7 @@ LL | let p = Some(45).and_then({ LL | | LL | | |x| println!("doubling {}", x); LL | | Some(x * 2) - | | ----------- + | | ----------- this tail expression is of type `std::option::Option<_>` LL | | LL | | }); | |_____^ expected an `FnOnce<({integer},)>` closure, found `Option<_>` diff --git a/src/test/ui/function-pointer/sized-ret-with-binder.rs b/src/test/ui/function-pointer/sized-ret-with-binder.rs new file mode 100644 index 00000000000..104ac4d222e --- /dev/null +++ b/src/test/ui/function-pointer/sized-ret-with-binder.rs @@ -0,0 +1,15 @@ +// check-pass + +#![feature(unboxed_closures)] + +fn is_fn<T: for<'a> Fn<(&'a (),)>>() {} +fn is_fn2<T: for<'a, 'b> Fn<(&'a &'b (),)>>() {} + +struct Outlives<'a, 'b>(std::marker::PhantomData<&'a &'b ()>); + +fn main() { + is_fn::<for<'a> fn(&'a ()) -> &'a ()>(); + is_fn::<for<'a> fn(&'a ()) -> &'a dyn std::fmt::Debug>(); + is_fn2::<for<'a, 'b> fn(&'a &'b ()) -> Outlives<'a, 'b>>(); + is_fn2::<for<'a, 'b> fn(&'a &'b ()) -> (&'a (), &'a ())>(); +} diff --git a/src/test/ui/function-pointer/unsized-ret.rs b/src/test/ui/function-pointer/unsized-ret.rs new file mode 100644 index 00000000000..60af5769d6d --- /dev/null +++ b/src/test/ui/function-pointer/unsized-ret.rs @@ -0,0 +1,14 @@ +#![feature(fn_traits)] +#![feature(unboxed_closures)] + +fn foo<F: Fn<T>, T>(f: Option<F>, t: T) { + let y = (f.unwrap()).call(t); +} + +fn main() { + foo::<fn() -> str, _>(None, ()); + //~^ ERROR the size for values of type `str` cannot be known at compilation time + + foo::<for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a), _>(None, (&(),)); + //~^ ERROR the size for values of type `(dyn std::fmt::Display + 'a)` cannot be known at compilation time +} diff --git a/src/test/ui/function-pointer/unsized-ret.stderr b/src/test/ui/function-pointer/unsized-ret.stderr new file mode 100644 index 00000000000..bec3e2aa3fe --- /dev/null +++ b/src/test/ui/function-pointer/unsized-ret.stderr @@ -0,0 +1,35 @@ +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/unsized-ret.rs:9:27 + | +LL | foo::<fn() -> str, _>(None, ()); + | --------------------- ^^^^ doesn't have a size known at compile-time + | | + | required by a bound introduced by this call + | + = help: within `fn() -> str`, the trait `Sized` is not implemented for `str` + = note: required because it appears within the type `fn() -> str` +note: required by a bound in `foo` + --> $DIR/unsized-ret.rs:4:11 + | +LL | fn foo<F: Fn<T>, T>(f: Option<F>, t: T) { + | ^^^^^ required by this bound in `foo` + +error[E0277]: the size for values of type `(dyn std::fmt::Display + 'a)` cannot be known at compilation time + --> $DIR/unsized-ret.rs:12:66 + | +LL | foo::<for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a), _>(None, (&(),)); + | ------------------------------------------------------------ ^^^^ doesn't have a size known at compile-time + | | + | required by a bound introduced by this call + | + = help: within `for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a)`, the trait `for<'a> Sized` is not implemented for `(dyn std::fmt::Display + 'a)` + = note: required because it appears within the type `for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a)` +note: required by a bound in `foo` + --> $DIR/unsized-ret.rs:4:11 + | +LL | fn foo<F: Fn<T>, T>(f: Option<F>, t: T) { + | ^^^^^ required by this bound in `foo` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/generator/size-moved-locals.rs b/src/test/ui/generator/size-moved-locals.rs index 3c756a86fc5..601a3141828 100644 --- a/src/test/ui/generator/size-moved-locals.rs +++ b/src/test/ui/generator/size-moved-locals.rs @@ -12,6 +12,7 @@ // edition:2018 // ignore-wasm32 issue #62807 // ignore-asmjs issue #62807 +// needs-unwind Size of Closures change on panic=abort #![feature(generators, generator_trait)] diff --git a/src/test/ui/generic-associated-types/bugs/hrtb-implied-1.rs b/src/test/ui/generic-associated-types/bugs/hrtb-implied-1.rs new file mode 100644 index 00000000000..719d1bd5a4c --- /dev/null +++ b/src/test/ui/generic-associated-types/bugs/hrtb-implied-1.rs @@ -0,0 +1,35 @@ +// check-fail +// known-bug + +// This gives us problems because `for<'a> I::Item<'a>: Debug` should mean "for +// all 'a where I::Item<'a> is WF", but really means "for all 'a possible" + +use std::fmt::Debug; + +pub trait LendingIterator { + type Item<'this> + where + Self: 'this; +} + +pub struct WindowsMut<'x> { + slice: &'x (), +} + +impl<'y> LendingIterator for WindowsMut<'y> { + type Item<'this> = &'this mut () where 'y: 'this; +} + +fn print_items<I>(_iter: I) +where + I: LendingIterator, + for<'a> I::Item<'a>: Debug, +{ +} + +fn main() { + let slice = &mut (); + //~^ temporary value dropped while borrowed + let windows = WindowsMut { slice }; + print_items::<WindowsMut<'_>>(windows); +} diff --git a/src/test/ui/generic-associated-types/bugs/hrtb-implied-1.stderr b/src/test/ui/generic-associated-types/bugs/hrtb-implied-1.stderr new file mode 100644 index 00000000000..414999881d4 --- /dev/null +++ b/src/test/ui/generic-associated-types/bugs/hrtb-implied-1.stderr @@ -0,0 +1,20 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/hrtb-implied-1.rs:31:22 + | +LL | let slice = &mut (); + | ^^ creates a temporary which is freed while still in use +... +LL | print_items::<WindowsMut<'_>>(windows); + | -------------------------------------- argument requires that borrow lasts for `'static` +LL | } + | - temporary value is freed at the end of this statement + | +note: due to current limitations in the borrow checker, this implies a `'static` lifetime + --> $DIR/hrtb-implied-1.rs:26:26 + | +LL | for<'a> I::Item<'a>: Debug, + | ^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/generic-associated-types/bugs/hrtb-implied-2.rs b/src/test/ui/generic-associated-types/bugs/hrtb-implied-2.rs new file mode 100644 index 00000000000..8e6c5348e71 --- /dev/null +++ b/src/test/ui/generic-associated-types/bugs/hrtb-implied-2.rs @@ -0,0 +1,40 @@ +// check-fail +// known-bug + +// This gives us problems because `for<'a> I::Item<'a>: Debug` should mean "for +// all 'a where I::Item<'a> is WF", but really means "for all 'a possible" + +trait LendingIterator: Sized { + type Item<'a> + where + Self: 'a; + fn next(&mut self) -> Self::Item<'_>; +} +fn fails<I: LendingIterator, F>(iter: &mut I, f: F) -> bool +where + F: FnMut(I::Item<'_>), +{ + let mut iter2 = Eat(iter, f); + let _next = iter2.next(); + //~^ borrowed data escapes + true +} +impl<I: LendingIterator> LendingIterator for &mut I { + type Item<'a> = I::Item<'a> where Self:'a; + fn next(&mut self) -> Self::Item<'_> { + (**self).next() + } +} + +struct Eat<I, F>(I, F); +impl<I: LendingIterator, F> Iterator for Eat<I, F> +where + F: FnMut(I::Item<'_>), +{ + type Item = (); + fn next(&mut self) -> Option<Self::Item> { + None + } +} + +fn main() {} diff --git a/src/test/ui/generic-associated-types/bugs/hrtb-implied-2.stderr b/src/test/ui/generic-associated-types/bugs/hrtb-implied-2.stderr new file mode 100644 index 00000000000..1ee270398de --- /dev/null +++ b/src/test/ui/generic-associated-types/bugs/hrtb-implied-2.stderr @@ -0,0 +1,22 @@ +error[E0521]: borrowed data escapes outside of function + --> $DIR/hrtb-implied-2.rs:18:17 + | +LL | fn fails<I: LendingIterator, F>(iter: &mut I, f: F) -> bool + | ---- - let's call the lifetime of this reference `'1` + | | + | `iter` is a reference that is only valid in the function body +... +LL | let _next = iter2.next(); + | ^^^^^^^^^^^^ + | | + | `iter` escapes the function body here + | argument requires that `'1` must outlive `'static` + | + = note: requirement occurs because of a mutable reference to `Eat<&mut I, F>` + = note: mutable references are invariant over their type parameter + = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance + = note: due to current limitations in the borrow checker, this implies a `'static` lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/generic-associated-types/bugs/hrtb-implied-3.rs b/src/test/ui/generic-associated-types/bugs/hrtb-implied-3.rs new file mode 100644 index 00000000000..bc9e6c8aea8 --- /dev/null +++ b/src/test/ui/generic-associated-types/bugs/hrtb-implied-3.rs @@ -0,0 +1,23 @@ +trait LendingIterator { + type Item<'a> + where + Self: 'a; +} + +impl LendingIterator for &str { + type Item<'a> = () where Self:'a; +} + +fn trivial_bound<I>(_: I) +where + I: LendingIterator, + for<'a> I::Item<'a>: Sized, +{ +} + +fn fails(iter: &str) { + trivial_bound(iter); + //~^ borrowed data escapes +} + +fn main() {} diff --git a/src/test/ui/generic-associated-types/bugs/hrtb-implied-3.stderr b/src/test/ui/generic-associated-types/bugs/hrtb-implied-3.stderr new file mode 100644 index 00000000000..c67e02437cd --- /dev/null +++ b/src/test/ui/generic-associated-types/bugs/hrtb-implied-3.stderr @@ -0,0 +1,22 @@ +error[E0521]: borrowed data escapes outside of function + --> $DIR/hrtb-implied-3.rs:19:5 + | +LL | fn fails(iter: &str) { + | ---- - let's call the lifetime of this reference `'1` + | | + | `iter` is a reference that is only valid in the function body +LL | trivial_bound(iter); + | ^^^^^^^^^^^^^^^^^^^ + | | + | `iter` escapes the function body here + | argument requires that `'1` must outlive `'static` + | +note: due to current limitations in the borrow checker, this implies a `'static` lifetime + --> $DIR/hrtb-implied-3.rs:14:26 + | +LL | for<'a> I::Item<'a>: Sized, + | ^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/generic-associated-types/trait-objects.extended.stderr b/src/test/ui/generic-associated-types/trait-objects.extended.stderr index 086177cc106..45b64d2b024 100644 --- a/src/test/ui/generic-associated-types/trait-objects.extended.stderr +++ b/src/test/ui/generic-associated-types/trait-objects.extended.stderr @@ -11,6 +11,8 @@ LL | x.size_hint().0 | | | `x` escapes the function body here | argument requires that `'1` must outlive `'static` + | + = note: due to current limitations in the borrow checker, this implies a `'static` lifetime error: aborting due to previous error diff --git a/src/test/ui/higher-rank-trait-bounds/hrtb-just-for-static.stderr b/src/test/ui/higher-rank-trait-bounds/hrtb-just-for-static.stderr index b4312091edb..31e11e12835 100644 --- a/src/test/ui/higher-rank-trait-bounds/hrtb-just-for-static.stderr +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-just-for-static.stderr @@ -14,6 +14,12 @@ LL | fn give_some<'a>() { | -- lifetime `'a` defined here LL | want_hrtb::<&'a u32>() | ^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` + | +note: due to current limitations in the borrow checker, this implies a `'static` lifetime + --> $DIR/hrtb-just-for-static.rs:9:15 + | +LL | where T : for<'a> Foo<&'a isize> + | ^^^^^^^^^^^^^^^^^^^^^^ error: implementation of `Foo` is not general enough --> $DIR/hrtb-just-for-static.rs:30:5 diff --git a/src/test/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.stderr b/src/test/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.stderr index 1461e7fd2dd..5e75a4cc8af 100644 --- a/src/test/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.stderr +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.stderr @@ -46,6 +46,12 @@ LL | fn foo_hrtb_bar_not<'b, T>(mut t: T) ... LL | foo_hrtb_bar_not(&mut t); | ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static` + | +note: due to current limitations in the borrow checker, this implies a `'static` lifetime + --> $DIR/hrtb-perfect-forwarding.rs:37:8 + | +LL | T: for<'a> Foo<&'a isize> + Bar<&'b isize>, + | ^^^^^^^^^^^^^^^^^^^^^^ error: implementation of `Bar` is not general enough --> $DIR/hrtb-perfect-forwarding.rs:43:5 diff --git a/src/test/ui/invalid/invalid-inline.rs b/src/test/ui/invalid/invalid-inline.rs index 8aa8f99f522..2501b1e23f2 100644 --- a/src/test/ui/invalid/invalid-inline.rs +++ b/src/test/ui/invalid/invalid-inline.rs @@ -1,19 +1,14 @@ #![allow(dead_code)] -#[inline(please_no)] //~ ERROR invalid argument -fn a() { -} - #[inline(please,no)] //~ ERROR expected one argument -fn b() { +fn a() { } #[inline()] //~ ERROR expected one argument -fn c() { +fn b() { } fn main() { a(); b(); - c(); } diff --git a/src/test/ui/invalid/invalid-inline.stderr b/src/test/ui/invalid/invalid-inline.stderr index f3d04264197..7edbf936b1b 100644 --- a/src/test/ui/invalid/invalid-inline.stderr +++ b/src/test/ui/invalid/invalid-inline.stderr @@ -1,22 +1,15 @@ -error[E0535]: invalid argument - --> $DIR/invalid-inline.rs:3:10 - | -LL | #[inline(please_no)] - | ^^^^^^^^^ - error[E0534]: expected one argument - --> $DIR/invalid-inline.rs:7:1 + --> $DIR/invalid-inline.rs:3:1 | LL | #[inline(please,no)] | ^^^^^^^^^^^^^^^^^^^^ error[E0534]: expected one argument - --> $DIR/invalid-inline.rs:11:1 + --> $DIR/invalid-inline.rs:7:1 | LL | #[inline()] | ^^^^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0534, E0535. -For more information about an error, try `rustc --explain E0534`. +For more information about this error, try `rustc --explain E0534`. diff --git a/src/test/ui/issues/issue-25901.rs b/src/test/ui/issues/issue-25901.rs index ba12e1ad021..1f7b341a97e 100644 --- a/src/test/ui/issues/issue-25901.rs +++ b/src/test/ui/issues/issue-25901.rs @@ -2,7 +2,7 @@ struct A; struct B; static S: &'static B = &A; -//~^ ERROR cannot perform deref coercion on `A` in statics +//~^ ERROR the trait bound use std::ops::Deref; diff --git a/src/test/ui/issues/issue-25901.stderr b/src/test/ui/issues/issue-25901.stderr index c6c80e41cf6..b9cac32229a 100644 --- a/src/test/ui/issues/issue-25901.stderr +++ b/src/test/ui/issues/issue-25901.stderr @@ -1,23 +1,15 @@ -error[E0015]: cannot perform deref coercion on `A` in statics +error[E0277]: the trait bound `A: Deref` is not satisfied --> $DIR/issue-25901.rs:4:24 | LL | static S: &'static B = &A; - | ^^ - | - = note: attempting to deref into `B` -note: deref defined here - --> $DIR/issue-25901.rs:10:5 + | ^^ the trait `~const Deref` is not implemented for `A` | -LL | type Target = B; - | ^^^^^^^^^^^ -note: impl defined here, but it is not `const` - --> $DIR/issue-25901.rs:9:1 +note: the trait `Deref` is implemented for `A`, but that implementation is not `const` + --> $DIR/issue-25901.rs:4:24 | -LL | impl Deref for A { - | ^^^^^^^^^^^^^^^^ - = note: calls in statics are limited to constant functions, tuple structs and tuple variants - = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell +LL | static S: &'static B = &A; + | ^^ error: aborting due to previous error -For more information about this error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/issues/issue-26217.stderr b/src/test/ui/issues/issue-26217.stderr index c7601caacdc..73c772205c3 100644 --- a/src/test/ui/issues/issue-26217.stderr +++ b/src/test/ui/issues/issue-26217.stderr @@ -5,6 +5,12 @@ LL | fn bar<'a>() { | -- lifetime `'a` defined here LL | foo::<&'a i32>(); | ^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` + | +note: due to current limitations in the borrow checker, this implies a `'static` lifetime + --> $DIR/issue-26217.rs:1:30 + | +LL | fn foo<T>() where for<'a> T: 'a {} + | ^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-50582.stderr b/src/test/ui/issues/issue-50582.stderr index 3d527eb6b4e..53ecc6112ff 100644 --- a/src/test/ui/issues/issue-50582.stderr +++ b/src/test/ui/issues/issue-50582.stderr @@ -7,13 +7,13 @@ LL | Vec::<[(); 1 + for x in 0..1 {}]>::new(); = note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information = help: add `#![feature(const_for)]` to the crate attributes to enable -error[E0277]: cannot add `()` to `{integer}` +error[E0277]: cannot add `()` to `{integer}` in const contexts --> $DIR/issue-50582.rs:2:18 | LL | Vec::<[(); 1 + for x in 0..1 {}]>::new(); | ^ no implementation for `{integer} + ()` | - = help: the trait `Add<()>` is not implemented for `{integer}` + = help: the trait `~const Add<()>` is not implemented for `{integer}` = help: the following other types implement trait `Add<Rhs>`: <&'a f32 as Add<f32>> <&'a f64 as Add<f64>> diff --git a/src/test/ui/issues/issue-87707.rs b/src/test/ui/issues/issue-87707.rs index 26e9e2c8f91..c14e52dfe4c 100644 --- a/src/test/ui/issues/issue-87707.rs +++ b/src/test/ui/issues/issue-87707.rs @@ -3,6 +3,7 @@ // run-fail // exec-env:RUST_BACKTRACE=0 // check-run-results +// needs-unwind uses catch_unwind use std::sync::Once; use std::panic; diff --git a/src/test/ui/issues/issue-87707.run.stderr b/src/test/ui/issues/issue-87707.run.stderr index e6c9ea0eb53..527c78ba89e 100644 --- a/src/test/ui/issues/issue-87707.run.stderr +++ b/src/test/ui/issues/issue-87707.run.stderr @@ -1,3 +1,3 @@ -thread 'main' panicked at 'Here Once instance is poisoned.', $DIR/issue-87707.rs:13:24 +thread 'main' panicked at 'Here Once instance is poisoned.', $DIR/issue-87707.rs:14:24 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'main' panicked at 'Once instance has previously been poisoned', $DIR/issue-87707.rs:15:7 +thread 'main' panicked at 'Once instance has previously been poisoned', $DIR/issue-87707.rs:16:7 diff --git a/src/test/ui/let-else/const-fn.rs b/src/test/ui/let-else/const-fn.rs new file mode 100644 index 00000000000..336b0b4b72a --- /dev/null +++ b/src/test/ui/let-else/const-fn.rs @@ -0,0 +1,19 @@ +// run-pass +// issue #101932 + +#![cfg_attr(bootstrap, feature(let_else))] + +const fn foo(a: Option<i32>) -> i32 { + let Some(a) = a else { + return 42 + }; + + a + 1 +} + +fn main() { + const A: i32 = foo(None); + const B: i32 = foo(Some(1)); + + println!("{} {}", A, B); +} diff --git a/src/test/ui/lexer/lex-emoji-identifiers.rs b/src/test/ui/lexer/lex-emoji-identifiers.rs new file mode 100644 index 00000000000..91b5929c0fe --- /dev/null +++ b/src/test/ui/lexer/lex-emoji-identifiers.rs @@ -0,0 +1,17 @@ +fn invalid_emoji_usages() { + let arrow↔️ = "basic emoji"; //~ ERROR: identifiers cannot contain emoji + // FIXME + let planet🪐 = "basic emoji"; //~ ERROR: unknown start of token + // FIXME + let wireless🛜 = "basic emoji"; //~ ERROR: unknown start of token + // FIXME + let key1️⃣ = "keycap sequence"; //~ ERROR: unknown start of token + //~^ WARN: identifier contains uncommon Unicode codepoints + let flag🇺🇳 = "flag sequence"; //~ ERROR: identifiers cannot contain emoji + let wales🏴 = "tag sequence"; //~ ERROR: identifiers cannot contain emoji + let folded🙏🏿 = "modifier sequence"; //~ ERROR: identifiers cannot contain emoji +} + +fn main() { + invalid_emoji_usages(); +} diff --git a/src/test/ui/lexer/lex-emoji-identifiers.stderr b/src/test/ui/lexer/lex-emoji-identifiers.stderr new file mode 100644 index 00000000000..6237c5d0236 --- /dev/null +++ b/src/test/ui/lexer/lex-emoji-identifiers.stderr @@ -0,0 +1,52 @@ +error: unknown start of token: \u{1fa90} + --> $DIR/lex-emoji-identifiers.rs:4:15 + | +LL | let planet🪐 = "basic emoji"; + | ^^ + +error: unknown start of token: \u{1f6dc} + --> $DIR/lex-emoji-identifiers.rs:6:17 + | +LL | let wireless🛜 = "basic emoji"; + | ^^ + +error: unknown start of token: \u{20e3} + --> $DIR/lex-emoji-identifiers.rs:8:14 + | +LL | let key1️⃣ = "keycap sequence"; + | ^ + +error: identifiers cannot contain emoji: `arrow↔️` + --> $DIR/lex-emoji-identifiers.rs:2:9 + | +LL | let arrow↔️ = "basic emoji"; + | ^^^^^^ + +error: identifiers cannot contain emoji: `flag🇺🇳` + --> $DIR/lex-emoji-identifiers.rs:10:9 + | +LL | let flag🇺🇳 = "flag sequence"; + | ^^^^^^ + +error: identifiers cannot contain emoji: `wales🏴` + --> $DIR/lex-emoji-identifiers.rs:11:9 + | +LL | let wales🏴 = "tag sequence"; + | ^^^^^^^ + +error: identifiers cannot contain emoji: `folded🙏🏿` + --> $DIR/lex-emoji-identifiers.rs:12:9 + | +LL | let folded🙏🏿 = "modifier sequence"; + | ^^^^^^^^^^ + +warning: identifier contains uncommon Unicode codepoints + --> $DIR/lex-emoji-identifiers.rs:8:9 + | +LL | let key1️⃣ = "keycap sequence"; + | ^^^^ + | + = note: `#[warn(uncommon_codepoints)]` on by default + +error: aborting due to 7 previous errors; 1 warning emitted + diff --git a/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs b/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs index f538ec64390..b8b6f0846bb 100644 --- a/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs +++ b/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs @@ -2,6 +2,7 @@ // ignore-tidy-linelength // only-x86_64 // run-pass +// needs-unwind Asserting on contents of error message #![allow(path_statements, unused_allocation)] #![feature(box_syntax, core_intrinsics, generic_assert, generic_assert_internals)] diff --git a/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs b/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs index 86697c58fbc..d46f396ee29 100644 --- a/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs +++ b/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs @@ -2,6 +2,7 @@ // ignore-tidy-linelength // only-x86_64 // run-pass +// needs-unwind Asserting on contents of error message #![feature(core_intrinsics, generic_assert, generic_assert_internals)] diff --git a/src/test/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs b/src/test/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs index 06c4993ec30..1f5a29ab524 100644 --- a/src/test/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs +++ b/src/test/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs @@ -1,6 +1,7 @@ // aux-build:common.rs // only-x86_64 // run-pass +// needs-unwind Asserting on contents of error message #![feature(core_intrinsics, generic_assert, generic_assert_internals)] diff --git a/src/test/ui/macros/syntax-error-recovery.rs b/src/test/ui/macros/syntax-error-recovery.rs new file mode 100644 index 00000000000..ae6de3c5046 --- /dev/null +++ b/src/test/ui/macros/syntax-error-recovery.rs @@ -0,0 +1,18 @@ +macro_rules! values { + ($($token:ident($value:literal) $(as $inner:ty)? => $attr:meta,)*) => { + #[derive(Debug)] + pub enum TokenKind { + $( + #[$attr] + $token $($inner)? = $value, + )* + } + }; +} +//~^^^^^ ERROR expected one of `(`, `,`, `=`, `{`, or `}`, found `(String)` +//~| ERROR macro expansion ignores token `(String)` and any following + +values!(STRING(1) as (String) => cfg(test),); +//~^ ERROR expected one of `!` or `::`, found `<eof>` + +fn main() {} diff --git a/src/test/ui/macros/syntax-error-recovery.stderr b/src/test/ui/macros/syntax-error-recovery.stderr new file mode 100644 index 00000000000..c153b3b910b --- /dev/null +++ b/src/test/ui/macros/syntax-error-recovery.stderr @@ -0,0 +1,30 @@ +error: expected one of `(`, `,`, `=`, `{`, or `}`, found `(String)` + --> $DIR/syntax-error-recovery.rs:7:26 + | +LL | $token $($inner)? = $value, + | ^^^^^^ expected one of `(`, `,`, `=`, `{`, or `}` +... +LL | values!(STRING(1) as (String) => cfg(test),); + | -------------------------------------------- in this macro invocation + | + = note: this error originates in the macro `values` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: macro expansion ignores token `(String)` and any following + --> $DIR/syntax-error-recovery.rs:7:26 + | +LL | $token $($inner)? = $value, + | ^^^^^^ +... +LL | values!(STRING(1) as (String) => cfg(test),); + | -------------------------------------------- caused by the macro expansion here + | + = note: the usage of `values!` is likely invalid in item context + +error: expected one of `!` or `::`, found `<eof>` + --> $DIR/syntax-error-recovery.rs:15:9 + | +LL | values!(STRING(1) as (String) => cfg(test),); + | ^^^^^^ expected one of `!` or `::` + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/never_type/issue-52443.rs b/src/test/ui/never_type/issue-52443.rs index cebcca944af..0498a8a1625 100644 --- a/src/test/ui/never_type/issue-52443.rs +++ b/src/test/ui/never_type/issue-52443.rs @@ -9,6 +9,6 @@ fn main() { [(); { for _ in 0usize.. {}; 0}]; //~^ ERROR `for` is not allowed in a `const` //~| ERROR cannot convert - //~| ERROR mutable references are not allowed in constants - //~| ERROR cannot call non-const fn + //~| ERROR mutable references + //~| ERROR cannot call } diff --git a/src/test/ui/nll/local-outlives-static-via-hrtb.stderr b/src/test/ui/nll/local-outlives-static-via-hrtb.stderr index 61009da49ff..f5c10f3ddea 100644 --- a/src/test/ui/nll/local-outlives-static-via-hrtb.stderr +++ b/src/test/ui/nll/local-outlives-static-via-hrtb.stderr @@ -9,6 +9,12 @@ LL | assert_static_via_hrtb(&local); LL | assert_static_via_hrtb_with_assoc_type(&&local); LL | } | - `local` dropped here while still borrowed + | +note: due to current limitations in the borrow checker, this implies a `'static` lifetime + --> $DIR/local-outlives-static-via-hrtb.rs:15:53 + | +LL | fn assert_static_via_hrtb<G>(_: G) where for<'a> G: Outlives<'a> {} + | ^^^^^^^^^^^^ error[E0597]: `local` does not live long enough --> $DIR/local-outlives-static-via-hrtb.rs:25:45 @@ -20,6 +26,12 @@ LL | assert_static_via_hrtb_with_assoc_type(&&local); | argument requires that `local` is borrowed for `'static` LL | } | - `local` dropped here while still borrowed + | +note: due to current limitations in the borrow checker, this implies a `'static` lifetime + --> $DIR/local-outlives-static-via-hrtb.rs:19:20 + | +LL | for<'a> &'a T: Reference<AssociatedType = &'a ()>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/nll/type-test-universe.stderr b/src/test/ui/nll/type-test-universe.stderr index 242486c360a..31e17d64b8c 100644 --- a/src/test/ui/nll/type-test-universe.stderr +++ b/src/test/ui/nll/type-test-universe.stderr @@ -11,6 +11,12 @@ LL | fn test2<'a>() { | -- lifetime `'a` defined here LL | outlives_forall::<Value<'a>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` + | +note: due to current limitations in the borrow checker, this implies a `'static` lifetime + --> $DIR/type-test-universe.rs:6:16 + | +LL | for<'u> T: 'u, + | ^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/panics/issue-47429-short-backtraces.legacy.run.stderr b/src/test/ui/panics/issue-47429-short-backtraces.legacy.run.stderr index b6223b93764..ac4ed8225bd 100644 --- a/src/test/ui/panics/issue-47429-short-backtraces.legacy.run.stderr +++ b/src/test/ui/panics/issue-47429-short-backtraces.legacy.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at 'explicit panic', $DIR/issue-47429-short-backtraces.rs:22:5 +thread 'main' panicked at 'explicit panic', $DIR/issue-47429-short-backtraces.rs:23:5 stack backtrace: 0: std::panicking::begin_panic 1: issue_47429_short_backtraces::main diff --git a/src/test/ui/panics/issue-47429-short-backtraces.rs b/src/test/ui/panics/issue-47429-short-backtraces.rs index f338ace6bb0..58d0fa62c34 100644 --- a/src/test/ui/panics/issue-47429-short-backtraces.rs +++ b/src/test/ui/panics/issue-47429-short-backtraces.rs @@ -12,6 +12,7 @@ // ignore-wasm no panic or subprocess support // ignore-emscripten no panic or subprocess support // ignore-sgx no subprocess support +// ignore-fuchsia Backtraces not symbolized // NOTE(eddyb) output differs between symbol mangling schemes // revisions: legacy v0 diff --git a/src/test/ui/panics/issue-47429-short-backtraces.v0.run.stderr b/src/test/ui/panics/issue-47429-short-backtraces.v0.run.stderr index c2bea449249..65401fe1c3d 100644 --- a/src/test/ui/panics/issue-47429-short-backtraces.v0.run.stderr +++ b/src/test/ui/panics/issue-47429-short-backtraces.v0.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at 'explicit panic', $DIR/issue-47429-short-backtraces.rs:22:5 +thread 'main' panicked at 'explicit panic', $DIR/issue-47429-short-backtraces.rs:23:5 stack backtrace: 0: std::panicking::begin_panic::<&str> 1: issue_47429_short_backtraces::main diff --git a/src/test/ui/panics/runtime-switch.legacy.run.stderr b/src/test/ui/panics/runtime-switch.legacy.run.stderr index f282f18839c..0f76551630c 100644 --- a/src/test/ui/panics/runtime-switch.legacy.run.stderr +++ b/src/test/ui/panics/runtime-switch.legacy.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at 'explicit panic', $DIR/runtime-switch.rs:25:5 +thread 'main' panicked at 'explicit panic', $DIR/runtime-switch.rs:26:5 stack backtrace: 0: std::panicking::begin_panic 1: runtime_switch::main diff --git a/src/test/ui/panics/runtime-switch.rs b/src/test/ui/panics/runtime-switch.rs index 37ef961e2d0..882340e495c 100644 --- a/src/test/ui/panics/runtime-switch.rs +++ b/src/test/ui/panics/runtime-switch.rs @@ -12,6 +12,7 @@ // ignore-wasm no panic or subprocess support // ignore-emscripten no panic or subprocess support // ignore-sgx no subprocess support +// ignore-fuchsia Backtrace not symbolized // NOTE(eddyb) output differs between symbol mangling schemes // revisions: legacy v0 diff --git a/src/test/ui/panics/runtime-switch.v0.run.stderr b/src/test/ui/panics/runtime-switch.v0.run.stderr index 7ce9722e5ed..a4ae441317d 100644 --- a/src/test/ui/panics/runtime-switch.v0.run.stderr +++ b/src/test/ui/panics/runtime-switch.v0.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at 'explicit panic', $DIR/runtime-switch.rs:25:5 +thread 'main' panicked at 'explicit panic', $DIR/runtime-switch.rs:26:5 stack backtrace: 0: std::panicking::begin_panic::<&str> 1: runtime_switch::main diff --git a/src/test/ui/privacy/access_levels.rs b/src/test/ui/privacy/access_levels.rs index d51d2b57267..aa718ab9254 100644 --- a/src/test/ui/privacy/access_levels.rs +++ b/src/test/ui/privacy/access_levels.rs @@ -1,49 +1,62 @@ #![feature(rustc_attrs)] -#[rustc_access_level] mod outer { //~ ERROR None - #[rustc_access_level] pub mod inner { //~ ERROR Some(Exported) - #[rustc_access_level] - extern "C" { //~ ERROR Some(Exported) - #[rustc_access_level] static a: u8; //~ ERROR None - #[rustc_access_level] pub fn b(); //~ ERROR Some(Exported) - } - #[rustc_access_level] - pub trait Trait { //~ ERROR Some(Exported) - #[rustc_access_level] const A: i32; //~ ERROR Some(Exported) - #[rustc_access_level] type B; //~ ERROR Some(Exported) +#[rustc_effective_visibility] +mod outer { //~ ERROR Public: pub(self), Exported: pub(self), Reachable: pub(self), ReachableFromImplTrait: pub(self) + #[rustc_effective_visibility] + pub mod inner1 { //~ ERROR Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + + #[rustc_effective_visibility] + extern "C" {} //~ ERROR Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + + #[rustc_effective_visibility] + pub trait PubTrait { //~ ERROR Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + #[rustc_effective_visibility] + const A: i32; //~ ERROR Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + #[rustc_effective_visibility] + type B; //~ ERROR Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub } - #[rustc_access_level] - pub struct Struct { //~ ERROR Some(Exported) - #[rustc_access_level] a: u8, //~ ERROR None - #[rustc_access_level] pub b: u8, //~ ERROR Some(Exported) - } + #[rustc_effective_visibility] + struct PrivStruct; //~ ERROR Public: pub(self), Exported: pub(self), Reachable: pub(self), ReachableFromImplTrait: pub(self) - #[rustc_access_level] - pub union Union { //~ ERROR Some(Exported) - #[rustc_access_level] a: u8, //~ ERROR None - #[rustc_access_level] pub b: u8, //~ ERROR Some(Exported) + #[rustc_effective_visibility] + pub union PubUnion { //~ ERROR Public: pub(self), 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 } - #[rustc_access_level] - pub enum Enum { //~ ERROR Some(Exported) - #[rustc_access_level] A( //~ ERROR Some(Exported) - #[rustc_access_level] Struct, //~ ERROR Some(Exported) - #[rustc_access_level] Union, //~ ERROR Some(Exported) + #[rustc_effective_visibility] + pub enum Enum { //~ ERROR Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + #[rustc_effective_visibility] + A( //~ ERROR Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + #[rustc_effective_visibility] + PubUnion, //~ ERROR Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub ), } } - #[rustc_access_level] macro_rules! none_macro { //~ ERROR None + #[rustc_effective_visibility] + macro_rules! none_macro { //~ Public: pub(self), Exported: pub(self), Reachable: pub(self), ReachableFromImplTrait: pub(self) () => {}; } #[macro_export] - #[rustc_access_level] macro_rules! public_macro { //~ ERROR Some(Public) + #[rustc_effective_visibility] + macro_rules! public_macro { //~ Public: pub, Exported: pub, Reachable: pub, ReachableFromImplTrait: pub () => {}; } + + #[rustc_effective_visibility] + pub struct ReachableStruct { //~ ERROR Public: pub(self), Exported: pub(self), Reachable: pub, ReachableFromImplTrait: pub + #[rustc_effective_visibility] + pub a: u8, //~ ERROR Public: pub(self), Exported: pub(self), Reachable: pub, ReachableFromImplTrait: pub + } } -pub use outer::inner; +pub use outer::inner1; + +pub fn foo() -> outer::ReachableStruct { outer::ReachableStruct {a: 0} } fn main() {} diff --git a/src/test/ui/privacy/access_levels.stderr b/src/test/ui/privacy/access_levels.stderr index f326293c384..2ed6c330a2f 100644 --- a/src/test/ui/privacy/access_levels.stderr +++ b/src/test/ui/privacy/access_levels.stderr @@ -1,125 +1,104 @@ -error: None - --> $DIR/access_levels.rs:3:23 +error: Public: pub(self), Exported: pub(self), Reachable: pub(self), ReachableFromImplTrait: pub(self) + --> $DIR/access_levels.rs:4:1 | -LL | #[rustc_access_level] mod outer { - | ^^^^^^^^^ +LL | mod outer { + | ^^^^^^^^^ -error: Some(Exported) - --> $DIR/access_levels.rs:4:27 +error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + --> $DIR/access_levels.rs:6:5 | -LL | #[rustc_access_level] pub mod inner { - | ^^^^^^^^^^^^^ +LL | pub mod inner1 { + | ^^^^^^^^^^^^^^ -error: Some(Exported) - --> $DIR/access_levels.rs:6:9 +error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + --> $DIR/access_levels.rs:9:9 | -LL | / extern "C" { -LL | | #[rustc_access_level] static a: u8; -LL | | #[rustc_access_level] pub fn b(); -LL | | } - | |_________^ +LL | extern "C" {} + | ^^^^^^^^^^^^^ -error: Some(Exported) - --> $DIR/access_levels.rs:11:9 +error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + --> $DIR/access_levels.rs:12:9 | -LL | pub trait Trait { - | ^^^^^^^^^^^^^^^ +LL | pub trait PubTrait { + | ^^^^^^^^^^^^^^^^^^ -error: Some(Exported) - --> $DIR/access_levels.rs:17:9 +error: Public: pub(self), Exported: pub(self), Reachable: pub(self), ReachableFromImplTrait: pub(self) + --> $DIR/access_levels.rs:20:9 | -LL | pub struct Struct { +LL | struct PrivStruct; | ^^^^^^^^^^^^^^^^^ -error: None - --> $DIR/access_levels.rs:18:35 - | -LL | #[rustc_access_level] a: u8, - | ^^^^^ - -error: Some(Exported) - --> $DIR/access_levels.rs:19:35 - | -LL | #[rustc_access_level] pub b: u8, - | ^^^^^^^^^ - -error: Some(Exported) +error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub --> $DIR/access_levels.rs:23:9 | -LL | pub union Union { - | ^^^^^^^^^^^^^^^ +LL | pub union PubUnion { + | ^^^^^^^^^^^^^^^^^^ -error: None - --> $DIR/access_levels.rs:24:35 +error: Public: pub(self), Exported: pub(self), Reachable: pub(self), ReachableFromImplTrait: pub(self) + --> $DIR/access_levels.rs:25:13 | -LL | #[rustc_access_level] a: u8, - | ^^^^^ +LL | a: u8, + | ^^^^^ -error: Some(Exported) - --> $DIR/access_levels.rs:25:35 +error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + --> $DIR/access_levels.rs:27:13 | -LL | #[rustc_access_level] pub b: u8, - | ^^^^^^^^^ +LL | pub b: u8, + | ^^^^^^^^^ -error: Some(Exported) - --> $DIR/access_levels.rs:29:9 +error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + --> $DIR/access_levels.rs:31:9 | LL | pub enum Enum { | ^^^^^^^^^^^^^ -error: Some(Exported) - --> $DIR/access_levels.rs:30:35 - | -LL | #[rustc_access_level] A( - | ^ - -error: Some(Exported) - --> $DIR/access_levels.rs:31:39 +error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + --> $DIR/access_levels.rs:33:13 | -LL | #[rustc_access_level] Struct, - | ^^^^^^ +LL | A( + | ^ -error: Some(Exported) - --> $DIR/access_levels.rs:32:39 +error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + --> $DIR/access_levels.rs:35:17 | -LL | #[rustc_access_level] Union, - | ^^^^^ +LL | PubUnion, + | ^^^^^^^^ -error: None - --> $DIR/access_levels.rs:37:27 +error: Public: pub(self), Exported: pub(self), Reachable: pub(self), ReachableFromImplTrait: pub(self) + --> $DIR/access_levels.rs:41:5 | -LL | #[rustc_access_level] macro_rules! none_macro { - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | macro_rules! none_macro { + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: Some(Public) - --> $DIR/access_levels.rs:42:27 +error: Public: pub, Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + --> $DIR/access_levels.rs:47:5 | -LL | #[rustc_access_level] macro_rules! public_macro { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | macro_rules! public_macro { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: Some(Exported) - --> $DIR/access_levels.rs:12:35 +error: Public: pub(self), Exported: pub(self), Reachable: pub, ReachableFromImplTrait: pub + --> $DIR/access_levels.rs:52:5 | -LL | #[rustc_access_level] const A: i32; - | ^^^^^^^^^^^^ +LL | pub struct ReachableStruct { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: Some(Exported) - --> $DIR/access_levels.rs:13:35 +error: Public: pub(self), Exported: pub(self), Reachable: pub, ReachableFromImplTrait: pub + --> $DIR/access_levels.rs:54:9 | -LL | #[rustc_access_level] type B; - | ^^^^^^ +LL | pub a: u8, + | ^^^^^^^^^ -error: None - --> $DIR/access_levels.rs:7:35 +error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + --> $DIR/access_levels.rs:14:13 | -LL | #[rustc_access_level] static a: u8; - | ^^^^^^^^^^^^ +LL | const A: i32; + | ^^^^^^^^^^^^ -error: Some(Exported) - --> $DIR/access_levels.rs:8:35 +error: Public: pub(self), Exported: pub, Reachable: pub, ReachableFromImplTrait: pub + --> $DIR/access_levels.rs:16:13 | -LL | #[rustc_access_level] pub fn b(); - | ^^^^^^^^^^ +LL | type B; + | ^^^^^^ -error: aborting due to 20 previous errors +error: aborting due to 17 previous errors diff --git a/src/test/ui/process/process-spawn-nonexistent.rs b/src/test/ui/process/process-spawn-nonexistent.rs index a513722639a..9dd608986df 100644 --- a/src/test/ui/process/process-spawn-nonexistent.rs +++ b/src/test/ui/process/process-spawn-nonexistent.rs @@ -1,6 +1,7 @@ // run-pass // ignore-emscripten no processes // ignore-sgx no processes +// ignore-fuchsia ErrorKind not translated use std::io::ErrorKind; use std::process::Command; diff --git a/src/test/ui/process/signal-exit-status.rs b/src/test/ui/process/signal-exit-status.rs index 0963dcc80f6..9519ed7b4c7 100644 --- a/src/test/ui/process/signal-exit-status.rs +++ b/src/test/ui/process/signal-exit-status.rs @@ -2,6 +2,7 @@ // ignore-emscripten no processes // ignore-sgx no processes // ignore-windows +// ignore-fuchsia code returned as ZX_TASK_RETCODE_EXCEPTION_KILL, FIXME (#58590) use std::env; use std::process::Command; diff --git a/src/test/ui/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.rs b/src/test/ui/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.rs new file mode 100644 index 00000000000..780a510c500 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.rs @@ -0,0 +1,14 @@ +// check-pass +#![feature(const_trait_impl)] + +#[const_trait] +trait Foo { + type Assoc: ~const Foo; + fn foo() {} +} + +const fn foo<T: ~const Foo>() { + <T as Foo>::Assoc::foo(); +} + +fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs b/src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs index 99eacaa837f..7d9dae52cf1 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs @@ -10,6 +10,7 @@ impl std::ops::Add for NonConstAdd { } } +#[const_trait] trait Foo { type Bar: ~const std::ops::Add; } @@ -19,6 +20,7 @@ impl const Foo for NonConstAdd { //~^ ERROR: cannot add `NonConstAdd` to `NonConstAdd` in const contexts } +#[const_trait] trait Baz { type Qux: std::ops::Add; } 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 64501c52374..ce2425010ad 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 @@ -1,17 +1,17 @@ error[E0277]: cannot add `NonConstAdd` to `NonConstAdd` in const contexts - --> $DIR/assoc-type.rs:18:16 + --> $DIR/assoc-type.rs:19:16 | LL | type Bar = NonConstAdd; | ^^^^^^^^^^^ no implementation for `NonConstAdd + NonConstAdd` | = help: the trait `~const Add` is not implemented for `NonConstAdd` note: the trait `Add` is implemented for `NonConstAdd`, but that implementation is not `const` - --> $DIR/assoc-type.rs:18:16 + --> $DIR/assoc-type.rs:19:16 | LL | type Bar = NonConstAdd; | ^^^^^^^^^^^ note: required by a bound in `Foo::Bar` - --> $DIR/assoc-type.rs:14:15 + --> $DIR/assoc-type.rs:15:15 | LL | type Bar: ~const std::ops::Add; | ^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo::Bar` diff --git a/src/test/ui/rfc-2632-const-trait-impl/auxiliary/staged-api.rs b/src/test/ui/rfc-2632-const-trait-impl/auxiliary/staged-api.rs index 19e9006094b..589e3f02420 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/auxiliary/staged-api.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/auxiliary/staged-api.rs @@ -3,6 +3,7 @@ #![stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")] +#[const_trait] pub trait MyTrait { #[stable(feature = "rust1", since = "1.0.0")] fn func(); diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs b/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs index 24b9235bb9a..dd993397420 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs @@ -1,5 +1,6 @@ #![feature(const_trait_impl)] +#[const_trait] pub trait Plus { fn plus(self, rhs: Self) -> Self; } @@ -23,7 +24,6 @@ pub const fn add_i32(a: i32, b: i32) -> i32 { pub const fn add_u32(a: u32, b: u32) -> u32 { a.plus(b) //~^ ERROR the trait bound - //~| ERROR cannot call non-const fn } fn main() {} 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 1fc9db27761..d9ad8043153 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 @@ -1,24 +1,19 @@ error[E0277]: the trait bound `u32: ~const Plus` is not satisfied - --> $DIR/call-const-trait-method-fail.rs:24:7 + --> $DIR/call-const-trait-method-fail.rs:25:7 | LL | a.plus(b) - | ^^^^^^^ the trait `~const Plus` is not implemented for `u32` + | ^^^^ the trait `~const Plus` is not implemented for `u32` | note: the trait `Plus` is implemented for `u32`, but that implementation is not `const` - --> $DIR/call-const-trait-method-fail.rs:24:7 + --> $DIR/call-const-trait-method-fail.rs:25:7 | LL | a.plus(b) - | ^^^^^^^ - -error[E0015]: cannot call non-const fn `<u32 as Plus>::plus` in constant functions - --> $DIR/call-const-trait-method-fail.rs:24:7 - | -LL | a.plus(b) - | ^^^^^^^ + | ^^^^ +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +LL | pub const fn add_u32(a: u32, b: u32) -> u32 where u32: ~const Plus { + | ++++++++++++++++++++++ -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.rs b/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.rs index cf38bc3c964..b64161b6aa0 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.rs @@ -21,6 +21,7 @@ impl const PartialEq for Int { } } +#[const_trait] pub trait Plus { fn plus(self, rhs: Self) -> Self; } diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs b/src/test/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs index 89dc47aad3d..50c46579086 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs @@ -1,6 +1,7 @@ // check-pass #![feature(const_trait_impl)] +#[const_trait] trait MyPartialEq { fn eq(&self, other: &Self) -> bool; } diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs b/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs index b3e3dd62be8..52984fb6be4 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs @@ -1,6 +1,7 @@ #![feature(const_trait_impl)] struct S; +#[const_trait] trait T { fn foo(); } diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr index 9e49785c589..c8783de4c3e 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr @@ -1,5 +1,5 @@ error[E0015]: cannot call non-const fn `non_const` in constant functions - --> $DIR/const-check-fns-in-const-impl.rs:11:16 + --> $DIR/const-check-fns-in-const-impl.rs:12:16 | LL | fn foo() { non_const() } | ^^^^^^^^^^^ 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 04462c0a11b..8b4c4065815 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 @@ -48,6 +48,7 @@ mod t { pub struct HasConstDrop(pub ConstDrop); pub struct TrivialFields(pub u8, pub i8, pub usize, pub isize); + #[const_trait] pub trait SomeTrait { fn foo(); } diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-impl-recovery.rs b/src/test/ui/rfc-2632-const-trait-impl/const-impl-recovery.rs index 470c653dd47..837124db04e 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-impl-recovery.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/const-impl-recovery.rs @@ -1,9 +1,11 @@ #![feature(const_trait_impl)] +#[const_trait] trait Foo {} const impl Foo for i32 {} //~ ERROR: expected identifier, found keyword +#[const_trait] trait Bar {} const impl<T: Foo> Bar for T {} //~ ERROR: expected identifier, found keyword diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-impl-recovery.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-impl-recovery.stderr index 709084c86e0..7217fc85543 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-impl-recovery.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/const-impl-recovery.stderr @@ -1,5 +1,5 @@ error: expected identifier, found keyword `impl` - --> $DIR/const-impl-recovery.rs:5:7 + --> $DIR/const-impl-recovery.rs:6:7 | LL | const impl Foo for i32 {} | ^^^^ expected identifier, found keyword @@ -11,7 +11,7 @@ LL + impl const Foo for i32 {} | error: expected identifier, found keyword `impl` - --> $DIR/const-impl-recovery.rs:9:7 + --> $DIR/const-impl-recovery.rs:11:7 | LL | const impl<T: Foo> Bar for T {} | ^^^^ expected identifier, found keyword diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-impl-requires-const-trait.rs b/src/test/ui/rfc-2632-const-trait-impl/const-impl-requires-const-trait.rs new file mode 100644 index 00000000000..1aff0562785 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/const-impl-requires-const-trait.rs @@ -0,0 +1,9 @@ +#![feature(const_trait_impl)] + +pub trait A {} +//~^ NOTE: this trait must be annotated with `#[const_trait]` + +impl const A for () {} +//~^ ERROR: const `impl`s must be for traits marked with `#[const_trait]` + +fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-impl-requires-const-trait.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-impl-requires-const-trait.stderr new file mode 100644 index 00000000000..6b465a9c62e --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/const-impl-requires-const-trait.stderr @@ -0,0 +1,14 @@ +error: const `impl`s must be for traits marked with `#[const_trait]` + --> $DIR/const-impl-requires-const-trait.rs:6:1 + | +LL | impl const A for () {} + | ^^^^^^^^^^^^^^^^^^^ + | +note: this trait must be annotated with `#[const_trait]` + --> $DIR/const-impl-requires-const-trait.rs:3:1 + | +LL | pub trait A {} + | ^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/rfc-2632-const-trait-impl/feature-gate.gated.stderr b/src/test/ui/rfc-2632-const-trait-impl/feature-gate.gated.stderr index af4d3909e40..4c630d33c55 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/feature-gate.gated.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/feature-gate.gated.stderr @@ -1,5 +1,5 @@ error: fatal error triggered by #[rustc_error] - --> $DIR/feature-gate.rs:13:1 + --> $DIR/feature-gate.rs:14:1 | LL | fn main() {} | ^^^^^^^^^ diff --git a/src/test/ui/rfc-2632-const-trait-impl/feature-gate.rs b/src/test/ui/rfc-2632-const-trait-impl/feature-gate.rs index 7bac72e1bb6..0b409fbaac9 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/feature-gate.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/feature-gate.rs @@ -5,6 +5,7 @@ #![feature(rustc_attrs)] struct S; +#[const_trait] //[stock]~ ERROR `const_trait` is a temporary placeholder trait T {} impl const T for S {} //[stock]~^ ERROR const trait impls are experimental diff --git a/src/test/ui/rfc-2632-const-trait-impl/feature-gate.stock.stderr b/src/test/ui/rfc-2632-const-trait-impl/feature-gate.stock.stderr index 91a8bb578a8..0e938c1c55d 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/feature-gate.stock.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/feature-gate.stock.stderr @@ -1,5 +1,5 @@ error[E0658]: const trait impls are experimental - --> $DIR/feature-gate.rs:9:6 + --> $DIR/feature-gate.rs:10:6 | LL | impl const T for S {} | ^^^^^ @@ -7,6 +7,15 @@ LL | impl const T for S {} = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to previous error +error[E0658]: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future. + --> $DIR/feature-gate.rs:8:1 + | +LL | #[const_trait] + | ^^^^^^^^^^^^^^ + | + = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information + = help: add `#![feature(const_trait_impl)]` 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/rfc-2632-const-trait-impl/hir-const-check.rs b/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.rs index 80a4442de2c..337c733403b 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.rs @@ -2,6 +2,7 @@ #![feature(const_trait_impl)] +#[const_trait] pub trait MyTrait { fn method(&self) -> Option<()>; } diff --git a/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.stderr b/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.stderr index 32df63e449d..6d2be1daa37 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.stderr @@ -1,5 +1,5 @@ error[E0658]: `?` is not allowed in a `const fn` - --> $DIR/hir-const-check.rs:11:9 + --> $DIR/hir-const-check.rs:12:9 | LL | Some(())?; | ^^^^^^^^^ diff --git a/src/test/ui/rfc-2632-const-trait-impl/inherent-impl-const-bounds.rs b/src/test/ui/rfc-2632-const-trait-impl/inherent-impl-const-bounds.rs index 2cef803a90e..f8ac793e4c1 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/inherent-impl-const-bounds.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/inherent-impl-const-bounds.rs @@ -3,7 +3,9 @@ struct S; +#[const_trait] trait A {} +#[const_trait] trait B {} impl const A for S {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/issue-100222.rs b/src/test/ui/rfc-2632-const-trait-impl/issue-100222.rs index 1004bb28c59..9f3f38ad4bc 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/issue-100222.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/issue-100222.rs @@ -16,6 +16,7 @@ pub trait IndexMut where Self: Index { impl Index for () { type Output = (); } +#[cfg(not(any(nn, yn)))] impl const IndexMut for <() as Index>::Output { const C: <Self as Index>::Output = (); type Assoc = <Self as Index>::Output; @@ -24,6 +25,15 @@ impl const IndexMut for <() as Index>::Output { {} } +#[cfg(any(nn, yn))] +impl IndexMut for <() as Index>::Output { + const C: <Self as Index>::Output = (); + type Assoc = <Self as Index>::Output; + fn foo(&mut self, x: <Self as Index>::Output) -> <Self as Index>::Output + where <Self as Index>::Output:, + {} +} + const C: <() as Index>::Output = (); fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/issue-92230-wf-super-trait-env.rs b/src/test/ui/rfc-2632-const-trait-impl/issue-92230-wf-super-trait-env.rs index 97c27ce1a1c..4d346965394 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/issue-92230-wf-super-trait-env.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/issue-92230-wf-super-trait-env.rs @@ -4,7 +4,9 @@ #![feature(const_trait_impl)] +#[const_trait] pub trait Super {} +#[const_trait] pub trait Sub: Super {} impl<A> const Super for &A where A: ~const Super {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/nested-closure.rs b/src/test/ui/rfc-2632-const-trait-impl/nested-closure.rs new file mode 100644 index 00000000000..a851136009c --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/nested-closure.rs @@ -0,0 +1,12 @@ +// check-pass + +#![feature(const_trait_impl, once_cell)] + +use std::sync::LazyLock; + +static EXTERN_FLAGS: LazyLock<String> = LazyLock::new(|| { + let x = || String::new(); + x() +}); + +fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.rs b/src/test/ui/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.rs index defef9e0409..1a4509b1869 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.rs @@ -2,6 +2,7 @@ #![feature(const_trait_impl)] +#[const_trait] trait Convert<T> { fn to(self) -> T; } diff --git a/src/test/ui/rfc-2632-const-trait-impl/static-const-trait-bound.rs b/src/test/ui/rfc-2632-const-trait-impl/static-const-trait-bound.rs new file mode 100644 index 00000000000..4520a36960c --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/static-const-trait-bound.rs @@ -0,0 +1,18 @@ +// check-pass +pub struct S<T, F: FnOnce() -> T = fn() -> T> { + f: F, + x: Option<T>, +} + +impl<T, F: FnOnce() -> T> S<T, F> { + pub const fn new(f: F) -> Self { + Self { f, x: None } + } +} + +#[derive(Default)] +pub struct Foo; + +static LOCKED_CALLSITES: S<Foo> = S::new(Default::default); + +fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/super-traits-fail.rs b/src/test/ui/rfc-2632-const-trait-impl/super-traits-fail.rs index af465cad3d2..3e2b81368a5 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/super-traits-fail.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/super-traits-fail.rs @@ -1,8 +1,10 @@ #![feature(const_trait_impl)] +#[const_trait] trait Foo { fn a(&self); } +#[const_trait] trait Bar: ~const Foo {} struct S; 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 9e8b8f8c6ba..9787792ab13 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 @@ -1,16 +1,16 @@ error[E0277]: the trait bound `S: ~const Foo` is not satisfied - --> $DIR/super-traits-fail.rs:13:12 + --> $DIR/super-traits-fail.rs:15:12 | LL | impl const Bar for S {} | ^^^ the trait `~const Foo` is not implemented for `S` | note: the trait `Foo` is implemented for `S`, but that implementation is not `const` - --> $DIR/super-traits-fail.rs:13:12 + --> $DIR/super-traits-fail.rs:15:12 | LL | impl const Bar for S {} | ^^^ note: required by a bound in `Bar` - --> $DIR/super-traits-fail.rs:6:12 + --> $DIR/super-traits-fail.rs:8:12 | LL | trait Bar: ~const Foo {} | ^^^^^^^^^^ required by this bound in `Bar` diff --git a/src/test/ui/rfc-2632-const-trait-impl/super-traits.rs b/src/test/ui/rfc-2632-const-trait-impl/super-traits.rs index aded4ca9a99..df96f6fb4ab 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/super-traits.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/super-traits.rs @@ -1,9 +1,12 @@ // check-pass #![feature(const_trait_impl)] +#[const_trait] trait Foo { fn a(&self); } + +#[const_trait] trait Bar: ~const Foo {} struct S; diff --git a/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-const.rs b/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-const.rs new file mode 100644 index 00000000000..7a88ec35c8f --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-const.rs @@ -0,0 +1,29 @@ +// Like trait-where-clause.rs, but we are calling from a const context. +// Checking the validity of traits' where clauses happen at a later stage. +// (`rustc_const_eval` instead of `rustc_typeck`) Therefore one file as a +// test is not enough. +#![feature(const_trait_impl)] + +trait Bar {} + +trait Foo { + fn a(); + fn b() where Self: ~const Bar; + fn c<T: ~const Bar>(); +} + +const fn test1<T: ~const Foo + Bar>() { + T::a(); + T::b(); + //~^ ERROR the trait bound + T::c::<T>(); + //~^ ERROR the trait bound +} + +const fn test2<T: ~const Foo + ~const Bar>() { + T::a(); + T::b(); + T::c::<T>(); +} + +fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-const.stderr b/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-const.stderr new file mode 100644 index 00000000000..13d8639de30 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-const.stderr @@ -0,0 +1,35 @@ +error[E0277]: the trait bound `T: ~const Bar` is not satisfied + --> $DIR/trait-where-clause-const.rs:17:5 + | +LL | T::b(); + | ^^^^^^ the trait `~const Bar` is not implemented for `T` + | +note: the trait `Bar` is implemented for `T`, but that implementation is not `const` + --> $DIR/trait-where-clause-const.rs:17:5 + | +LL | T::b(); + | ^^^^^^ +help: consider further restricting this bound + | +LL | const fn test1<T: ~const Foo + Bar + ~const Bar>() { + | ++++++++++++ + +error[E0277]: the trait bound `T: ~const Bar` is not satisfied + --> $DIR/trait-where-clause-const.rs:19:5 + | +LL | T::c::<T>(); + | ^^^^^^^^^^^ the trait `~const Bar` is not implemented for `T` + | +note: the trait `Bar` is implemented for `T`, but that implementation is not `const` + --> $DIR/trait-where-clause-const.rs:19:5 + | +LL | T::c::<T>(); + | ^^^^^^^^^^^ +help: consider further restricting this bound + | +LL | const fn test1<T: ~const Foo + Bar + ~const Bar>() { + | ++++++++++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-run.rs b/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-run.rs index b7cf9a13b79..4b8b004069d 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-run.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-run.rs @@ -2,6 +2,7 @@ #![feature(const_trait_impl)] +#[const_trait] trait Bar { fn bar() -> u8; } diff --git a/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause.rs b/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause.rs index d37ed3bb8dd..5bd23a8cb20 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause.rs @@ -8,7 +8,7 @@ trait Foo { fn c<T: ~const Bar>(); } -const fn test1<T: ~const Foo + Bar>() { +fn test1<T: Foo>() { T::a(); T::b(); //~^ ERROR the trait bound @@ -16,21 +16,7 @@ const fn test1<T: ~const Foo + Bar>() { //~^ ERROR the trait bound } -const fn test2<T: ~const Foo + ~const Bar>() { - T::a(); - T::b(); - T::c::<T>(); -} - -fn test3<T: Foo>() { - T::a(); - T::b(); - //~^ ERROR the trait bound - T::c::<T>(); - //~^ ERROR the trait bound -} - -fn test4<T: Foo + Bar>() { +fn test2<T: Foo + Bar>() { T::a(); T::b(); T::c::<T>(); diff --git a/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause.stderr b/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause.stderr index fd5fe25ddcf..96365d33433 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause.stderr @@ -1,47 +1,5 @@ -error[E0277]: the trait bound `T: ~const Bar` is not satisfied - --> $DIR/trait-where-clause.rs:13:5 - | -LL | T::b(); - | ^^^^ the trait `~const Bar` is not implemented for `T` - | -note: the trait `Bar` is implemented for `T`, but that implementation is not `const` - --> $DIR/trait-where-clause.rs:13:5 - | -LL | T::b(); - | ^^^^ -note: required by a bound in `Foo::b` - --> $DIR/trait-where-clause.rs:7:24 - | -LL | fn b() where Self: ~const Bar; - | ^^^^^^^^^^ required by this bound in `Foo::b` -help: consider further restricting this bound - | -LL | const fn test1<T: ~const Foo + Bar + ~const Bar>() { - | ++++++++++++ - -error[E0277]: the trait bound `T: ~const Bar` is not satisfied - --> $DIR/trait-where-clause.rs:15:12 - | -LL | T::c::<T>(); - | ^ the trait `~const Bar` is not implemented for `T` - | -note: the trait `Bar` is implemented for `T`, but that implementation is not `const` - --> $DIR/trait-where-clause.rs:15:12 - | -LL | T::c::<T>(); - | ^ -note: required by a bound in `Foo::c` - --> $DIR/trait-where-clause.rs:8:13 - | -LL | fn c<T: ~const Bar>(); - | ^^^^^^^^^^ required by this bound in `Foo::c` -help: consider further restricting this bound - | -LL | const fn test1<T: ~const Foo + Bar + ~const Bar>() { - | ++++++++++++ - error[E0277]: the trait bound `T: Bar` is not satisfied - --> $DIR/trait-where-clause.rs:27:5 + --> $DIR/trait-where-clause.rs:13:5 | LL | T::b(); | ^^^^ the trait `Bar` is not implemented for `T` @@ -53,11 +11,11 @@ LL | fn b() where Self: ~const Bar; | ^^^^^^^^^^ required by this bound in `Foo::b` help: consider further restricting this bound | -LL | fn test3<T: Foo + Bar>() { +LL | fn test1<T: Foo + Bar>() { | +++++ error[E0277]: the trait bound `T: Bar` is not satisfied - --> $DIR/trait-where-clause.rs:29:12 + --> $DIR/trait-where-clause.rs:15:12 | LL | T::c::<T>(); | ^ the trait `Bar` is not implemented for `T` @@ -69,9 +27,9 @@ LL | fn c<T: ~const Bar>(); | ^^^^^^^^^^ required by this bound in `Foo::c` help: consider further restricting this bound | -LL | fn test3<T: Foo + Bar>() { +LL | fn test1<T: Foo + Bar>() { | +++++ -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/runtime/backtrace-debuginfo.rs b/src/test/ui/runtime/backtrace-debuginfo.rs index 7c9f1a7f2f4..8b5466b6cfa 100644 --- a/src/test/ui/runtime/backtrace-debuginfo.rs +++ b/src/test/ui/runtime/backtrace-debuginfo.rs @@ -12,6 +12,7 @@ // ignore-pretty issue #37195 // ignore-emscripten spawning processes is not supported // ignore-sgx no processes +// ignore-fuchsia Backtrace not symbolized, trace different line alignment use std::env; diff --git a/src/test/ui/runtime/out-of-stack.rs b/src/test/ui/runtime/out-of-stack.rs index 73c31cd9721..6873abc49b2 100644 --- a/src/test/ui/runtime/out-of-stack.rs +++ b/src/test/ui/runtime/out-of-stack.rs @@ -5,6 +5,7 @@ // ignore-android: FIXME (#20004) // ignore-emscripten no processes // ignore-sgx no processes +// ignore-fuchsia must translate zircon signal to SIGABRT, FIXME (#58590) #![feature(core_intrinsics)] #![feature(rustc_private)] diff --git a/src/test/ui/span/E0535.stderr b/src/test/ui/span/E0535.stderr index f52c3f9f2c0..b1411bc436a 100644 --- a/src/test/ui/span/E0535.stderr +++ b/src/test/ui/span/E0535.stderr @@ -3,6 +3,8 @@ error[E0535]: invalid argument | LL | #[inline(unknown)] | ^^^^^^^ + | + = help: valid inline arguments are `always` and `never` error: aborting due to previous error diff --git a/src/test/ui/stability-attribute/missing-const-stability.rs b/src/test/ui/stability-attribute/missing-const-stability.rs index d89886af314..6eff899bfbf 100644 --- a/src/test/ui/stability-attribute/missing-const-stability.rs +++ b/src/test/ui/stability-attribute/missing-const-stability.rs @@ -19,6 +19,7 @@ impl Foo { } #[stable(feature = "stable", since = "1.0.0")] +#[const_trait] pub trait Bar { #[stable(feature = "stable", since = "1.0.0")] fn fun(); diff --git a/src/test/ui/stability-attribute/missing-const-stability.stderr b/src/test/ui/stability-attribute/missing-const-stability.stderr index 10978728fa3..4cfbe152891 100644 --- a/src/test/ui/stability-attribute/missing-const-stability.stderr +++ b/src/test/ui/stability-attribute/missing-const-stability.stderr @@ -5,7 +5,7 @@ LL | pub const fn foo() {} | ^^^^^^^^^^^^^^^^^^^^^ error: implementation has missing const stability attribute - --> $DIR/missing-const-stability.rs:27:1 + --> $DIR/missing-const-stability.rs:28:1 | LL | / impl const Bar for Foo { LL | | diff --git a/src/test/ui/std-backtrace.rs b/src/test/ui/std-backtrace.rs index 3f8306baf8a..59574b471dd 100644 --- a/src/test/ui/std-backtrace.rs +++ b/src/test/ui/std-backtrace.rs @@ -4,6 +4,7 @@ // ignore-openbsd no support for libbacktrace without filename // ignore-sgx no processes // ignore-msvc see #62897 and `backtrace-debuginfo.rs` test +// ignore-fuchsia Backtraces not symbolized // compile-flags:-g // compile-flags:-Cstrip=none diff --git a/src/test/ui/suggestions/issue-101623.rs b/src/test/ui/suggestions/issue-101623.rs new file mode 100644 index 00000000000..d18a4a21f0a --- /dev/null +++ b/src/test/ui/suggestions/issue-101623.rs @@ -0,0 +1,25 @@ +pub struct Stuff { + inner: *mut (), +} + +pub struct Wrap<T>(T); + +fn fun<T>(t: T) -> Wrap<T> { + todo!() +} + +pub trait Trait<'de> { + fn do_stuff(_: Wrap<&'de mut Self>); +} + +impl<'a> Trait<'a> for () { + fn do_stuff(_: Wrap<&'a mut Self>) {} +} + +fn fun2(t: &mut Stuff) -> () { + let Stuff { inner, .. } = t; + Trait::do_stuff({ fun(&mut *inner) }); + //~^ ERROR the trait bound `*mut (): Trait<'_>` is not satisfied +} + +fn main() {} diff --git a/src/test/ui/suggestions/issue-101623.stderr b/src/test/ui/suggestions/issue-101623.stderr new file mode 100644 index 00000000000..361483cc08d --- /dev/null +++ b/src/test/ui/suggestions/issue-101623.stderr @@ -0,0 +1,14 @@ +error[E0277]: the trait bound `*mut (): Trait<'_>` is not satisfied + --> $DIR/issue-101623.rs:21:21 + | +LL | Trait::do_stuff({ fun(&mut *inner) }); + | --------------- ^^----------------^^ + | | | + | | the trait `Trait<'_>` is not implemented for `*mut ()` + | required by a bound introduced by this call + | + = help: the trait `Trait<'a>` is implemented for `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/suggestions/issue-101984.rs b/src/test/ui/suggestions/issue-101984.rs new file mode 100644 index 00000000000..5f7ecb77e0e --- /dev/null +++ b/src/test/ui/suggestions/issue-101984.rs @@ -0,0 +1,27 @@ +use std::marker::PhantomData; + +type Component = fn(&()); + +struct Wrapper { + router: Router<(Component, Box<Self>)>, +} + +struct Match<C>(PhantomData<C>); + +struct Router<T>(PhantomData<T>); + +impl<T> Router<T> { + pub fn at(&self) -> Result<Match<&T>, ()> { + todo!() + } +} + +impl Wrapper { + fn at(&self, path: &str) -> Result<(Component, Box<Self>), ()> { + let (cmp, router) = self.router.at()?; + //~^ ERROR mismatched types + todo!() + } +} + +fn main() {} diff --git a/src/test/ui/suggestions/issue-101984.stderr b/src/test/ui/suggestions/issue-101984.stderr new file mode 100644 index 00000000000..c744c62d11f --- /dev/null +++ b/src/test/ui/suggestions/issue-101984.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/issue-101984.rs:21:13 + | +LL | let (cmp, router) = self.router.at()?; + | ^^^^^^^^^^^^^ ----------------- this expression has type `Match<&(for<'r> fn(&'r ()), Box<Wrapper>)>` + | | + | expected struct `Match`, found tuple + | + = note: expected struct `Match<&(for<'r> fn(&'r ()), Box<Wrapper>)>` + found tuple `(_, _)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug.rs b/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug.rs index 811832848d9..9a50c0f988a 100644 --- a/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug.rs +++ b/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug.rs @@ -1,8 +1,9 @@ // compile-flags: --edition=2021 +// check-pass #![feature(type_alias_impl_trait)] fn main() { - type T = impl Copy; //~ ERROR unconstrained opaque type + type T = impl Copy; let foo: T = (1u32, 2u32); let (a, b): (u32, u32) = foo; } diff --git a/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug.stderr b/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug.stderr deleted file mode 100644 index 03b172e6de5..00000000000 --- a/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: unconstrained opaque type - --> $DIR/cross_inference_pattern_bug.rs:5:14 - | -LL | type T = impl Copy; - | ^^^^^^^^^ - | - = note: `T` must be used in combination with a concrete type within the same module - -error: aborting due to previous error - diff --git a/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug_no_type.rs b/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug_no_type.rs index 328096d44b4..b929122a6c2 100644 --- a/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug_no_type.rs +++ b/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug_no_type.rs @@ -1,13 +1,13 @@ -// known-bug: #96572 // compile-flags: --edition=2021 --crate-type=lib // rustc-env:RUST_BACKTRACE=0 +// check-pass // tracked in https://github.com/rust-lang/rust/issues/96572 #![feature(type_alias_impl_trait)] fn main() { - type T = impl Copy; // error: unconstrained opaque type + type T = impl Copy; let foo: T = (1u32, 2u32); - let (a, b) = foo; // removing this line makes the code compile + let (a, b) = foo; // this line used to make the code fail } diff --git a/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug_no_type.stderr b/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug_no_type.stderr deleted file mode 100644 index 8aa1f495639..00000000000 --- a/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug_no_type.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: unconstrained opaque type - --> $DIR/cross_inference_pattern_bug_no_type.rs:10:14 - | -LL | type T = impl Copy; // error: unconstrained opaque type - | ^^^^^^^^^ - | - = note: `T` must be used in combination with a concrete type within the same module - -error: aborting due to previous error - diff --git a/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr b/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr index d20b1cc6d85..0a34e8486a5 100644 --- a/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr @@ -1,10 +1,11 @@ -error[E0275]: overflow evaluating the requirement `fn() -> Foo {foo}: Sized` +error[E0275]: overflow evaluating the requirement `Foo: Sized` --> $DIR/issue-53398-cyclic-types.rs:5:13 | LL | fn foo() -> Foo { | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_53398_cyclic_types`) + = note: required because it appears within the type `fn() -> Foo {foo}` error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained-mismatch.rs b/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained-mismatch.rs new file mode 100644 index 00000000000..825710851b0 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained-mismatch.rs @@ -0,0 +1,10 @@ +#![feature(type_alias_impl_trait)] + +fn main() { + type T = impl Copy; + let foo: T = Some((1u32, 2u32)); + match foo { + None => (), + Some((a, b, c)) => (), //~ ERROR mismatched types + } +} diff --git a/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained-mismatch.stderr b/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained-mismatch.stderr new file mode 100644 index 00000000000..728244a1844 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained-mismatch.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/issue-96572-unconstrained-mismatch.rs:8:14 + | +LL | match foo { + | --- this expression has type `T` +LL | None => (), +LL | Some((a, b, c)) => (), + | ^^^^^^^^^ expected a tuple with 2 elements, found one with 3 elements + | + = note: expected tuple `(u32, u32)` + found tuple `(_, _, _)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained.rs b/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained.rs new file mode 100644 index 00000000000..2c740ccc1ae --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained.rs @@ -0,0 +1,92 @@ +#![feature(type_alias_impl_trait)] +// check-pass + +fn main() { + type T = impl Copy; + let foo: T = Some((1u32, 2u32)); + match foo { + None => (), + Some((a, b)) => (), + } +} + +fn upvar() { + #[derive(Copy, Clone)] + struct Foo((u32, u32)); + + type T = impl Copy; + let foo: T = Foo((1u32, 2u32)); + let x = move || { + let Foo((a, b)) = foo; + }; +} + +fn enum_upvar() { + type T = impl Copy; + let foo: T = Some((1u32, 2u32)); + let x = move || { + match foo { + None => (), + Some((a, b)) => (), + } + }; +} + +fn r#struct() { + #[derive(Copy, Clone)] + struct Foo((u32, u32)); + + type U = impl Copy; + let foo: U = Foo((1u32, 2u32)); + let Foo((a, b)) = foo; +} + +mod only_pattern { + type T = impl Copy; + + fn foo(foo: T) { + let (mut x, mut y) = foo; + x = 42; + y = "foo"; + } + + type U = impl Copy; + + fn bar(bar: Option<U>) { + match bar { + Some((mut x, mut y)) => { + x = 42; + y = "foo"; + } + None => {} + } + } +} + +mod only_pattern_rpit { + #[allow(unconditional_recursion)] + fn foo(b: bool) -> impl Copy { + let (mut x, mut y) = foo(false); + x = 42; + y = "foo"; + if b { + panic!() + } else { + foo(true) + } + } + + fn bar(b: bool) -> Option<impl Copy> { + if b { + return None; + } + match bar(!b) { + Some((mut x, mut y)) => { + x = 42; + y = "foo"; + } + None => {} + } + None + } +} |
