mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-02 10:18:25 +00:00
Also bail out if predicates contain errors.
This commit is contained in:
parent
1987471d05
commit
538b0004bc
@ -41,7 +41,7 @@ impl<'tcx> MirPass<'tcx> for ImpossiblePredicates {
|
||||
tracing::trace!(def_id = ?body.source.def_id());
|
||||
let predicates = tcx.predicates_of(body.source.def_id()).instantiate_identity(tcx);
|
||||
tracing::trace!(?predicates);
|
||||
let predicates = predicates
|
||||
let predicates: Vec<_> = predicates
|
||||
.predicates
|
||||
.into_iter()
|
||||
.filter(|p| {
|
||||
@ -54,7 +54,7 @@ impl<'tcx> MirPass<'tcx> for ImpossiblePredicates {
|
||||
})
|
||||
.collect();
|
||||
tracing::trace!(?predicates);
|
||||
if traits::impossible_predicates(tcx, predicates) {
|
||||
if predicates.references_error() || traits::impossible_predicates(tcx, predicates) {
|
||||
trace!("found unsatisfiable predicates");
|
||||
// Clear the body to only contain a single `unreachable` statement.
|
||||
let bbs = body.basic_blocks.as_mut();
|
||||
|
@ -1,7 +0,0 @@
|
||||
//@ known-bug: #140100
|
||||
fn a()
|
||||
where
|
||||
b: Sized,
|
||||
{
|
||||
println!()
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
//@ known-bug: #140365
|
||||
//@compile-flags: -C opt-level=1 -Zvalidate-mir
|
||||
fn f() -> &'static str
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
""
|
||||
}
|
20
tests/ui/mir/meaningless-bound.rs
Normal file
20
tests/ui/mir/meaningless-bound.rs
Normal file
@ -0,0 +1,20 @@
|
||||
//! Regression test for #140100 and #140365
|
||||
//@compile-flags: -C opt-level=1 -Zvalidate-mir
|
||||
|
||||
fn a()
|
||||
where
|
||||
b: Sized,
|
||||
//~^ ERROR cannot find type `b` in this scope
|
||||
{
|
||||
println!()
|
||||
}
|
||||
|
||||
fn f() -> &'static str
|
||||
where
|
||||
Self: Sized,
|
||||
//~^ ERROR cannot find type `Self` in this scope
|
||||
{
|
||||
""
|
||||
}
|
||||
|
||||
fn main() {}
|
19
tests/ui/mir/meaningless-bound.stderr
Normal file
19
tests/ui/mir/meaningless-bound.stderr
Normal file
@ -0,0 +1,19 @@
|
||||
error[E0412]: cannot find type `b` in this scope
|
||||
--> $DIR/meaningless-bound.rs:6:5
|
||||
|
|
||||
LL | b: Sized,
|
||||
| ^ not found in this scope
|
||||
|
||||
error[E0411]: cannot find type `Self` in this scope
|
||||
--> $DIR/meaningless-bound.rs:14:5
|
||||
|
|
||||
LL | fn f() -> &'static str
|
||||
| - `Self` not allowed in a function
|
||||
LL | where
|
||||
LL | Self: Sized,
|
||||
| ^^^^ `Self` is only available in impls, traits, and type definitions
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0411, E0412.
|
||||
For more information about an error, try `rustc --explain E0411`.
|
Loading…
x
Reference in New Issue
Block a user