1
Fork 0

Auto merge of #117180 - matthiaskrgr:rollup-rxhl6ep, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #117111 (Remove support for alias `-Z instrument-coverage`)
 - #117141 (Require target features to match exactly during inlining)
 - #117152 (Fix unwrap suggestion for async fn)
 - #117154 (implement C ABI lowering for CSKY)
 - #117159 (Work around the fact that `check_mod_type_wf` may spuriously return `ErrorGuaranteed`)
 - #117163 (compiletest: Display compilation errors in mir-opt tests)
 - #117173 (Make `Iterator` a lang item)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2023-10-25 19:29:58 +00:00
commit ab5c841a1f
95 changed files with 842 additions and 380 deletions

View file

@ -210,6 +210,7 @@ language_item_table! {
FnOnceOutput, sym::fn_once_output, fn_once_output, Target::AssocTy, GenericRequirement::None; 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); Future, sym::future_trait, future_trait, Target::Trait, GenericRequirement::Exact(0);
CoroutineState, sym::coroutine_state, gen_state, Target::Enum, GenericRequirement::None; CoroutineState, sym::coroutine_state, gen_state, Target::Enum, GenericRequirement::None;
Coroutine, sym::coroutine, gen_trait, Target::Trait, GenericRequirement::Minimum(1); Coroutine, sym::coroutine, gen_trait, Target::Trait, GenericRequirement::Minimum(1);

View file

