forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
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#105292 - JulianKnodt:no_eager_commit, r=Box…
…yUwU Change a commit_if_ok call to probe Removes an over-eager `commit_if_ok` which makes inference worse. I'm not entirely sure whether it's ok to remove the check that types are the same, because casting seems to cause equality checks with incorrect types? Fixes rust-lang#105037 r? ``@BoxyUwU``
- Loading branch information
Showing
10 changed files
with
221 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#![feature(generic_const_exprs)] | ||
#![allow(incomplete_features)] | ||
|
||
fn foo<const N: usize, const M: usize>() -> [(); N+2] | ||
where | ||
[(); N + 1]:, | ||
[(); M + 1]:, | ||
{ | ||
bar() | ||
//~^ ERROR: unconstrained | ||
} | ||
|
||
fn bar<const N: usize>() -> [(); N] | ||
where | ||
[(); N + 1]:, | ||
{ | ||
[(); N] | ||
} | ||
|
||
fn main() {} |
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: unconstrained generic constant | ||
--> $DIR/ensure_is_evaluatable.rs:9:5 | ||
| | ||
LL | bar() | ||
| ^^^ | ||
| | ||
= help: try adding a `where` bound using this expression: `where [(); N + 1]:` | ||
note: required by a bound in `bar` | ||
--> $DIR/ensure_is_evaluatable.rs:15:10 | ||
| | ||
LL | fn bar<const N: usize>() -> [(); N] | ||
| --- required by a bound in this | ||
LL | where | ||
LL | [(); N + 1]:, | ||
| ^^^^^ required by this bound in `bar` | ||
|
||
error: aborting due to previous error | ||
|
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,23 @@ | ||
#![feature(generic_const_exprs)] | ||
#![allow(incomplete_features)] | ||
|
||
const fn both(_: usize, b: usize) -> usize { | ||
b | ||
} | ||
|
||
fn foo<const N: usize, const M: usize>() -> [(); N + 2] | ||
where | ||
[(); both(N + 1, M + 1)]:, | ||
{ | ||
bar() | ||
//~^ ERROR: unconstrained generic constant | ||
} | ||
|
||
fn bar<const N: usize>() -> [(); N] | ||
where | ||
[(); N + 1]:, | ||
{ | ||
[(); N] | ||
} | ||
|
||
fn main() {} |
18 changes: 18 additions & 0 deletions
18
src/test/ui/const-generics/fn_with_two_const_inputs.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: unconstrained generic constant | ||
--> $DIR/fn_with_two_const_inputs.rs:12:5 | ||
| | ||
LL | bar() | ||
| ^^^ | ||
| | ||
= help: try adding a `where` bound using this expression: `where [(); N + 1]:` | ||
note: required by a bound in `bar` | ||
--> $DIR/fn_with_two_const_inputs.rs:18:10 | ||
| | ||
LL | fn bar<const N: usize>() -> [(); N] | ||
| --- required by a bound in this | ||
LL | where | ||
LL | [(); N + 1]:, | ||
| ^^^^^ required by this bound in `bar` | ||
|
||
error: aborting due to previous error | ||
|
22 changes: 22 additions & 0 deletions
22
src/test/ui/const-generics/fn_with_two_same_const_inputs.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,22 @@ | ||
// check-pass | ||
#![feature(generic_const_exprs)] | ||
#![allow(incomplete_features)] | ||
|
||
const fn both(_: usize, b: usize) -> usize { | ||
b | ||
} | ||
|
||
fn foo<const N: usize>() | ||
where | ||
[(); both(N + 1, N + 1)]:, | ||
{ | ||
bar::<N>(); | ||
} | ||
|
||
fn bar<const N: usize>() | ||
where | ||
[(); N + 1]:, | ||
{ | ||
} | ||
|
||
fn main() {} |
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,35 @@ | ||
// run-pass | ||
#![feature(generic_const_exprs)] | ||
#![allow(incomplete_features)] | ||
#![allow(dead_code)] | ||
|
||
trait Table<const D: usize>: Sync { | ||
const COLUMNS: usize; | ||
} | ||
|
||
struct Table1<const D: usize>; | ||
impl<const D: usize> Table<D> for Table1<D> { | ||
const COLUMNS: usize = 123; | ||
} | ||
|
||
struct Table2<const D: usize>; | ||
impl<const D: usize> Table<D> for Table2<D> { | ||
const COLUMNS: usize = 456; | ||
} | ||
|
||
fn process_table<T: Table<D>, const D: usize>(_table: T) | ||
where | ||
[(); T::COLUMNS]:, | ||
{ | ||
} | ||
|
||
fn process_all_tables<const D: usize>() | ||
where | ||
[(); Table2::<D>::COLUMNS]:, | ||
[(); Table1::<D>::COLUMNS]:, | ||
{ | ||
process_table(Table1::<D>); | ||
process_table(Table2::<D>); | ||
} | ||
|
||
fn main() {} |
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,19 @@ | ||
// check-pass | ||
#![feature(generic_const_exprs)] | ||
#![allow(incomplete_features)] | ||
|
||
fn foo<const N: usize>() | ||
where | ||
[(); N + 1]:, | ||
[(); N + 1]:, | ||
{ | ||
bar::<N>(); | ||
} | ||
|
||
fn bar<const N: usize>() | ||
where | ||
[(); N + 1]:, | ||
{ | ||
} | ||
|
||
fn main() {} |
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 @@ | ||
#![feature(generic_const_exprs)] | ||
#![allow(incomplete_features)] | ||
|
||
fn foo<const N: usize>() | ||
where | ||
[(); N + 1 + 1]:, | ||
{ | ||
bar(); | ||
//~^ ERROR: type annotations | ||
} | ||
|
||
fn bar<const N: usize>() | ||
where | ||
[(); N + 1]:, | ||
{ | ||
} | ||
|
||
fn main() {} |
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,22 @@ | ||
error[E0284]: type annotations needed | ||
--> $DIR/unify_with_nested_expr.rs:8:5 | ||
| | ||
LL | bar(); | ||
| ^^^ cannot infer the value of the const parameter `N` declared on the function `bar` | ||
| | ||
note: required by a bound in `bar` | ||
--> $DIR/unify_with_nested_expr.rs:14:10 | ||
| | ||
LL | fn bar<const N: usize>() | ||
| --- required by a bound in this | ||
LL | where | ||
LL | [(); N + 1]:, | ||
| ^^^^^ required by this bound in `bar` | ||
help: consider specifying the generic argument | ||
| | ||
LL | bar::<N>(); | ||
| +++++ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0284`. |