Rollup merge of #67914 - Aaron1011:fix/const-prop-impossible, r=matthewjasper,oli-obk
Don't run const propagation on items with inconsistent bounds Fixes #67696 Using `#![feature(trivial_bounds)]`, it's possible to write functions with unsatisfiable 'where' clauses, making them uncallable. However, the user can act as if these 'where' clauses are true inside the body of the function, leading to code that would normally be impossible to write. Since const propgation can run even without any user-written calls to a function, we need to explcitly check for these uncallable functions.
This commit is contained in:
commit
89b065dbd2
8 changed files with 115 additions and 14 deletions
20
src/test/ui/consts/issue-67696-const-prop-ice.rs
Normal file
20
src/test/ui/consts/issue-67696-const-prop-ice.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// check-pass
|
||||
// compile-flags: --emit=mir,link
|
||||
// Checks that we don't ICE due to attempting to run const prop
|
||||
// on a function with unsatisifable 'where' clauses
|
||||
|
||||
#![allow(unused)]
|
||||
|
||||
trait A {
|
||||
fn foo(&self) -> Self where Self: Copy;
|
||||
}
|
||||
|
||||
impl A for [fn(&())] {
|
||||
fn foo(&self) -> Self where Self: Copy { *(&[] as &[_]) }
|
||||
}
|
||||
|
||||
impl A for i32 {
|
||||
fn foo(&self) -> Self { 3 }
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,4 +1,8 @@
|
|||
// run-pass
|
||||
// check-pass
|
||||
// compile-flags: --emit=mir,link
|
||||
// Force mir to be emitted, to ensure that const
|
||||
// propagation doesn't ICE on a function
|
||||
// with an 'impossible' body. See issue #67696
|
||||
// Inconsistent bounds with trait implementations
|
||||
|
||||
#![feature(trivial_bounds)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue