Auto merge of #120847 - oli-obk:track_errors9, r=compiler-errors

Continue compilation after check_mod_type_wf errors

The ICEs fixed here were probably reachable through const eval gymnastics before, but now they are easily reachable without that, too.

The new errors are often bugfixes, where useful errors were missing, because they were reported after the early abort. In other cases sometimes they are just duplication of already emitted errors, which won't be user-visible due to deduplication.

fixes https://github.com/rust-lang/rust/issues/120860
This commit is contained in:
bors 2024-02-14 18:32:19 +00:00
commit ee9c7c940c
215 changed files with 2723 additions and 293 deletions

View File

@ -187,8 +187,10 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
}
tcx.sess.time("wf_checking", || {
tcx.hir().try_par_for_each_module(|module| tcx.ensure().check_mod_type_wf(module))
})?;
tcx.hir().par_for_each_module(|module| {
let _ = tcx.ensure().check_mod_type_wf(module);
})
});
if tcx.features().rustc_attrs {
collect::test_opaque_hidden_types(tcx)?;

View File

@ -518,12 +518,9 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
.report_mismatched_types(&cause, method_self_ty, self_ty, terr)
.emit();
} else {
span_bug!(
self.span,
"{} was a subtype of {} but now is not?",
self_ty,
method_self_ty
);
error!("{self_ty} was a subtype of {method_self_ty} but now is not?");
// This must already have errored elsewhere.
self.dcx().has_errors().unwrap();
}
}
}

View File

