forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#67914 - Aaron1011:fix/const-prop-impossible…
…, r=matthewjasper Don't run const propagation on items with inconsistent bounds Fixes rust-lang#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.
- Loading branch information
Showing
3 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
6 changes: 5 additions & 1 deletion
6
src/test/ui/trivial-bounds/trivial-bounds-inconsistent-associated-functions.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters