Revert "Remove deferred sized checks"
This reverts commit 33212bf7f527798a8cfa2bbb38781742f4ca718a.
This commit is contained in:
parent
2b443a8d97
commit
2820bc4b69
@ -561,17 +561,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
// We just want to check sizedness, so instead of introducing
|
// We just want to check sizedness, so instead of introducing
|
||||||
// placeholder lifetimes with probing, we just replace higher lifetimes
|
// placeholder lifetimes with probing, we just replace higher lifetimes
|
||||||
// with fresh vars.
|
// with fresh vars.
|
||||||
let arg_span = args.get(i).map(|a| a.span);
|
let span = args.get(i).map(|a| a.span).unwrap_or(expr.span);
|
||||||
let span = arg_span.unwrap_or(expr.span);
|
|
||||||
let input = self.replace_bound_vars_with_fresh_vars(
|
let input = self.replace_bound_vars_with_fresh_vars(
|
||||||
span,
|
span,
|
||||||
infer::LateBoundRegionConversionTime::FnCall,
|
infer::LateBoundRegionConversionTime::FnCall,
|
||||||
fn_sig.input(i),
|
fn_sig.input(i),
|
||||||
);
|
);
|
||||||
self.require_type_is_sized(
|
self.require_type_is_sized_deferred(
|
||||||
self.normalize_associated_types_in(span, input),
|
input,
|
||||||
span,
|
span,
|
||||||
traits::SizedArgumentType(arg_span),
|
traits::SizedArgumentType(None),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -586,11 +585,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
infer::LateBoundRegionConversionTime::FnCall,
|
infer::LateBoundRegionConversionTime::FnCall,
|
||||||
fn_sig.output(),
|
fn_sig.output(),
|
||||||
);
|
);
|
||||||
self.require_type_is_sized(
|
self.require_type_is_sized_deferred(output, expr.span, traits::SizedReturnType);
|
||||||
self.normalize_associated_types_in(expr.span, output),
|
|
||||||
expr.span,
|
|
||||||
traits::SizedReturnType,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We always require that the type provided as the value for
|
// We always require that the type provided as the value for
|
||||||
|
@ -442,6 +442,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn require_type_is_sized_deferred(
|
||||||
|
&self,
|
||||||
|
ty: Ty<'tcx>,
|
||||||
|
span: Span,
|
||||||
|
code: traits::ObligationCauseCode<'tcx>,
|
||||||
|
) {
|
||||||
|
if !ty.references_error() {
|
||||||
|
self.deferred_sized_obligations.borrow_mut().push((ty, span, code));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn register_bound(
|
pub fn register_bound(
|
||||||
&self,
|
&self,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
|
@ -35,6 +35,11 @@ pub struct Inherited<'a, 'tcx> {
|
|||||||
|
|
||||||
pub(super) fulfillment_cx: RefCell<Box<dyn TraitEngine<'tcx>>>,
|
pub(super) fulfillment_cx: RefCell<Box<dyn TraitEngine<'tcx>>>,
|
||||||
|
|
||||||
|
// Some additional `Sized` obligations badly affect type inference.
|
||||||
|
// These obligations are added in a later stage of typeck.
|
||||||
|
pub(super) deferred_sized_obligations:
|
||||||
|
RefCell<Vec<(Ty<'tcx>, Span, traits::ObligationCauseCode<'tcx>)>>,
|
||||||
|
|
||||||
// When we process a call like `c()` where `c` is a closure type,
|
// When we process a call like `c()` where `c` is a closure type,
|
||||||
// we may not have decided yet whether `c` is a `Fn`, `FnMut`, or
|
// we may not have decided yet whether `c` is a `Fn`, `FnMut`, or
|
||||||
// `FnOnce` closure. In that case, we defer full resolution of the
|
// `FnOnce` closure. In that case, we defer full resolution of the
|
||||||
@ -112,6 +117,7 @@ impl<'a, 'tcx> Inherited<'a, 'tcx> {
|
|||||||
infcx,
|
infcx,
|
||||||
fulfillment_cx: RefCell::new(<dyn TraitEngine<'_>>::new(tcx)),
|
fulfillment_cx: RefCell::new(<dyn TraitEngine<'_>>::new(tcx)),
|
||||||
locals: RefCell::new(Default::default()),
|
locals: RefCell::new(Default::default()),
|
||||||
|
deferred_sized_obligations: RefCell::new(Vec::new()),
|
||||||
deferred_call_resolutions: RefCell::new(Default::default()),
|
deferred_call_resolutions: RefCell::new(Default::default()),
|
||||||
deferred_cast_checks: RefCell::new(Vec::new()),
|
deferred_cast_checks: RefCell::new(Vec::new()),
|
||||||
deferred_transmute_checks: RefCell::new(Vec::new()),
|
deferred_transmute_checks: RefCell::new(Vec::new()),
|
||||||
|
@ -466,6 +466,11 @@ fn typeck_with_fallback<'tcx>(
|
|||||||
fcx.resolve_rvalue_scopes(def_id.to_def_id());
|
fcx.resolve_rvalue_scopes(def_id.to_def_id());
|
||||||
fcx.resolve_generator_interiors(def_id.to_def_id());
|
fcx.resolve_generator_interiors(def_id.to_def_id());
|
||||||
|
|
||||||
|
for (ty, span, code) in fcx.deferred_sized_obligations.borrow_mut().drain(..) {
|
||||||
|
let ty = fcx.normalize_ty(span, ty);
|
||||||
|
fcx.require_type_is_sized(ty, span, code);
|
||||||
|
}
|
||||||
|
|
||||||
fcx.select_all_obligations_or_error();
|
fcx.select_all_obligations_or_error();
|
||||||
|
|
||||||
if !fcx.infcx.is_tainted_by_errors() {
|
if !fcx.infcx.is_tainted_by_errors() {
|
||||||
|
@ -9,6 +9,7 @@ where
|
|||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
<[T; N.get()]>::try_from(())
|
<[T; N.get()]>::try_from(())
|
||||||
//~^ error: the trait bound
|
//~^ error: the trait bound
|
||||||
|
//~| error: the trait bound
|
||||||
//~| error: mismatched types
|
//~| error: mismatched types
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,12 +29,14 @@ pub fn f1_uint_uint() {
|
|||||||
f1(2u32, 4u32);
|
f1(2u32, 4u32);
|
||||||
//~^ ERROR `u32: Foo` is not satisfied
|
//~^ ERROR `u32: Foo` is not satisfied
|
||||||
//~| ERROR `u32: Foo` is not satisfied
|
//~| ERROR `u32: Foo` is not satisfied
|
||||||
|
//~| ERROR `u32: Foo` is not satisfied
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn f1_uint_int() {
|
pub fn f1_uint_int() {
|
||||||
f1(2u32, 4i32);
|
f1(2u32, 4i32);
|
||||||
//~^ ERROR `u32: Foo` is not satisfied
|
//~^ ERROR `u32: Foo` is not satisfied
|
||||||
//~| ERROR `u32: Foo` is not satisfied
|
//~| ERROR `u32: Foo` is not satisfied
|
||||||
|
//~| ERROR `u32: Foo` is not satisfied
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn f2_int() {
|
pub fn f2_int() {
|
||||||
|
@ -31,6 +31,14 @@ note: required by a bound in `f1`
|
|||||||
LL | pub fn f1<T: Foo>(a: T, x: T::A) {}
|
LL | pub fn f1<T: Foo>(a: T, x: T::A) {}
|
||||||
| ^^^ required by this bound in `f1`
|
| ^^^ required by this bound in `f1`
|
||||||
|
|
||||||
|
error[E0277]: the trait bound `u32: Foo` is not satisfied
|
||||||
|
--> $DIR/associated-types-path-2.rs:29:5
|
||||||
|
|
|
||||||
|
LL | f1(2u32, 4u32);
|
||||||
|
| ^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `u32`
|
||||||
|
|
|
||||||
|
= help: the trait `Foo` is implemented for `i32`
|
||||||
|
|
||||||
error[E0277]: the trait bound `u32: Foo` is not satisfied
|
error[E0277]: the trait bound `u32: Foo` is not satisfied
|
||||||
--> $DIR/associated-types-path-2.rs:29:14
|
--> $DIR/associated-types-path-2.rs:29:14
|
||||||
|
|
|
|
||||||
@ -40,7 +48,7 @@ LL | f1(2u32, 4u32);
|
|||||||
= help: the trait `Foo` is implemented for `i32`
|
= help: the trait `Foo` is implemented for `i32`
|
||||||
|
|
||||||
error[E0277]: the trait bound `u32: Foo` is not satisfied
|
error[E0277]: the trait bound `u32: Foo` is not satisfied
|
||||||
--> $DIR/associated-types-path-2.rs:35:8
|
--> $DIR/associated-types-path-2.rs:36:8
|
||||||
|
|
|
|
||||||
LL | f1(2u32, 4i32);
|
LL | f1(2u32, 4i32);
|
||||||
| -- ^^^^ the trait `Foo` is not implemented for `u32`
|
| -- ^^^^ the trait `Foo` is not implemented for `u32`
|
||||||
@ -55,7 +63,15 @@ LL | pub fn f1<T: Foo>(a: T, x: T::A) {}
|
|||||||
| ^^^ required by this bound in `f1`
|
| ^^^ required by this bound in `f1`
|
||||||
|
|
||||||
error[E0277]: the trait bound `u32: Foo` is not satisfied
|
error[E0277]: the trait bound `u32: Foo` is not satisfied
|
||||||
--> $DIR/associated-types-path-2.rs:35:14
|
--> $DIR/associated-types-path-2.rs:36:5
|
||||||
|
|
|
||||||
|
LL | f1(2u32, 4i32);
|
||||||
|
| ^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `u32`
|
||||||
|
|
|
||||||
|
= help: the trait `Foo` is implemented for `i32`
|
||||||
|
|
||||||
|
error[E0277]: the trait bound `u32: Foo` is not satisfied
|
||||||
|
--> $DIR/associated-types-path-2.rs:36:14
|
||||||
|
|
|
|
||||||
LL | f1(2u32, 4i32);
|
LL | f1(2u32, 4i32);
|
||||||
| ^^^^ the trait `Foo` is not implemented for `u32`
|
| ^^^^ the trait `Foo` is not implemented for `u32`
|
||||||
@ -63,7 +79,7 @@ LL | f1(2u32, 4i32);
|
|||||||
= help: the trait `Foo` is implemented for `i32`
|
= help: the trait `Foo` is implemented for `i32`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/associated-types-path-2.rs:41:18
|
--> $DIR/associated-types-path-2.rs:43:18
|
||||||
|
|
|
|
||||||
LL | let _: i32 = f2(2i32);
|
LL | let _: i32 = f2(2i32);
|
||||||
| --- ^^^^^^^^ expected `i32`, found `u32`
|
| --- ^^^^^^^^ expected `i32`, found `u32`
|
||||||
@ -75,7 +91,7 @@ help: you can convert a `u32` to an `i32` and panic if the converted value doesn
|
|||||||
LL | let _: i32 = f2(2i32).try_into().unwrap();
|
LL | let _: i32 = f2(2i32).try_into().unwrap();
|
||||||
| ++++++++++++++++++++
|
| ++++++++++++++++++++
|
||||||
|
|
||||||
error: aborting due to 6 previous errors
|
error: aborting due to 8 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0277, E0308.
|
Some errors have detailed explanations: E0277, E0308.
|
||||||
For more information about an error, try `rustc --explain E0277`.
|
For more information about an error, try `rustc --explain E0277`.
|
||||||
|
@ -18,11 +18,8 @@ LL | foo(*x);
|
|||||||
| ^^ 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 `(dyn Foo + 'static)`
|
= help: the trait `Sized` is not implemented for `(dyn Foo + 'static)`
|
||||||
|
= note: all function arguments must have a statically known size
|
||||||
= help: unsized fn params are gated as an unstable feature
|
= help: unsized fn params are gated as an unstable feature
|
||||||
help: function arguments must have a statically known size, borrowed types always have a known size
|
|
||||||
|
|
|
||||||
LL | foo(&*x);
|
|
||||||
| +
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
let _ = Iterator::next(&mut ());
|
let _ = Iterator::next(&mut ());
|
||||||
//~^ ERROR `()` is not an iterator
|
//~^ ERROR `()` is not an iterator
|
||||||
|
//~| ERROR `()` is not an iterator
|
||||||
|
//~| ERROR `()` is not an iterator
|
||||||
|
|
||||||
for _ in false {}
|
for _ in false {}
|
||||||
//~^ ERROR `bool` is not an iterator
|
//~^ ERROR `bool` is not an iterator
|
||||||
|
|
||||||
let _ = Iterator::next(&mut ());
|
let _ = Iterator::next(&mut ());
|
||||||
//~^ ERROR `()` is not an iterator
|
//~^ ERROR `()` is not an iterator
|
||||||
|
//~| ERROR `()` is not an iterator
|
||||||
|
|
||||||
other()
|
other()
|
||||||
}
|
}
|
||||||
@ -16,9 +19,12 @@ pub fn other() {
|
|||||||
|
|
||||||
let _ = Iterator::next(&mut ());
|
let _ = Iterator::next(&mut ());
|
||||||
//~^ ERROR `()` is not an iterator
|
//~^ ERROR `()` is not an iterator
|
||||||
|
//~| ERROR `()` is not an iterator
|
||||||
|
//~| ERROR `()` is not an iterator
|
||||||
|
|
||||||
let _ = Iterator::next(&mut ());
|
let _ = Iterator::next(&mut ());
|
||||||
//~^ ERROR `()` is not an iterator
|
//~^ ERROR `()` is not an iterator
|
||||||
|
//~| ERROR `()` is not an iterator
|
||||||
|
|
||||||
for _ in false {}
|
for _ in false {}
|
||||||
//~^ ERROR `bool` is not an iterator
|
//~^ ERROR `bool` is not an iterator
|
||||||
|
@ -8,8 +8,16 @@ LL | let _ = Iterator::next(&mut ());
|
|||||||
|
|
|
|
||||||
= help: the trait `Iterator` is not implemented for `()`
|
= help: the trait `Iterator` is not implemented for `()`
|
||||||
|
|
||||||
|
error[E0277]: `()` is not an iterator
|
||||||
|
--> $DIR/issue-28098.rs:2:13
|
||||||
|
|
|
||||||
|
LL | let _ = Iterator::next(&mut ());
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator
|
||||||
|
|
|
||||||
|
= help: the trait `Iterator` is not implemented for `()`
|
||||||
|
|
||||||
error[E0277]: `bool` is not an iterator
|
error[E0277]: `bool` is not an iterator
|
||||||
--> $DIR/issue-28098.rs:5:14
|
--> $DIR/issue-28098.rs:7:14
|
||||||
|
|
|
|
||||||
LL | for _ in false {}
|
LL | for _ in false {}
|
||||||
| ^^^^^ `bool` is not an iterator
|
| ^^^^^ `bool` is not an iterator
|
||||||
@ -18,7 +26,7 @@ LL | for _ in false {}
|
|||||||
= note: required for `bool` to implement `IntoIterator`
|
= note: required for `bool` to implement `IntoIterator`
|
||||||
|
|
||||||
error[E0277]: `()` is not an iterator
|
error[E0277]: `()` is not an iterator
|
||||||
--> $DIR/issue-28098.rs:8:28
|
--> $DIR/issue-28098.rs:10:28
|
||||||
|
|
|
|
||||||
LL | let _ = Iterator::next(&mut ());
|
LL | let _ = Iterator::next(&mut ());
|
||||||
| -------------- ^^^^^^^ `()` is not an iterator
|
| -------------- ^^^^^^^ `()` is not an iterator
|
||||||
@ -28,12 +36,18 @@ LL | let _ = Iterator::next(&mut ());
|
|||||||
= help: the trait `Iterator` is not implemented for `()`
|
= help: the trait `Iterator` is not implemented for `()`
|
||||||
|
|
||||||
error[E0277]: `()` is not an iterator
|
error[E0277]: `()` is not an iterator
|
||||||
--> $DIR/issue-28098.rs:17:28
|
--> $DIR/issue-28098.rs:10:13
|
||||||
|
|
|
|
||||||
LL | let _ = Iterator::next(&mut ());
|
LL | let _ = Iterator::next(&mut ());
|
||||||
| -------------- ^^^^^^^ `()` is not an iterator
|
| ^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator
|
||||||
| |
|
|
|
||||||
| required by a bound introduced by this call
|
= help: the trait `Iterator` is not implemented for `()`
|
||||||
|
|
||||||
|
error[E0277]: `()` is not an iterator
|
||||||
|
--> $DIR/issue-28098.rs:2:13
|
||||||
|
|
|
||||||
|
LL | let _ = Iterator::next(&mut ());
|
||||||
|
| ^^^^^^^^^^^^^^ `()` is not an iterator
|
||||||
|
|
|
|
||||||
= help: the trait `Iterator` is not implemented for `()`
|
= help: the trait `Iterator` is not implemented for `()`
|
||||||
|
|
||||||
@ -47,8 +61,34 @@ LL | let _ = Iterator::next(&mut ());
|
|||||||
|
|
|
|
||||||
= help: the trait `Iterator` is not implemented for `()`
|
= help: the trait `Iterator` is not implemented for `()`
|
||||||
|
|
||||||
|
error[E0277]: `()` is not an iterator
|
||||||
|
--> $DIR/issue-28098.rs:20:13
|
||||||
|
|
|
||||||
|
LL | let _ = Iterator::next(&mut ());
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator
|
||||||
|
|
|
||||||
|
= help: the trait `Iterator` is not implemented for `()`
|
||||||
|
|
||||||
|
error[E0277]: `()` is not an iterator
|
||||||
|
--> $DIR/issue-28098.rs:25:28
|
||||||
|
|
|
||||||
|
LL | let _ = Iterator::next(&mut ());
|
||||||
|
| -------------- ^^^^^^^ `()` is not an iterator
|
||||||
|
| |
|
||||||
|
| required by a bound introduced by this call
|
||||||
|
|
|
||||||
|
= help: the trait `Iterator` is not implemented for `()`
|
||||||
|
|
||||||
|
error[E0277]: `()` is not an iterator
|
||||||
|
--> $DIR/issue-28098.rs:25:13
|
||||||
|
|
|
||||||
|
LL | let _ = Iterator::next(&mut ());
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator
|
||||||
|
|
|
||||||
|
= help: the trait `Iterator` is not implemented for `()`
|
||||||
|
|
||||||
error[E0277]: `bool` is not an iterator
|
error[E0277]: `bool` is not an iterator
|
||||||
--> $DIR/issue-28098.rs:23:14
|
--> $DIR/issue-28098.rs:29:14
|
||||||
|
|
|
|
||||||
LL | for _ in false {}
|
LL | for _ in false {}
|
||||||
| ^^^^^ `bool` is not an iterator
|
| ^^^^^ `bool` is not an iterator
|
||||||
@ -56,6 +96,14 @@ LL | for _ in false {}
|
|||||||
= help: the trait `Iterator` is not implemented for `bool`
|
= help: the trait `Iterator` is not implemented for `bool`
|
||||||
= note: required for `bool` to implement `IntoIterator`
|
= note: required for `bool` to implement `IntoIterator`
|
||||||
|
|
||||||
error: aborting due to 6 previous errors
|
error[E0277]: `()` is not an iterator
|
||||||
|
--> $DIR/issue-28098.rs:20:13
|
||||||
|
|
|
||||||
|
LL | let _ = Iterator::next(&mut ());
|
||||||
|
| ^^^^^^^^^^^^^^ `()` is not an iterator
|
||||||
|
|
|
||||||
|
= help: the trait `Iterator` is not implemented for `()`
|
||||||
|
|
||||||
|
error: aborting due to 12 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0277`.
|
For more information about this error, try `rustc --explain E0277`.
|
||||||
|
@ -32,8 +32,14 @@ impl Index<Bar<usize>> for [i32] {
|
|||||||
fn main() {
|
fn main() {
|
||||||
Index::index(&[] as &[i32], 2u32);
|
Index::index(&[] as &[i32], 2u32);
|
||||||
//~^ ERROR E0277
|
//~^ ERROR E0277
|
||||||
|
//~| ERROR E0277
|
||||||
|
//~| ERROR E0277
|
||||||
Index::index(&[] as &[i32], Foo(2u32));
|
Index::index(&[] as &[i32], Foo(2u32));
|
||||||
//~^ ERROR E0277
|
//~^ ERROR E0277
|
||||||
|
//~| ERROR E0277
|
||||||
|
//~| ERROR E0277
|
||||||
Index::index(&[] as &[i32], Bar(2u32));
|
Index::index(&[] as &[i32], Bar(2u32));
|
||||||
//~^ ERROR E0277
|
//~^ ERROR E0277
|
||||||
|
//~| ERROR E0277
|
||||||
|
//~| ERROR E0277
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,19 @@ LL | Index::index(&[] as &[i32], 2u32);
|
|||||||
<[i32] as Index<Bar<usize>>>
|
<[i32] as Index<Bar<usize>>>
|
||||||
<[i32] as Index<Foo<usize>>>
|
<[i32] as Index<Foo<usize>>>
|
||||||
|
|
||||||
|
error[E0277]: the trait bound `[i32]: Index<u32>` is not satisfied
|
||||||
|
--> $DIR/multiple-impls.rs:33:5
|
||||||
|
|
|
||||||
|
LL | Index::index(&[] as &[i32], 2u32);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait message
|
||||||
|
|
|
||||||
|
= help: the trait `Index<u32>` is not implemented for `[i32]`
|
||||||
|
= help: the following other types implement trait `Index<Idx>`:
|
||||||
|
<[i32] as Index<Bar<usize>>>
|
||||||
|
<[i32] as Index<Foo<usize>>>
|
||||||
|
|
||||||
error[E0277]: the trait bound `[i32]: Index<Foo<u32>>` is not satisfied
|
error[E0277]: the trait bound `[i32]: Index<Foo<u32>>` is not satisfied
|
||||||
--> $DIR/multiple-impls.rs:35:33
|
--> $DIR/multiple-impls.rs:37:33
|
||||||
|
|
|
|
||||||
LL | Index::index(&[] as &[i32], Foo(2u32));
|
LL | Index::index(&[] as &[i32], Foo(2u32));
|
||||||
| ------------ ^^^^^^^^^ on impl for Foo
|
| ------------ ^^^^^^^^^ on impl for Foo
|
||||||
@ -24,8 +35,19 @@ LL | Index::index(&[] as &[i32], Foo(2u32));
|
|||||||
<[i32] as Index<Bar<usize>>>
|
<[i32] as Index<Bar<usize>>>
|
||||||
<[i32] as Index<Foo<usize>>>
|
<[i32] as Index<Foo<usize>>>
|
||||||
|
|
||||||
|
error[E0277]: the trait bound `[i32]: Index<Foo<u32>>` is not satisfied
|
||||||
|
--> $DIR/multiple-impls.rs:37:5
|
||||||
|
|
|
||||||
|
LL | Index::index(&[] as &[i32], Foo(2u32));
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ on impl for Foo
|
||||||
|
|
|
||||||
|
= help: the trait `Index<Foo<u32>>` is not implemented for `[i32]`
|
||||||
|
= help: the following other types implement trait `Index<Idx>`:
|
||||||
|
<[i32] as Index<Bar<usize>>>
|
||||||
|
<[i32] as Index<Foo<usize>>>
|
||||||
|
|
||||||
error[E0277]: the trait bound `[i32]: Index<Bar<u32>>` is not satisfied
|
error[E0277]: the trait bound `[i32]: Index<Bar<u32>>` is not satisfied
|
||||||
--> $DIR/multiple-impls.rs:37:33
|
--> $DIR/multiple-impls.rs:41:33
|
||||||
|
|
|
|
||||||
LL | Index::index(&[] as &[i32], Bar(2u32));
|
LL | Index::index(&[] as &[i32], Bar(2u32));
|
||||||
| ------------ ^^^^^^^^^ on impl for Bar
|
| ------------ ^^^^^^^^^ on impl for Bar
|
||||||
@ -37,6 +59,50 @@ LL | Index::index(&[] as &[i32], Bar(2u32));
|
|||||||
<[i32] as Index<Bar<usize>>>
|
<[i32] as Index<Bar<usize>>>
|
||||||
<[i32] as Index<Foo<usize>>>
|
<[i32] as Index<Foo<usize>>>
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error[E0277]: the trait bound `[i32]: Index<Bar<u32>>` is not satisfied
|
||||||
|
--> $DIR/multiple-impls.rs:41:5
|
||||||
|
|
|
||||||
|
LL | Index::index(&[] as &[i32], Bar(2u32));
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ on impl for Bar
|
||||||
|
|
|
||||||
|
= help: the trait `Index<Bar<u32>>` is not implemented for `[i32]`
|
||||||
|
= help: the following other types implement trait `Index<Idx>`:
|
||||||
|
<[i32] as Index<Bar<usize>>>
|
||||||
|
<[i32] as Index<Foo<usize>>>
|
||||||
|
|
||||||
|
error[E0277]: the trait bound `[i32]: Index<u32>` is not satisfied
|
||||||
|
--> $DIR/multiple-impls.rs:33:5
|
||||||
|
|
|
||||||
|
LL | Index::index(&[] as &[i32], 2u32);
|
||||||
|
| ^^^^^^^^^^^^ trait message
|
||||||
|
|
|
||||||
|
= help: the trait `Index<u32>` is not implemented for `[i32]`
|
||||||
|
= help: the following other types implement trait `Index<Idx>`:
|
||||||
|
<[i32] as Index<Bar<usize>>>
|
||||||
|
<[i32] as Index<Foo<usize>>>
|
||||||
|
|
||||||
|
error[E0277]: the trait bound `[i32]: Index<Foo<u32>>` is not satisfied
|
||||||
|
--> $DIR/multiple-impls.rs:37:5
|
||||||
|
|
|
||||||
|
LL | Index::index(&[] as &[i32], Foo(2u32));
|
||||||
|
| ^^^^^^^^^^^^ on impl for Foo
|
||||||
|
|
|
||||||
|
= help: the trait `Index<Foo<u32>>` is not implemented for `[i32]`
|
||||||
|
= help: the following other types implement trait `Index<Idx>`:
|
||||||
|
<[i32] as Index<Bar<usize>>>
|
||||||
|
<[i32] as Index<Foo<usize>>>
|
||||||
|
|
||||||
|
error[E0277]: the trait bound `[i32]: Index<Bar<u32>>` is not satisfied
|
||||||
|
--> $DIR/multiple-impls.rs:41:5
|
||||||
|
|
|
||||||
|
LL | Index::index(&[] as &[i32], Bar(2u32));
|
||||||
|
| ^^^^^^^^^^^^ on impl for Bar
|
||||||
|
|
|
||||||
|
= help: the trait `Index<Bar<u32>>` is not implemented for `[i32]`
|
||||||
|
= help: the following other types implement trait `Index<Idx>`:
|
||||||
|
<[i32] as Index<Bar<usize>>>
|
||||||
|
<[i32] as Index<Foo<usize>>>
|
||||||
|
|
||||||
|
error: aborting due to 9 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0277`.
|
For more information about this error, try `rustc --explain E0277`.
|
||||||
|
@ -21,4 +21,6 @@ impl Index<usize> for [i32] {
|
|||||||
fn main() {
|
fn main() {
|
||||||
Index::<u32>::index(&[1, 2, 3] as &[i32], 2u32);
|
Index::<u32>::index(&[1, 2, 3] as &[i32], 2u32);
|
||||||
//~^ ERROR E0277
|
//~^ ERROR E0277
|
||||||
|
//~| ERROR E0277
|
||||||
|
//~| ERROR E0277
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,24 @@ LL | Index::<u32>::index(&[1, 2, 3] as &[i32], 2u32);
|
|||||||
= help: the trait `Index<u32>` is not implemented for `[i32]`
|
= help: the trait `Index<u32>` is not implemented for `[i32]`
|
||||||
= help: the trait `Index<usize>` is implemented for `[i32]`
|
= help: the trait `Index<usize>` is implemented for `[i32]`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error[E0277]: the trait bound `[i32]: Index<u32>` is not satisfied
|
||||||
|
--> $DIR/on-impl.rs:22:5
|
||||||
|
|
|
||||||
|
LL | Index::<u32>::index(&[1, 2, 3] as &[i32], 2u32);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ a usize is required to index into a slice
|
||||||
|
|
|
||||||
|
= help: the trait `Index<u32>` is not implemented for `[i32]`
|
||||||
|
= help: the trait `Index<usize>` is implemented for `[i32]`
|
||||||
|
|
||||||
|
error[E0277]: the trait bound `[i32]: Index<u32>` is not satisfied
|
||||||
|
--> $DIR/on-impl.rs:22:5
|
||||||
|
|
|
||||||
|
LL | Index::<u32>::index(&[1, 2, 3] as &[i32], 2u32);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^ a usize is required to index into a slice
|
||||||
|
|
|
||||||
|
= help: the trait `Index<u32>` is not implemented for `[i32]`
|
||||||
|
= help: the trait `Index<usize>` is implemented for `[i32]`
|
||||||
|
|
||||||
|
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`.
|
||||||
|
@ -3,6 +3,7 @@ use std::ops::Add;
|
|||||||
fn main() {
|
fn main() {
|
||||||
<i32 as Add<u32>>::add(1, 2);
|
<i32 as Add<u32>>::add(1, 2);
|
||||||
//~^ ERROR cannot add `u32` to `i32`
|
//~^ ERROR cannot add `u32` to `i32`
|
||||||
|
//~| ERROR cannot add `u32` to `i32`
|
||||||
<i32 as Add<i32>>::add(1u32, 2);
|
<i32 as Add<i32>>::add(1u32, 2);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
<i32 as Add<i32>>::add(1, 2u32);
|
<i32 as Add<i32>>::add(1, 2u32);
|
||||||
|
@ -19,7 +19,7 @@ LL | <i32 as Add<u32>>::add(1, 2);
|
|||||||
and 48 others
|
and 48 others
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/ufcs-qpath-self-mismatch.rs:6:28
|
--> $DIR/ufcs-qpath-self-mismatch.rs:7:28
|
||||||
|
|
|
|
||||||
LL | <i32 as Add<i32>>::add(1u32, 2);
|
LL | <i32 as Add<i32>>::add(1u32, 2);
|
||||||
| ---------------------- ^^^^ expected `i32`, found `u32`
|
| ---------------------- ^^^^ expected `i32`, found `u32`
|
||||||
@ -37,7 +37,7 @@ LL | <i32 as Add<i32>>::add(1i32, 2);
|
|||||||
| ~~~
|
| ~~~
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/ufcs-qpath-self-mismatch.rs:8:31
|
--> $DIR/ufcs-qpath-self-mismatch.rs:9:31
|
||||||
|
|
|
|
||||||
LL | <i32 as Add<i32>>::add(1, 2u32);
|
LL | <i32 as Add<i32>>::add(1, 2u32);
|
||||||
| ---------------------- ^^^^ expected `i32`, found `u32`
|
| ---------------------- ^^^^ expected `i32`, found `u32`
|
||||||
@ -54,7 +54,25 @@ help: change the type of the numeric literal from `u32` to `i32`
|
|||||||
LL | <i32 as Add<i32>>::add(1, 2i32);
|
LL | <i32 as Add<i32>>::add(1, 2i32);
|
||||||
| ~~~
|
| ~~~
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error[E0277]: cannot add `u32` to `i32`
|
||||||
|
--> $DIR/ufcs-qpath-self-mismatch.rs:4:5
|
||||||
|
|
|
||||||
|
LL | <i32 as Add<u32>>::add(1, 2);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^ no implementation for `i32 + u32`
|
||||||
|
|
|
||||||
|
= help: the trait `Add<u32>` is not implemented for `i32`
|
||||||
|
= help: the following other types implement trait `Add<Rhs>`:
|
||||||
|
<&'a f32 as Add<f32>>
|
||||||
|
<&'a f64 as Add<f64>>
|
||||||
|
<&'a i128 as Add<i128>>
|
||||||
|
<&'a i16 as Add<i16>>
|
||||||
|
<&'a i32 as Add<i32>>
|
||||||
|
<&'a i64 as Add<i64>>
|
||||||
|
<&'a i8 as Add<i8>>
|
||||||
|
<&'a isize as Add<isize>>
|
||||||
|
and 48 others
|
||||||
|
|
||||||
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0277, E0308.
|
Some errors have detailed explanations: E0277, E0308.
|
||||||
For more information about an error, try `rustc --explain E0277`.
|
For more information about an error, try `rustc --explain E0277`.
|
||||||
|
@ -5,11 +5,8 @@ LL | &X(*Y)
|
|||||||
| ^^ 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 `[u8]`
|
= help: the trait `Sized` is not implemented for `[u8]`
|
||||||
|
= note: all function arguments must have a statically known size
|
||||||
= help: unsized fn params are gated as an unstable feature
|
= help: unsized fn params are gated as an unstable feature
|
||||||
help: function arguments must have a statically known size, borrowed types always have a known size
|
|
||||||
|
|
|
||||||
LL | &X(&*Y)
|
|
||||||
| +
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user