@ -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); let param_env = tcx.param_env(item_def_id);
for field in &def.non_enum_variant().fields { 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) { if !allowed_union_field(field_ty, tcx, param_env) {
let (field_span, ty_span) = match tcx.hir().get_if_local(field.did) { let (field_span, ty_span) = match tcx.hir().get_if_local(field.did) {

View file

@ -202,15 +202,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)) 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. // NOTE: This is copy/pasted in librustdoc/core.rs and should be kept in sync.
tcx.sess.time("item_types_checking", || { tcx.sess.time("item_types_checking", || {
tcx.hir().for_each_module(|module| tcx.ensure().check_mod_item_types(module)) 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 { if tcx.features().rustc_attrs {
tcx.sess.track_errors(|| collect::test_opaque_hidden_types(tcx))?; tcx.sess.track_errors(|| collect::test_opaque_hidden_types(tcx))?;
} }

View file

@ -1747,19 +1747,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
expected: Ty<'tcx>, expected: Ty<'tcx>,
found: Ty<'tcx>, found: Ty<'tcx>,
) -> bool { ) -> 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| { let ret_ty_matches = |diagnostic_item| {
if let Some(ret_ty) = self let Some(sig) = self.body_fn_sig() else {
.ret_coercion return false;
.as_ref() };
.map(|c| self.resolve_vars_if_possible(c.borrow().expected_ty())) let ty::Adt(kind, _) = sig.output().kind() else {
&& let ty::Adt(kind, _) = ret_ty.kind() return false;
&& self.tcx.get_diagnostic_item(diagnostic_item) == Some(kind.did()) };
{ self.tcx.is_diagnostic_item(diagnostic_item, kind.did())
true
} else {
false
}
}; };
// don't suggest anything like `Ok(ok_val).unwrap()` , `Some(some_val).unwrap()`, // don't suggest anything like `Ok(ok_val).unwrap()` , `Some(some_val).unwrap()`,

View file

@ -856,6 +856,11 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
// This check has to be run after all lints are done processing. We don't // 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. // define a lint filter, as all lint checks should have finished at this point.
sess.time("check_lint_expectations", || tcx.ensure().check_expectations(None)); 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 { if sess.opts.unstable_opts.print_vtable_sizes {

View file

@ -789,7 +789,6 @@ fn test_unstable_options_tracking_hash() {
tracked!(inline_mir, Some(true)); tracked!(inline_mir, Some(true));
tracked!(inline_mir_hint_threshold, Some(123)); tracked!(inline_mir_hint_threshold, Some(123));
tracked!(inline_mir_threshold, Some(123)); tracked!(inline_mir_threshold, Some(123));
tracked!(instrument_coverage, Some(InstrumentCoverage::All));
tracked!(instrument_mcount, true); tracked!(instrument_mcount, true);
tracked!(instrument_xray, Some(InstrumentXRay::default())); tracked!(instrument_xray, Some(InstrumentXRay::default()));
tracked!(link_directives, false); tracked!(link_directives, false);

View file

@ -438,10 +438,8 @@ impl<'tcx> Inliner<'tcx> {
return Err("incompatible instruction set"); return Err("incompatible instruction set");
} }
for feature in &callee_attrs.target_features { if callee_attrs.target_features != self.codegen_fn_attrs.target_features {
if !self.codegen_fn_attrs.target_features.contains(feature) { return Err("incompatible target features");
return Err("incompatible target feature");
}
} }
Ok(()) Ok(())

View file

@ -2739,29 +2739,24 @@ pub fn build_session_options(
_ => {} _ => {}
} }
// Handle both `-Z instrument-coverage` and `-C instrument-coverage`; the latter takes // Check for unstable values of `-C instrument-coverage`.
// precedence. // This is what prevents them from being used on stable compilers.
match (cg.instrument_coverage, unstable_opts.instrument_coverage) { match cg.instrument_coverage {
(Some(ic_c), Some(ic_z)) if ic_c != ic_z => { // Stable values:
handler.early_error( Some(InstrumentCoverage::All | InstrumentCoverage::Off) | None => {}
"incompatible values passed for `-C instrument-coverage` \ // Unstable values:
and `-Z instrument-coverage`", 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`",
);
}
} }
(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;
}
_ => {}
} }
if cg.instrument_coverage.is_some() && cg.instrument_coverage != Some(InstrumentCoverage::Off) { if cg.instrument_coverage.is_some() && cg.instrument_coverage != Some(InstrumentCoverage::Off) {

View file

@ -1593,16 +1593,6 @@ options! {
"a default MIR inlining threshold (default: 50)"), "a default MIR inlining threshold (default: 50)"),
input_stats: bool = (false, parse_bool, [UNTRACKED], input_stats: bool = (false, parse_bool, [UNTRACKED],
"gather statistics about the input (default: no)"), "gather statistics about the input (default: no)"),
#[rustc_lint_opt_deny_field_access("use `Session::instrument_coverage` instead of this field")]
instrument_coverage: Option<InstrumentCoverage> = (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], instrument_mcount: bool = (false, parse_bool, [TRACKED],
"insert function instrument code for mcount-based tracing (default: no)"), "insert function instrument code for mcount-based tracing (default: no)"),
instrument_xray: Option<InstrumentXRay> = (None, parse_instrument_xray, [TRACKED], instrument_xray: Option<InstrumentXRay> = (None, parse_instrument_xray, [TRACKED],

View file

@ -910,6 +910,7 @@ symbols! {
iter, iter,
iter_mut, iter_mut,
iter_repeat, iter_repeat,
iterator,
iterator_collect_fn, iterator_collect_fn,
kcfi, kcfi,
keyword, keyword,

View file

@ -1,17 +1,39 @@
// See https://github.com/llvm/llvm-project/blob/d85b94bf0080dcd780656c0f5e6342800720eba9/llvm/lib/Target/CSKY/CSKYCallingConv.td // Reference: CSKY ABI Manual
use crate::abi::call::{ArgAbi, FnAbi}; // 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<Ty>(ret: &mut ArgAbi<'_, Ty>) { use crate::abi::call::{ArgAbi, FnAbi, Reg, Uniform};
if ret.layout.is_aggregate() || ret.layout.size.bits() > 64 {
ret.make_indirect(); fn classify_ret<Ty>(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 { } else {
ret.extend_integer_width_to(32); arg.extend_integer_width_to(32);
} }
} }
fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) { fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) {
if arg.layout.is_aggregate() || arg.layout.size.bits() > 64 { // For argument type, the first 4*XLen parts of aggregate will be passed
arg.make_indirect(); // 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 { } else {
arg.extend_integer_width_to(32); arg.extend_integer_width_to(32);
} }

View file

@ -69,6 +69,7 @@ fn _assert_is_object_safe(_: &dyn Iterator<Item = ()>) {}
message = "`{Self}` is not an iterator" message = "`{Self}` is not an iterator"
)] )]
#[doc(notable_trait)] #[doc(notable_trait)]
#[cfg_attr(not(bootstrap), lang = "iterator")]
#[rustc_diagnostic_item = "Iterator"] #[rustc_diagnostic_item = "Iterator"]
#[must_use = "iterators are lazy and do nothing unless consumed"] #[must_use = "iterators are lazy and do nothing unless consumed"]
pub trait Iterator { pub trait Iterator {

View file

@ -10,9 +10,15 @@ target | std | host | notes
`csky-unknown-linux-gnuabiv2hf` | ✓ | | C-SKY abiv2 Linux, hardfloat (little endian) `csky-unknown-linux-gnuabiv2hf` | ✓ | | C-SKY abiv2 Linux, hardfloat (little endian)
Reference: 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 ## Target maintainers

View file

@ -24,6 +24,16 @@ help: you might be missing a type parameter
LL | impl<N, M, VAL> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {} LL | impl<N, M, VAL> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
| +++++ | +++++
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<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `VAL` in implementation
For more information about this error, try `rustc --explain E0412`. error: aborting due to 3 previous errors
Some errors have detailed explanations: E0046, E0412.
For more information about an error, try `rustc --explain E0046`.

View file

@ -3999,10 +3999,10 @@ impl<'test> TestCx<'test> {
let passes = std::mem::take(&mut test_info.passes); let passes = std::mem::take(&mut test_info.passes);
let proc_res = self.compile_test_with_passes(should_run, Emit::Mir, 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() { if !proc_res.status.success() {
self.fatal_proc_rec("compilation failed!", &proc_res); self.fatal_proc_rec("compilation failed!", &proc_res);
} }
self.check_mir_dump(test_info);
if let WillExecute::Yes = should_run { if let WillExecute::Yes = should_run {
let proc_res = self.exec_compiled_test(); let proc_res = self.exec_compiled_test();

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -1,51 +1,71 @@
// skip-filecheck
// Checks that only functions with compatible attributes are inlined. // Checks that only functions with compatible attributes are inlined.
//
// only-x86_64 // only-x86_64
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -Cpanic=abort
#![crate_type = "lib"] #![crate_type = "lib"]
#![feature(no_sanitize)] #![feature(no_sanitize)]
#![feature(target_feature_11)] #![feature(target_feature_11)]
#![feature(c_variadic)] #![feature(c_variadic)]
// EMIT_MIR inline_compatibility.inlined_target_feature.Inline.diff
#[target_feature(enable = "sse2")]
pub unsafe fn inlined_target_feature() {
target_feature();
}
// EMIT_MIR inline_compatibility.not_inlined_target_feature.Inline.diff
pub unsafe fn not_inlined_target_feature() {
target_feature();
}
// EMIT_MIR inline_compatibility.inlined_no_sanitize.Inline.diff
#[no_sanitize(address)]
pub unsafe fn inlined_no_sanitize() {
no_sanitize();
}
// EMIT_MIR inline_compatibility.not_inlined_no_sanitize.Inline.diff
pub unsafe fn not_inlined_no_sanitize() {
no_sanitize();
}
#[inline] #[inline]
#[target_feature(enable = "sse2")] #[target_feature(enable = "sse2")]
pub unsafe fn target_feature() {} unsafe fn sse2() {}
#[inline]
fn nop() {}
// CHECK-LABEL: fn f0()
// CHECK: bb0: {
// CHECK-NEXT: return;
#[target_feature(enable = "sse2")]
pub unsafe fn f0() {
sse2();
}
// CHECK-LABEL: fn f1()
// CHECK: bb0: {
// CHECK-NEXT: sse2()
pub unsafe fn f1() {
sse2();
}
// CHECK-LABEL: fn f2()
// CHECK: bb0: {
// CHECK-NEXT: nop()
#[target_feature(enable = "avx")]
pub unsafe fn f2() {
nop();
}
#[inline] #[inline]
#[no_sanitize(address)] #[no_sanitize(address)]
pub unsafe fn no_sanitize() {} pub unsafe fn no_sanitize() {}
// EMIT_MIR inline_compatibility.not_inlined_c_variadic.Inline.diff // CHECK-LABEL: fn inlined_no_sanitize()
pub unsafe fn not_inlined_c_variadic() { // CHECK: bb0: {
let s = sum(4u32, 4u32, 30u32, 200u32, 1000u32); // CHECK-NEXT: return;
#[no_sanitize(address)]
pub unsafe fn inlined_no_sanitize() {
no_sanitize();
}
// CHECK-LABEL: fn not_inlined_no_sanitize()
// CHECK: bb0: {
// CHECK-NEXT: no_sanitize()
pub unsafe fn not_inlined_no_sanitize() {
no_sanitize();
}
// 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 _ = sum(4u32, 4u32, 30u32, 200u32, 1000u32);
} }
#[no_mangle]
#[inline(always)] #[inline(always)]
#[no_mangle]
unsafe extern "C" fn sum(n: u32, mut vs: ...) -> u32 { unsafe extern "C" fn sum(n: u32, mut vs: ...) -> u32 {
let mut s = 0; let mut s = 0;
let mut i = 0; let mut i = 0;

View file

@ -14,5 +14,6 @@ fn foo<A: TraitWAssocConst<A=32>>() { //~ ERROR E0658
fn main<A: TraitWAssocConst<A=32>>() { fn main<A: TraitWAssocConst<A=32>>() {
//~^ ERROR E0658 //~^ ERROR E0658
//~| ERROR E0131
foo::<Demo>(); foo::<Demo>();
} }

View file

@ -39,7 +39,13 @@ error[E0562]: `impl Trait` only allowed in function and inherent method argument
LL | impl TraitWAssocConst for impl Demo { 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<A: TraitWAssocConst<A=32>>() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `main` cannot have generic parameters
Some errors have detailed explanations: E0404, E0562, E0658. error: aborting due to 6 previous errors
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`.

View file

@ -10,6 +10,18 @@ note: required by a bound in `Ty::Pr`
LL | type Pr<T: Copy> = T; LL | type Pr<T: Copy> = T;
| ^^^^ required by this bound in `Ty::Pr` | ^^^^ 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> = 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: Copy> = 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`. For more information about this error, try `rustc --explain E0277`.

View file

@ -1,5 +1,5 @@
error[E0277]: the trait bound `Vec<()>: Copy` is not satisfied 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<Vec<()>>; LL | let _: Ty::Pr<Vec<()>>;
| ^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Vec<()>` | ^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Vec<()>`

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough 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>() { LL | fn user<'a>() {
| -- lifetime `'a` defined here | -- lifetime `'a` defined here

View file

@ -14,6 +14,7 @@ impl Ty {
#[cfg(item)] #[cfg(item)]
const _: Ty::Pr<String> = String::new(); //[item]~ the trait bound `String: Copy` is not satisfied const _: Ty::Pr<String> = String::new(); //[item]~ the trait bound `String: Copy` is not satisfied
//[item]~^ the trait bound `String: Copy` is not satisfied
fn main() { fn main() {
#[cfg(local)] #[cfg(local)]

View file

@ -21,6 +21,7 @@ trait Other {
impl<T:Get> Other for T { impl<T:Get> Other for T {
fn uhoh<U:Get>(&self, foo: U, bar: <(T, U) as Get>::Value) {} fn uhoh<U:Get>(&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
//~| ERROR the trait bound `(T, U): Get` is not satisfied
} }
fn main() { } fn main() { }

View file

@ -21,6 +21,18 @@ help: consider further restricting `Self`
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get {} LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::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<U:Get>(&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`. For more information about this error, try `rustc --explain E0277`.

View file

@ -6,5 +6,6 @@
trait NotObjectSafe { fn eq(&self, other: Self); } trait NotObjectSafe { fn eq(&self, other: Self); }
impl NotObjectSafe for dyn NotObjectSafe { } impl NotObjectSafe for dyn NotObjectSafe { }
//~^ ERROR E0038 //~^ ERROR E0038
//~| ERROR E0046
fn main() { } fn main() { }

View file

@ -13,6 +13,15 @@ LL | trait NotObjectSafe { fn eq(&self, other: Self); }
| this trait cannot be made into an object... | this trait cannot be made into an object...
= help: consider moving `eq` to another trait = 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
For more information about this error, try `rustc --explain E0038`. error: aborting due to 2 previous errors
Some errors have detailed explanations: E0038, E0046.
For more information about an error, try `rustc --explain E0038`.

View file

@ -0,0 +1,13 @@
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
trait Q {
const ASSOC: usize;
}
impl<const N: u64> Q for [u8; N] {}
//~^ ERROR not all trait items implemented
pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] {}
pub fn main() {}

View file

@ -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<const N: u64> Q for [u8; N] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `ASSOC` in implementation
error: aborting due to previous error
For more information about this error, try `rustc --explain E0046`.

View file

@ -2,15 +2,19 @@ use std::fmt::Debug;
const CONST_0: dyn Debug + Sync = *(&0 as &(dyn Debug + Sync)); 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
//~| ERROR the size for values of type
const CONST_FOO: str = *"foo"; const CONST_FOO: str = *"foo";
//~^ ERROR the size for values of type //~^ 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)); 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
//~| ERROR the size for values of type
static STATIC_BAR: str = *"bar"; static STATIC_BAR: str = *"bar";
//~^ ERROR the size for values of type //~^ ERROR the size for values of type
//~| ERROR the size for values of type
fn main() { fn main() {
println!("{:?} {:?} {:?} {:?}", &CONST_0, &CONST_FOO, &STATIC_1, &STATIC_BAR); println!("{:?} {:?} {:?} {:?}", &CONST_0, &CONST_FOO, &STATIC_1, &STATIC_BAR);

View file

@ -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)` = 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 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"; LL | const CONST_FOO: str = *"foo";
| ^^^ doesn't have a size known at compile-time | ^^^ 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` = 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 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)); LL | static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync));
| ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | ^^^^^^^^^^^^^^^^ 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)` = 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 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"; LL | static STATIC_BAR: str = *"bar";
| ^^^ doesn't have a size known at compile-time | ^^^ doesn't have a size known at compile-time
| |
= help: the trait `Sized` is not implemented for `str` = 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`. For more information about this error, try `rustc --explain E0277`.

View file

@ -12,7 +12,8 @@ struct StreamingSliceIter<'a, T> {
impl<'b, T: 'b> StreamingIter for StreamingSliceIter<'b, T> { impl<'b, T: 'b> StreamingIter for StreamingSliceIter<'b, T> {
type Item<'a> = &'a mut 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> { fn next(&mut self) -> Option<&mut T> {
loop {} loop {}
} }

View file

@ -11,6 +11,26 @@ help: consider adding an explicit lifetime bound
LL | type Item<'a> = &'a mut T where T: 'a; 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;
| ++++++++++++++
For more information about this error, try `rustc --explain E0309`. error: aborting due to 2 previous errors
Some errors have detailed explanations: E0309, E0477.
For more information about an error, try `rustc --explain E0309`.

View file

@ -7,6 +7,7 @@ pub trait X {
impl X for () { impl X for () {
type Y<'a> = &'a (); type Y<'a> = &'a ();
//~^ ERROR lifetime bound not satisfied
} }
struct B<'a, T: for<'r> X<Y<'r> = &'r ()>> { struct B<'a, T: for<'r> X<Y<'r> = &'r ()>> {

View file

@ -12,44 +12,64 @@ LL | #![warn(unused_lifetimes)]
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
error[E0478]: lifetime bound not satisfied error[E0478]: lifetime bound not satisfied
--> $DIR/unsatisfied-item-lifetime-bound.rs:13:8 --> $DIR/unsatisfied-item-lifetime-bound.rs:14:8
| |
LL | f: <T as X>::Y<'a>, LL | f: <T as X>::Y<'a>,
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
| |
note: lifetime parameter instantiated with the lifetime `'a` as defined here 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<Y<'r> = &'r ()>> { LL | struct B<'a, T: for<'r> X<Y<'r> = &'r ()>> {
| ^^ | ^^
= note: but lifetime parameter must outlive the static lifetime = note: but lifetime parameter must outlive the static lifetime
error[E0478]: lifetime bound not satisfied error[E0478]: lifetime bound not satisfied
--> $DIR/unsatisfied-item-lifetime-bound.rs:18:8 --> $DIR/unsatisfied-item-lifetime-bound.rs:19:8
| |
LL | f: <T as X>::Y<'a>, LL | f: <T as X>::Y<'a>,
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
| |
note: lifetime parameter instantiated with the lifetime `'a` as defined here 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> { LL | struct C<'a, T: X> {
| ^^ | ^^
= note: but lifetime parameter must outlive the static lifetime = note: but lifetime parameter must outlive the static lifetime
error[E0478]: lifetime bound not satisfied 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>, LL | f: <() as X>::Y<'a>,
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
| |
note: lifetime parameter instantiated with the lifetime `'a` as defined here 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> { LL | struct D<'a> {
| ^^ | ^^
= note: but lifetime parameter must outlive the static lifetime = 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`. For more information about this error, try `rustc --explain E0478`.

View file

@ -1,3 +0,0 @@
// compile-flags: -Cinstrument-coverage=except-unused-functions
fn main() {}

View file

@ -1,3 +0,0 @@
// compile-flags: -Cinstrument-coverage=except-unused-generics
fn main() {}

View file

@ -0,0 +1,2 @@
error: `-C instrument-coverage=branch` and `-C instrument-coverage=except-*` require `-Z unstable-options`

View file

@ -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() {}

View file

@ -14,5 +14,6 @@ struct Bar {
const FOO : Foo = Foo; const FOO : Foo = Foo;
const BAR : Bar = Bar { foos: &[&FOO]}; const BAR : Bar = Bar { foos: &[&FOO]};
//~^ ERROR E0038
fn main() { } fn main() { }

View file

@ -20,6 +20,29 @@ help: alternatively, consider constraining `qiz` so it does not apply to trait o
LL | fn qiz() where Self: Sized; 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 <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $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`. For more information about this error, try `rustc --explain E0038`.

View file

@ -2,6 +2,8 @@ fn main() {
static foo: dyn Fn() -> u32 = || -> u32 { static foo: dyn Fn() -> u32 = || -> u32 {
//~^ ERROR the size for values of type //~^ ERROR the size for values of type
//~| ERROR cannot be shared between threads safely //~| ERROR cannot be shared between threads safely
//~| ERROR the size for values of type
//~| ERROR mismatched types
0 0
}; };
} }

View file

@ -15,6 +15,39 @@ LL | static foo: dyn Fn() -> u32 = || -> u32 {
| |
= help: the trait `Sized` is not implemented for `(dyn Fn() -> u32 + 'static)` = 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
For more information about this error, try `rustc --explain E0277`. 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
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.

View file

@ -10,3 +10,4 @@ struct Multiply<N, M> {
} }
impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {} impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
//~^ ERROR cannot find type `VAL` in this scope //~^ ERROR cannot find type `VAL` in this scope
//~| ERROR not all trait items implemented

View file

@ -20,6 +20,16 @@ help: you might be missing a type parameter
LL | impl<N, M, VAL> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {} LL | impl<N, M, VAL> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
| +++++ | +++++
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<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `VAL` in implementation
For more information about this error, try `rustc --explain E0412`. error: aborting due to 3 previous errors
Some errors have detailed explanations: E0046, E0412.
For more information about an error, try `rustc --explain E0046`.

View file

@ -9,6 +9,8 @@ static FOO: (dyn AsRef<OsStr>, u8) = ("hello", 42);
const BAR: (&Path, [u8], usize) = ("hello", [], 42); const BAR: (&Path, [u8], usize) = ("hello", [], 42);
//~^ ERROR cannot find type `Path` in this scope //~^ ERROR cannot find type `Path` in this scope
//~| ERROR the size for values of type `[u8]` cannot be known at compilation time //~| ERROR the size for values of type `[u8]` cannot be known at compilation time
//~| ERROR mismatched types
static BAZ: ([u8], usize) = ([], 0); static BAZ: ([u8], usize) = ([], 0);
//~^ ERROR the size for values of type `[u8]` cannot be known at compilation time //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
//~| ERROR mismatched types

View file

@ -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 = 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 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); LL | static BAZ: ([u8], usize) = ([], 0);
| ^^^^^^^^^^^^^ doesn't have a size known at compile-time | ^^^^^^^^^^^^^ 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]` = help: the trait `Sized` is not implemented for `[u8]`
= note: only the last element of a tuple may have a dynamically sized type = 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]`
Some errors have detailed explanations: E0277, E0412. 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, E0308, E0412.
For more information about an error, try `rustc --explain E0277`. For more information about an error, try `rustc --explain E0277`.

View file

@ -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() {}

View file

@ -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`.

View file

@ -13,3 +13,5 @@ trait Project {
#[proc_macro] #[proc_macro]
pub fn uwu() -> <() as Project>::Assoc {} pub fn uwu() -> <() as Project>::Assoc {}
//~^ ERROR the trait bound `(): Project` is not satisfied //~^ 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

View file

@ -10,6 +10,32 @@ help: this trait has no implementations, consider adding one
LL | trait Project { 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
For more information about this error, try `rustc --explain E0277`. 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
Some errors have detailed explanations: E0277, E0593.
For more information about an error, try `rustc --explain E0277`.

View file

@ -22,6 +22,7 @@ impl Simd for i32x4 {
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct T<S: Simd>([S::Lane; S::SIZE]); pub struct T<S: Simd>([S::Lane; S::SIZE]);
//~^ ERROR unconstrained generic constant //~^ ERROR unconstrained generic constant
//~| ERROR SIMD vector element type should be a primitive scalar
extern "platform-intrinsic" { extern "platform-intrinsic" {
fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T; fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T;

View file

@ -6,5 +6,12 @@ LL | pub struct T<S: Simd>([S::Lane; S::SIZE]);
| |
= help: try adding a `where` bound using this expression: `where [(); 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: Simd>([S::Lane; S::SIZE]);
| ^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0077`.

View file

@ -19,6 +19,7 @@ impl<B: ?Sized> Display for Cow<'_, B> {
//~^ ERROR: the trait bound `B: Clone` is not satisfied [E0277] //~^ ERROR: the trait bound `B: Clone` is not satisfied [E0277]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 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]
//~| ERROR: the trait bound `B: Clone` is not satisfied [E0277]
write!(f, "foo") write!(f, "foo")
} }
} }

View file

@ -22,6 +22,18 @@ help: consider further restricting this bound
LL | impl<B: ?Sized + std::clone::Clone> Display for Cow<'_, B> { LL | impl<B: ?Sized + std::clone::Clone> 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<B: ?Sized + std::clone::Clone> Display for Cow<'_, B> {
| +++++++++++++++++++
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0277`. For more information about this error, try `rustc --explain E0277`.

View file

@ -8,7 +8,7 @@ struct Foo<T:Trait> {
static X: Foo<usize> = Foo { static X: Foo<usize> = Foo {
//~^ ERROR E0277 //~^ ERROR E0277
x: 1, x: 1, //~ ERROR: E0277
}; };
fn main() { fn main() {

View file

@ -15,6 +15,23 @@ note: required by a bound in `Foo`
LL | struct Foo<T:Trait> { LL | struct Foo<T:Trait> {
| ^^^^^ required by this bound in `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<T:Trait> {
| ^^^^^ required by this bound in `Foo`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`. For more information about this error, try `rustc --explain E0277`.

View file

@ -10,7 +10,7 @@ trait Default {
} }
impl<T> Default for T { impl<T> Default for T {
default type Id = T; default type Id = T; //~ ERROR: type annotations needed
// This will be fixed by #111994 // This will be fixed by #111994
fn intu(&self) -> &Self::Id { //~ ERROR type annotations needed fn intu(&self) -> &Self::Id { //~ ERROR type annotations needed
self self

View file

@ -16,6 +16,13 @@ LL | fn intu(&self) -> &Self::Id {
| |
= note: cannot satisfy `<T as Default>::Id == _` = note: cannot satisfy `<T as Default>::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 `<T as Default>::Id`
For more information about this error, try `rustc --explain E0284`. error: aborting due to 2 previous errors; 1 warning emitted
Some errors have detailed explanations: E0282, E0284.
For more information about an error, try `rustc --explain E0282`.

View file

@ -8,5 +8,6 @@ type Underconstrained<T: Trait> = impl Send;
// no `Trait` bound // no `Trait` bound
fn underconstrain<T>(_: T) -> Underconstrained<T> { fn underconstrain<T>(_: T) -> Underconstrained<T> {
//~^ ERROR the trait bound `T: Trait` //~^ ERROR the trait bound `T: Trait`
//~| ERROR the trait bound `T: Trait`
unimplemented!() unimplemented!()
} }

View file

@ -14,6 +14,27 @@ help: consider restricting type parameter `T`
LL | fn underconstrain<T: Trait>(_: T) -> Underconstrained<T> { LL | fn underconstrain<T: Trait>(_: T) -> Underconstrained<T> {
| +++++++ | +++++++
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>(_: T) -> Underconstrained<T> {
| ___________________________________________________^
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<T: Trait> = impl Send;
| ^^^^^ required by this bound
help: consider restricting type parameter `T`
|
LL | fn underconstrain<T: Trait>(_: T) -> Underconstrained<T> {
| +++++++
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`. For more information about this error, try `rustc --explain E0277`.

View file

@ -7,6 +7,7 @@ type Underconstrained<T: std::fmt::Debug> = impl Send;
// not a defining use, because it doesn't define *all* possible generics // not a defining use, because it doesn't define *all* possible generics
fn underconstrained<U>(_: U) -> Underconstrained<U> { fn underconstrained<U>(_: U) -> Underconstrained<U> {
//~^ ERROR `U` doesn't implement `Debug` //~^ ERROR `U` doesn't implement `Debug`
//~| ERROR `U` doesn't implement `Debug`
5u32 5u32
} }
@ -15,5 +16,6 @@ type Underconstrained2<T: std::fmt::Debug> = impl Send;
// not a defining use, because it doesn't define *all* possible generics // not a defining use, because it doesn't define *all* possible generics
fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> { fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> {
//~^ ERROR `V` doesn't implement `Debug` //~^ ERROR `V` doesn't implement `Debug`
//~| ERROR `V` doesn't implement `Debug`
5u32 5u32
} }

View file

@ -15,13 +15,13 @@ LL | fn underconstrained<U: std::fmt::Debug>(_: U) -> Underconstrained<U> {
| +++++++++++++++++ | +++++++++++++++++
error[E0277]: `V` doesn't implement `Debug` error[E0277]: `V` doesn't implement `Debug`
--> $DIR/generic_underconstrained2.rs:16:43 --> $DIR/generic_underconstrained2.rs:17:43
| |
LL | fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> { LL | fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> {
| ^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `Debug` | ^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `Debug`
| |
note: required by a bound on the type alias `Underconstrained2` 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<T: std::fmt::Debug> = impl Send; LL | type Underconstrained2<T: std::fmt::Debug> = impl Send;
| ^^^^^^^^^^^^^^^ required by this bound | ^^^^^^^^^^^^^^^ required by this bound
@ -30,6 +30,48 @@ help: consider restricting type parameter `V`
LL | fn underconstrained2<U, V: std::fmt::Debug>(_: U, _: V) -> Underconstrained2<V> { LL | fn underconstrained2<U, V: std::fmt::Debug>(_: U, _: V) -> Underconstrained2<V> {
| +++++++++++++++++ | +++++++++++++++++
error: aborting due to 2 previous errors error[E0277]: `U` doesn't implement `Debug`
--> $DIR/generic_underconstrained2.rs:8:53
|
LL | fn underconstrained<U>(_: U) -> Underconstrained<U> {
| _____________________________________________________^
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<T: std::fmt::Debug> = impl Send;
| ^^^^^^^^^^^^^^^ required by this bound
help: consider restricting type parameter `U`
|
LL | fn underconstrained<U: std::fmt::Debug>(_: U) -> Underconstrained<U> {
| +++++++++++++++++
error[E0277]: `V` doesn't implement `Debug`
--> $DIR/generic_underconstrained2.rs:17:64
|
LL | fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> {
| ________________________________________________________________^
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<T: std::fmt::Debug> = impl Send;
| ^^^^^^^^^^^^^^^ required by this bound
help: consider restricting type parameter `V`
|
LL | fn underconstrained2<U, V: std::fmt::Debug>(_: U, _: V) -> Underconstrained2<V> {
| +++++++++++++++++
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0277`. For more information about this error, try `rustc --explain E0277`.

View file

@ -36,6 +36,7 @@ impl<'a, T> SomeTrait for &'a Bar<T> {
fn dummy1(self: &&'a Bar<T>) { } fn dummy1(self: &&'a Bar<T>) { }
fn dummy2(self: &Bar<T>) {} //~ ERROR mismatched `self` parameter type fn dummy2(self: &Bar<T>) {} //~ ERROR mismatched `self` parameter type
//~^ ERROR mismatched `self` parameter type //~^ ERROR mismatched `self` parameter type
//~| ERROR has an incompatible type for trait
fn dummy3(self: &&Bar<T>) {} fn dummy3(self: &&Bar<T>) {}
//~^ ERROR mismatched `self` parameter type //~^ ERROR mismatched `self` parameter type
//~| expected reference `&'a Bar<T>` //~| expected reference `&'a Bar<T>`

View file

@ -64,7 +64,7 @@ LL | fn dummy2(self: &Bar<T>) {}
| ^^^^^^^ | ^^^^^^^
error[E0308]: mismatched `self` parameter type 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<T>) {} LL | fn dummy3(self: &&Bar<T>) {}
| ^^^^^^^^ lifetime mismatch | ^^^^^^^^ lifetime mismatch
@ -72,7 +72,7 @@ LL | fn dummy3(self: &&Bar<T>) {}
= note: expected reference `&'a Bar<T>` = note: expected reference `&'a Bar<T>`
found reference `&Bar<T>` found reference `&Bar<T>`
note: the anonymous lifetime defined here... 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<T>) {} LL | fn dummy3(self: &&Bar<T>) {}
| ^^^^^^^ | ^^^^^^^
@ -83,7 +83,7 @@ LL | impl<'a, T> SomeTrait for &'a Bar<T> {
| ^^ | ^^
error[E0308]: mismatched `self` parameter type 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<T>) {} LL | fn dummy3(self: &&Bar<T>) {}
| ^^^^^^^^ lifetime mismatch | ^^^^^^^^ lifetime mismatch
@ -96,12 +96,29 @@ note: the lifetime `'a` as defined here...
LL | impl<'a, T> SomeTrait for &'a Bar<T> { LL | impl<'a, T> SomeTrait for &'a Bar<T> {
| ^^ | ^^
note: ...does not necessarily outlive the anonymous lifetime defined here 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<T>) {} LL | fn dummy3(self: &&Bar<T>) {}
| ^^^^^^^ | ^^^^^^^
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<T>) {}
| ------^^^^^^^
| | |
| | expected `&'a Bar<T>`, found `Bar<T>`
| 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<T>)`
found signature `fn(&Bar<T>)`
Some errors have detailed explanations: E0307, E0308. error: aborting due to 8 previous errors
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`.

View file

@ -4,6 +4,7 @@ union PtrRepr<T: ?Sized> {
mut_ptr: *mut T, mut_ptr: *mut T,
components: PtrComponents<T>, components: PtrComponents<T>,
//~^ ERROR the trait bound //~^ ERROR the trait bound
//~| ERROR field must implement `Copy`
} }
#[repr(C)] #[repr(C)]

View file

@ -5,7 +5,7 @@ LL | components: PtrComponents<T>,
| ^^^^^^^^^^^^^^^^ the trait `Pointee` is not implemented for `T` | ^^^^^^^^^^^^^^^^ the trait `Pointee` is not implemented for `T`
| |
note: required by a bound in `PtrComponents` note: required by a bound in `PtrComponents`
--> $DIR/issue-81199.rs:10:25 --> $DIR/issue-81199.rs:11:25
| |
LL | struct PtrComponents<T: Pointee + ?Sized> { LL | struct PtrComponents<T: Pointee + ?Sized> {
| ^^^^^^^ required by this bound in `PtrComponents` | ^^^^^^^ required by this bound in `PtrComponents`
@ -14,6 +14,19 @@ help: consider further restricting this bound
LL | union PtrRepr<T: ?Sized + Pointee> { LL | union PtrRepr<T: ?Sized + Pointee> {
| +++++++++ | +++++++++
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<T>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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<PtrComponents<T>>,
| +++++++++++++++++++++++ +
For more information about this error, try `rustc --explain E0277`. error: aborting due to 2 previous errors
Some errors have detailed explanations: E0277, E0740.
For more information about an error, try `rustc --explain E0277`.

View file

@ -17,7 +17,7 @@ LL | a: Box<str>,
| ++++ + | ++++ +
error[E0277]: the size for values of type `str` cannot be known at compilation time 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, LL | b: str,
| ^^^ doesn't have a size known at compile-time | ^^^ 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<str>, LL | b: Box<str>,
| ++++ + | ++++ +
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<str>,
| +++++++++++++++++++++++ +
For more information about this error, try `rustc --explain E0277`. 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<str>,
| +++++++++++++++++++++++ +
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0277, E0740.
For more information about an error, try `rustc --explain E0277`.

View file

@ -4,6 +4,7 @@
union U { union U {
a: str, a: str,
//~^ ERROR the size for values of type //~^ ERROR the size for values of type
//~| ERROR field must implement `Copy`
b: u8, b: u8,
} }
@ -12,6 +13,7 @@ union W {
a: u8, a: u8,
b: str, b: str,
//~^ ERROR the size for values of type //~^ ERROR the size for values of type
//~| ERROR field must implement `Copy`
} }
fn main() {} fn main() {}

View file

@ -17,7 +17,7 @@ LL | a: Box<str>,
| ++++ + | ++++ +
error[E0277]: the size for values of type `str` cannot be known at compilation time 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, LL | b: str,
| ^^^ doesn't have a size known at compile-time | ^^^ 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<str>, LL | b: Box<str>,
| ++++ + | ++++ +
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<str>,
| +++++++++++++++++++++++ +
For more information about this error, try `rustc --explain E0277`. 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<str>,
| +++++++++++++++++++++++ +
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0277, E0740.
For more information about an error, try `rustc --explain E0277`.

View file

@ -9,6 +9,7 @@ struct S5<Y>(Y);
impl<X: ?Sized> T3<X> for S5<X> { impl<X: ?Sized> T3<X> for S5<X> {
//~^ ERROR the size for values of type //~^ ERROR the size for values of type
//~| ERROR not all trait items implemented
} }
fn main() { } fn main() { }

View file

@ -24,6 +24,16 @@ LL - impl<X: ?Sized> T3<X> for S5<X> {
LL + impl<X> T3<X> for S5<X> { LL + impl<X> T3<X> for S5<X> {
| |
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<X: ?Sized> T3<X> for S5<X> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation
For more information about this error, try `rustc --explain E0277`. error: aborting due to 2 previous errors
Some errors have detailed explanations: E0046, E0277.
For more information about an error, try `rustc --explain E0046`.

View file

@ -7,6 +7,7 @@ trait T2<Z> {
struct S4<Y: ?Sized>(Box<Y>); struct S4<Y: ?Sized>(Box<Y>);
impl<X: ?Sized> T2<X> for S4<X> { impl<X: ?Sized> T2<X> for S4<X> {
//~^ ERROR the size for values of type //~^ ERROR the size for values of type
//~| ERROR not all trait items implemented
} }
fn main() { } fn main() { }

View file

@ -21,6 +21,16 @@ help: consider relaxing the implicit `Sized` restriction
LL | trait T2<Z: ?Sized> { LL | trait T2<Z: ?Sized> {
| ++++++++ | ++++++++
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<X: ?Sized> T2<X> for S4<X> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation
For more information about this error, try `rustc --explain E0277`. error: aborting due to 2 previous errors
Some errors have detailed explanations: E0046, E0277.
For more information about an error, try `rustc --explain E0046`.

View file

@ -11,6 +11,7 @@ trait T1<Z: T> {
struct S3<Y: ?Sized>(Box<Y>); struct S3<Y: ?Sized>(Box<Y>);
impl<X: ?Sized + T> T1<X> for S3<X> { impl<X: ?Sized + T> T1<X> for S3<X> {
//~^ ERROR the size for values of type //~^ ERROR the size for values of type
//~| ERROR not all trait items implemented
} }
fn main() { } fn main() { }

View file

@ -21,6 +21,16 @@ help: consider relaxing the implicit `Sized` restriction
LL | trait T1<Z: T + ?Sized> { LL | trait T1<Z: T + ?Sized> {
| ++++++++ | ++++++++
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<X: ?Sized + T> T1<X> for S3<X> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `dummy` in implementation
For more information about this error, try `rustc --explain E0277`. error: aborting due to 2 previous errors
Some errors have detailed explanations: E0046, E0277.
For more information about an error, try `rustc --explain E0046`.

View file

@ -5,6 +5,7 @@ pub struct Table<T, const N: usize>([Option<T>; N]);
impl<'a, T, const N: usize> IntoIterator for &'a Table<T, N> { impl<'a, T, const N: usize> IntoIterator for &'a Table<T, N> {
type IntoIter = std::iter::Flatten<std::slice::Iter<'a, T>>; //~ ERROR `&'a T` is not an iterator type IntoIter = std::iter::Flatten<std::slice::Iter<'a, T>>; //~ ERROR `&'a T` is not an iterator
//~^ ERROR `&'a T` is not an iterator
type Item = &'a T; type Item = &'a T;
fn into_iter(self) -> Self::IntoIter { //~ ERROR `&'a T` is not an iterator fn into_iter(self) -> Self::IntoIter { //~ ERROR `&'a T` is not an iterator

View file

@ -11,7 +11,7 @@ note: required by a bound in `Flatten`
--> $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL --> $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL
error[E0277]: `&'a T` is not an iterator 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 { LL | fn into_iter(self) -> Self::IntoIter {
| ^^^^^^^^^^^^^^ `&'a T` is not an iterator | ^^^^^^^^^^^^^^ `&'a T` is not an iterator
@ -22,6 +22,18 @@ LL | fn into_iter(self) -> Self::IntoIter {
note: required by a bound in `Flatten` note: required by a bound in `Flatten`
--> $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL --> $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<std::slice::Iter<'a, T>>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `&'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<std::slice::Iter<'a, T>>` 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`. For more information about this error, try `rustc --explain E0277`.

View file

@ -2,6 +2,7 @@ struct NeedsDropTypes<'tcx, F>(std::marker::PhantomData<&'tcx F>);
impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F> impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F>
//~^ ERROR type annotations needed //~^ ERROR type annotations needed
//~| ERROR not all trait items implemented
where where
F: Fn(&Missing) -> Result<I, ()>, F: Fn(&Missing) -> Result<I, ()>,
//~^ ERROR cannot find type `Missing` in this scope //~^ ERROR cannot find type `Missing` in this scope

View file

@ -1,11 +1,11 @@
error[E0412]: cannot find type `Missing` in this scope 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<I, ()>, LL | F: Fn(&Missing) -> Result<I, ()>,
| ^^^^^^^ not found in this scope | ^^^^^^^ not found in this scope
error[E0412]: cannot find type `Missing` 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<Item = Missing>, LL | I: Iterator<Item = Missing>,
| ^^^^^^^ not found in this scope | ^^^^^^^ not found in this scope
@ -26,7 +26,22 @@ LL | impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F>
LL | I: Iterator<Item = Missing>, LL | I: Iterator<Item = Missing>,
| ------------------------ unsatisfied trait bound introduced here | ------------------------ 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<I, ()>,
LL | |
LL | | I: Iterator<Item = Missing>,
| |________________________________^ missing `Item`, `next` in implementation
|
= help: implement the missing item: `type Item = /* Type */;`
= help: implement the missing item: `fn next(&mut self) -> Option<<Self as Iterator>::Item> { todo!() }`
Some errors have detailed explanations: E0283, E0412. error: aborting due to 4 previous errors
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`.

View file

@ -9,6 +9,7 @@ struct NotCopy;
const FOO: IsCopy<Option<NotCopy>> = IsCopy { t: None }; const FOO: IsCopy<Option<NotCopy>> = IsCopy { t: None };
//~^ ERROR E0277 //~^ ERROR E0277
//~| ERROR E0277
fn main() { } fn main() { }

View file

@ -16,6 +16,24 @@ LL + #[derive(Copy)]
LL | struct NotCopy; 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<Option<NotCopy>> = IsCopy { t: None };
| ^^^^ the trait `Copy` is not implemented for `NotCopy`
|
= note: required for `Option<NotCopy>` to implement `Copy`
note: required by a bound in `IsCopy`
--> $DIR/wf-const-type.rs:7:17
|
LL | struct IsCopy<T:Copy> { 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`. For more information about this error, try `rustc --explain E0277`.

View file

@ -9,6 +9,7 @@ struct NotCopy;
static FOO: IsCopy<Option<NotCopy>> = IsCopy { t: None }; static FOO: IsCopy<Option<NotCopy>> = IsCopy { t: None };
//~^ ERROR E0277 //~^ ERROR E0277
//~| ERROR E0277
fn main() { } fn main() { }

View file

@ -16,6 +16,24 @@ LL + #[derive(Copy)]
LL | struct NotCopy; 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<Option<NotCopy>> = IsCopy { t: None };
| ^^^^ the trait `Copy` is not implemented for `NotCopy`
|
= note: required for `Option<NotCopy>` to implement `Copy`
note: required by a bound in `IsCopy`
--> $DIR/wf-static-type.rs:7:17
|
LL | struct IsCopy<T:Copy> { 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`. For more information about this error, try `rustc --explain E0277`.