forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#107867 - compiler-errors:new-solver-fn-trait-…
…safety, r=lcnr Check that built-in callable types validate their output type is `Sized` (in new solver) Working on parity with old solver. Putting this up for consideration, it's not *really* needed or anything just yet. Maybe it's better to approach this from another direction (like always checking the item bounds when calling `consider_assumption`? we may need that for coinduction to be sound though?) This basically implements rust-lang#100096 for the new solver.
- Loading branch information
Showing
5 changed files
with
135 additions
and
74 deletions.
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
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
17 changes: 17 additions & 0 deletions
17
tests/ui/traits/new-solver/builtin-fn-must-return-sized.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// compile-flags: -Ztrait-solver=next | ||
|
||
#![feature(fn_traits)] | ||
#![feature(unboxed_closures)] | ||
#![feature(tuple_trait)] | ||
|
||
use std::ops::Fn; | ||
use std::marker::Tuple; | ||
|
||
fn foo<F: Fn<T>, T: Tuple>(f: Option<F>, t: T) { | ||
let y = (f.unwrap()).call(t); | ||
} | ||
|
||
fn main() { | ||
foo::<fn() -> str, _>(None, ()); | ||
//~^ expected a `Fn<_>` closure, found `fn() -> str` | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/ui/traits/new-solver/builtin-fn-must-return-sized.stderr
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,18 @@ | ||
error[E0277]: expected a `Fn<_>` closure, found `fn() -> str` | ||
--> $DIR/builtin-fn-must-return-sized.rs:15:27 | ||
| | ||
LL | foo::<fn() -> str, _>(None, ()); | ||
| --------------------- ^^^^ expected an `Fn<_>` closure, found `fn() -> str` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
= help: the trait `Fn<_>` is not implemented for `fn() -> str` | ||
note: required by a bound in `foo` | ||
--> $DIR/builtin-fn-must-return-sized.rs:10:11 | ||
| | ||
LL | fn foo<F: Fn<T>, T: Tuple>(f: Option<F>, t: T) { | ||
| ^^^^^ required by this bound in `foo` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |