From ff7bf792ce7d6a8650fb3596e3afad82023c5e14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Fri, 20 Oct 2023 00:00:00 +0000 Subject: [PATCH 01/10] Migrate inline_compatibility.rs test to FileCheck --- ...nlined_no_sanitize.Inline.panic-abort.diff | 21 ------- ...lined_no_sanitize.Inline.panic-unwind.diff | 21 ------- ...ned_target_feature.Inline.panic-abort.diff | 21 ------- ...ed_target_feature.Inline.panic-unwind.diff | 21 ------- ...inlined_c_variadic.Inline.panic-abort.diff | 22 -------- ...nlined_c_variadic.Inline.panic-unwind.diff | 22 -------- ...nlined_no_sanitize.Inline.panic-abort.diff | 19 ------- ...lined_no_sanitize.Inline.panic-unwind.diff | 19 ------- ...ned_target_feature.Inline.panic-abort.diff | 19 ------- ...ed_target_feature.Inline.panic-unwind.diff | 19 ------- tests/mir-opt/inline/inline_compatibility.rs | 56 +++++++++++-------- 11 files changed, 34 insertions(+), 226 deletions(-) delete mode 100644 tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-abort.diff delete mode 100644 tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-unwind.diff delete mode 100644 tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-abort.diff delete mode 100644 tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-unwind.diff delete mode 100644 tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-abort.diff delete mode 100644 tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-unwind.diff delete mode 100644 tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-abort.diff delete mode 100644 tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-unwind.diff delete mode 100644 tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-abort.diff delete mode 100644 tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-unwind.diff diff --git a/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-abort.diff deleted file mode 100644 index eac51000cac49..0000000000000 --- a/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-abort.diff +++ /dev/null @@ -1,21 +0,0 @@ -- // MIR for `inlined_no_sanitize` before Inline -+ // MIR for `inlined_no_sanitize` after Inline - - fn inlined_no_sanitize() -> () { - let mut _0: (); - let _1: (); -+ scope 1 (inlined no_sanitize) { -+ } - - bb0: { - StorageLive(_1); -- _1 = no_sanitize() -> [return: bb1, unwind unreachable]; -- } -- -- bb1: { - StorageDead(_1); - _0 = const (); - return; - } - } - diff --git a/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-unwind.diff deleted file mode 100644 index eba5ad9cf2694..0000000000000 --- a/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-unwind.diff +++ /dev/null @@ -1,21 +0,0 @@ -- // MIR for `inlined_no_sanitize` before Inline -+ // MIR for `inlined_no_sanitize` after Inline - - fn inlined_no_sanitize() -> () { - let mut _0: (); - let _1: (); -+ scope 1 (inlined no_sanitize) { -+ } - - bb0: { - StorageLive(_1); -- _1 = no_sanitize() -> [return: bb1, unwind continue]; -- } -- -- bb1: { - StorageDead(_1); - _0 = const (); - return; - } - } - diff --git a/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-abort.diff deleted file mode 100644 index c2a81b9804e7e..0000000000000 --- a/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-abort.diff +++ /dev/null @@ -1,21 +0,0 @@ -- // MIR for `inlined_target_feature` before Inline -+ // MIR for `inlined_target_feature` after Inline - - fn inlined_target_feature() -> () { - let mut _0: (); - let _1: (); -+ scope 1 (inlined target_feature) { -+ } - - bb0: { - StorageLive(_1); -- _1 = target_feature() -> [return: bb1, unwind unreachable]; -- } -- -- bb1: { - StorageDead(_1); - _0 = const (); - return; - } - } - diff --git a/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-unwind.diff deleted file mode 100644 index 24457819b2c10..0000000000000 --- a/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-unwind.diff +++ /dev/null @@ -1,21 +0,0 @@ -- // MIR for `inlined_target_feature` before Inline -+ // MIR for `inlined_target_feature` after Inline - - fn inlined_target_feature() -> () { - let mut _0: (); - let _1: (); -+ scope 1 (inlined target_feature) { -+ } - - bb0: { - StorageLive(_1); -- _1 = target_feature() -> [return: bb1, unwind continue]; -- } -- -- bb1: { - StorageDead(_1); - _0 = const (); - return; - } - } - diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-abort.diff deleted file mode 100644 index 791c5a0f29f89..0000000000000 --- a/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-abort.diff +++ /dev/null @@ -1,22 +0,0 @@ -- // MIR for `not_inlined_c_variadic` before Inline -+ // MIR for `not_inlined_c_variadic` after Inline - - fn not_inlined_c_variadic() -> () { - let mut _0: (); - let _1: u32; - scope 1 { - debug s => _1; - } - - bb0: { - StorageLive(_1); - _1 = sum(const 4_u32, const 4_u32, const 30_u32, const 200_u32, const 1000_u32) -> [return: bb1, unwind unreachable]; - } - - bb1: { - _0 = const (); - StorageDead(_1); - return; - } - } - diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-unwind.diff deleted file mode 100644 index 364acab6d9361..0000000000000 --- a/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-unwind.diff +++ /dev/null @@ -1,22 +0,0 @@ -- // MIR for `not_inlined_c_variadic` before Inline -+ // MIR for `not_inlined_c_variadic` after Inline - - fn not_inlined_c_variadic() -> () { - let mut _0: (); - let _1: u32; - scope 1 { - debug s => _1; - } - - bb0: { - StorageLive(_1); - _1 = sum(const 4_u32, const 4_u32, const 30_u32, const 200_u32, const 1000_u32) -> [return: bb1, unwind continue]; - } - - bb1: { - _0 = const (); - StorageDead(_1); - return; - } - } - diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-abort.diff deleted file mode 100644 index b9d0946b7c3a3..0000000000000 --- a/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-abort.diff +++ /dev/null @@ -1,19 +0,0 @@ -- // MIR for `not_inlined_no_sanitize` before Inline -+ // MIR for `not_inlined_no_sanitize` after Inline - - fn not_inlined_no_sanitize() -> () { - let mut _0: (); - let _1: (); - - bb0: { - StorageLive(_1); - _1 = no_sanitize() -> [return: bb1, unwind unreachable]; - } - - bb1: { - StorageDead(_1); - _0 = const (); - return; - } - } - diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-unwind.diff deleted file mode 100644 index 965b7ddca3201..0000000000000 --- a/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-unwind.diff +++ /dev/null @@ -1,19 +0,0 @@ -- // MIR for `not_inlined_no_sanitize` before Inline -+ // MIR for `not_inlined_no_sanitize` after Inline - - fn not_inlined_no_sanitize() -> () { - let mut _0: (); - let _1: (); - - bb0: { - StorageLive(_1); - _1 = no_sanitize() -> [return: bb1, unwind continue]; - } - - bb1: { - StorageDead(_1); - _0 = const (); - return; - } - } - diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-abort.diff deleted file mode 100644 index 7c689a73482ad..0000000000000 --- a/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-abort.diff +++ /dev/null @@ -1,19 +0,0 @@ -- // MIR for `not_inlined_target_feature` before Inline -+ // MIR for `not_inlined_target_feature` after Inline - - fn not_inlined_target_feature() -> () { - let mut _0: (); - let _1: (); - - bb0: { - StorageLive(_1); - _1 = target_feature() -> [return: bb1, unwind unreachable]; - } - - bb1: { - StorageDead(_1); - _0 = const (); - return; - } - } - diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-unwind.diff deleted file mode 100644 index bcdbd6e33140f..0000000000000 --- a/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-unwind.diff +++ /dev/null @@ -1,19 +0,0 @@ -- // MIR for `not_inlined_target_feature` before Inline -+ // MIR for `not_inlined_target_feature` after Inline - - fn not_inlined_target_feature() -> () { - let mut _0: (); - let _1: (); - - bb0: { - StorageLive(_1); - _1 = target_feature() -> [return: bb1, unwind continue]; - } - - bb1: { - StorageDead(_1); - _0 = const (); - return; - } - } - diff --git a/tests/mir-opt/inline/inline_compatibility.rs b/tests/mir-opt/inline/inline_compatibility.rs index 52f4debf5dbad..988fbe333366a 100644 --- a/tests/mir-opt/inline/inline_compatibility.rs +++ b/tests/mir-opt/inline/inline_compatibility.rs @@ -1,51 +1,63 @@ -// skip-filecheck // Checks that only functions with compatible attributes are inlined. -// // only-x86_64 -// EMIT_MIR_FOR_EACH_PANIC_STRATEGY +// compile-flags: -Cpanic=abort #![crate_type = "lib"] #![feature(no_sanitize)] #![feature(target_feature_11)] #![feature(c_variadic)] -// EMIT_MIR inline_compatibility.inlined_target_feature.Inline.diff +#[inline] +#[target_feature(enable = "sse2")] +unsafe fn sse2() {} + +#[inline] +fn nop() {} + +// CHECK-LABEL: fn f0() +// CHECK: bb0: { +// CHECK-NEXT: return; #[target_feature(enable = "sse2")] -pub unsafe fn inlined_target_feature() { - target_feature(); +pub unsafe fn f0() { + sse2(); } -// EMIT_MIR inline_compatibility.not_inlined_target_feature.Inline.diff -pub unsafe fn not_inlined_target_feature() { - target_feature(); +// CHECK-LABEL: fn f1() +// CHECK: bb0: { +// CHECK-NEXT: sse2() +pub unsafe fn f1() { + sse2(); } -// EMIT_MIR inline_compatibility.inlined_no_sanitize.Inline.diff +#[inline] +#[no_sanitize(address)] +pub unsafe fn no_sanitize() {} + +// CHECK-LABEL: fn inlined_no_sanitize() +// CHECK: bb0: { +// CHECK-NEXT: return; #[no_sanitize(address)] pub unsafe fn inlined_no_sanitize() { no_sanitize(); } -// EMIT_MIR inline_compatibility.not_inlined_no_sanitize.Inline.diff +// CHECK-LABEL: fn not_inlined_no_sanitize() +// CHECK: bb0: { +// CHECK-NEXT: no_sanitize() pub unsafe fn not_inlined_no_sanitize() { no_sanitize(); } -#[inline] -#[target_feature(enable = "sse2")] -pub unsafe fn target_feature() {} - -#[inline] -#[no_sanitize(address)] -pub unsafe fn no_sanitize() {} - -// EMIT_MIR inline_compatibility.not_inlined_c_variadic.Inline.diff +// CHECK-LABEL: fn not_inlined_c_variadic() +// CHECK: bb0: { +// CHECK-NEXT: StorageLive(_1) +// CHECK-NEXT: _1 = sum pub unsafe fn not_inlined_c_variadic() { - let s = sum(4u32, 4u32, 30u32, 200u32, 1000u32); + let _ = sum(4u32, 4u32, 30u32, 200u32, 1000u32); } -#[no_mangle] #[inline(always)] +#[no_mangle] unsafe extern "C" fn sum(n: u32, mut vs: ...) -> u32 { let mut s = 0; let mut i = 0; From b3cfd5bb04d1622b4bd35da7983e29321be18e47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Fri, 20 Oct 2023 00:00:00 +0000 Subject: [PATCH 02/10] Precommit target features compatibility test --- tests/mir-opt/inline/inline_compatibility.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/mir-opt/inline/inline_compatibility.rs b/tests/mir-opt/inline/inline_compatibility.rs index 988fbe333366a..8045ea39f95ba 100644 --- a/tests/mir-opt/inline/inline_compatibility.rs +++ b/tests/mir-opt/inline/inline_compatibility.rs @@ -29,6 +29,14 @@ pub unsafe fn f1() { sse2(); } +// CHECK-LABEL: fn f2() +// CHECK: bb0: { +// CHECK-NEXT: return; +#[target_feature(enable = "avx")] +pub unsafe fn f2() { + nop(); +} + #[inline] #[no_sanitize(address)] pub unsafe fn no_sanitize() {} From 011b260cc83713599c4a3ff9bb242f92ee792b7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Fri, 20 Oct 2023 00:00:00 +0000 Subject: [PATCH 03/10] Require target features to match exactly during inlining In general it is not correct to inline a callee with a target features that are subset of the callee. Require target features to match exactly during inlining. The exact match could be potentially relaxed, but this would require identifying specific feature that are allowed to differ, those that need to match, and those that can be present in caller but not in callee. This resolves MIR part of #116573. For other concerns with respect to the previous implementation also see areInlineCompatible in LLVM. --- compiler/rustc_mir_transform/src/inline.rs | 6 ++---- tests/mir-opt/inline/inline_compatibility.rs | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index 8b33e00c63cca..277060573bcb9 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -438,10 +438,8 @@ impl<'tcx> Inliner<'tcx> { return Err("incompatible instruction set"); } - for feature in &callee_attrs.target_features { - if !self.codegen_fn_attrs.target_features.contains(feature) { - return Err("incompatible target feature"); - } + if callee_attrs.target_features != self.codegen_fn_attrs.target_features { + return Err("incompatible target features"); } Ok(()) diff --git a/tests/mir-opt/inline/inline_compatibility.rs b/tests/mir-opt/inline/inline_compatibility.rs index 8045ea39f95ba..3ad880715fe67 100644 --- a/tests/mir-opt/inline/inline_compatibility.rs +++ b/tests/mir-opt/inline/inline_compatibility.rs @@ -31,7 +31,7 @@ pub unsafe fn f1() { // CHECK-LABEL: fn f2() // CHECK: bb0: { -// CHECK-NEXT: return; +// CHECK-NEXT: nop() #[target_feature(enable = "avx")] pub unsafe fn f2() { nop(); From bc185097191e7598f50d39e768acde6c95a4d7d5 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Wed, 25 Oct 2023 11:36:45 +1100 Subject: [PATCH 04/10] coverage: UI test for unstable value `-C instrument-coverage=branch` --- tests/ui/instrument-coverage/except-unused-functions.rs | 3 --- tests/ui/instrument-coverage/except-unused-generics.rs | 3 --- ...xcept-unused-functions.stderr => unstable.branch.stderr} | 0 ...erics.stderr => unstable.except-unused-functions.stderr} | 0 .../unstable.except-unused-generics.stderr | 2 ++ tests/ui/instrument-coverage/unstable.rs | 6 ++++++ 6 files changed, 8 insertions(+), 6 deletions(-) delete mode 100644 tests/ui/instrument-coverage/except-unused-functions.rs delete mode 100644 tests/ui/instrument-coverage/except-unused-generics.rs rename tests/ui/instrument-coverage/{except-unused-functions.stderr => unstable.branch.stderr} (100%) rename tests/ui/instrument-coverage/{except-unused-generics.stderr => unstable.except-unused-functions.stderr} (100%) create mode 100644 tests/ui/instrument-coverage/unstable.except-unused-generics.stderr create mode 100644 tests/ui/instrument-coverage/unstable.rs diff --git a/tests/ui/instrument-coverage/except-unused-functions.rs b/tests/ui/instrument-coverage/except-unused-functions.rs deleted file mode 100644 index 5a0b7d4fef900..0000000000000 --- a/tests/ui/instrument-coverage/except-unused-functions.rs +++ /dev/null @@ -1,3 +0,0 @@ -// compile-flags: -Cinstrument-coverage=except-unused-functions - -fn main() {} diff --git a/tests/ui/instrument-coverage/except-unused-generics.rs b/tests/ui/instrument-coverage/except-unused-generics.rs deleted file mode 100644 index 4b1ddf29026ca..0000000000000 --- a/tests/ui/instrument-coverage/except-unused-generics.rs +++ /dev/null @@ -1,3 +0,0 @@ -// compile-flags: -Cinstrument-coverage=except-unused-generics - -fn main() {} diff --git a/tests/ui/instrument-coverage/except-unused-functions.stderr b/tests/ui/instrument-coverage/unstable.branch.stderr similarity index 100% rename from tests/ui/instrument-coverage/except-unused-functions.stderr rename to tests/ui/instrument-coverage/unstable.branch.stderr diff --git a/tests/ui/instrument-coverage/except-unused-generics.stderr b/tests/ui/instrument-coverage/unstable.except-unused-functions.stderr similarity index 100% rename from tests/ui/instrument-coverage/except-unused-generics.stderr rename to tests/ui/instrument-coverage/unstable.except-unused-functions.stderr diff --git a/tests/ui/instrument-coverage/unstable.except-unused-generics.stderr b/tests/ui/instrument-coverage/unstable.except-unused-generics.stderr new file mode 100644 index 0000000000000..acc633a2a6d2f --- /dev/null +++ b/tests/ui/instrument-coverage/unstable.except-unused-generics.stderr @@ -0,0 +1,2 @@ +error: `-C instrument-coverage=branch` and `-C instrument-coverage=except-*` require `-Z unstable-options` + diff --git a/tests/ui/instrument-coverage/unstable.rs b/tests/ui/instrument-coverage/unstable.rs new file mode 100644 index 0000000000000..c16bcd0bf6d13 --- /dev/null +++ b/tests/ui/instrument-coverage/unstable.rs @@ -0,0 +1,6 @@ +// revisions: branch except-unused-functions except-unused-generics +// [branch] compile-flags: -Cinstrument-coverage=branch +// [except-unused-functions] compile-flags: -Cinstrument-coverage=except-unused-functions +// [except-unused-generics] compile-flags: -Cinstrument-coverage=except-unused-generics + +fn main() {} From 65b0f6adb08385ed984eee6273d65518cd768b80 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Tue, 24 Oct 2023 12:23:00 +1100 Subject: [PATCH 05/10] Remove support for alias `-Z instrument-coverage` This flag was stabilized in rustc 1.60.0 as `-C instrument-coverage`, but the old unstable flag was kept around as an alias to ease migration. --- compiler/rustc_interface/src/tests.rs | 1 - compiler/rustc_session/src/config.rs | 39 ++++++++++++--------------- compiler/rustc_session/src/options.rs | 10 ------- 3 files changed, 17 insertions(+), 33 deletions(-) diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index ec4fd78994e95..657bce7384b4c 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -789,7 +789,6 @@ fn test_unstable_options_tracking_hash() { tracked!(inline_mir, Some(true)); tracked!(inline_mir_hint_threshold, Some(123)); tracked!(inline_mir_threshold, Some(123)); - tracked!(instrument_coverage, Some(InstrumentCoverage::All)); tracked!(instrument_mcount, true); tracked!(instrument_xray, Some(InstrumentXRay::default())); tracked!(link_directives, false); diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 84933588f17fe..78e410488c35a 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -2739,29 +2739,24 @@ pub fn build_session_options( _ => {} } - // Handle both `-Z instrument-coverage` and `-C instrument-coverage`; the latter takes - // precedence. - match (cg.instrument_coverage, unstable_opts.instrument_coverage) { - (Some(ic_c), Some(ic_z)) if ic_c != ic_z => { - handler.early_error( - "incompatible values passed for `-C instrument-coverage` \ - and `-Z instrument-coverage`", - ); - } - (Some(InstrumentCoverage::Off | InstrumentCoverage::All), _) => {} - (Some(_), _) if !unstable_opts.unstable_options => { - handler.early_error( - "`-C instrument-coverage=branch` and `-C instrument-coverage=except-*` \ - require `-Z unstable-options`", - ); - } - (None, None) => {} - (None, ic) => { - handler - .early_warn("`-Z instrument-coverage` is deprecated; use `-C instrument-coverage`"); - cg.instrument_coverage = ic; + // Check for unstable values of `-C instrument-coverage`. + // This is what prevents them from being used on stable compilers. + match cg.instrument_coverage { + // Stable values: + Some(InstrumentCoverage::All | InstrumentCoverage::Off) | None => {} + // Unstable values: + Some( + InstrumentCoverage::Branch + | InstrumentCoverage::ExceptUnusedFunctions + | InstrumentCoverage::ExceptUnusedGenerics, + ) => { + if !unstable_opts.unstable_options { + handler.early_error( + "`-C instrument-coverage=branch` and `-C instrument-coverage=except-*` \ + require `-Z unstable-options`", + ); + } } - _ => {} } if cg.instrument_coverage.is_some() && cg.instrument_coverage != Some(InstrumentCoverage::Off) { diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 77aaf951f0db0..35c167837e5ff 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1593,16 +1593,6 @@ options! { "a default MIR inlining threshold (default: 50)"), input_stats: bool = (false, parse_bool, [UNTRACKED], "gather statistics about the input (default: no)"), - #[rustc_lint_opt_deny_field_access("use `Session::instrument_coverage` instead of this field")] - instrument_coverage: Option = (None, parse_instrument_coverage, [TRACKED], - "instrument the generated code to support LLVM source-based code coverage \ - reports (note, the compiler build config must include `profiler = true`); \ - implies `-C symbol-mangling-version=v0`. Optional values are: - `=all` (implicit value) - `=branch` - `=except-unused-generics` - `=except-unused-functions` - `=off` (default)"), instrument_mcount: bool = (false, parse_bool, [TRACKED], "insert function instrument code for mcount-based tracing (default: no)"), instrument_xray: Option = (None, parse_instrument_xray, [TRACKED], From 23341434bdfdecf882b886146e6a25a9a15f09d9 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 25 Oct 2023 02:29:44 +0000 Subject: [PATCH 06/10] Fix unwrap suggestion for async fn --- .../src/fn_ctxt/suggestions.rs | 22 ++++++++-------- .../async-unwrap-suggestion.rs | 22 ++++++++++++++++ .../async-unwrap-suggestion.stderr | 25 +++++++++++++++++++ 3 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 tests/ui/mismatched_types/async-unwrap-suggestion.rs create mode 100644 tests/ui/mismatched_types/async-unwrap-suggestion.stderr diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index 13aa6454bc363..e1dbf37743fc6 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -1747,19 +1747,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expected: Ty<'tcx>, found: Ty<'tcx>, ) -> bool { - let ty::Adt(adt, args) = found.kind() else { return false }; + let ty::Adt(adt, args) = found.kind() else { + return false; + }; let ret_ty_matches = |diagnostic_item| { - if let Some(ret_ty) = self - .ret_coercion - .as_ref() - .map(|c| self.resolve_vars_if_possible(c.borrow().expected_ty())) - && let ty::Adt(kind, _) = ret_ty.kind() - && self.tcx.get_diagnostic_item(diagnostic_item) == Some(kind.did()) - { - true - } else { - false - } + let Some(sig) = self.body_fn_sig() else { + return false; + }; + let ty::Adt(kind, _) = sig.output().kind() else { + return false; + }; + self.tcx.is_diagnostic_item(diagnostic_item, kind.did()) }; // don't suggest anything like `Ok(ok_val).unwrap()` , `Some(some_val).unwrap()`, diff --git a/tests/ui/mismatched_types/async-unwrap-suggestion.rs b/tests/ui/mismatched_types/async-unwrap-suggestion.rs new file mode 100644 index 0000000000000..9698cc29ffd4a --- /dev/null +++ b/tests/ui/mismatched_types/async-unwrap-suggestion.rs @@ -0,0 +1,22 @@ +// edition: 2021 + +async fn dont_suggest() -> i32 { + if false { + return Ok(6); + //~^ ERROR mismatched types + } + + 5 +} + +async fn do_suggest() -> i32 { + if false { + let s = Ok(6); + return s; + //~^ ERROR mismatched types + } + + 5 +} + +fn main() {} diff --git a/tests/ui/mismatched_types/async-unwrap-suggestion.stderr b/tests/ui/mismatched_types/async-unwrap-suggestion.stderr new file mode 100644 index 0000000000000..80ca76a4b86d5 --- /dev/null +++ b/tests/ui/mismatched_types/async-unwrap-suggestion.stderr @@ -0,0 +1,25 @@ +error[E0308]: mismatched types + --> $DIR/async-unwrap-suggestion.rs:5:16 + | +LL | return Ok(6); + | ^^^^^ expected `i32`, found `Result<{integer}, _>` + | + = note: expected type `i32` + found enum `Result<{integer}, _>` + +error[E0308]: mismatched types + --> $DIR/async-unwrap-suggestion.rs:15:16 + | +LL | return s; + | ^ expected `i32`, found `Result<{integer}, _>` + | + = note: expected type `i32` + found enum `Result<{integer}, _>` +help: consider using `Result::expect` to unwrap the `Result<{integer}, _>` value, panicking if the value is a `Result::Err` + | +LL | return s.expect("REASON"); + | +++++++++++++++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. From beaf46f7e5a103207e8c2f8c9ffe8409f487168d Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 25 Oct 2023 10:49:24 +0000 Subject: [PATCH 07/10] Work around the fact that `check_mod_type_wf` may spuriously return `ErrorGuaranteed`, even if that error is only emitted by `check_modwitem_types` --- .../rustc_hir_analysis/src/check/check.rs | 6 ++- compiler/rustc_hir_analysis/src/lib.rs | 8 +++- .../clippy/tests/ui/crashes/ice-6252.stderr | 14 +++++- tests/ui/associated-consts/issue-105330.rs | 1 + .../ui/associated-consts/issue-105330.stderr | 12 +++-- .../generic-associated-types-bad.item.stderr | 14 +++++- .../generic-associated-types-bad.local.stderr | 2 +- ...generic-associated-types-bad.region.stderr | 2 +- .../generic-associated-types-bad.rs | 1 + ...associated-types-no-suitable-supertrait.rs | 1 + ...ciated-types-no-suitable-supertrait.stderr | 14 +++++- ...erence-impl-trait-for-trait-object-safe.rs | 1 + ...ce-impl-trait-for-trait-object-safe.stderr | 13 ++++- .../generic_const_exprs/type_mismatch.rs | 13 +++++ .../generic_const_exprs/type_mismatch.stderr | 12 +++++ tests/ui/consts/const-unsized.rs | 4 ++ tests/ui/consts/const-unsized.stderr | 44 +++++++++++++++-- .../generic-associated-types/issue-84931.rs | 3 +- .../issue-84931.stderr | 24 +++++++++- .../unsatisfied-item-lifetime-bound.rs | 1 + .../unsatisfied-item-lifetime-bound.stderr | 34 ++++++++++--- tests/ui/issues/issue-19380.rs | 1 + tests/ui/issues/issue-19380.stderr | 25 +++++++++- tests/ui/issues/issue-24446.rs | 2 + tests/ui/issues/issue-24446.stderr | 37 +++++++++++++- tests/ui/issues/issue-77919.rs | 1 + tests/ui/issues/issue-77919.stderr | 14 +++++- tests/ui/layout/issue-84108.rs | 2 + tests/ui/layout/issue-84108.stderr | 24 ++++++++-- tests/ui/proc-macro/bad-projection.rs | 2 + tests/ui/proc-macro/bad-projection.stderr | 30 +++++++++++- tests/ui/simd/array-trait.rs | 1 + tests/ui/simd/array-trait.stderr | 9 +++- .../min_specialization/issue-79224.rs | 1 + .../min_specialization/issue-79224.stderr | 14 +++++- .../bound/on-structs-and-enums-static.rs | 2 +- .../bound/on-structs-and-enums-static.stderr | 19 +++++++- .../new-solver/specialization-transmute.rs | 2 +- .../specialization-transmute.stderr | 11 ++++- .../generic_underconstrained.rs | 1 + .../generic_underconstrained.stderr | 23 ++++++++- .../generic_underconstrained2.rs | 2 + .../generic_underconstrained2.stderr | 48 +++++++++++++++++-- tests/ui/ufcs/ufcs-explicit-self-bad.rs | 1 + tests/ui/ufcs/ufcs-explicit-self-bad.stderr | 31 +++++++++--- tests/ui/union/issue-81199.rs | 1 + tests/ui/union/issue-81199.stderr | 19 ++++++-- .../ui/union/union-unsized.mirunsafeck.stderr | 31 ++++++++++-- tests/ui/union/union-unsized.rs | 2 + .../union/union-unsized.thirunsafeck.stderr | 31 ++++++++++-- .../unsized/unsized-trait-impl-self-type.rs | 1 + .../unsized-trait-impl-self-type.stderr | 14 +++++- .../unsized/unsized-trait-impl-trait-arg.rs | 1 + .../unsized-trait-impl-trait-arg.stderr | 14 +++++- tests/ui/unsized/unsized7.rs | 1 + tests/ui/unsized/unsized7.stderr | 14 +++++- tests/ui/wf/hir-wf-check-erase-regions.rs | 1 + tests/ui/wf/hir-wf-check-erase-regions.stderr | 16 ++++++- tests/ui/wf/issue-110157.rs | 1 + tests/ui/wf/issue-110157.stderr | 25 ++++++++-- tests/ui/wf/wf-const-type.rs | 1 + tests/ui/wf/wf-const-type.stderr | 20 +++++++- tests/ui/wf/wf-static-type.rs | 1 + tests/ui/wf/wf-static-type.stderr | 20 +++++++- 64 files changed, 661 insertions(+), 80 deletions(-) create mode 100644 tests/ui/const-generics/generic_const_exprs/type_mismatch.rs create mode 100644 tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 360d31b863c1d..e61ca232de643 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -128,7 +128,11 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b let param_env = tcx.param_env(item_def_id); for field in &def.non_enum_variant().fields { - let field_ty = tcx.normalize_erasing_regions(param_env, field.ty(tcx, args)); + let Ok(field_ty) = tcx.try_normalize_erasing_regions(param_env, field.ty(tcx, args)) + else { + tcx.sess.delay_span_bug(span, "could not normalize field type"); + continue; + }; if !allowed_union_field(field_ty, tcx, param_env) { let (field_span, ty_span) = match tcx.hir().get_if_local(field.did) { diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 0622aa2ee80fb..55393c087da63 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -205,15 +205,19 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> { })?; } - tcx.sess.time("wf_checking", || { + let errs = tcx.sess.time("wf_checking", || { tcx.hir().try_par_for_each_module(|module| tcx.ensure().check_mod_type_wf(module)) - })?; + }); // NOTE: This is copy/pasted in librustdoc/core.rs and should be kept in sync. tcx.sess.time("item_types_checking", || { tcx.hir().for_each_module(|module| tcx.ensure().check_mod_item_types(module)) }); + // HACK: `check_mod_type_wf` may spuriously emit errors due to `delay_span_bug`, even if those errors + // only actually get emitted in `check_mod_item_types`. + errs?; + if tcx.features().rustc_attrs { tcx.sess.track_errors(|| collect::test_opaque_hidden_types(tcx))?; } diff --git a/src/tools/clippy/tests/ui/crashes/ice-6252.stderr b/src/tools/clippy/tests/ui/crashes/ice-6252.stderr index 30be9dde73c3b..f929bec9583c5 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-6252.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-6252.stderr @@ -24,6 +24,16 @@ help: you might be missing a type parameter LL | impl TypeVal for Multiply where N: TypeVal {} | +++++ -error: aborting due to 2 previous errors +error[E0046]: not all trait items implemented, missing: `VAL` + --> $DIR/ice-6252.rs:11:1 + | +LL | const VAL: T; + | ------------ `VAL` from trait +... +LL | impl TypeVal for Multiply where N: TypeVal {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `VAL` in implementation + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0412`. +Some errors have detailed explanations: E0046, E0412. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/associated-consts/issue-105330.rs b/tests/ui/associated-consts/issue-105330.rs index 285e89cce4985..6c6dae864f340 100644 --- a/tests/ui/associated-consts/issue-105330.rs +++ b/tests/ui/associated-consts/issue-105330.rs @@ -14,5 +14,6 @@ fn foo>() { //~ ERROR E0658 fn main>() { //~^ ERROR E0658 + //~| ERROR E0131 foo::(); } diff --git a/tests/ui/associated-consts/issue-105330.stderr b/tests/ui/associated-consts/issue-105330.stderr index 55207909f7af5..aeedf6b194978 100644 --- a/tests/ui/associated-consts/issue-105330.stderr +++ b/tests/ui/associated-consts/issue-105330.stderr @@ -39,7 +39,13 @@ error[E0562]: `impl Trait` only allowed in function and inherent method argument LL | impl TraitWAssocConst for impl Demo { | ^^^^^^^^^ -error: aborting due to 5 previous errors +error[E0131]: `main` function is not allowed to have generic parameters + --> $DIR/issue-105330.rs:15:8 + | +LL | fn main>() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `main` cannot have generic parameters + +error: aborting due to 6 previous errors -Some errors have detailed explanations: E0404, E0562, E0658. -For more information about an error, try `rustc --explain E0404`. +Some errors have detailed explanations: E0131, E0404, E0562, E0658. +For more information about an error, try `rustc --explain E0131`. diff --git a/tests/ui/associated-inherent-types/generic-associated-types-bad.item.stderr b/tests/ui/associated-inherent-types/generic-associated-types-bad.item.stderr index 464b59c249fe1..0620725ca3334 100644 --- a/tests/ui/associated-inherent-types/generic-associated-types-bad.item.stderr +++ b/tests/ui/associated-inherent-types/generic-associated-types-bad.item.stderr @@ -10,6 +10,18 @@ note: required by a bound in `Ty::Pr` LL | type Pr = T; | ^^^^ required by this bound in `Ty::Pr` -error: aborting due to previous error +error[E0277]: the trait bound `String: Copy` is not satisfied + --> $DIR/generic-associated-types-bad.rs:16:27 + | +LL | const _: Ty::Pr = String::new(); + | ^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` + | +note: required by a bound in `Ty::Pr` + --> $DIR/generic-associated-types-bad.rs:10:16 + | +LL | type Pr = T; + | ^^^^ required by this bound in `Ty::Pr` + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/associated-inherent-types/generic-associated-types-bad.local.stderr b/tests/ui/associated-inherent-types/generic-associated-types-bad.local.stderr index 4f371b24e8034..fcf828c21c7c2 100644 --- a/tests/ui/associated-inherent-types/generic-associated-types-bad.local.stderr +++ b/tests/ui/associated-inherent-types/generic-associated-types-bad.local.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `Vec<()>: Copy` is not satisfied - --> $DIR/generic-associated-types-bad.rs:20:12 + --> $DIR/generic-associated-types-bad.rs:21:12 | LL | let _: Ty::Pr>; | ^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Vec<()>` diff --git a/tests/ui/associated-inherent-types/generic-associated-types-bad.region.stderr b/tests/ui/associated-inherent-types/generic-associated-types-bad.region.stderr index 74ec39424edcb..94c20521857f0 100644 --- a/tests/ui/associated-inherent-types/generic-associated-types-bad.region.stderr +++ b/tests/ui/associated-inherent-types/generic-associated-types-bad.region.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/generic-associated-types-bad.rs:25:12 + --> $DIR/generic-associated-types-bad.rs:26:12 | LL | fn user<'a>() { | -- lifetime `'a` defined here diff --git a/tests/ui/associated-inherent-types/generic-associated-types-bad.rs b/tests/ui/associated-inherent-types/generic-associated-types-bad.rs index e66392a0a9411..f5deec422f59a 100644 --- a/tests/ui/associated-inherent-types/generic-associated-types-bad.rs +++ b/tests/ui/associated-inherent-types/generic-associated-types-bad.rs @@ -14,6 +14,7 @@ impl Ty { #[cfg(item)] const _: Ty::Pr = String::new(); //[item]~ the trait bound `String: Copy` is not satisfied +//[item]~^ the trait bound `String: Copy` is not satisfied fn main() { #[cfg(local)] diff --git a/tests/ui/associated-types/associated-types-no-suitable-supertrait.rs b/tests/ui/associated-types/associated-types-no-suitable-supertrait.rs index c373c5855cdc0..cc0101d63cf21 100644 --- a/tests/ui/associated-types/associated-types-no-suitable-supertrait.rs +++ b/tests/ui/associated-types/associated-types-no-suitable-supertrait.rs @@ -21,6 +21,7 @@ trait Other { impl Other for T { fn uhoh(&self, foo: U, bar: <(T, U) as Get>::Value) {} //~^ ERROR the trait bound `(T, U): Get` is not satisfied + //~| ERROR the trait bound `(T, U): Get` is not satisfied } fn main() { } diff --git a/tests/ui/associated-types/associated-types-no-suitable-supertrait.stderr b/tests/ui/associated-types/associated-types-no-suitable-supertrait.stderr index b3f2e16ba0de8..9ebc45387e86e 100644 --- a/tests/ui/associated-types/associated-types-no-suitable-supertrait.stderr +++ b/tests/ui/associated-types/associated-types-no-suitable-supertrait.stderr @@ -21,6 +21,18 @@ help: consider further restricting `Self` LL | fn uhoh(&self, foo: U, bar: ::Value) where Self: Get {} | +++++++++++++++ -error: aborting due to 2 previous errors +error[E0277]: the trait bound `(T, U): Get` is not satisfied + --> $DIR/associated-types-no-suitable-supertrait.rs:22:5 + | +LL | fn uhoh(&self, foo: U, bar: <(T, U) as Get>::Value) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `(T, U)` + | +help: this trait has no implementations, consider adding one + --> $DIR/associated-types-no-suitable-supertrait.rs:12:1 + | +LL | trait Get { + | ^^^^^^^^^ + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs b/tests/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs index 20ff875491ff4..bce3b0fd729fe 100644 --- a/tests/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs +++ b/tests/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs @@ -6,5 +6,6 @@ trait NotObjectSafe { fn eq(&self, other: Self); } impl NotObjectSafe for dyn NotObjectSafe { } //~^ ERROR E0038 +//~| ERROR E0046 fn main() { } diff --git a/tests/ui/coherence/coherence-impl-trait-for-trait-object-safe.stderr b/tests/ui/coherence/coherence-impl-trait-for-trait-object-safe.stderr index e9090c1b6bcfb..1dcc30ee652dd 100644 --- a/tests/ui/coherence/coherence-impl-trait-for-trait-object-safe.stderr +++ b/tests/ui/coherence/coherence-impl-trait-for-trait-object-safe.stderr @@ -13,6 +13,15 @@ LL | trait NotObjectSafe { fn eq(&self, other: Self); } | this trait cannot be made into an object... = help: consider moving `eq` to another trait -error: aborting due to previous error +error[E0046]: not all trait items implemented, missing: `eq` + --> $DIR/coherence-impl-trait-for-trait-object-safe.rs:7:1 + | +LL | trait NotObjectSafe { fn eq(&self, other: Self); } + | -------------------------- `eq` from trait +LL | impl NotObjectSafe for dyn NotObjectSafe { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `eq` in implementation + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0038`. +Some errors have detailed explanations: E0038, E0046. +For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/const-generics/generic_const_exprs/type_mismatch.rs b/tests/ui/const-generics/generic_const_exprs/type_mismatch.rs new file mode 100644 index 0000000000000..5813f09818410 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/type_mismatch.rs @@ -0,0 +1,13 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +trait Q { + const ASSOC: usize; +} + +impl Q for [u8; N] {} +//~^ ERROR not all trait items implemented + +pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] {} + +pub fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr b/tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr new file mode 100644 index 0000000000000..0314d7ed23d3f --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr @@ -0,0 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `ASSOC` + --> $DIR/type_mismatch.rs:8:1 + | +LL | const ASSOC: usize; + | ------------------ `ASSOC` from trait +... +LL | impl Q for [u8; N] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `ASSOC` in implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/consts/const-unsized.rs b/tests/ui/consts/const-unsized.rs index 319b8ef97deae..e0b06a27109b7 100644 --- a/tests/ui/consts/const-unsized.rs +++ b/tests/ui/consts/const-unsized.rs @@ -2,15 +2,19 @@ use std::fmt::Debug; const CONST_0: dyn Debug + Sync = *(&0 as &(dyn Debug + Sync)); //~^ ERROR the size for values of type +//~| ERROR the size for values of type const CONST_FOO: str = *"foo"; //~^ ERROR the size for values of type +//~| ERROR the size for values of type static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync)); //~^ ERROR the size for values of type +//~| ERROR the size for values of type static STATIC_BAR: str = *"bar"; //~^ ERROR the size for values of type +//~| ERROR the size for values of type fn main() { println!("{:?} {:?} {:?} {:?}", &CONST_0, &CONST_FOO, &STATIC_1, &STATIC_BAR); diff --git a/tests/ui/consts/const-unsized.stderr b/tests/ui/consts/const-unsized.stderr index 27b200648eb95..674f0cb99e776 100644 --- a/tests/ui/consts/const-unsized.stderr +++ b/tests/ui/consts/const-unsized.stderr @@ -7,7 +7,7 @@ LL | const CONST_0: dyn Debug + Sync = *(&0 as &(dyn Debug + Sync)); = help: the trait `Sized` is not implemented for `(dyn Debug + Sync + 'static)` error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/const-unsized.rs:6:18 + --> $DIR/const-unsized.rs:7:18 | LL | const CONST_FOO: str = *"foo"; | ^^^ doesn't have a size known at compile-time @@ -15,7 +15,7 @@ LL | const CONST_FOO: str = *"foo"; = help: the trait `Sized` is not implemented for `str` error[E0277]: the size for values of type `(dyn Debug + Sync + 'static)` cannot be known at compilation time - --> $DIR/const-unsized.rs:9:18 + --> $DIR/const-unsized.rs:11:18 | LL | static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync)); | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -23,13 +23,49 @@ LL | static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync)); = help: the trait `Sized` is not implemented for `(dyn Debug + Sync + 'static)` error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/const-unsized.rs:12:20 + --> $DIR/const-unsized.rs:15:20 | LL | static STATIC_BAR: str = *"bar"; | ^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` -error: aborting due to 4 previous errors +error[E0277]: the size for values of type `(dyn Debug + Sync + 'static)` cannot be known at compilation time + --> $DIR/const-unsized.rs:3:35 + | +LL | const CONST_0: dyn Debug + Sync = *(&0 as &(dyn Debug + Sync)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Debug + Sync + 'static)` + = note: constant expressions must have a statically known size + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/const-unsized.rs:7:24 + | +LL | const CONST_FOO: str = *"foo"; + | ^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: constant expressions must have a statically known size + +error[E0277]: the size for values of type `(dyn Debug + Sync + 'static)` cannot be known at compilation time + --> $DIR/const-unsized.rs:11:37 + | +LL | static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Debug + Sync + 'static)` + = note: constant expressions must have a statically known size + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/const-unsized.rs:15:26 + | +LL | static STATIC_BAR: str = *"bar"; + | ^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: constant expressions must have a statically known size + +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generic-associated-types/issue-84931.rs b/tests/ui/generic-associated-types/issue-84931.rs index 4123ce9d4d94c..2ef990a7a9072 100644 --- a/tests/ui/generic-associated-types/issue-84931.rs +++ b/tests/ui/generic-associated-types/issue-84931.rs @@ -12,7 +12,8 @@ struct StreamingSliceIter<'a, T> { impl<'b, T: 'b> StreamingIter for StreamingSliceIter<'b, T> { type Item<'a> = &'a mut T; - //~^ the parameter type + //~^ ERROR: the parameter type + //~| ERROR: does not fulfill the required lifetime fn next(&mut self) -> Option<&mut T> { loop {} } diff --git a/tests/ui/generic-associated-types/issue-84931.stderr b/tests/ui/generic-associated-types/issue-84931.stderr index fe9932c205a17..04e14b9c746f3 100644 --- a/tests/ui/generic-associated-types/issue-84931.stderr +++ b/tests/ui/generic-associated-types/issue-84931.stderr @@ -11,6 +11,26 @@ help: consider adding an explicit lifetime bound LL | type Item<'a> = &'a mut T where T: 'a; | +++++++++++ -error: aborting due to previous error +error[E0477]: the type `StreamingSliceIter<'b, T>` does not fulfill the required lifetime + --> $DIR/issue-84931.rs:14:21 + | +LL | type Item<'a> where Self: 'a; + | ------------- definition of `Item` from trait +... +LL | type Item<'a> = &'a mut T; + | ^^^^^^^^^ + | +note: type must outlive the lifetime `'a` as defined here + --> $DIR/issue-84931.rs:14:15 + | +LL | type Item<'a> = &'a mut T; + | ^^ +help: copy the `where` clause predicates from the trait + | +LL | type Item<'a> = &'a mut T where Self: 'a; + | ++++++++++++++ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0309`. +Some errors have detailed explanations: E0309, E0477. +For more information about an error, try `rustc --explain E0309`. diff --git a/tests/ui/generic-associated-types/unsatisfied-item-lifetime-bound.rs b/tests/ui/generic-associated-types/unsatisfied-item-lifetime-bound.rs index 060ee8821d8da..a3f3b1a6d4d9a 100644 --- a/tests/ui/generic-associated-types/unsatisfied-item-lifetime-bound.rs +++ b/tests/ui/generic-associated-types/unsatisfied-item-lifetime-bound.rs @@ -7,6 +7,7 @@ pub trait X { impl X for () { type Y<'a> = &'a (); + //~^ ERROR lifetime bound not satisfied } struct B<'a, T: for<'r> X = &'r ()>> { diff --git a/tests/ui/generic-associated-types/unsatisfied-item-lifetime-bound.stderr b/tests/ui/generic-associated-types/unsatisfied-item-lifetime-bound.stderr index a69cd0028c1f1..f73ed5956da21 100644 --- a/tests/ui/generic-associated-types/unsatisfied-item-lifetime-bound.stderr +++ b/tests/ui/generic-associated-types/unsatisfied-item-lifetime-bound.stderr @@ -12,44 +12,64 @@ LL | #![warn(unused_lifetimes)] | ^^^^^^^^^^^^^^^^ error[E0478]: lifetime bound not satisfied - --> $DIR/unsatisfied-item-lifetime-bound.rs:13:8 + --> $DIR/unsatisfied-item-lifetime-bound.rs:14:8 | LL | f: ::Y<'a>, | ^^^^^^^^^^^^^^^ | note: lifetime parameter instantiated with the lifetime `'a` as defined here - --> $DIR/unsatisfied-item-lifetime-bound.rs:12:10 + --> $DIR/unsatisfied-item-lifetime-bound.rs:13:10 | LL | struct B<'a, T: for<'r> X = &'r ()>> { | ^^ = note: but lifetime parameter must outlive the static lifetime error[E0478]: lifetime bound not satisfied - --> $DIR/unsatisfied-item-lifetime-bound.rs:18:8 + --> $DIR/unsatisfied-item-lifetime-bound.rs:19:8 | LL | f: ::Y<'a>, | ^^^^^^^^^^^^^^^ | note: lifetime parameter instantiated with the lifetime `'a` as defined here - --> $DIR/unsatisfied-item-lifetime-bound.rs:17:10 + --> $DIR/unsatisfied-item-lifetime-bound.rs:18:10 | LL | struct C<'a, T: X> { | ^^ = note: but lifetime parameter must outlive the static lifetime error[E0478]: lifetime bound not satisfied - --> $DIR/unsatisfied-item-lifetime-bound.rs:23:8 + --> $DIR/unsatisfied-item-lifetime-bound.rs:24:8 | LL | f: <() as X>::Y<'a>, | ^^^^^^^^^^^^^^^^ | note: lifetime parameter instantiated with the lifetime `'a` as defined here - --> $DIR/unsatisfied-item-lifetime-bound.rs:22:10 + --> $DIR/unsatisfied-item-lifetime-bound.rs:23:10 | LL | struct D<'a> { | ^^ = note: but lifetime parameter must outlive the static lifetime -error: aborting due to 3 previous errors; 1 warning emitted +error[E0478]: lifetime bound not satisfied + --> $DIR/unsatisfied-item-lifetime-bound.rs:9:18 + | +LL | type Y<'a: 'static>; + | ------------------- definition of `Y` from trait +... +LL | type Y<'a> = &'a (); + | ^^^^^^ + | +note: lifetime parameter instantiated with the lifetime `'a` as defined here + --> $DIR/unsatisfied-item-lifetime-bound.rs:9:12 + | +LL | type Y<'a> = &'a (); + | ^^ + = note: but lifetime parameter must outlive the static lifetime +help: copy the `where` clause predicates from the trait + | +LL | type Y<'a> = &'a () where 'a: 'static; + | +++++++++++++++++ + +error: aborting due to 4 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0478`. diff --git a/tests/ui/issues/issue-19380.rs b/tests/ui/issues/issue-19380.rs index 5c10e2067e408..fce737cba18d2 100644 --- a/tests/ui/issues/issue-19380.rs +++ b/tests/ui/issues/issue-19380.rs @@ -14,5 +14,6 @@ struct Bar { const FOO : Foo = Foo; const BAR : Bar = Bar { foos: &[&FOO]}; +//~^ ERROR E0038 fn main() { } diff --git a/tests/ui/issues/issue-19380.stderr b/tests/ui/issues/issue-19380.stderr index b2aeb5edf29e2..37e280fbcc725 100644 --- a/tests/ui/issues/issue-19380.stderr +++ b/tests/ui/issues/issue-19380.stderr @@ -20,6 +20,29 @@ help: alternatively, consider constraining `qiz` so it does not apply to trait o LL | fn qiz() where Self: Sized; | +++++++++++++++++ -error: aborting due to previous error +error[E0038]: the trait `Qiz` cannot be made into an object + --> $DIR/issue-19380.rs:16:33 + | +LL | const BAR : Bar = Bar { foos: &[&FOO]}; + | ^^^^ `Qiz` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + --> $DIR/issue-19380.rs:2:6 + | +LL | trait Qiz { + | --- this trait cannot be made into an object... +LL | fn qiz(); + | ^^^ ...because associated function `qiz` has no `self` parameter + = note: required for the cast from `&Foo` to `&'static (dyn Qiz + 'static)` +help: consider turning `qiz` into a method by giving it a `&self` argument + | +LL | fn qiz(&self); + | +++++ +help: alternatively, consider constraining `qiz` so it does not apply to trait objects + | +LL | fn qiz() where Self: Sized; + | +++++++++++++++++ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/issues/issue-24446.rs b/tests/ui/issues/issue-24446.rs index 9ab952ade9cf4..6cf8846506d3e 100644 --- a/tests/ui/issues/issue-24446.rs +++ b/tests/ui/issues/issue-24446.rs @@ -2,6 +2,8 @@ fn main() { static foo: dyn Fn() -> u32 = || -> u32 { //~^ ERROR the size for values of type //~| ERROR cannot be shared between threads safely + //~| ERROR the size for values of type + //~| ERROR mismatched types 0 }; } diff --git a/tests/ui/issues/issue-24446.stderr b/tests/ui/issues/issue-24446.stderr index 72d528f1619a0..9c206e5ef3c42 100644 --- a/tests/ui/issues/issue-24446.stderr +++ b/tests/ui/issues/issue-24446.stderr @@ -15,6 +15,39 @@ LL | static foo: dyn Fn() -> u32 = || -> u32 { | = help: the trait `Sized` is not implemented for `(dyn Fn() -> u32 + 'static)` -error: aborting due to 2 previous errors +error[E0277]: the size for values of type `(dyn Fn() -> u32 + 'static)` cannot be known at compilation time + --> $DIR/issue-24446.rs:2:35 + | +LL | static foo: dyn Fn() -> u32 = || -> u32 { + | ___________________________________^ +LL | | +LL | | +LL | | +LL | | +LL | | 0 +LL | | }; + | |_____^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Fn() -> u32 + 'static)` + = note: constant expressions must have a statically known size + +error[E0308]: mismatched types + --> $DIR/issue-24446.rs:2:35 + | +LL | static foo: dyn Fn() -> u32 = || -> u32 { + | ___________________________________^ +LL | | +LL | | +LL | | +LL | | +LL | | 0 +LL | | }; + | |_____^ expected `dyn Fn`, found closure + | + = note: expected trait object `(dyn Fn() -> u32 + 'static)` + found closure `{closure@$DIR/issue-24446.rs:2:35: 2:44}` + +error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/issues/issue-77919.rs b/tests/ui/issues/issue-77919.rs index 3cbf493afb82f..bf603314977f9 100644 --- a/tests/ui/issues/issue-77919.rs +++ b/tests/ui/issues/issue-77919.rs @@ -10,3 +10,4 @@ struct Multiply { } impl TypeVal for Multiply where N: TypeVal {} //~^ ERROR cannot find type `VAL` in this scope +//~| ERROR not all trait items implemented diff --git a/tests/ui/issues/issue-77919.stderr b/tests/ui/issues/issue-77919.stderr index 9d2f859e05af6..dbbe70ff06990 100644 --- a/tests/ui/issues/issue-77919.stderr +++ b/tests/ui/issues/issue-77919.stderr @@ -20,6 +20,16 @@ help: you might be missing a type parameter LL | impl TypeVal for Multiply where N: TypeVal {} | +++++ -error: aborting due to 2 previous errors +error[E0046]: not all trait items implemented, missing: `VAL` + --> $DIR/issue-77919.rs:11:1 + | +LL | const VAL: T; + | ------------ `VAL` from trait +... +LL | impl TypeVal for Multiply where N: TypeVal {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `VAL` in implementation + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0412`. +Some errors have detailed explanations: E0046, E0412. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/layout/issue-84108.rs b/tests/ui/layout/issue-84108.rs index dd025c9b443f8..af21d1d6210b6 100644 --- a/tests/ui/layout/issue-84108.rs +++ b/tests/ui/layout/issue-84108.rs @@ -9,6 +9,8 @@ static FOO: (dyn AsRef, u8) = ("hello", 42); const BAR: (&Path, [u8], usize) = ("hello", [], 42); //~^ ERROR cannot find type `Path` in this scope //~| ERROR the size for values of type `[u8]` cannot be known at compilation time +//~| ERROR mismatched types static BAZ: ([u8], usize) = ([], 0); //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time +//~| ERROR mismatched types diff --git a/tests/ui/layout/issue-84108.stderr b/tests/ui/layout/issue-84108.stderr index 5ad450bed0781..3a02e73f96b78 100644 --- a/tests/ui/layout/issue-84108.stderr +++ b/tests/ui/layout/issue-84108.stderr @@ -30,7 +30,7 @@ LL | const BAR: (&Path, [u8], usize) = ("hello", [], 42); = note: only the last element of a tuple may have a dynamically sized type error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/issue-84108.rs:13:13 + --> $DIR/issue-84108.rs:14:13 | LL | static BAZ: ([u8], usize) = ([], 0); | ^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -38,7 +38,25 @@ LL | static BAZ: ([u8], usize) = ([], 0); = help: the trait `Sized` is not implemented for `[u8]` = note: only the last element of a tuple may have a dynamically sized type -error: aborting due to 4 previous errors +error[E0308]: mismatched types + --> $DIR/issue-84108.rs:9:45 + | +LL | const BAR: (&Path, [u8], usize) = ("hello", [], 42); + | ^^ expected `[u8]`, found `[_; 0]` + | + = note: expected slice `[u8]` + found array `[_; 0]` + +error[E0308]: mismatched types + --> $DIR/issue-84108.rs:14:30 + | +LL | static BAZ: ([u8], usize) = ([], 0); + | ^^ expected `[u8]`, found `[_; 0]` + | + = note: expected slice `[u8]` + found array `[_; 0]` + +error: aborting due to 6 previous errors -Some errors have detailed explanations: E0277, E0412. +Some errors have detailed explanations: E0277, E0308, E0412. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/proc-macro/bad-projection.rs b/tests/ui/proc-macro/bad-projection.rs index d214c7ac8b274..c7cffdc9b4794 100644 --- a/tests/ui/proc-macro/bad-projection.rs +++ b/tests/ui/proc-macro/bad-projection.rs @@ -13,3 +13,5 @@ trait Project { #[proc_macro] pub fn uwu() -> <() as Project>::Assoc {} //~^ ERROR the trait bound `(): Project` is not satisfied +//~| ERROR the trait bound `(): Project` is not satisfied +//~| ERROR function is expected to take 1 argument, but it takes 0 arguments diff --git a/tests/ui/proc-macro/bad-projection.stderr b/tests/ui/proc-macro/bad-projection.stderr index 8716defa17ae9..aea5d6d7c8439 100644 --- a/tests/ui/proc-macro/bad-projection.stderr +++ b/tests/ui/proc-macro/bad-projection.stderr @@ -10,6 +10,32 @@ help: this trait has no implementations, consider adding one LL | trait Project { | ^^^^^^^^^^^^^ -error: aborting due to previous error +error[E0593]: function is expected to take 1 argument, but it takes 0 arguments + --> $DIR/bad-projection.rs:14:1 + | +LL | pub fn uwu() -> <() as Project>::Assoc {} + | --------------------------------------^^^ + | | + | expected function that takes 1 argument + | takes 0 arguments + | required by a bound introduced by this call + | +note: required by a bound in `ProcMacro::bang` + --> $SRC_DIR/proc_macro/src/bridge/client.rs:LL:COL + +error[E0277]: the trait bound `(): Project` is not satisfied + --> $DIR/bad-projection.rs:14:1 + | +LL | pub fn uwu() -> <() as Project>::Assoc {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Project` is not implemented for `()` + | +help: this trait has no implementations, consider adding one + --> $DIR/bad-projection.rs:9:1 + | +LL | trait Project { + | ^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0277, E0593. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/simd/array-trait.rs b/tests/ui/simd/array-trait.rs index 45c10b3781604..883d718c49ba4 100644 --- a/tests/ui/simd/array-trait.rs +++ b/tests/ui/simd/array-trait.rs @@ -22,6 +22,7 @@ impl Simd for i32x4 { #[derive(Copy, Clone)] pub struct T([S::Lane; S::SIZE]); //~^ ERROR unconstrained generic constant +//~| ERROR SIMD vector element type should be a primitive scalar extern "platform-intrinsic" { fn simd_insert(x: T, idx: u32, y: E) -> T; diff --git a/tests/ui/simd/array-trait.stderr b/tests/ui/simd/array-trait.stderr index 765215c393977..cf6026912aaed 100644 --- a/tests/ui/simd/array-trait.stderr +++ b/tests/ui/simd/array-trait.stderr @@ -6,5 +6,12 @@ LL | pub struct T([S::Lane; S::SIZE]); | = help: try adding a `where` bound using this expression: `where [(); S::SIZE]:` -error: aborting due to previous error +error[E0077]: SIMD vector element type should be a primitive scalar (integer/float/pointer) type + --> $DIR/array-trait.rs:23:1 + | +LL | pub struct T([S::Lane; S::SIZE]); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0077`. diff --git a/tests/ui/specialization/min_specialization/issue-79224.rs b/tests/ui/specialization/min_specialization/issue-79224.rs index 104bddd076ec1..a118cb28b381a 100644 --- a/tests/ui/specialization/min_specialization/issue-79224.rs +++ b/tests/ui/specialization/min_specialization/issue-79224.rs @@ -19,6 +19,7 @@ impl Display for Cow<'_, B> { //~^ ERROR: the trait bound `B: Clone` is not satisfied [E0277] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { //~^ ERROR: the trait bound `B: Clone` is not satisfied [E0277] + //~| ERROR: the trait bound `B: Clone` is not satisfied [E0277] write!(f, "foo") } } diff --git a/tests/ui/specialization/min_specialization/issue-79224.stderr b/tests/ui/specialization/min_specialization/issue-79224.stderr index 9a4d557a152c6..7541579498e8a 100644 --- a/tests/ui/specialization/min_specialization/issue-79224.stderr +++ b/tests/ui/specialization/min_specialization/issue-79224.stderr @@ -22,6 +22,18 @@ help: consider further restricting this bound LL | impl Display for Cow<'_, B> { | +++++++++++++++++++ -error: aborting due to 2 previous errors +error[E0277]: the trait bound `B: Clone` is not satisfied + --> $DIR/issue-79224.rs:20:5 + | +LL | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `B` + | + = note: required for `B` to implement `ToOwned` +help: consider further restricting this bound + | +LL | impl Display for Cow<'_, B> { + | +++++++++++++++++++ + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/bound/on-structs-and-enums-static.rs b/tests/ui/traits/bound/on-structs-and-enums-static.rs index df3f8b8a59961..066416cb362a3 100644 --- a/tests/ui/traits/bound/on-structs-and-enums-static.rs +++ b/tests/ui/traits/bound/on-structs-and-enums-static.rs @@ -8,7 +8,7 @@ struct Foo { static X: Foo = Foo { //~^ ERROR E0277 - x: 1, + x: 1, //~ ERROR: E0277 }; fn main() { diff --git a/tests/ui/traits/bound/on-structs-and-enums-static.stderr b/tests/ui/traits/bound/on-structs-and-enums-static.stderr index fa14aff684d53..28bbe00c58218 100644 --- a/tests/ui/traits/bound/on-structs-and-enums-static.stderr +++ b/tests/ui/traits/bound/on-structs-and-enums-static.stderr @@ -15,6 +15,23 @@ note: required by a bound in `Foo` LL | struct Foo { | ^^^^^ required by this bound in `Foo` -error: aborting due to previous error +error[E0277]: the trait bound `usize: Trait` is not satisfied + --> $DIR/on-structs-and-enums-static.rs:11:8 + | +LL | x: 1, + | ^ the trait `Trait` is not implemented for `usize` + | +help: this trait has no implementations, consider adding one + --> $DIR/on-structs-and-enums-static.rs:1:1 + | +LL | trait Trait { + | ^^^^^^^^^^^ +note: required by a bound in `Foo` + --> $DIR/on-structs-and-enums-static.rs:5:14 + | +LL | struct Foo { + | ^^^^^ 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/tests/ui/traits/new-solver/specialization-transmute.rs b/tests/ui/traits/new-solver/specialization-transmute.rs index f6b19e7adf512..7523b8283215b 100644 --- a/tests/ui/traits/new-solver/specialization-transmute.rs +++ b/tests/ui/traits/new-solver/specialization-transmute.rs @@ -10,7 +10,7 @@ trait Default { } impl Default for T { - default type Id = T; + default type Id = T; //~ ERROR: type annotations needed // This will be fixed by #111994 fn intu(&self) -> &Self::Id { //~ ERROR type annotations needed self diff --git a/tests/ui/traits/new-solver/specialization-transmute.stderr b/tests/ui/traits/new-solver/specialization-transmute.stderr index 09b1405fefbf3..18965a465b3fa 100644 --- a/tests/ui/traits/new-solver/specialization-transmute.stderr +++ b/tests/ui/traits/new-solver/specialization-transmute.stderr @@ -16,6 +16,13 @@ LL | fn intu(&self) -> &Self::Id { | = note: cannot satisfy `::Id == _` -error: aborting due to previous error; 1 warning emitted +error[E0282]: type annotations needed + --> $DIR/specialization-transmute.rs:13:23 + | +LL | default type Id = T; + | ^ cannot infer type for associated type `::Id` + +error: aborting due to 2 previous errors; 1 warning emitted -For more information about this error, try `rustc --explain E0284`. +Some errors have detailed explanations: E0282, E0284. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/type-alias-impl-trait/generic_underconstrained.rs b/tests/ui/type-alias-impl-trait/generic_underconstrained.rs index d87a25aad5830..1acacc778de6c 100644 --- a/tests/ui/type-alias-impl-trait/generic_underconstrained.rs +++ b/tests/ui/type-alias-impl-trait/generic_underconstrained.rs @@ -8,5 +8,6 @@ type Underconstrained = impl Send; // no `Trait` bound fn underconstrain(_: T) -> Underconstrained { //~^ ERROR the trait bound `T: Trait` + //~| ERROR the trait bound `T: Trait` unimplemented!() } diff --git a/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr b/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr index bc9280127acca..88529b370f133 100644 --- a/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr +++ b/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr @@ -14,6 +14,27 @@ help: consider restricting type parameter `T` LL | fn underconstrain(_: T) -> Underconstrained { | +++++++ -error: aborting due to previous error +error[E0277]: the trait bound `T: Trait` is not satisfied + --> $DIR/generic_underconstrained.rs:9:51 + | +LL | fn underconstrain(_: T) -> Underconstrained { + | ___________________________________________________^ +LL | | +LL | | +LL | | unimplemented!() +LL | | } + | |_^ the trait `Trait` is not implemented for `T` + | +note: required by a bound on the type alias `Underconstrained` + --> $DIR/generic_underconstrained.rs:6:26 + | +LL | type Underconstrained = impl Send; + | ^^^^^ required by this bound +help: consider restricting type parameter `T` + | +LL | fn underconstrain(_: T) -> Underconstrained { + | +++++++ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/type-alias-impl-trait/generic_underconstrained2.rs b/tests/ui/type-alias-impl-trait/generic_underconstrained2.rs index 8adc0bf32a6aa..1e1bece9a1c0b 100644 --- a/tests/ui/type-alias-impl-trait/generic_underconstrained2.rs +++ b/tests/ui/type-alias-impl-trait/generic_underconstrained2.rs @@ -7,6 +7,7 @@ type Underconstrained = impl Send; // not a defining use, because it doesn't define *all* possible generics fn underconstrained(_: U) -> Underconstrained { //~^ ERROR `U` doesn't implement `Debug` + //~| ERROR `U` doesn't implement `Debug` 5u32 } @@ -15,5 +16,6 @@ type Underconstrained2 = impl Send; // not a defining use, because it doesn't define *all* possible generics fn underconstrained2(_: U, _: V) -> Underconstrained2 { //~^ ERROR `V` doesn't implement `Debug` + //~| ERROR `V` doesn't implement `Debug` 5u32 } diff --git a/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr b/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr index fdc9ec090dbee..b3b9cbca96854 100644 --- a/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr +++ b/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr @@ -15,13 +15,13 @@ LL | fn underconstrained(_: U) -> Underconstrained { | +++++++++++++++++ error[E0277]: `V` doesn't implement `Debug` - --> $DIR/generic_underconstrained2.rs:16:43 + --> $DIR/generic_underconstrained2.rs:17:43 | LL | fn underconstrained2(_: U, _: V) -> Underconstrained2 { | ^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `Debug` | note: required by a bound on the type alias `Underconstrained2` - --> $DIR/generic_underconstrained2.rs:13:27 + --> $DIR/generic_underconstrained2.rs:14:27 | LL | type Underconstrained2 = impl Send; | ^^^^^^^^^^^^^^^ required by this bound @@ -30,6 +30,48 @@ help: consider restricting type parameter `V` LL | fn underconstrained2(_: U, _: V) -> Underconstrained2 { | +++++++++++++++++ -error: aborting due to 2 previous errors +error[E0277]: `U` doesn't implement `Debug` + --> $DIR/generic_underconstrained2.rs:8:53 + | +LL | fn underconstrained(_: U) -> Underconstrained { + | _____________________________________________________^ +LL | | +LL | | +LL | | 5u32 +LL | | } + | |_^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | +note: required by a bound on the type alias `Underconstrained` + --> $DIR/generic_underconstrained2.rs:5:26 + | +LL | type Underconstrained = impl Send; + | ^^^^^^^^^^^^^^^ required by this bound +help: consider restricting type parameter `U` + | +LL | fn underconstrained(_: U) -> Underconstrained { + | +++++++++++++++++ + +error[E0277]: `V` doesn't implement `Debug` + --> $DIR/generic_underconstrained2.rs:17:64 + | +LL | fn underconstrained2(_: U, _: V) -> Underconstrained2 { + | ________________________________________________________________^ +LL | | +LL | | +LL | | 5u32 +LL | | } + | |_^ `V` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | +note: required by a bound on the type alias `Underconstrained2` + --> $DIR/generic_underconstrained2.rs:14:27 + | +LL | type Underconstrained2 = impl Send; + | ^^^^^^^^^^^^^^^ required by this bound +help: consider restricting type parameter `V` + | +LL | fn underconstrained2(_: U, _: V) -> Underconstrained2 { + | +++++++++++++++++ + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/ufcs/ufcs-explicit-self-bad.rs b/tests/ui/ufcs/ufcs-explicit-self-bad.rs index cb1fac0bae6ae..9b0f99a189a76 100644 --- a/tests/ui/ufcs/ufcs-explicit-self-bad.rs +++ b/tests/ui/ufcs/ufcs-explicit-self-bad.rs @@ -36,6 +36,7 @@ impl<'a, T> SomeTrait for &'a Bar { fn dummy1(self: &&'a Bar) { } fn dummy2(self: &Bar) {} //~ ERROR mismatched `self` parameter type //~^ ERROR mismatched `self` parameter type + //~| ERROR has an incompatible type for trait fn dummy3(self: &&Bar) {} //~^ ERROR mismatched `self` parameter type //~| expected reference `&'a Bar` diff --git a/tests/ui/ufcs/ufcs-explicit-self-bad.stderr b/tests/ui/ufcs/ufcs-explicit-self-bad.stderr index f325d1d8182f1..0efaa41d48a1c 100644 --- a/tests/ui/ufcs/ufcs-explicit-self-bad.stderr +++ b/tests/ui/ufcs/ufcs-explicit-self-bad.stderr @@ -64,7 +64,7 @@ LL | fn dummy2(self: &Bar) {} | ^^^^^^^ error[E0308]: mismatched `self` parameter type - --> $DIR/ufcs-explicit-self-bad.rs:39:21 + --> $DIR/ufcs-explicit-self-bad.rs:40:21 | LL | fn dummy3(self: &&Bar) {} | ^^^^^^^^ lifetime mismatch @@ -72,7 +72,7 @@ LL | fn dummy3(self: &&Bar) {} = note: expected reference `&'a Bar` found reference `&Bar` note: the anonymous lifetime defined here... - --> $DIR/ufcs-explicit-self-bad.rs:39:22 + --> $DIR/ufcs-explicit-self-bad.rs:40:22 | LL | fn dummy3(self: &&Bar) {} | ^^^^^^^ @@ -83,7 +83,7 @@ LL | impl<'a, T> SomeTrait for &'a Bar { | ^^ error[E0308]: mismatched `self` parameter type - --> $DIR/ufcs-explicit-self-bad.rs:39:21 + --> $DIR/ufcs-explicit-self-bad.rs:40:21 | LL | fn dummy3(self: &&Bar) {} | ^^^^^^^^ lifetime mismatch @@ -96,12 +96,29 @@ note: the lifetime `'a` as defined here... LL | impl<'a, T> SomeTrait for &'a Bar { | ^^ note: ...does not necessarily outlive the anonymous lifetime defined here - --> $DIR/ufcs-explicit-self-bad.rs:39:22 + --> $DIR/ufcs-explicit-self-bad.rs:40:22 | LL | fn dummy3(self: &&Bar) {} | ^^^^^^^ -error: aborting due to 7 previous errors +error[E0053]: method `dummy2` has an incompatible type for trait + --> $DIR/ufcs-explicit-self-bad.rs:37:21 + | +LL | fn dummy2(self: &Bar) {} + | ------^^^^^^^ + | | | + | | expected `&'a Bar`, found `Bar` + | help: change the self-receiver type to match the trait: `&self` + | +note: type in trait + --> $DIR/ufcs-explicit-self-bad.rs:31:15 + | +LL | fn dummy2(&self); + | ^^^^^ + = note: expected signature `fn(&&'a Bar)` + found signature `fn(&Bar)` + +error: aborting due to 8 previous errors -Some errors have detailed explanations: E0307, E0308. -For more information about an error, try `rustc --explain E0307`. +Some errors have detailed explanations: E0053, E0307, E0308. +For more information about an error, try `rustc --explain E0053`. diff --git a/tests/ui/union/issue-81199.rs b/tests/ui/union/issue-81199.rs index 628e7c6ed5da8..b8b0d9d33e791 100644 --- a/tests/ui/union/issue-81199.rs +++ b/tests/ui/union/issue-81199.rs @@ -4,6 +4,7 @@ union PtrRepr { mut_ptr: *mut T, components: PtrComponents, //~^ ERROR the trait bound + //~| ERROR field must implement `Copy` } #[repr(C)] diff --git a/tests/ui/union/issue-81199.stderr b/tests/ui/union/issue-81199.stderr index 5bb98675361a0..0dd894beb2a46 100644 --- a/tests/ui/union/issue-81199.stderr +++ b/tests/ui/union/issue-81199.stderr @@ -5,7 +5,7 @@ LL | components: PtrComponents, | ^^^^^^^^^^^^^^^^ the trait `Pointee` is not implemented for `T` | note: required by a bound in `PtrComponents` - --> $DIR/issue-81199.rs:10:25 + --> $DIR/issue-81199.rs:11:25 | LL | struct PtrComponents { | ^^^^^^^ required by this bound in `PtrComponents` @@ -14,6 +14,19 @@ help: consider further restricting this bound LL | union PtrRepr { | +++++++++ -error: aborting due to previous error +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union + --> $DIR/issue-81199.rs:5:5 + | +LL | components: PtrComponents, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` + | +LL | components: std::mem::ManuallyDrop>, + | +++++++++++++++++++++++ + + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0277, E0740. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/union/union-unsized.mirunsafeck.stderr b/tests/ui/union/union-unsized.mirunsafeck.stderr index 59ab835fba22d..f8da20413b2ac 100644 --- a/tests/ui/union/union-unsized.mirunsafeck.stderr +++ b/tests/ui/union/union-unsized.mirunsafeck.stderr @@ -17,7 +17,7 @@ LL | a: Box, | ++++ + error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/union-unsized.rs:13:8 + --> $DIR/union-unsized.rs:14:8 | LL | b: str, | ^^^ doesn't have a size known at compile-time @@ -34,6 +34,31 @@ help: the `Box` type always has a statically known size and allocates its conten LL | b: Box, | ++++ + -error: aborting due to 2 previous errors +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union + --> $DIR/union-unsized.rs:5:5 + | +LL | a: str, + | ^^^^^^ + | + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` + | +LL | a: std::mem::ManuallyDrop, + | +++++++++++++++++++++++ + + +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union + --> $DIR/union-unsized.rs:14:5 + | +LL | b: str, + | ^^^^^^ + | + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` + | +LL | b: std::mem::ManuallyDrop, + | +++++++++++++++++++++++ + + +error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0277, E0740. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/union/union-unsized.rs b/tests/ui/union/union-unsized.rs index 8e897d7d3c6d6..b95b2e414f39a 100644 --- a/tests/ui/union/union-unsized.rs +++ b/tests/ui/union/union-unsized.rs @@ -4,6 +4,7 @@ union U { a: str, //~^ ERROR the size for values of type + //~| ERROR field must implement `Copy` b: u8, } @@ -12,6 +13,7 @@ union W { a: u8, b: str, //~^ ERROR the size for values of type + //~| ERROR field must implement `Copy` } fn main() {} diff --git a/tests/ui/union/union-unsized.thirunsafeck.stderr b/tests/ui/union/union-unsized.thirunsafeck.stderr index 59ab835fba22d..f8da20413b2ac 100644 --- a/tests/ui/union/union-unsized.thirunsafeck.stderr +++ b/tests/ui/union/union-unsized.thirunsafeck.stderr @@ -17,7 +17,7 @@ LL | a: Box, | ++++ + error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/union-unsized.rs:13:8 + --> $DIR/union-unsized.rs:14:8 | LL | b: str, | ^^^ doesn't have a size known at compile-time @@ -34,6 +34,31 @@ help: the `Box` type always has a statically known size and allocates its conten LL | b: Box, | ++++ + -error: aborting due to 2 previous errors +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union + --> $DIR/union-unsized.rs:5:5 + | +LL | a: str, + | ^^^^^^ + | + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` + | +LL | a: std::mem::ManuallyDrop, + | +++++++++++++++++++++++ + + +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union + --> $DIR/union-unsized.rs:14:5 + | +LL | b: str, + | ^^^^^^ + | + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` + | +LL | b: std::mem::ManuallyDrop, + | +++++++++++++++++++++++ + + +error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0277, E0740. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized/unsized-trait-impl-self-type.rs b/tests/ui/unsized/unsized-trait-impl-self-type.rs index df571a83382c0..603c0a221ec02 100644 --- a/tests/ui/unsized/unsized-trait-impl-self-type.rs +++ b/tests/ui/unsized/unsized-trait-impl-self-type.rs @@ -9,6 +9,7 @@ struct S5(Y); impl T3 for S5 { //~^ ERROR the size for values of type + //~| ERROR not all trait items implemented } fn main() { } diff --git a/tests/ui/unsized/unsized-trait-impl-self-type.stderr b/tests/ui/unsized/unsized-trait-impl-self-type.stderr index 4955d463fc26f..5bc8dc590cacb 100644 --- a/tests/ui/unsized/unsized-trait-impl-self-type.stderr +++ b/tests/ui/unsized/unsized-trait-impl-self-type.stderr @@ -24,6 +24,16 @@ LL - impl T3 for S5 { LL + impl T3 for S5 { | -error: aborting due to previous error +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/unsized-trait-impl-self-type.rs:10:1 + | +LL | fn foo(&self, z: &Z); + | --------------------- `foo` from trait +... +LL | impl T3 for S5 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0046, E0277. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/unsized/unsized-trait-impl-trait-arg.rs b/tests/ui/unsized/unsized-trait-impl-trait-arg.rs index 96e7e371f2aa4..e7602b175c89b 100644 --- a/tests/ui/unsized/unsized-trait-impl-trait-arg.rs +++ b/tests/ui/unsized/unsized-trait-impl-trait-arg.rs @@ -7,6 +7,7 @@ trait T2 { struct S4(Box); impl T2 for S4 { //~^ ERROR the size for values of type + //~| ERROR not all trait items implemented } fn main() { } diff --git a/tests/ui/unsized/unsized-trait-impl-trait-arg.stderr b/tests/ui/unsized/unsized-trait-impl-trait-arg.stderr index 8761c293af465..e9353d2bbd94a 100644 --- a/tests/ui/unsized/unsized-trait-impl-trait-arg.stderr +++ b/tests/ui/unsized/unsized-trait-impl-trait-arg.stderr @@ -21,6 +21,16 @@ help: consider relaxing the implicit `Sized` restriction LL | trait T2 { | ++++++++ -error: aborting due to previous error +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/unsized-trait-impl-trait-arg.rs:8:1 + | +LL | fn foo(&self, z: Z); + | -------------------- `foo` from trait +... +LL | impl T2 for S4 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0046, E0277. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/unsized/unsized7.rs b/tests/ui/unsized/unsized7.rs index 422a784814e91..63e015c28d378 100644 --- a/tests/ui/unsized/unsized7.rs +++ b/tests/ui/unsized/unsized7.rs @@ -11,6 +11,7 @@ trait T1 { struct S3(Box); impl T1 for S3 { //~^ ERROR the size for values of type + //~| ERROR not all trait items implemented } fn main() { } diff --git a/tests/ui/unsized/unsized7.stderr b/tests/ui/unsized/unsized7.stderr index c313a2724c038..2edde15965343 100644 --- a/tests/ui/unsized/unsized7.stderr +++ b/tests/ui/unsized/unsized7.stderr @@ -21,6 +21,16 @@ help: consider relaxing the implicit `Sized` restriction LL | trait T1 { | ++++++++ -error: aborting due to previous error +error[E0046]: not all trait items implemented, missing: `dummy` + --> $DIR/unsized7.rs:12:1 + | +LL | fn dummy(&self) -> Z; + | --------------------- `dummy` from trait +... +LL | impl T1 for S3 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `dummy` in implementation + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0046, E0277. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/wf/hir-wf-check-erase-regions.rs b/tests/ui/wf/hir-wf-check-erase-regions.rs index 3855f2c35c1fb..2820d5f6d0744 100644 --- a/tests/ui/wf/hir-wf-check-erase-regions.rs +++ b/tests/ui/wf/hir-wf-check-erase-regions.rs @@ -5,6 +5,7 @@ pub struct Table([Option; N]); impl<'a, T, const N: usize> IntoIterator for &'a Table { type IntoIter = std::iter::Flatten>; //~ ERROR `&'a T` is not an iterator + //~^ ERROR `&'a T` is not an iterator type Item = &'a T; fn into_iter(self) -> Self::IntoIter { //~ ERROR `&'a T` is not an iterator diff --git a/tests/ui/wf/hir-wf-check-erase-regions.stderr b/tests/ui/wf/hir-wf-check-erase-regions.stderr index 2843983c716a6..eb0a8f8f69a25 100644 --- a/tests/ui/wf/hir-wf-check-erase-regions.stderr +++ b/tests/ui/wf/hir-wf-check-erase-regions.stderr @@ -11,7 +11,7 @@ note: required by a bound in `Flatten` --> $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL error[E0277]: `&'a T` is not an iterator - --> $DIR/hir-wf-check-erase-regions.rs:10:27 + --> $DIR/hir-wf-check-erase-regions.rs:11:27 | LL | fn into_iter(self) -> Self::IntoIter { | ^^^^^^^^^^^^^^ `&'a T` is not an iterator @@ -22,6 +22,18 @@ LL | fn into_iter(self) -> Self::IntoIter { note: required by a bound in `Flatten` --> $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL -error: aborting due to 2 previous errors +error[E0277]: `&'a T` is not an iterator + --> $DIR/hir-wf-check-erase-regions.rs:7:21 + | +LL | type IntoIter = std::iter::Flatten>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `&'a T` is not an iterator + | + = help: the trait `Iterator` is not implemented for `&'a T` + = help: the trait `Iterator` is implemented for `&mut I` + = note: required for `Flatten>` to implement `Iterator` +note: required by a bound in `std::iter::IntoIterator::IntoIter` + --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/wf/issue-110157.rs b/tests/ui/wf/issue-110157.rs index 43a8ce72ff1bc..07e2c5d58c340 100644 --- a/tests/ui/wf/issue-110157.rs +++ b/tests/ui/wf/issue-110157.rs @@ -2,6 +2,7 @@ struct NeedsDropTypes<'tcx, F>(std::marker::PhantomData<&'tcx F>); impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F> //~^ ERROR type annotations needed +//~| ERROR not all trait items implemented where F: Fn(&Missing) -> Result, //~^ ERROR cannot find type `Missing` in this scope diff --git a/tests/ui/wf/issue-110157.stderr b/tests/ui/wf/issue-110157.stderr index 91d801e9470ee..16bd34a6d8e44 100644 --- a/tests/ui/wf/issue-110157.stderr +++ b/tests/ui/wf/issue-110157.stderr @@ -1,11 +1,11 @@ error[E0412]: cannot find type `Missing` in this scope - --> $DIR/issue-110157.rs:6:12 + --> $DIR/issue-110157.rs:7:12 | LL | F: Fn(&Missing) -> Result, | ^^^^^^^ not found in this scope error[E0412]: cannot find type `Missing` in this scope - --> $DIR/issue-110157.rs:8:24 + --> $DIR/issue-110157.rs:9:24 | LL | I: Iterator, | ^^^^^^^ not found in this scope @@ -26,7 +26,22 @@ LL | impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F> LL | I: Iterator, | ------------------------ unsatisfied trait bound introduced here -error: aborting due to 3 previous errors +error[E0046]: not all trait items implemented, missing: `Item`, `next` + --> $DIR/issue-110157.rs:3:1 + | +LL | / impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F> +LL | | +LL | | +LL | | where +LL | | F: Fn(&Missing) -> Result, +LL | | +LL | | I: Iterator, + | |________________________________^ missing `Item`, `next` in implementation + | + = help: implement the missing item: `type Item = /* Type */;` + = help: implement the missing item: `fn next(&mut self) -> Option<::Item> { todo!() }` + +error: aborting due to 4 previous errors -Some errors have detailed explanations: E0283, E0412. -For more information about an error, try `rustc --explain E0283`. +Some errors have detailed explanations: E0046, E0283, E0412. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/wf/wf-const-type.rs b/tests/ui/wf/wf-const-type.rs index df79aa26712d1..64b0d9c8de797 100644 --- a/tests/ui/wf/wf-const-type.rs +++ b/tests/ui/wf/wf-const-type.rs @@ -9,6 +9,7 @@ struct NotCopy; const FOO: IsCopy> = IsCopy { t: None }; //~^ ERROR E0277 +//~| ERROR E0277 fn main() { } diff --git a/tests/ui/wf/wf-const-type.stderr b/tests/ui/wf/wf-const-type.stderr index 617969720a60a..039e907705ee6 100644 --- a/tests/ui/wf/wf-const-type.stderr +++ b/tests/ui/wf/wf-const-type.stderr @@ -16,6 +16,24 @@ LL + #[derive(Copy)] LL | struct NotCopy; | -error: aborting due to previous error +error[E0277]: the trait bound `NotCopy: Copy` is not satisfied + --> $DIR/wf-const-type.rs:10:50 + | +LL | const FOO: IsCopy> = IsCopy { t: None }; + | ^^^^ the trait `Copy` is not implemented for `NotCopy` + | + = note: required for `Option` to implement `Copy` +note: required by a bound in `IsCopy` + --> $DIR/wf-const-type.rs:7:17 + | +LL | struct IsCopy { t: T } + | ^^^^ required by this bound in `IsCopy` +help: consider annotating `NotCopy` with `#[derive(Copy)]` + | +LL + #[derive(Copy)] +LL | struct NotCopy; + | + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/wf/wf-static-type.rs b/tests/ui/wf/wf-static-type.rs index 1c35e1daf4499..f454fe30e7750 100644 --- a/tests/ui/wf/wf-static-type.rs +++ b/tests/ui/wf/wf-static-type.rs @@ -9,6 +9,7 @@ struct NotCopy; static FOO: IsCopy> = IsCopy { t: None }; //~^ ERROR E0277 +//~| ERROR E0277 fn main() { } diff --git a/tests/ui/wf/wf-static-type.stderr b/tests/ui/wf/wf-static-type.stderr index bb5a57834ebd2..65dae26014375 100644 --- a/tests/ui/wf/wf-static-type.stderr +++ b/tests/ui/wf/wf-static-type.stderr @@ -16,6 +16,24 @@ LL + #[derive(Copy)] LL | struct NotCopy; | -error: aborting due to previous error +error[E0277]: the trait bound `NotCopy: Copy` is not satisfied + --> $DIR/wf-static-type.rs:10:51 + | +LL | static FOO: IsCopy> = IsCopy { t: None }; + | ^^^^ the trait `Copy` is not implemented for `NotCopy` + | + = note: required for `Option` to implement `Copy` +note: required by a bound in `IsCopy` + --> $DIR/wf-static-type.rs:7:17 + | +LL | struct IsCopy { t: T } + | ^^^^ required by this bound in `IsCopy` +help: consider annotating `NotCopy` with `#[derive(Copy)]` + | +LL + #[derive(Copy)] +LL | struct NotCopy; + | + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. From 32339f8e806c565c8411bc9e25d37ea027153541 Mon Sep 17 00:00:00 2001 From: dirreke Date: Wed, 25 Oct 2023 20:47:06 +0800 Subject: [PATCH 08/10] implement C ABI lowering for CSKY --- compiler/rustc_target/src/abi/call/csky.rs | 38 +++++++++++++++---- .../csky-unknown-linux-gnuabiv2.md | 10 ++++- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_target/src/abi/call/csky.rs b/compiler/rustc_target/src/abi/call/csky.rs index bbe95fa20ac55..706493b0a6a69 100644 --- a/compiler/rustc_target/src/abi/call/csky.rs +++ b/compiler/rustc_target/src/abi/call/csky.rs @@ -1,17 +1,39 @@ -// See /~https://github.com/llvm/llvm-project/blob/d85b94bf0080dcd780656c0f5e6342800720eba9/llvm/lib/Target/CSKY/CSKYCallingConv.td -use crate::abi::call::{ArgAbi, FnAbi}; +// Reference: CSKY ABI Manual +// https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1695027452256/T-HEAD_800_Series_ABI_Standards_Manual.pdf +// +// Reference: Clang CSKY lowering code +// /~https://github.com/llvm/llvm-project/blob/4a074f32a6914f2a8d7215d78758c24942dddc3d/clang/lib/CodeGen/Targets/CSKY.cpp#L76-L162 -fn classify_ret(ret: &mut ArgAbi<'_, Ty>) { - if ret.layout.is_aggregate() || ret.layout.size.bits() > 64 { - ret.make_indirect(); +use crate::abi::call::{ArgAbi, FnAbi, Reg, Uniform}; + +fn classify_ret(arg: &mut ArgAbi<'_, Ty>) { + // For return type, aggregate which <= 2*XLen will be returned in registers. + // Otherwise, aggregate will be returned indirectly. + if arg.layout.is_aggregate() { + let total = arg.layout.size; + if total.bits() > 64 { + arg.make_indirect(); + } else if total.bits() > 32 { + arg.cast_to(Uniform { unit: Reg::i32(), total }); + } else { + arg.cast_to(Reg::i32()); + } } else { - ret.extend_integer_width_to(32); + arg.extend_integer_width_to(32); } } fn classify_arg(arg: &mut ArgAbi<'_, Ty>) { - if arg.layout.is_aggregate() || arg.layout.size.bits() > 64 { - arg.make_indirect(); + // For argument type, the first 4*XLen parts of aggregate will be passed + // in registers, and the rest will be passed in stack. + // So we can coerce to integers directly and let backend handle it correctly. + if arg.layout.is_aggregate() { + let total = arg.layout.size; + if total.bits() > 32 { + arg.cast_to(Uniform { unit: Reg::i32(), total }); + } else { + arg.cast_to(Reg::i32()); + } } else { arg.extend_integer_width_to(32); } diff --git a/src/doc/rustc/src/platform-support/csky-unknown-linux-gnuabiv2.md b/src/doc/rustc/src/platform-support/csky-unknown-linux-gnuabiv2.md index 57c717c182de4..a54abcb606ea7 100644 --- a/src/doc/rustc/src/platform-support/csky-unknown-linux-gnuabiv2.md +++ b/src/doc/rustc/src/platform-support/csky-unknown-linux-gnuabiv2.md @@ -10,9 +10,15 @@ target | std | host | notes `csky-unknown-linux-gnuabiv2hf` | ✓ | | C-SKY abiv2 Linux, hardfloat (little endian) Reference: -https://c-sky.github.io/ -https://gitlab.com/c-sky/ +- [CSKY ABI Manual](https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1695027452256/T-HEAD_800_Series_ABI_Standards_Manual.pdf) +- [csky-linux-gnuabiv2-toolchain](https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource/1356021/1619528643136/csky-linux-gnuabiv2-tools-x86_64-glibc-linux-4.9.56-20210423.tar.gz) +- [csky-linux-gnuabiv2-qemu](https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1689324918932/xuantie-qemu-x86_64-Ubuntu-18.04-20230714-0202.tar.gz) + +other links: + +- https://c-sky.github.io/ +- https://gitlab.com/c-sky/ ## Target maintainers From a9fad1c357b8d9d1f2fb04b8906c326adb462898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Wed, 25 Oct 2023 00:00:00 +0000 Subject: [PATCH 09/10] compiletest: Display compilation errors in mir-opt tests --- src/tools/compiletest/src/runtest.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index ac270a1f0ba4d..87d0404e7d821 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -3999,10 +3999,10 @@ impl<'test> TestCx<'test> { let passes = std::mem::take(&mut test_info.passes); let proc_res = self.compile_test_with_passes(should_run, Emit::Mir, passes); - self.check_mir_dump(test_info); if !proc_res.status.success() { self.fatal_proc_rec("compilation failed!", &proc_res); } + self.check_mir_dump(test_info); if let WillExecute::Yes = should_run { let proc_res = self.exec_compiled_test(); From 268ec72839a2152c012bac9418f2c041e13d1aab Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 23 Oct 2023 09:41:30 +0000 Subject: [PATCH 10/10] Make `Iterator` a lang item --- compiler/rustc_hir/src/lang_items.rs | 1 + compiler/rustc_interface/src/passes.rs | 5 +++++ compiler/rustc_span/src/symbol.rs | 1 + library/core/src/iter/traits/iterator.rs | 1 + 4 files changed, 8 insertions(+) diff --git a/compiler/rustc_hir/src/lang_items.rs b/compiler/rustc_hir/src/lang_items.rs index cdfc67d5740f6..c8ac95e29949b 100644 --- a/compiler/rustc_hir/src/lang_items.rs +++ b/compiler/rustc_hir/src/lang_items.rs @@ -210,6 +210,7 @@ language_item_table! { FnOnceOutput, sym::fn_once_output, fn_once_output, Target::AssocTy, GenericRequirement::None; + Iterator, sym::iterator, iterator_trait, Target::Trait, GenericRequirement::Exact(0); Future, sym::future_trait, future_trait, Target::Trait, GenericRequirement::Exact(0); CoroutineState, sym::coroutine_state, gen_state, Target::Enum, GenericRequirement::None; Coroutine, sym::coroutine, gen_trait, Target::Trait, GenericRequirement::Minimum(1); diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 998e2686005fd..884afae23d803 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -856,6 +856,11 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> { // This check has to be run after all lints are done processing. We don't // define a lint filter, as all lint checks should have finished at this point. sess.time("check_lint_expectations", || tcx.ensure().check_expectations(None)); + + // This query is only invoked normally if a diagnostic is emitted that needs any + // diagnostic item. If the crate compiles without checking any diagnostic items, + // we will fail to emit overlap diagnostics. Thus we invoke it here unconditionally. + let _ = tcx.all_diagnostic_items(()); }); if sess.opts.unstable_opts.print_vtable_sizes { diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index d3205f8eca12a..ff61143a12ba2 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -910,6 +910,7 @@ symbols! { iter, iter_mut, iter_repeat, + iterator, iterator_collect_fn, kcfi, keyword, diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index c7ace58afa866..166d04e078d90 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -69,6 +69,7 @@ fn _assert_is_object_safe(_: &dyn Iterator) {} message = "`{Self}` is not an iterator" )] #[doc(notable_trait)] +#[cfg_attr(not(bootstrap), lang = "iterator")] #[rustc_diagnostic_item = "Iterator"] #[must_use = "iterators are lazy and do nothing unless consumed"] pub trait Iterator {