@ -3,6 +3,7 @@ use crate::thir::cx::region::Scope;
use crate::thir::cx::Cx;
use crate::thir::util::UserAnnotatedTyHelpers;
use itertools::Itertools;
use rustc_ast::LitKind;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_hir as hir;
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
@ -20,7 +21,8 @@ use rustc_middle::ty::GenericArgs;
use rustc_middle::ty::{
self, AdtKind, InlineConstArgs, InlineConstArgsParts, ScalarInt, Ty, UpvarArgs, UserType,
};
use rustc_span::{sym, Span};
use rustc_span::source_map::Spanned;
use rustc_span::{sym, Span, DUMMY_SP};
use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
impl<'tcx> Cx<'tcx> {
@ -894,7 +896,14 @@ impl<'tcx> Cx<'tcx> {
Res::Def(DefKind::ConstParam, def_id) => {
let hir_id = self.tcx.local_def_id_to_hir_id(def_id.expect_local());
let generics = self.tcx.generics_of(hir_id.owner);
let index = generics.param_def_id_to_index[&def_id];
let Some(&index) = generics.param_def_id_to_index.get(&def_id) else {
self.tcx.dcx().has_errors().unwrap();
// We already errored about a late bound const
return ExprKind::Literal {
lit: &Spanned { span: DUMMY_SP, node: LitKind::Err },
neg: false,
};
};
let name = self.tcx.hir().name(hir_id);
let param = ty::ParamConst::new(index, name);

View File

@ -3116,10 +3116,11 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
obligation.param_env,
trait_ref.args.const_at(3),
) else {
span_bug!(
self.dcx().span_delayed_bug(
span,
"Unable to construct rustc_transmute::Assume where it was previously possible"
"Unable to construct rustc_transmute::Assume where it was previously possible",
);
return GetSafeTransmuteErrorAndReason::Silent;
};
match rustc_transmute::TransmuteTypeEnv::new(self.infcx).is_transmutable(

View File

@ -25,7 +25,11 @@ impl Tr for Foo {
fn main() {
b(10);
//~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument
Foo::bar();
//~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument
<Foo as Tr>::a();
//~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument
<Foo as Tr>::b();
//~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument
}

View File

@ -28,6 +28,30 @@ error: functions with the "rust-call" ABI must take a single non-self tuple argu
LL | extern "rust-call" fn b() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 5 previous errors
error[E0277]: functions with the "rust-call" ABI must take a single non-self tuple argument
--> $DIR/issue-22565-rust-call.rs:27:7
|
LL | b(10);
| ^^ the trait `Tuple` is not implemented for `i32`
error: functions with the "rust-call" ABI must take a single non-self tuple argument
--> $DIR/issue-22565-rust-call.rs:29:5
|
LL | Foo::bar();
| ^^^^^^^^^^
error: functions with the "rust-call" ABI must take a single non-self tuple argument
--> $DIR/issue-22565-rust-call.rs:31:5
|
LL | <Foo as Tr>::a();
| ^^^^^^^^^^^^^^^^
error: functions with the "rust-call" ABI must take a single non-self tuple argument
--> $DIR/issue-22565-rust-call.rs:33:5
|
LL | <Foo as Tr>::b();
| ^^^^^^^^^^^^^^^^
error: aborting due to 9 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -7,6 +7,7 @@ trait Trait {
impl dyn Trait {
//~^ ERROR the trait `Trait` cannot be made into an object [E0038]
const fn n() -> usize { Self::N }
//~^ ERROR the trait `Trait` cannot be made into an object [E0038]
}
fn main() {}

View File

@ -13,6 +13,21 @@ LL | const N: usize;
| ^ ...because it contains this associated `const`
= help: consider moving `N` to another trait
error: aborting due to 1 previous error
error[E0038]: the trait `Trait` cannot be made into an object
--> $DIR/associated-const-in-trait.rs:9:29
|
LL | const fn n() -> usize { Self::N }
| ^^^^ `Trait` 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/associated-const-in-trait.rs:4:11
|
LL | trait Trait {
| ----- this trait cannot be made into an object...
LL | const N: usize;
| ^ ...because it contains this associated `const`
= help: consider moving `N` to another trait
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0038`.

View File

@ -10,10 +10,15 @@ impl TraitWAssocConst for impl Demo { //~ ERROR E0404
fn foo<A: TraitWAssocConst<A=32>>() { //~ ERROR E0658
foo::<Demo>()();
//~^ ERROR is not satisfied
//~| ERROR type mismatch
//~| ERROR expected function, found `()`
}
fn main<A: TraitWAssocConst<A=32>>() {
//~^ ERROR E0658
//~| ERROR E0131
foo::<Demo>();
//~^ ERROR type mismatch
//~| ERROR is not satisfied
}

View File

@ -26,7 +26,7 @@ LL | fn foo<A: TraitWAssocConst<A=32>>() {
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: associated const equality is incomplete
--> $DIR/issue-105330.rs:15:29
--> $DIR/issue-105330.rs:18:29
|
LL | fn main<A: TraitWAssocConst<A=32>>() {
| ^^^^
@ -44,12 +44,76 @@ LL | impl TraitWAssocConst for impl Demo {
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0131]: `main` function is not allowed to have generic parameters
--> $DIR/issue-105330.rs:15:8
--> $DIR/issue-105330.rs:18:8
|
LL | fn main<A: TraitWAssocConst<A=32>>() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `main` cannot have generic parameters
error: aborting due to 6 previous errors
error[E0277]: the trait bound `Demo: TraitWAssocConst` is not satisfied
--> $DIR/issue-105330.rs:12:11
|
LL | foo::<Demo>()();
| ^^^^ the trait `TraitWAssocConst` is not implemented for `Demo`
|
= help: the trait `TraitWAssocConst` is implemented for `{type error}`
note: required by a bound in `foo`
--> $DIR/issue-105330.rs:11:11
|
LL | fn foo<A: TraitWAssocConst<A=32>>() {
| ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `foo`
Some errors have detailed explanations: E0131, E0404, E0562, E0658.
error[E0271]: type mismatch resolving `<Demo as TraitWAssocConst>::A == 32`
--> $DIR/issue-105330.rs:12:11
|
LL | foo::<Demo>()();
| ^^^^ expected `32`, found `<Demo as TraitWAssocConst>::A`
|
= note: expected constant `32`
found constant `<Demo as TraitWAssocConst>::A`
note: required by a bound in `foo`
--> $DIR/issue-105330.rs:11:28
|
LL | fn foo<A: TraitWAssocConst<A=32>>() {
| ^^^^ required by this bound in `foo`
error[E0618]: expected function, found `()`
--> $DIR/issue-105330.rs:12:5
|
LL | fn foo<A: TraitWAssocConst<A=32>>() {
| ----------------------------------- `foo::<Demo>` defined here returns `()`
LL | foo::<Demo>()();
| ^^^^^^^^^^^^^--
| |
| call expression requires function
error[E0277]: the trait bound `Demo: TraitWAssocConst` is not satisfied
--> $DIR/issue-105330.rs:21:11
|
LL | foo::<Demo>();
| ^^^^ the trait `TraitWAssocConst` is not implemented for `Demo`
|
= help: the trait `TraitWAssocConst` is implemented for `{type error}`
note: required by a bound in `foo`
--> $DIR/issue-105330.rs:11:11
|
LL | fn foo<A: TraitWAssocConst<A=32>>() {
| ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `foo`
error[E0271]: type mismatch resolving `<Demo as TraitWAssocConst>::A == 32`
--> $DIR/issue-105330.rs:21:11
|
LL | foo::<Demo>();
| ^^^^ expected `32`, found `<Demo as TraitWAssocConst>::A`
|
= note: expected constant `32`
found constant `<Demo as TraitWAssocConst>::A`
note: required by a bound in `foo`
--> $DIR/issue-105330.rs:11:28
|
LL | fn foo<A: TraitWAssocConst<A=32>>() {
| ^^^^ required by this bound in `foo`
error: aborting due to 11 previous errors
Some errors have detailed explanations: E0131, E0271, E0277, E0404, E0562, E0618, E0658.
For more information about an error, try `rustc --explain E0131`.

View File

@ -8,5 +8,6 @@ impl Lexer<'d> { //~ ERROR use of undeclared lifetime name `'d`
}
fn test(_: Lexer::Cursor) {}
//~^ ERROR: lifetime may not live long enough
fn main() {}

View File

@ -6,6 +6,15 @@ LL | impl Lexer<'d> {
| |
| help: consider introducing lifetime `'d` here: `<'d>`
error: aborting due to 1 previous error
error: lifetime may not live long enough
--> $DIR/issue-109299.rs:10:1
|
LL | fn test(_: Lexer::Cursor) {}
| ^^^^^^^^-^^^^^^^^^^^^^^^^
| | |
| | has type `Lexer<'1>::Cursor`
| requires that `'1` must outlive `'static`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0261`.

View File

@ -18,5 +18,7 @@ impl Other for u32 {}
fn bar(_: Foo<for<'a> fn(&'a ())>::Assoc) {}
//~^ ERROR mismatched types
//~| ERROR mismatched types
//~| ERROR higher-ranked subtype error
//~| ERROR higher-ranked subtype error
fn main() {}

View File

@ -17,6 +17,20 @@ LL | fn bar(_: Foo<for<'a> fn(&'a ())>::Assoc) {}
found struct `Foo<for<'a> fn(&'a ())>`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 2 previous errors
error: higher-ranked subtype error
--> $DIR/issue-109789.rs:18:1
|
LL | fn bar(_: Foo<for<'a> fn(&'a ())>::Assoc) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: higher-ranked subtype error
--> $DIR/issue-109789.rs:18:1
|
LL | fn bar(_: Foo<for<'a> fn(&'a ())>::Assoc) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0308`.

View File

@ -10,5 +10,6 @@ impl Lexer<'static> {
}
fn test(_: Lexer::Cursor) {} //~ ERROR mismatched types
//~^ ERROR: lifetime may not live long enough
fn main() {}

View File

@ -13,6 +13,15 @@ LL | fn test(_: Lexer::Cursor) {}
| ^^^^^
= note: ...does not necessarily outlive the static lifetime
error: aborting due to 1 previous error
error: lifetime may not live long enough
--> $DIR/regionck-2.rs:12:1
|
LL | fn test(_: Lexer::Cursor) {}
| ^^^^^^^^-^^^^^^^^^^^^^^^^
| | |
| | has type `Lexer<'1>::Cursor`
| requires that `'1` must outlive `'static`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.

View File

@ -8,9 +8,9 @@ trait Get {
}
trait Other {
fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get {}
fn uhoh<U: Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Sized, Self: Get, Self: Get {}
//~^ ERROR the trait bound `Self: Get` is not satisfied
//~| ERROR the trait bound `Self: Get` is not satisfied
}
fn main() {
}
fn main() {}

View File

@ -8,9 +8,9 @@ trait Get {
}
trait Other {
fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
fn uhoh<U: Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Sized {}
//~^ ERROR the trait bound `Self: Get` is not satisfied
//~| ERROR the trait bound `Self: Get` is not satisfied
}
fn main() {
}
fn main() {}

View File

@ -1,14 +1,25 @@
error[E0277]: the trait bound `Self: Get` is not satisfied
--> $DIR/associated-types-for-unimpl-trait.rs:11:40
--> $DIR/associated-types-for-unimpl-trait.rs:11:41
|
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
| ^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self`
LL | fn uhoh<U: Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Sized {}
| ^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self`
|
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: Sized, Self: Get {}
| +++++++++++
error: aborting due to 1 previous error
error[E0277]: the trait bound `Self: Get` is not satisfied
--> $DIR/associated-types-for-unimpl-trait.rs:11:81
|
LL | fn uhoh<U: Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Sized {}
| ^^ the trait `Get` is not implemented for `Self`
|
help: consider further restricting `Self`
|
LL | fn uhoh<U: Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Sized, Self: Get {}
| +++++++++++
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -10,7 +10,7 @@ struct Struct {
impl Struct {
fn uhoh<T>(foo: <T as Get>::Value) {}
//~^ ERROR the trait bound `T: Get` is not satisfied
//~| ERROR the trait bound `T: Get` is not satisfied
}
fn main() {
}
fn main() {}

View File

@ -9,6 +9,17 @@ help: consider restricting type parameter `T`
LL | fn uhoh<T: Get>(foo: <T as Get>::Value) {}
| +++++
error: aborting due to 1 previous error
error[E0277]: the trait bound `T: Get` is not satisfied
--> $DIR/associated-types-no-suitable-bound.rs:11:40
|
LL | fn uhoh<T>(foo: <T as Get>::Value) {}
| ^^ the trait `Get` is not implemented for `T`
|
help: consider restricting type parameter `T`
|
LL | fn uhoh<T: Get>(foo: <T as Get>::Value) {}
| +++++
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -16,6 +16,7 @@ trait Get {
trait Other {
fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
//~^ ERROR the trait bound `Self: Get` is not satisfied
//~| ERROR the trait bound `Self: Get` is not satisfied
}
fn main() { }

View File

@ -9,6 +9,17 @@ help: consider further restricting `Self`
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get {}
| +++++++++++++++
error: aborting due to 1 previous error
error[E0277]: the trait bound `Self: Get` is not satisfied
--> $DIR/associated-types-no-suitable-supertrait-2.rs:17:62
|
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
| ^^ the trait `Get` is not implemented for `Self`
|
help: consider further restricting `Self`
|
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get {}
| +++++++++++++++
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

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

View File

@ -1,5 +1,5 @@
error[E0277]: the trait bound `(T, U): Get` is not satisfied
--> $DIR/associated-types-no-suitable-supertrait.rs:22:5
--> $DIR/associated-types-no-suitable-supertrait.rs:23:5
|
LL | fn uhoh<U:Get>(&self, foo: U, bar: <(T, U) as Get>::Value) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `(T, U)`
@ -11,7 +11,7 @@ LL | trait Get {
| ^^^^^^^^^
error[E0277]: the trait bound `(T, U): Get` is not satisfied
--> $DIR/associated-types-no-suitable-supertrait.rs:22:40
--> $DIR/associated-types-no-suitable-supertrait.rs:23:40
|
LL | fn uhoh<U:Get>(&self, foo: U, bar: <(T, U) as Get>::Value) {}
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `(T, U)`
@ -33,6 +33,29 @@ help: consider further restricting `Self`
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get {}
| +++++++++++++++
error: aborting due to 3 previous errors
error[E0277]: the trait bound `Self: Get` is not satisfied
--> $DIR/associated-types-no-suitable-supertrait.rs:17:62
|
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
| ^^ the trait `Get` is not implemented for `Self`
|
help: consider further restricting `Self`
|
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get {}
| +++++++++++++++
error[E0277]: the trait bound `(T, U): Get` is not satisfied
--> $DIR/associated-types-no-suitable-supertrait.rs:23:64
|
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 5 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -15,4 +15,5 @@ impl X<'_> for i32 {
fn main() {
1i32.f("abc");
//~^ ERROR the trait bound `str: Clone`
}

View File

@ -14,6 +14,22 @@ LL | where
LL | for<'b> <Self as X<'b>>::U: Clone,
| ^^^^^ required by this bound in `X`
error: aborting due to 1 previous error
error[E0277]: the trait bound `str: Clone` is not satisfied
--> $DIR/hr-associated-type-bound-1.rs:17:10
|
LL | 1i32.f("abc");
| ^ the trait `Clone` is not implemented for `str`
|
= help: the trait `Clone` is implemented for `String`
note: required by a bound in `X::f`
--> $DIR/hr-associated-type-bound-1.rs:3:33
|
LL | for<'b> <Self as X<'b>>::U: Clone,
| ^^^^^ required by this bound in `X::f`
...
LL | fn f(&self, x: &Self::U) {
| - required by a bound in this associated function
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -7,6 +7,9 @@ where
fn f<'a, T: X<'a> + ?Sized>(x: &<T as X<'a>>::U) {
//~^ ERROR the trait bound `for<'b> <T as X<'b>>::U: Clone` is not satisfied
<<T as X<'_>>::U>::clone(x);
//~^ ERROR the trait bound `for<'b> <T as X<'b>>::U: Clone` is not satisfied
//~| ERROR the trait bound `for<'b> <T as X<'b>>::U: Clone` is not satisfied
//~| ERROR the trait bound `<T as X<'_>>::U: Clone` is not satisfied
}
pub fn main() {

View File

@ -17,6 +17,55 @@ help: consider further restricting the associated type
LL | fn f<'a, T: X<'a> + ?Sized>(x: &<T as X<'a>>::U) where for<'b> <T as X<'b>>::U: Clone {
| ++++++++++++++++++++++++++++++++++++
error: aborting due to 1 previous error
error[E0277]: the trait bound `for<'b> <T as X<'b>>::U: Clone` is not satisfied
--> $DIR/hr-associated-type-bound-object.rs:9:7
|
LL | <<T as X<'_>>::U>::clone(x);
| ^ the trait `for<'b> Clone` is not implemented for `<T as X<'b>>::U`
|
note: required by a bound in `X::U`
--> $DIR/hr-associated-type-bound-object.rs:3:33
|
LL | for<'b> <Self as X<'b>>::U: Clone,
| ^^^^^ required by this bound in `X::U`
LL | {
LL | type U: ?Sized;
| - required by a bound in this associated type
help: consider further restricting the associated type
|
LL | fn f<'a, T: X<'a> + ?Sized>(x: &<T as X<'a>>::U) where for<'b> <T as X<'b>>::U: Clone {
| ++++++++++++++++++++++++++++++++++++
error[E0277]: the trait bound `<T as X<'_>>::U: Clone` is not satisfied
--> $DIR/hr-associated-type-bound-object.rs:9:6
|
LL | <<T as X<'_>>::U>::clone(x);
| ^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `<T as X<'_>>::U`
|
help: consider further restricting the associated type
|
LL | fn f<'a, T: X<'a> + ?Sized>(x: &<T as X<'a>>::U) where <T as X<'_>>::U: Clone {
| ++++++++++++++++++++++++++++
error[E0277]: the trait bound `for<'b> <T as X<'b>>::U: Clone` is not satisfied
--> $DIR/hr-associated-type-bound-object.rs:9:5
|
LL | <<T as X<'_>>::U>::clone(x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'b> Clone` is not implemented for `<T as X<'b>>::U`
|
note: required by a bound in `X`
--> $DIR/hr-associated-type-bound-object.rs:3:33
|
LL | trait X<'a>
| - required by a bound in this trait
LL | where
LL | for<'b> <Self as X<'b>>::U: Clone,
| ^^^^^ required by this bound in `X`
help: consider further restricting the associated type
|
LL | fn f<'a, T: X<'a> + ?Sized>(x: &<T as X<'a>>::U) where for<'b> <T as X<'b>>::U: Clone {
| ++++++++++++++++++++++++++++++++++++
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -17,4 +17,5 @@ impl<'a> Y<'a, u8> for u8 {
fn main() {
1u8.g("abc");
//~^ ERROR the trait bound `str: Clone` is not satisfied
}

View File

@ -14,6 +14,22 @@ LL | trait Y<'a, T: ?Sized>
LL | for<'b> <Self as Y<'b, T>>::V: Clone,
| ^^^^^ required by this bound in `Y`
error: aborting due to 1 previous error
error[E0277]: the trait bound `str: Clone` is not satisfied
--> $DIR/hr-associated-type-bound-param-1.rs:19:9
|
LL | 1u8.g("abc");
| ^ the trait `Clone` is not implemented for `str`
|
= help: the trait `Clone` is implemented for `String`
note: required by a bound in `Y::g`
--> $DIR/hr-associated-type-bound-param-1.rs:4:36
|
LL | for<'b> <Self as Y<'b, T>>::V: Clone,
| ^^^^^ required by this bound in `Y::g`
...
LL | fn g(&self, x: &Self::V) {
| - required by a bound in this associated function
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -8,6 +8,8 @@ where
type W: ?Sized;
fn h(&self, x: &T::W) {
<T::W>::clone(x);
//~^ the trait bound `str: Clone` is not satisfied
//~| the trait bound `str: Clone` is not satisfied
}
}
@ -18,4 +20,5 @@ impl<'a> Z<'a, u16> for u16 {
fn main() {
1u16.h("abc");
//~^ ERROR Clone` is not satisfied
}

View File

@ -15,7 +15,7 @@ LL | for<'b> <T as Z<'b, u16>>::W: Clone,
| ^^^^^ required by this bound in `Z`
error[E0277]: the trait bound `str: Clone` is not satisfied
--> $DIR/hr-associated-type-bound-param-2.rs:15:14
--> $DIR/hr-associated-type-bound-param-2.rs:17:14
|
LL | type W = str;
| ^^^ the trait `Clone` is not implemented for `str`, which is required by `for<'b> <u16 as Z<'b, u16>>::W: Clone`
@ -47,6 +47,54 @@ LL | for<'b> <T as Z<'b, u16>>::W: Clone,
| ^^^^^ required by this bound in `Z`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 3 previous errors
error[E0277]: the trait bound `str: Clone` is not satisfied
--> $DIR/hr-associated-type-bound-param-2.rs:10:10
|
LL | <T::W>::clone(x);
| ^^^^ the trait `Clone` is not implemented for `str`
|
= help: the trait `Clone` is implemented for `String`
note: required by a bound in `Z::W`
--> $DIR/hr-associated-type-bound-param-2.rs:6:35
|
LL | for<'b> <T as Z<'b, u16>>::W: Clone,
| ^^^^^ required by this bound in `Z::W`
LL | {
LL | type W: ?Sized;
| - required by a bound in this associated type
error[E0277]: the trait bound `str: Clone` is not satisfied
--> $DIR/hr-associated-type-bound-param-2.rs:10:9
|
LL | <T::W>::clone(x);
| ^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `str`
|
= help: the trait `Clone` is implemented for `String`
note: required by a bound in `Z`
--> $DIR/hr-associated-type-bound-param-2.rs:6:35
|
LL | trait Z<'a, T: ?Sized>
| - required by a bound in this trait
...
LL | for<'b> <T as Z<'b, u16>>::W: Clone,
| ^^^^^ required by this bound in `Z`
error[E0277]: the trait bound `str: Clone` is not satisfied
--> $DIR/hr-associated-type-bound-param-2.rs:22:10
|
LL | 1u16.h("abc");
| ^ the trait `Clone` is not implemented for `str`
|
= help: the trait `Clone` is implemented for `String`
note: required by a bound in `Z::h`
--> $DIR/hr-associated-type-bound-param-2.rs:6:35
|
LL | for<'b> <T as Z<'b, u16>>::W: Clone,
| ^^^^^ required by this bound in `Z::h`
...
LL | fn h(&self, x: &T::W) {
| - required by a bound in this associated function
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -16,4 +16,5 @@ impl<S, T> X<'_, (T,)> for (S,) {
pub fn main() {
<(i32,) as X<(i32,)>>::f("abc");
//~^ ERROR the trait bound `str: Clone` is not satisfied
}

View File

@ -14,6 +14,22 @@ LL | trait X<'a, T>
LL | for<'b> <T as X<'b, T>>::U: Clone,
| ^^^^^ required by this bound in `X`
error: aborting due to 1 previous error
error[E0277]: the trait bound `str: Clone` is not satisfied
--> $DIR/hr-associated-type-bound-param-3.rs:18:5
|
LL | <(i32,) as X<(i32,)>>::f("abc");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `str`
|
= help: the trait `Clone` is implemented for `String`
note: required by a bound in `X::f`
--> $DIR/hr-associated-type-bound-param-3.rs:4:33
|
LL | for<'b> <T as X<'b, T>>::U: Clone,
| ^^^^^ required by this bound in `X::f`
...
LL | fn f(x: &<T as X<'_, T>>::U) {
| - required by a bound in this associated function
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -16,4 +16,5 @@ impl<S, T> X<'_, T> for (S,) {
pub fn main() {
<(i32,) as X<i32>>::f("abc");
//~^ ERROR the trait bound `str: Clone` is not satisfied
}

View File

@ -14,6 +14,22 @@ LL | trait X<'a, T>
LL | for<'b> <(T,) as X<'b, T>>::U: Clone,
| ^^^^^ required by this bound in `X`
error: aborting due to 1 previous error
error[E0277]: the trait bound `str: Clone` is not satisfied
--> $DIR/hr-associated-type-bound-param-4.rs:18:5
|
LL | <(i32,) as X<i32>>::f("abc");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `str`
|
= help: the trait `Clone` is implemented for `String`
note: required by a bound in `X::f`
--> $DIR/hr-associated-type-bound-param-4.rs:4:36
|
LL | for<'b> <(T,) as X<'b, T>>::U: Clone,
| ^^^^^ required by this bound in `X::f`
...
LL | fn f(x: &<(T,) as X<'_, T>>::U) {
| - required by a bound in this associated function
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -34,4 +34,5 @@ impl<S, T> X<'_, Box<T>> for S {
pub fn main() {
<i32 as X<Box<i32>>>::f("abc");
//~^ ERROR the trait bound `str: Clone` is not satisfied
}

View File

@ -30,6 +30,22 @@ LL | trait X<'a, T: Cycle + for<'b> X<'b, T>>
LL | for<'b> <T::Next as X<'b, T::Next>>::U: Clone,
| ^^^^^ required by this bound in `X`
error: aborting due to 2 previous errors
error[E0277]: the trait bound `str: Clone` is not satisfied
--> $DIR/hr-associated-type-bound-param-5.rs:36:5
|
LL | <i32 as X<Box<i32>>>::f("abc");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `str`
|
= help: the trait `Clone` is implemented for `String`
note: required by a bound in `X::f`
--> $DIR/hr-associated-type-bound-param-5.rs:15:33
|
LL | for<'b> <T as X<'b, T>>::U: Clone,
| ^^^^^ required by this bound in `X::f`
...
LL | fn f(x: &<T as X<'_, T>>::U) {
| - required by a bound in this associated function
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -16,4 +16,6 @@ impl<S, T> X<'_, T> for (S,) {
pub fn main() {
<(i32,) as X<i32>>::f("abc");
//~^ ERROR the trait bound `for<'b> i32: X<'b, i32>` is not satisfied
//~| ERROR the trait bound `i32: X<'_, i32>` is not satisfied
}

View File

@ -9,6 +9,22 @@ help: consider restricting type parameter `T`
LL | impl<S, T: for<'b> X<'b, T>> X<'_, T> for (S,) {
| ++++++++++++++++++
error: aborting due to 1 previous error
error[E0277]: the trait bound `for<'b> i32: X<'b, i32>` is not satisfied
--> $DIR/hr-associated-type-bound-param-6.rs:18:5
|
LL | <(i32,) as X<i32>>::f("abc");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'b> X<'b, i32>` is not implemented for `i32`
|
= help: the trait `X<'_, T>` is implemented for `(S,)`
error[E0277]: the trait bound `i32: X<'_, i32>` is not satisfied
--> $DIR/hr-associated-type-bound-param-6.rs:18:27
|
LL | <(i32,) as X<i32>>::f("abc");
| ^^^^^ the trait `X<'_, i32>` is not implemented for `i32`
|
= help: the trait `X<'_, T>` is implemented for `(S,)`
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -17,4 +17,5 @@ impl<T: Copy + std::ops::Deref> UnsafeCopy<'_, T> for T {
pub fn main() {
<&'static str>::bug(&"");
//~^ type mismatch resolving `<&str as Deref>::Target == &str`
}

View File

@ -21,6 +21,21 @@ help: consider further restricting this bound
LL | impl<T: Copy + std::ops::Deref<Target = T>> UnsafeCopy<'_, T> for T {
| ++++++++++++
error: aborting due to 1 previous error
error[E0271]: type mismatch resolving `<&str as Deref>::Target == &str`
--> $DIR/hr-associated-type-projection-1.rs:19:6
|
LL | <&'static str>::bug(&"");
| ^^^^^^^^^^^^ expected `&str`, found `str`
|
note: required by a bound in `UnsafeCopy::bug`
--> $DIR/hr-associated-type-projection-1.rs:3:64
|
LL | for<'b> <Self as UnsafeCopy<'b, T>>::Item: std::ops::Deref<Target = T>,
| ^^^^^^^^^^ required by this bound in `UnsafeCopy::bug`
...
LL | fn bug(item: &Self::Item) -> () {
| --- required by a bound in this associated function
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0271`.

View File

@ -6,9 +6,9 @@ trait From<Src> {
trait To {
fn to<Dst>(
self
self //~ ERROR the size for values of type
) -> <Dst as From<Self>>::Result where Dst: From<Self> { //~ ERROR the size for values of type
From::from(self)
From::from(self) //~ ERROR the size for values of type
}
}

View File

@ -18,6 +18,42 @@ help: consider relaxing the implicit `Sized` restriction
LL | trait From<Src: ?Sized> {
| ++++++++
error: aborting due to 1 previous error
error[E0277]: the size for values of type `Self` cannot be known at compilation time
--> $DIR/issue-20005.rs:9:9
|
LL | self
| ^^^^ doesn't have a size known at compile-time
|
= help: unsized fn params are gated as an unstable feature
help: consider further restricting `Self`
|
LL | ) -> <Dst as From<Self>>::Result where Dst: From<Self>, Self: Sized {
| +++++++++++++
help: function arguments must have a statically known size, borrowed types always have a known size
|
LL | &self
| +
error[E0277]: the size for values of type `Self` cannot be known at compilation time
--> $DIR/issue-20005.rs:11:9
|
LL | From::from(self)
| ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
note: required by an implicit `Sized` bound in `From`
--> $DIR/issue-20005.rs:1:12
|
LL | trait From<Src> {
| ^^^ required by the implicit `Sized` requirement on this type parameter in `From`
help: consider further restricting `Self`
|
LL | ) -> <Dst as From<Self>>::Result where Dst: From<Self>, Self: Sized {
| +++++++++++++
help: consider relaxing the implicit `Sized` restriction
|
LL | trait From<Src: ?Sized> {
| ++++++++
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -35,6 +35,8 @@ pub trait Column: Expression {}
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
pub enum ColumnInsertValue<Col, Expr> where
//~^ ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied

View File

@ -18,7 +18,7 @@ LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Co
| +++++++++++++++++++++++++++++++++++++++
error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
--> $DIR/issue-38821.rs:38:1
--> $DIR/issue-38821.rs:40:1
|
LL | pub enum ColumnInsertValue<Col, Expr> where
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`, which is required by `<Col as Expression>::SqlType: IntoNullable`
@ -36,7 +36,7 @@ LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Co
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
--> $DIR/issue-38821.rs:38:1
--> $DIR/issue-38821.rs:40:1
|
LL | / pub enum ColumnInsertValue<Col, Expr> where
LL | |
@ -283,6 +283,38 @@ LL | impl<T: NotNull> IntoNullable for T {
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 16 previous errors
error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
--> $DIR/issue-38821.rs:23:10
|
LL | #[derive(Debug, Copy, Clone)]
| ^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`, which is required by `<Col as Expression>::SqlType: IntoNullable`
|
note: required for `<Col as Expression>::SqlType` to implement `IntoNullable`
--> $DIR/issue-38821.rs:9:18
|
LL | impl<T: NotNull> IntoNullable for T {
| ------- ^^^^^^^^^^^^ ^
| |
| unsatisfied trait bound introduced here
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
= note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
--> $DIR/issue-38821.rs:23:23
|
LL | #[derive(Debug, Copy, Clone)]
| ^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`, which is required by `<Col as Expression>::SqlType: IntoNullable`
|
note: required for `<Col as Expression>::SqlType` to implement `IntoNullable`
--> $DIR/issue-38821.rs:9:18
|
LL | impl<T: NotNull> IntoNullable for T {
| ------- ^^^^^^^^^^^^ ^
| |
| unsatisfied trait bound introduced here
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 18 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -22,5 +22,7 @@ pub trait ThriftService<Bug: NotFoo>:
fn with_factory<H>(factory: dyn ThriftService<()>) {}
//~^ ERROR the trait bound `(): Foo` is not satisfied
//~| ERROR the trait bound `(): Foo` is not satisfied
//~| ERROR cannot be known at compilation time
fn main() {}

View File

@ -66,6 +66,35 @@ help: consider further restricting this bound
LL | pub trait ThriftService<Bug: NotFoo + Foo>:
| +++++
error: aborting due to 5 previous errors
error[E0277]: the trait bound `(): Foo` is not satisfied
--> $DIR/issue-59324.rs:23:52
|
LL | fn with_factory<H>(factory: dyn ThriftService<()>) {}
| ^^ the trait `Foo` is not implemented for `()`
|
help: this trait has no implementations, consider adding one
--> $DIR/issue-59324.rs:3:1
|
LL | pub trait Foo: NotFoo {
| ^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the size for values of type `(dyn ThriftService<(), AssocType = _> + 'static)` cannot be known at compilation time
--> $DIR/issue-59324.rs:23:20
|
LL | fn with_factory<H>(factory: dyn ThriftService<()>) {}
| ^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `(dyn ThriftService<(), AssocType = _> + 'static)`
= help: unsized fn params are gated as an unstable feature
help: you can use `impl Trait` as the argument type
|
LL | fn with_factory<H>(factory: impl ThriftService<()>) {}
| ~~~~
help: function arguments must have a statically known size, borrowed types always have a known size
|
LL | fn with_factory<H>(factory: &dyn ThriftService<()>) {}
| +
error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -21,7 +21,9 @@ impl WithAssoc for Foo<u32, ()> {
fn generic<T, U>(v: Foo<T, U>, f: fn(<Foo<T, U> as WithAssoc>::Output) -> i32) {
//~^ ERROR `Foo<T, U>` cannot be sent between threads safely
//~| ERROR `Foo<T, U>` cannot be sent between threads safely
f(foo(v));
//~^ ERROR `Foo<T, U>` cannot be sent between threads safely
}
fn foo<T: Send>(x: T) -> <T as WithAssoc>::Output {

View File

@ -17,6 +17,50 @@ help: consider introducing a `where` clause, but there might be an alternative b
LL | fn generic<T, U>(v: Foo<T, U>, f: fn(<Foo<T, U> as WithAssoc>::Output) -> i32) where Foo<T, U>: Send {
| +++++++++++++++++++++
error: aborting due to 1 previous error
error[E0277]: `Foo<T, U>` cannot be sent between threads safely
--> $DIR/issue-83857-ub.rs:22:80
|
LL | fn generic<T, U>(v: Foo<T, U>, f: fn(<Foo<T, U> as WithAssoc>::Output) -> i32) {
| ________________________________________________________________________________^
LL | |
LL | |
LL | | f(foo(v));
LL | |
LL | | }
| |_^ `Foo<T, U>` cannot be sent between threads safely
|
= help: the trait `Send` is not implemented for `Foo<T, U>`, which is required by `Foo<T, U>: WithAssoc`
note: required for `Foo<T, U>` to implement `WithAssoc`
--> $DIR/issue-83857-ub.rs:15:15
|
LL | impl<T: Send> WithAssoc for T {
| ---- ^^^^^^^^^ ^
| |
| unsatisfied trait bound introduced here
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | fn generic<T, U>(v: Foo<T, U>, f: fn(<Foo<T, U> as WithAssoc>::Output) -> i32) where Foo<T, U>: Send {
| +++++++++++++++++++++
error[E0277]: `Foo<T, U>` cannot be sent between threads safely
--> $DIR/issue-83857-ub.rs:25:11
|
LL | f(foo(v));
| --- ^ `Foo<T, U>` cannot be sent between threads safely
| |
| required by a bound introduced by this call
|
= help: the trait `Send` is not implemented for `Foo<T, U>`
note: required by a bound in `foo`
--> $DIR/issue-83857-ub.rs:29:11
|
LL | fn foo<T: Send>(x: T) -> <T as WithAssoc>::Output {
| ^^^^ required by this bound in `foo`
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | fn generic<T, U>(v: Foo<T, U>, f: fn(<Foo<T, U> as WithAssoc>::Output) -> i32) where Foo<T, U>: Send {
| +++++++++++++++++++++
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -14,4 +14,5 @@ fn main() {
let (tx, rx) = channel();
1193182.foo(tx);
assert_eq!(rx.recv(), 1193182);
//~^ ERROR: mismatched types
}

View File

@ -17,6 +17,20 @@ help: consider adding an explicit lifetime bound
LL | impl <T: Sync + 'static> Foo for T { }
| +++++++++
error: aborting due to 1 previous error
error[E0308]: mismatched types
--> $DIR/builtin-superkinds-self-type.rs:16:27
|
LL | assert_eq!(rx.recv(), 1193182);
| ^^^^^^^ expected `Result<{integer}, RecvError>`, found integer
|
= note: expected enum `Result<{integer}, RecvError>`
found type `{integer}`
help: try wrapping the expression in `Ok`
|
LL | assert_eq!(rx.recv(), Ok(1193182));
| +++ +
For more information about this error, try `rustc --explain E0310`.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0308, E0310.
For more information about an error, try `rustc --explain E0308`.

View File

@ -5,6 +5,7 @@ struct X<F> where F: FnOnce() + 'static + Send {
fn foo<F>(blk: F) -> X<F> where F: FnOnce() + 'static {
//~^ ERROR `F` cannot be sent between threads safely
return X { field: blk };
//~^ ERROR `F` cannot be sent between threads safely
}
fn main() {

View File

@ -14,6 +14,22 @@ help: consider further restricting this bound
LL | fn foo<F>(blk: F) -> X<F> where F: FnOnce() + 'static + std::marker::Send {
| +++++++++++++++++++
error: aborting due to 1 previous error
error[E0277]: `F` cannot be sent between threads safely
--> $DIR/closure-bounds-cant-promote-superkind-in-struct.rs:7:23
|
LL | return X { field: blk };
| ^^^ `F` cannot be sent between threads safely
|
note: required by a bound in `X`
--> $DIR/closure-bounds-cant-promote-superkind-in-struct.rs:1:43
|
LL | struct X<F> where F: FnOnce() + 'static + Send {
| ^^^^ required by this bound in `X`
help: consider further restricting this bound
|
LL | fn foo<F>(blk: F) -> X<F> where F: FnOnce() + 'static + std::marker::Send {
| +++++++++++++++++++
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -23,6 +23,7 @@ impl MyTrait<MyType> for MyType {
//~^ ERROR E0119
fn get(&self) -> usize { (*self).clone() }
//~^ ERROR incompatible type
//~| ERROR mismatched types
}
fn main() { }

View File

@ -24,7 +24,15 @@ LL | fn get(&self) -> T;
= note: expected signature `fn(&MyType) -> MyType`
found signature `fn(&MyType) -> usize`
error: aborting due to 2 previous errors
error[E0308]: mismatched types
--> $DIR/coherence-blanket-conflicts-with-specific-multidispatch.rs:24:30
|
LL | fn get(&self) -> usize { (*self).clone() }
| ----- ^^^^^^^^^^^^^^^ expected `usize`, found `MyType`
| |
| expected `usize` because of return type
Some errors have detailed explanations: E0053, E0119.
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0053, E0119, E0308.
For more information about an error, try `rustc --explain E0053`.

View File

@ -15,6 +15,7 @@ impl<T> MyTrait for (T,T) {
impl<A,B> MyTrait for (A,B) {
//~^ ERROR E0119
fn get(&self) -> usize { self.dummy }
//~^ ERROR: no field `dummy`
}
fn main() { }

View File

@ -7,6 +7,13 @@ LL | impl<T> MyTrait for (T,T) {
LL | impl<A,B> MyTrait for (A,B) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_, _)`
error: aborting due to 1 previous error
error[E0609]: no field `dummy` on type `&(A, B)`
--> $DIR/coherence-tuple-conflict.rs:17:35
|
LL | fn get(&self) -> usize { self.dummy }
| ^^^^^ unknown field
For more information about this error, try `rustc --explain E0119`.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0119, E0609.
For more information about an error, try `rustc --explain E0119`.

View File

@ -20,6 +20,13 @@ LL | | for<'a> *const T: ToUnit<'a>,
|
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
error: aborting due to 1 previous error
error[E0284]: type annotations needed: cannot satisfy `<for<'a> fn(&'a (), ()) as Overlap<for<'a> fn(&'a (), ())>>::Assoc == usize`
--> $DIR/associated-type.rs:44:59
|
LL | foo::<for<'a> fn(&'a (), ()), for<'a> fn(&'a (), ())>(3usize);
| ^^^^^^ cannot satisfy `<for<'a> fn(&'a (), ()) as Overlap<for<'a> fn(&'a (), ())>>::Assoc == usize`
For more information about this error, try `rustc --explain E0119`.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0119, E0284.
For more information about an error, try `rustc --explain E0119`.

View File

@ -42,4 +42,5 @@ fn foo<T: Overlap<U>, U>(x: T::Assoc) -> T::Assoc {
fn main() {
foo::<for<'a> fn(&'a (), ()), for<'a> fn(&'a (), ())>(3usize);
//[next]~^ ERROR: cannot satisfy
}

View File

@ -1,5 +1,5 @@
error: unconstrained generic constant
--> $DIR/const-argument-if-length.rs:17:10
--> $DIR/const-argument-if-length.rs:18:10
|
LL | pad: [u8; is_zst::<T>()],
| ^^^^^^^^^^^^^^^^^^^
@ -7,7 +7,7 @@ LL | pad: [u8; is_zst::<T>()],
= help: try adding a `where` bound using this expression: `where [(); is_zst::<T>()]:`
error[E0277]: the size for values of type `T` cannot be known at compilation time
--> $DIR/const-argument-if-length.rs:15:12
--> $DIR/const-argument-if-length.rs:16:12
|
LL | pub struct AtLeastByte<T: ?Sized> {
| - this type parameter needs to be `Sized`
@ -30,6 +30,22 @@ help: the `Box` type always has a statically known size and allocates its conten
LL | value: Box<T>,
| ++++ +
error: aborting due to 2 previous errors
error[E0277]: the size for values of type `T` cannot be known at compilation time
--> $DIR/const-argument-if-length.rs:7:28
|
LL | pub const fn is_zst<T: ?Sized>() -> usize {
| - this type parameter needs to be `Sized`
LL | if std::mem::size_of::<T>() == 0 {
| ^ doesn't have a size known at compile-time
|
note: required by an implicit `Sized` bound in `std::mem::size_of`
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
LL - pub const fn is_zst<T: ?Sized>() -> usize {
LL + pub const fn is_zst<T>() -> usize {
|
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -1,5 +1,5 @@
error: generic parameters may not be used in const operations
--> $DIR/const-argument-if-length.rs:17:24
--> $DIR/const-argument-if-length.rs:18:24
|
LL | pad: [u8; is_zst::<T>()],
| ^ cannot perform const operation using `T`
@ -8,7 +8,7 @@ LL | pad: [u8; is_zst::<T>()],
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error[E0277]: the size for values of type `T` cannot be known at compilation time
--> $DIR/const-argument-if-length.rs:15:12
--> $DIR/const-argument-if-length.rs:16:12
|
LL | pub struct AtLeastByte<T: ?Sized> {
| - this type parameter needs to be `Sized`
@ -31,6 +31,22 @@ help: the `Box` type always has a statically known size and allocates its conten
LL | value: Box<T>,
| ++++ +
error: aborting due to 2 previous errors
error[E0277]: the size for values of type `T` cannot be known at compilation time
--> $DIR/const-argument-if-length.rs:7:28
|
LL | pub const fn is_zst<T: ?Sized>() -> usize {
| - this type parameter needs to be `Sized`
LL | if std::mem::size_of::<T>() == 0 {
| ^ doesn't have a size known at compile-time
|
note: required by an implicit `Sized` bound in `std::mem::size_of`
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
LL - pub const fn is_zst<T: ?Sized>() -> usize {
LL + pub const fn is_zst<T>() -> usize {
|
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -5,6 +5,7 @@
pub const fn is_zst<T: ?Sized>() -> usize {
if std::mem::size_of::<T>() == 0 {
//~^ ERROR the size for values of type `T` cannot be known at compilation time
1
} else {
0

View File

@ -4,6 +4,27 @@ error[E0741]: using function pointers as const generic parameters is forbidden
LL | struct Checked<const F: fn(usize) -> bool>;
| ^^^^^^^^^^^^^^^^^
error: aborting due to 1 previous error
error[E0308]: mismatched types
--> $DIR/fn-const-param-infer.rs:23:24
|
LL | let _ = Checked::<{generic_arg::<u32>}>;
| ^^^^^^^^^^^^^^^^^^ expected fn pointer, found fn item
|
= note: expected fn pointer `fn(usize) -> _`
found fn item `fn(u32) -> _ {generic_arg::<u32>}`
For more information about this error, try `rustc --explain E0741`.
error[E0282]: type annotations needed
--> $DIR/fn-const-param-infer.rs:25:23
|
LL | let _ = Checked::<generic>;
| ^^^^^^^ cannot infer type of the type parameter `T` declared on the function `generic`
|
help: consider specifying the generic argument
|
LL | let _ = Checked::<generic::<T>>;
| +++++
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0282, E0308, E0741.
For more information about an error, try `rustc --explain E0282`.

View File

@ -6,5 +6,27 @@ LL | struct Checked<const F: fn(usize) -> bool>;
|
= note: the only supported types are integers, `bool` and `char`
error: aborting due to 1 previous error
error[E0308]: mismatched types
--> $DIR/fn-const-param-infer.rs:23:24
|
LL | let _ = Checked::<{generic_arg::<u32>}>;
| ^^^^^^^^^^^^^^^^^^ expected fn pointer, found fn item
|
= note: expected fn pointer `fn(usize) -> _`
found fn item `fn(u32) -> _ {generic_arg::<u32>}`
error[E0282]: type annotations needed
--> $DIR/fn-const-param-infer.rs:25:23
|
LL | let _ = Checked::<generic>;
| ^^^^^^^ cannot infer type of the type parameter `T` declared on the function `generic`
|
help: consider specifying the generic argument
|
LL | let _ = Checked::<generic::<T>>;
| +++++
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0282, E0308.
For more information about an error, try `rustc --explain E0282`.

View File

@ -20,9 +20,9 @@ fn main() {
let _ = Checked::<generic_arg>;
let _ = Checked::<{generic_arg::<usize>}>;
let _ = Checked::<{generic_arg::<u32>}>;
let _ = Checked::<{generic_arg::<u32>}>; //~ ERROR: mismatched types
let _ = Checked::<generic>;
let _ = Checked::<generic>; //~ ERROR: type annotations needed
let _ = Checked::<{generic::<u16>}>;
let _: Checked<{generic::<u16>}> = Checked::<{generic::<u16>}>;
let _: Checked<{generic::<u32>}> = Checked::<{generic::<u16>}>;

View File

@ -16,6 +16,7 @@ impl<const N: usize> Example<N> {
Self {
a: [0.; N],
b: [0.; complex_maths(N)],
//~^ ERROR: unconstrained generic constant
}
}
}

View File

@ -6,5 +6,13 @@ LL | b: [f32; complex_maths(N)],
|
= help: try adding a `where` bound using this expression: `where [(); complex_maths(N)]:`
error: aborting due to 1 previous error
error: unconstrained generic constant
--> $DIR/no_where_clause.rs:18:15
|
LL | b: [0.; complex_maths(N)],
| ^^^^^^^^^^^^^^^^
|
= help: try adding a `where` bound using this expression: `where [(); complex_maths(N)]:`
error: aborting due to 2 previous errors

View File

@ -15,7 +15,7 @@ impl Foo for () {
}
fn use_dyn(v: &dyn Foo) { //~ERROR the trait `Foo` cannot be made into an object
v.test();
v.test(); //~ERROR the trait `Foo` cannot be made into an object
}
fn main() {}

View File

@ -16,6 +16,24 @@ LL | fn test(&self) -> [u8; bar::<Self>()];
= help: consider moving `test` to another trait
= help: only type `()` implements the trait, consider using it directly instead
error: aborting due to 1 previous error
error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/object-safety-err-ret.rs:18:5
|
LL | v.test();
| ^^^^^^^^ `Foo` 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/object-safety-err-ret.rs:8:8
|
LL | trait Foo {
| --- this trait cannot be made into an object...
LL | fn test(&self) -> [u8; bar::<Self>()];
| ^^^^ ^^^^^^^^^^^^^^^^^^^ ...because method `test` references the `Self` type in its return type
| |
| ...because method `test` references the `Self` type in its `where` clause
= help: consider moving `test` to another trait
= help: only type `()` implements the trait, consider using it directly instead
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0038`.

View File

@ -34,6 +34,47 @@ LL + #[derive(ConstParamTy)]
LL | struct Foo(u8);
|
error: aborting due to 3 previous errors
error: unconstrained generic constant
--> $DIR/unify-op-with-fn-call.rs:30:12
|
LL | bar2::<{ std::ops::Add::add(N, N) }>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: try adding a `where` bound using this expression: `where [(); { std::ops::Add::add(N, N) }]:`
For more information about this error, try `rustc --explain E0741`.
error[E0015]: cannot call non-const operator in constants
--> $DIR/unify-op-with-fn-call.rs:20:39
|
LL | fn foo<const N: Foo>(a: Evaluatable<{ N + N }>) {
| ^^^^^
|
note: impl defined here, but it is not `const`
--> $DIR/unify-op-with-fn-call.rs:10:1
|
LL | impl const std::ops::Add for Foo {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(effects)]` to the crate attributes to enable
error[E0015]: cannot call non-const fn `<Foo as Add>::add` in constants
--> $DIR/unify-op-with-fn-call.rs:21:13
|
LL | bar::<{ std::ops::Add::add(N, N) }>();
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(effects)]` to the crate attributes to enable
error[E0015]: cannot call non-const fn `<usize as Add>::add` in constants
--> $DIR/unify-op-with-fn-call.rs:30:14
|
LL | bar2::<{ std::ops::Add::add(N, N) }>();
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(effects)]` to the crate attributes to enable
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0015, E0741.
For more information about an error, try `rustc --explain E0015`.

View File

@ -15,6 +15,16 @@ LL | fn foo<const N: usize, const A: [u8; N]>() {}
= note: the only supported types are integers, `bool` and `char`
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
error: aborting due to 2 previous errors
error[E0747]: type provided when a constant was expected
--> $DIR/issue-62878.rs:10:11
|
LL | foo::<_, { [1] }>();
| ^
|
= help: const arguments cannot yet be inferred with `_`
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
For more information about this error, try `rustc --explain E0770`.
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0747, E0770.
For more information about an error, try `rustc --explain E0747`.

View File

@ -8,4 +8,5 @@ fn foo<const N: usize, const A: [u8; N]>() {}
fn main() {
foo::<_, { [1] }>();
//[min]~^ ERROR: type provided when a constant was expected
}

View File

@ -1,7 +1,7 @@
error[E0741]: using function pointers as const generic parameters is forbidden
--> $DIR/issue-72352.rs:7:42
--> $DIR/issue-72352.rs:8:42
|
LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const c_char) -> usize {
| ^^^^^^^^^^^^^^^^^^
error: aborting due to 1 previous error

View File

@ -1,7 +1,7 @@
error: using function pointers as const generic parameters is forbidden
--> $DIR/issue-72352.rs:7:42
--> $DIR/issue-72352.rs:8:42
|
LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const c_char) -> usize {
| ^^^^^^^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`

View File

@ -1,10 +1,11 @@
// revisions: full min
#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
use std::ffi::{CStr, CString};
use std::ffi::{c_char, CStr, CString};
unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const c_char) -> usize {
//~^ ERROR: using function pointers as const generic parameters is forbidden
F(CStr::from_ptr(ptr))
}
@ -16,7 +17,5 @@ fn safely_do_the_thing(s: &CStr) -> usize {
fn main() {
let baguette = CString::new("baguette").unwrap();
let ptr = baguette.as_ptr();
println!("{}", unsafe {
unsafely_do_the_thing::<safely_do_the_thing>(ptr)
});
println!("{}", unsafe { unsafely_do_the_thing::<safely_do_the_thing>(ptr) });
}

View File

@ -4,6 +4,18 @@ error[E0741]: using raw pointers as const generic parameters is forbidden
LL | struct Const<const P: *const u32>;
| ^^^^^^^^^^
error: aborting due to 1 previous error
error[E0308]: mismatched types
--> $DIR/raw-ptr-const-param.rs:9:40
|
LL | let _: Const<{ 15 as *const _ }> = Const::<{ 10 as *const _ }>;
| ------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{0xf as *const u32}`, found `{0xa as *const u32}`
| |
| expected due to this
|
= note: expected struct `Const<{0xf as *const u32}>`
found struct `Const<{0xa as *const u32}>`
For more information about this error, try `rustc --explain E0741`.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0308, E0741.
For more information about an error, try `rustc --explain E0308`.

View File

@ -6,5 +6,17 @@ LL | struct Const<const P: *const u32>;
|
= note: the only supported types are integers, `bool` and `char`
error: aborting due to 1 previous error
error[E0308]: mismatched types
--> $DIR/raw-ptr-const-param.rs:9:40
|
LL | let _: Const<{ 15 as *const _ }> = Const::<{ 10 as *const _ }>;
| ------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{0xf as *const u32}`, found `{0xa as *const u32}`
| |
| expected due to this
|
= note: expected struct `Const<{0xf as *const u32}>`
found struct `Const<{0xa as *const u32}>`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.

View File

@ -7,5 +7,6 @@ struct Const<const P: *const u32>; //~ ERROR: using raw pointers as const generi
fn main() {
let _: Const<{ 15 as *const _ }> = Const::<{ 10 as *const _ }>;
//~^ ERROR: mismatched types
let _: Const<{ 10 as *const _ }> = Const::<{ 10 as *const _ }>;
}

View File

@ -16,5 +16,39 @@ LL | struct ConstBytes<const T: &'static [u8]>;
= note: the only supported types are integers, `bool` and `char`
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
error: aborting due to 2 previous errors
error[E0308]: mismatched types
--> $DIR/slice-const-param-mismatch.rs:14:35
|
LL | let _: ConstString<"Hello"> = ConstString::<"World">;
| -------------------- ^^^^^^^^^^^^^^^^^^^^^^ expected `"Hello"`, found `"World"`
| |
| expected due to this
|
= note: expected struct `ConstString<"Hello">`
found struct `ConstString<"World">`
error[E0308]: mismatched types
--> $DIR/slice-const-param-mismatch.rs:16:33
|
LL | let _: ConstString<"ℇ㇈↦"> = ConstString::<"ℇ㇈↥">;
| ------------------- ^^^^^^^^^^^^^^^^^^^^^ expected `"ℇ㇈↦"`, found `"ℇ㇈↥"`
| |
| expected due to this
|
= note: expected struct `ConstString<"ℇ㇈↦">`
found struct `ConstString<"ℇ㇈↥">`
error[E0308]: mismatched types
--> $DIR/slice-const-param-mismatch.rs:18:33
|
LL | let _: ConstBytes<b"AAA"> = ConstBytes::<b"BBB">;
| ------------------ ^^^^^^^^^^^^^^^^^^^^ expected `b"AAA"`, found `b"BBB"`
| |
| expected due to this
|
= note: expected struct `ConstBytes<b"AAA">`
found struct `ConstBytes<b"BBB">`
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0308`.

View File

@ -11,9 +11,9 @@ struct ConstBytes<const T: &'static [u8]>;
pub fn main() {
let _: ConstString<"Hello"> = ConstString::<"Hello">;
let _: ConstString<"Hello"> = ConstString::<"World">; //[full]~ ERROR mismatched types
let _: ConstString<"Hello"> = ConstString::<"World">; //~ ERROR mismatched types
let _: ConstString<"ℇ㇈↦"> = ConstString::<"ℇ㇈↦">;
let _: ConstString<"ℇ㇈↦"> = ConstString::<"ℇ㇈↥">; //[full]~ ERROR mismatched types
let _: ConstString<"ℇ㇈↦"> = ConstString::<"ℇ㇈↥">; //~ ERROR mismatched types
let _: ConstBytes<b"AAA"> = ConstBytes::<{&[0x41, 0x41, 0x41]}>;
let _: ConstBytes<b"AAA"> = ConstBytes::<b"BBB">; //[full]~ ERROR mismatched types
let _: ConstBytes<b"AAA"> = ConstBytes::<b"BBB">; //~ ERROR mismatched types
}

View File

@ -18,4 +18,6 @@ static STATIC_BAR: str = *"bar";
fn main() {
println!("{:?} {:?} {:?} {:?}", &CONST_0, &CONST_FOO, &STATIC_1, &STATIC_BAR);
//~^ ERROR: cannot move a value of type `str`
//~| ERROR: cannot move a value of type `dyn Debug + Sync`
}

View File

@ -66,6 +66,19 @@ LL | static STATIC_BAR: str = *"bar";
= 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
error[E0161]: cannot move a value of type `str`
--> $DIR/const-unsized.rs:20:48
|
LL | println!("{:?} {:?} {:?} {:?}", &CONST_0, &CONST_FOO, &STATIC_1, &STATIC_BAR);
| ^^^^^^^^^ the size of `str` cannot be statically determined
For more information about this error, try `rustc --explain E0277`.
error[E0161]: cannot move a value of type `dyn Debug + Sync`
--> $DIR/const-unsized.rs:20:38
|
LL | println!("{:?} {:?} {:?} {:?}", &CONST_0, &CONST_FOO, &STATIC_1, &STATIC_BAR);
| ^^^^^^^ the size of `dyn Debug + Sync` cannot be statically determined
error: aborting due to 10 previous errors
Some errors have detailed explanations: E0161, E0277.
For more information about an error, try `rustc --explain E0161`.

View File

@ -28,4 +28,5 @@ fn require<A,B>()
fn main() {
require::<i32, u32>();
//~^ ERROR `i32: Bar<u32>` is not satisfied
}

View File

@ -12,6 +12,25 @@ LL | trait Bar<X> { }
= help: see issue #48214
= help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
error: aborting due to 1 previous error
error[E0277]: the trait bound `i32: Bar<u32>` is not satisfied
--> $DIR/cross-fn-cache-hole.rs:30:15
|
LL | require::<i32, u32>();
| ^^^ the trait `Bar<u32>` is not implemented for `i32`
|
help: this trait has no implementations, consider adding one
--> $DIR/cross-fn-cache-hole.rs:11:1
|
LL | trait Bar<X> { }
| ^^^^^^^^^^^^
note: required by a bound in `require`
--> $DIR/cross-fn-cache-hole.rs:25:14
|
LL | fn require<A,B>()
| ------- required by a bound in this function
LL | where A: Bar<B>
| ^^^^^^ required by this bound in `require`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -5,6 +5,8 @@ trait Trait {
fn call_foo(x: Box<dyn Trait>) {
//~^ ERROR E0038
let y = x.foo();
//~^ ERROR E0038
//~| ERROR E0277
}
fn main() {

View File

@ -13,6 +13,32 @@ LL | fn foo(&self) -> Self;
| ^^^^ ...because method `foo` references the `Self` type in its return type
= help: consider moving `foo` to another trait
error: aborting due to 1 previous error
error[E0038]: the trait `Trait` cannot be made into an object
--> $DIR/E0038.rs:7:13
|
LL | let y = x.foo();
| ^^^^^^^ `Trait` 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/E0038.rs:2:22
|
LL | trait Trait {
| ----- this trait cannot be made into an object...
LL | fn foo(&self) -> Self;
| ^^^^ ...because method `foo` references the `Self` type in its return type
= help: consider moving `foo` to another trait
For more information about this error, try `rustc --explain E0038`.
error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time
--> $DIR/E0038.rs:7:9
|
LL | let y = x.foo();
| ^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `dyn Trait`
= note: all local variables must have a statically known size
= help: unsized locals are gated as an unstable feature
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0038, E0277.
For more information about an error, try `rustc --explain E0038`.

View File

@ -1,6 +1,8 @@
#![feature(unboxed_closures)]
fn foo<F: Fn<i32>>(f: F) -> F::Output { f(3) } //~ ERROR E0059
//~^ ERROR `i32` is not a tuple
//~| ERROR cannot use call notation
fn main() {
}

View File

@ -7,6 +7,19 @@ LL | fn foo<F: Fn<i32>>(f: F) -> F::Output { f(3) }
note: required by a bound in `Fn`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
error: aborting due to 1 previous error
error[E0277]: `i32` is not a tuple
--> $DIR/E0059.rs:3:41
|
LL | fn foo<F: Fn<i32>>(f: F) -> F::Output { f(3) }
| ^^^^ the trait `Tuple` is not implemented for `i32`
For more information about this error, try `rustc --explain E0059`.
error[E0059]: cannot use call notation; the first type parameter for the function trait is neither a tuple nor unit
--> $DIR/E0059.rs:3:41
|
LL | fn foo<F: Fn<i32>>(f: F) -> F::Output { f(3) }
| ^^^^
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0059, E0277.
For more information about an error, try `rustc --explain E0059`.

View File

@ -15,6 +15,7 @@ fn baz<I>(x: &<I as Foo<A=Bar>>::A) {}
//~| ERROR associated type bindings are not allowed here [E0229]
//~| ERROR associated type bindings are not allowed here [E0229]
//~| ERROR the trait bound `I: Foo` is not satisfied
//~| ERROR the trait bound `I: Foo` is not satisfied
fn main() {
}

View File

@ -31,7 +31,18 @@ help: consider restricting type parameter `I`
LL | fn baz<I: Foo>(x: &<I as Foo<A=Bar>>::A) {}
| +++++
error: aborting due to 4 previous errors
error[E0277]: the trait bound `I: Foo` is not satisfied
--> $DIR/E0229.rs:13:37
|
LL | fn baz<I>(x: &<I as Foo<A=Bar>>::A) {}
| ^^ the trait `Foo` is not implemented for `I`
|
help: consider restricting type parameter `I`
|
LL | fn baz<I: Foo>(x: &<I as Foo<A=Bar>>::A) {}
| +++++
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0229, E0277.
For more information about an error, try `rustc --explain E0229`.

View File

@ -3,4 +3,5 @@ fn main() {
static symbol: [usize]; //~ ERROR: the size for values of type
}
println!("{}", symbol[0]);
//~^ ERROR: extern static is unsafe
}

View File

@ -6,6 +6,15 @@ LL | static symbol: [usize];
|
= help: the trait `Sized` is not implemented for `[usize]`
error: aborting due to 1 previous error
error[E0133]: use of extern static is unsafe and requires unsafe function or block
--> $DIR/issue-36122-accessing-externed-dst.rs:5:20
|
LL | println!("{}", symbol[0]);
| ^^^^^^ use of extern static
|
= note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
For more information about this error, try `rustc --explain E0277`.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0133, E0277.
For more information about an error, try `rustc --explain E0133`.

View File

@ -18,6 +18,6 @@ where
fn main() {
let x = String::from("Hello World!");
let y = f(&x, ());
drop(x);
drop(x); //~ ERROR cannot move out of `x`
println!("{}", y);
}

View File

@ -16,6 +16,19 @@ help: consider adding an explicit lifetime bound
LL | impl<'a, T: 'a> Trait<'a> for T {
| ++++
error: aborting due to 1 previous error
error[E0505]: cannot move out of `x` because it is borrowed
--> $DIR/implied-bounds-unnorm-associated-type-5.rs:21:10
|
LL | let x = String::from("Hello World!");
| - binding `x` declared here
LL | let y = f(&x, ());
| -- borrow of `x` occurs here
LL | drop(x);
| ^ move out of `x` occurs here
LL | println!("{}", y);
| - borrow later used here
For more information about this error, try `rustc --explain E0309`.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0309, E0505.
For more information about an error, try `rustc --explain E0309`.

View File

@ -16,6 +16,43 @@ LL | type A<'a> where Self: 'a;
Fooer<T>
Fooy
error: aborting due to 1 previous error
error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/gat-in-trait-path.rs:32:5
|
LL | f(Box::new(foo));
| ^^^^^^^^^^^^^ `Foo` 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/gat-in-trait-path.rs:10:10
|
LL | trait Foo {
| --- this trait cannot be made into an object...
LL | type A<'a> where Self: 'a;
| ^ ...because it contains the generic associated type `A`
= help: consider moving `A` to another trait
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Foo` for this new enum and using it instead:
Fooer<T>
Fooy
error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/gat-in-trait-path.rs:32:5
|
LL | f(Box::new(foo));
| ^^^^^^^^^^^^^ `Foo` 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/gat-in-trait-path.rs:10:10
|
LL | trait Foo {
| --- this trait cannot be made into an object...
LL | type A<'a> where Self: 'a;
| ^ ...because it contains the generic associated type `A`
= help: consider moving `A` to another trait
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Foo` for this new enum and using it instead:
Fooer<T>
Fooy
= note: required for the cast from `Box<Fooer<{integer}>>` to `Box<(dyn Foo<A = &'a ()> + 'static)>`
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0038`.

View File

@ -30,4 +30,6 @@ fn f(_arg : Box<dyn for<'a> Foo<A<'a> = &'a ()>>) {}
fn main() {
let foo = Fooer(5);
f(Box::new(foo));
//[base]~^ the trait `Foo` cannot be made into an object
//[base]~| the trait `Foo` cannot be made into an object
}

View File

@ -9,6 +9,7 @@ impl<T> X for T { //~ ERROR: not all trait items implemented
//~^ ERROR missing generics for associated type
//~^^ ERROR missing generics for associated type
//~| ERROR method `foo` has 1 type parameter but its trait declaration has 0 type parameters
//~| ERROR may not live long enough
t
}
}

View File

@ -51,7 +51,16 @@ LL | type Y<'a>;
LL | impl<T> X for T {
| ^^^^^^^^^^^^^^^ missing `Y` in implementation
error: aborting due to 4 previous errors
error: lifetime may not live long enough
--> $DIR/gat-trait-path-missing-lifetime.rs:8:3
|
LL | fn foo<'a, T1: X<Y = T1>>(t : T1) -> T1::Y<'a> {
| ^^^^^^^--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | lifetime `'a` defined here
| requires that `'a` must outlive `'static`
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0046, E0049, E0107.
For more information about an error, try `rustc --explain E0046`.

Some files were not shown because too many files have changed in this diff Show More