Closed
Description
Regression from 1.45.0-beta.4 (2020-07-13 e99e6422a2f799fc86a3)
to 1.46.0-nightly (2020-07-15 7e11379f3b4c376fbb9a)
.
The following code yields an incorrect error:
use std::convert::identity;
pub fn is_sorted_and_has_duplicates_by<T, S: PartialEq + PartialOrd>(
data: &[T],
key: impl Fn(&T) -> S,
) -> Option<&T> {
unimplemented!()
}
pub fn is_sorted_and_has_duplicates<T: PartialEq + PartialOrd>(data: &[T]) -> Option<&T> {
is_sorted_and_has_duplicates_by(data, identity)
}
On beta, this gives:
error[E0631]: type mismatch in function arguments
--> src/lib.rs:11:43
|
3 | pub fn is_sorted_and_has_duplicates_by<T, S: PartialEq + PartialOrd>(
| ------------------------------- required by a bound in this
4 | data: &[T],
5 | key: impl Fn(&T) -> S,
| ----------- required by this bound in `is_sorted_and_has_duplicates_by`
...
11 | is_sorted_and_has_duplicates_by(data, identity)
| ^^^^^^^^
| |
| expected signature of `for<'r> fn(&'r T) -> _`
| found signature of `fn(_) -> _`
error[E0271]: type mismatch resolving `for<'r> <fn(_) -> _ {std::convert::identity::<_>} as std::ops::FnOnce<(&'r T,)>>::Output == _`
--> src/lib.rs:11:5
|
3 | pub fn is_sorted_and_has_duplicates_by<T, S: PartialEq + PartialOrd>(
| ------------------------------- required by a bound in this
4 | data: &[T],
5 | key: impl Fn(&T) -> S,
| - required by this bound in `is_sorted_and_has_duplicates_by`
...
11 | is_sorted_and_has_duplicates_by(data, identity)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter, found concrete lifetime
On nightly, this:
error[E0308]: mismatched types
--> src/lib.rs:11:5
|
11 | is_sorted_and_has_duplicates_by(data, identity)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected type `std::ops::FnOnce<(&T,)>`
found type `std::ops::FnOnce<(&T,)>`
Activity
[-]Type mismatch in function arguments E0631, E0271 are false recognized as E0308 mismatched types[/-][+]Type mismatch in function arguments E0631, E0271 are falsely recognized as E0308 mismatched types[/+]vandenheuvel commentedon Jul 20, 2020
@jonas-schievink would you be so kind to label this issue? It's sliding down the list while being hard to search.
JohnTitor commentedon Jul 20, 2020
Regression occurred between nightly-2020-06-23 and nightly-2020-06-24, I suspect #73643 is related (it's #72493?).
LeSeulArtichaut commentedon Jul 20, 2020
It would be great to find the culprit PR.
@rustbot ping cleanup
rustbot commentedon Jul 20, 2020
Hey Cleanup Crew ICE-breakers! This bug has been identified as a good
"Cleanup ICE-breaking candidate". In case it's useful, here are some
instructions for tackling these sorts of bugs. Maybe take a look?
Thanks! <3
cc @AminArria @camelid @chrissimpkins @contrun @DutchGhost @elshize @ethanboxx @h-michael @HallerPatrick @hdhoang @hellow554 @imtsuki @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @senden9 @shekohex @sinato @spastorino @turboladen @woshilapin @yerke
kanru commentedon Jul 20, 2020
searched nightlies: from nightly-2020-06-23 to nightly-2020-06-24
regressed nightly: nightly-2020-06-24
searched commits: from 6bb3dbf to ff5b446
regressed commit: 1557fb0
bisected with cargo-bisect-rustc v0.5.1
Host triple: x86_64-unknown-linux-gnu
Reproduce with:
If we rule out document changes then we have
#72271
#72493
#73398
#73496
#73515
LeSeulArtichaut commentedon Jul 21, 2020
Bisection seems to confirm this, cc @nikomatsakis
kanru commentedon Jul 21, 2020
With a little more git bisect it seems 6873a76 is the first bad commit
And I guess the change to the test case also shows that
24 remaining items