Flush errors before deep normalize in dropck_outlives
This commit is contained in:
parent
1a7f290a9a
commit
df1da673f7
3 changed files with 115 additions and 0 deletions
|
|
@ -196,6 +196,14 @@ where
|
|||
debug!("dropck_outlives: ty from dtorck_types = {:?}", ty);
|
||||
ty
|
||||
} else {
|
||||
// Flush errors b/c `deeply_normalize` doesn't expect pending
|
||||
// obligations, and we may have pending obligations from the
|
||||
// branch above (from other types).
|
||||
let errors = ocx.select_all_or_error();
|
||||
if !errors.is_empty() {
|
||||
return Err(errors);
|
||||
}
|
||||
|
||||
ocx.deeply_normalize(&cause, param_env, ty)?;
|
||||
|
||||
let errors = ocx.select_where_possible();
|
||||
|
|
|
|||
31
tests/ui/drop/dropck-normalize-errors.rs
Normal file
31
tests/ui/drop/dropck-normalize-errors.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// Test that we don't ICE when computing the drop types for
|
||||
|
||||
trait Decode<'a> {
|
||||
type Decoder;
|
||||
}
|
||||
|
||||
trait NonImplementedTrait {
|
||||
type Assoc;
|
||||
}
|
||||
struct NonImplementedStruct;
|
||||
|
||||
pub struct ADecoder<'a> {
|
||||
b: <B as Decode<'a>>::Decoder,
|
||||
}
|
||||
fn make_a_decoder<'a>() -> ADecoder<'a> {
|
||||
//~^ ERROR the trait bound
|
||||
//~| ERROR the trait bound
|
||||
panic!()
|
||||
}
|
||||
|
||||
struct B;
|
||||
impl<'a> Decode<'a> for B {
|
||||
type Decoder = BDecoder;
|
||||
//~^ ERROR the trait bound
|
||||
}
|
||||
pub struct BDecoder {
|
||||
non_implemented: <NonImplementedStruct as NonImplementedTrait>::Assoc,
|
||||
//~^ ERROR the trait bound
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
76
tests/ui/drop/dropck-normalize-errors.stderr
Normal file
76
tests/ui/drop/dropck-normalize-errors.stderr
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
error[E0277]: the trait bound `NonImplementedStruct: NonImplementedTrait` is not satisfied in `ADecoder<'a>`
|
||||
--> $DIR/dropck-normalize-errors.rs:15:28
|
||||
|
|
||||
LL | fn make_a_decoder<'a>() -> ADecoder<'a> {
|
||||
| ^^^^^^^^^^^^ within `ADecoder<'a>`, the trait `NonImplementedTrait` is not implemented for `NonImplementedStruct`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/dropck-normalize-errors.rs:7:1
|
||||
|
|
||||
LL | trait NonImplementedTrait {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: required because it appears within the type `BDecoder`
|
||||
--> $DIR/dropck-normalize-errors.rs:26:12
|
||||
|
|
||||
LL | pub struct BDecoder {
|
||||
| ^^^^^^^^
|
||||
note: required because it appears within the type `ADecoder<'a>`
|
||||
--> $DIR/dropck-normalize-errors.rs:12:12
|
||||
|
|
||||
LL | pub struct ADecoder<'a> {
|
||||
| ^^^^^^^^
|
||||
= note: the return type of a function must have a statically known size
|
||||
|
||||
error[E0277]: the trait bound `NonImplementedStruct: NonImplementedTrait` is not satisfied in `BDecoder`
|
||||
--> $DIR/dropck-normalize-errors.rs:23:20
|
||||
|
|
||||
LL | type Decoder = BDecoder;
|
||||
| ^^^^^^^^ within `BDecoder`, the trait `NonImplementedTrait` is not implemented for `NonImplementedStruct`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/dropck-normalize-errors.rs:7:1
|
||||
|
|
||||
LL | trait NonImplementedTrait {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: required because it appears within the type `BDecoder`
|
||||
--> $DIR/dropck-normalize-errors.rs:26:12
|
||||
|
|
||||
LL | pub struct BDecoder {
|
||||
| ^^^^^^^^
|
||||
note: required by a bound in `Decode::Decoder`
|
||||
--> $DIR/dropck-normalize-errors.rs:4:5
|
||||
|
|
||||
LL | type Decoder;
|
||||
| ^^^^^^^^^^^^^ required by this bound in `Decode::Decoder`
|
||||
help: consider relaxing the implicit `Sized` restriction
|
||||
|
|
||||
LL | type Decoder: ?Sized;
|
||||
| ++++++++
|
||||
|
||||
error[E0277]: the trait bound `NonImplementedStruct: NonImplementedTrait` is not satisfied
|
||||
--> $DIR/dropck-normalize-errors.rs:27:22
|
||||
|
|
||||
LL | non_implemented: <NonImplementedStruct as NonImplementedTrait>::Assoc,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NonImplementedTrait` is not implemented for `NonImplementedStruct`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/dropck-normalize-errors.rs:7:1
|
||||
|
|
||||
LL | trait NonImplementedTrait {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `NonImplementedStruct: NonImplementedTrait` is not satisfied
|
||||
--> $DIR/dropck-normalize-errors.rs:15:28
|
||||
|
|
||||
LL | fn make_a_decoder<'a>() -> ADecoder<'a> {
|
||||
| ^^^^^^^^^^^^ the trait `NonImplementedTrait` is not implemented for `NonImplementedStruct`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/dropck-normalize-errors.rs:7:1
|
||||
|
|
||||
LL | trait NonImplementedTrait {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue