Skip to content

Commit e269e6b

Browse files
committed
Auto merge of rust-lang#90314 - matthiaskrgr:rollup-ag1js8n, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - rust-lang#90296 (Remove fNN::lerp) - rust-lang#90302 (Remove unneeded into_iter) - rust-lang#90303 (Add regression test for issue 90164) - rust-lang#90305 (Add regression test for rust-lang#87258) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 612356a + fcc9a9a commit e269e6b

File tree

12 files changed

+104
-192
lines changed

12 files changed

+104
-192
lines changed

Diff for: library/std/src/f32.rs

-36
Original file line numberDiff line numberDiff line change
@@ -878,40 +878,4 @@ impl f32 {
878878
pub fn atanh(self) -> f32 {
879879
0.5 * ((2.0 * self) / (1.0 - self)).ln_1p()
880880
}
881-
882-
/// Linear interpolation between `start` and `end`.
883-
///
884-
/// This enables linear interpolation between `start` and `end`, where start is represented by
885-
/// `self == 0.0` and `end` is represented by `self == 1.0`. This is the basis of all
886-
/// "transition", "easing", or "step" functions; if you change `self` from 0.0 to 1.0
887-
/// at a given rate, the result will change from `start` to `end` at a similar rate.
888-
///
889-
/// Values below 0.0 or above 1.0 are allowed, allowing you to extrapolate values outside the
890-
/// range from `start` to `end`. This also is useful for transition functions which might
891-
/// move slightly past the end or start for a desired effect. Mathematically, the values
892-
/// returned are equivalent to `start + self * (end - start)`, although we make a few specific
893-
/// guarantees that are useful specifically to linear interpolation.
894-
///
895-
/// These guarantees are:
896-
///
897-
/// * If `start` and `end` are [finite], the value at 0.0 is always `start` and the
898-
/// value at 1.0 is always `end`. (exactness)
899-
/// * If `start` and `end` are [finite], the values will always move in the direction from
900-
/// `start` to `end` (monotonicity)
901-
/// * If `self` is [finite] and `start == end`, the value at any point will always be
902-
/// `start == end`. (consistency)
903-
///
904-
/// [finite]: #method.is_finite
905-
#[must_use = "method returns a new number and does not mutate the original value"]
906-
#[unstable(feature = "float_interpolation", issue = "86269")]
907-
pub fn lerp(self, start: f32, end: f32) -> f32 {
908-
// consistent
909-
if start == end {
910-
start
911-
912-
// exact/monotonic
913-
} else {
914-
self.mul_add(end, (-self).mul_add(start, start))
915-
}
916-
}
917881
}

Diff for: library/std/src/f32/tests.rs

-63
Original file line numberDiff line numberDiff line change
@@ -757,66 +757,3 @@ fn test_total_cmp() {
757757
assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&f32::INFINITY));
758758
assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&s_nan()));
759759
}
760-
761-
#[test]
762-
fn test_lerp_exact() {
763-
// simple values
764-
assert_eq!(f32::lerp(0.0, 2.0, 4.0), 2.0);
765-
assert_eq!(f32::lerp(1.0, 2.0, 4.0), 4.0);
766-
767-
// boundary values
768-
assert_eq!(f32::lerp(0.0, f32::MIN, f32::MAX), f32::MIN);
769-
assert_eq!(f32::lerp(1.0, f32::MIN, f32::MAX), f32::MAX);
770-
}
771-
772-
#[test]
773-
fn test_lerp_consistent() {
774-
assert_eq!(f32::lerp(f32::MAX, f32::MIN, f32::MIN), f32::MIN);
775-
assert_eq!(f32::lerp(f32::MIN, f32::MAX, f32::MAX), f32::MAX);
776-
777-
// as long as t is finite, a/b can be infinite
778-
assert_eq!(f32::lerp(f32::MAX, f32::NEG_INFINITY, f32::NEG_INFINITY), f32::NEG_INFINITY);
779-
assert_eq!(f32::lerp(f32::MIN, f32::INFINITY, f32::INFINITY), f32::INFINITY);
780-
}
781-
782-
#[test]
783-
fn test_lerp_nan_infinite() {
784-
// non-finite t is not NaN if a/b different
785-
assert!(!f32::lerp(f32::INFINITY, f32::MIN, f32::MAX).is_nan());
786-
assert!(!f32::lerp(f32::NEG_INFINITY, f32::MIN, f32::MAX).is_nan());
787-
}
788-
789-
#[test]
790-
fn test_lerp_values() {
791-
// just a few basic values
792-
assert_eq!(f32::lerp(0.25, 1.0, 2.0), 1.25);
793-
assert_eq!(f32::lerp(0.50, 1.0, 2.0), 1.50);
794-
assert_eq!(f32::lerp(0.75, 1.0, 2.0), 1.75);
795-
}
796-
797-
#[test]
798-
fn test_lerp_monotonic() {
799-
// near 0
800-
let below_zero = f32::lerp(-f32::EPSILON, f32::MIN, f32::MAX);
801-
let zero = f32::lerp(0.0, f32::MIN, f32::MAX);
802-
let above_zero = f32::lerp(f32::EPSILON, f32::MIN, f32::MAX);
803-
assert!(below_zero <= zero);
804-
assert!(zero <= above_zero);
805-
assert!(below_zero <= above_zero);
806-
807-
// near 0.5
808-
let below_half = f32::lerp(0.5 - f32::EPSILON, f32::MIN, f32::MAX);
809-
let half = f32::lerp(0.5, f32::MIN, f32::MAX);
810-
let above_half = f32::lerp(0.5 + f32::EPSILON, f32::MIN, f32::MAX);
811-
assert!(below_half <= half);
812-
assert!(half <= above_half);
813-
assert!(below_half <= above_half);
814-
815-
// near 1
816-
let below_one = f32::lerp(1.0 - f32::EPSILON, f32::MIN, f32::MAX);
817-
let one = f32::lerp(1.0, f32::MIN, f32::MAX);
818-
let above_one = f32::lerp(1.0 + f32::EPSILON, f32::MIN, f32::MAX);
819-
assert!(below_one <= one);
820-
assert!(one <= above_one);
821-
assert!(below_one <= above_one);
822-
}

Diff for: library/std/src/f64.rs

-36
Original file line numberDiff line numberDiff line change
@@ -881,42 +881,6 @@ impl f64 {
881881
0.5 * ((2.0 * self) / (1.0 - self)).ln_1p()
882882
}
883883

884-
/// Linear interpolation between `start` and `end`.
885-
///
886-
/// This enables linear interpolation between `start` and `end`, where start is represented by
887-
/// `self == 0.0` and `end` is represented by `self == 1.0`. This is the basis of all
888-
/// "transition", "easing", or "step" functions; if you change `self` from 0.0 to 1.0
889-
/// at a given rate, the result will change from `start` to `end` at a similar rate.
890-
///
891-
/// Values below 0.0 or above 1.0 are allowed, allowing you to extrapolate values outside the
892-
/// range from `start` to `end`. This also is useful for transition functions which might
893-
/// move slightly past the end or start for a desired effect. Mathematically, the values
894-
/// returned are equivalent to `start + self * (end - start)`, although we make a few specific
895-
/// guarantees that are useful specifically to linear interpolation.
896-
///
897-
/// These guarantees are:
898-
///
899-
/// * If `start` and `end` are [finite], the value at 0.0 is always `start` and the
900-
/// value at 1.0 is always `end`. (exactness)
901-
/// * If `start` and `end` are [finite], the values will always move in the direction from
902-
/// `start` to `end` (monotonicity)
903-
/// * If `self` is [finite] and `start == end`, the value at any point will always be
904-
/// `start == end`. (consistency)
905-
///
906-
/// [finite]: #method.is_finite
907-
#[must_use = "method returns a new number and does not mutate the original value"]
908-
#[unstable(feature = "float_interpolation", issue = "86269")]
909-
pub fn lerp(self, start: f64, end: f64) -> f64 {
910-
// consistent
911-
if start == end {
912-
start
913-
914-
// exact/monotonic
915-
} else {
916-
self.mul_add(end, (-self).mul_add(start, start))
917-
}
918-
}
919-
920884
// Solaris/Illumos requires a wrapper around log, log2, and log10 functions
921885
// because of their non-standard behavior (e.g., log(-n) returns -Inf instead
922886
// of expected NaN).

Diff for: library/std/src/f64/tests.rs

-55
Original file line numberDiff line numberDiff line change
@@ -753,58 +753,3 @@ fn test_total_cmp() {
753753
assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&f64::INFINITY));
754754
assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&s_nan()));
755755
}
756-
757-
#[test]
758-
fn test_lerp_exact() {
759-
// simple values
760-
assert_eq!(f64::lerp(0.0, 2.0, 4.0), 2.0);
761-
assert_eq!(f64::lerp(1.0, 2.0, 4.0), 4.0);
762-
763-
// boundary values
764-
assert_eq!(f64::lerp(0.0, f64::MIN, f64::MAX), f64::MIN);
765-
assert_eq!(f64::lerp(1.0, f64::MIN, f64::MAX), f64::MAX);
766-
}
767-
768-
#[test]
769-
fn test_lerp_consistent() {
770-
assert_eq!(f64::lerp(f64::MAX, f64::MIN, f64::MIN), f64::MIN);
771-
assert_eq!(f64::lerp(f64::MIN, f64::MAX, f64::MAX), f64::MAX);
772-
773-
// as long as t is finite, a/b can be infinite
774-
assert_eq!(f64::lerp(f64::MAX, f64::NEG_INFINITY, f64::NEG_INFINITY), f64::NEG_INFINITY);
775-
assert_eq!(f64::lerp(f64::MIN, f64::INFINITY, f64::INFINITY), f64::INFINITY);
776-
}
777-
778-
#[test]
779-
fn test_lerp_nan_infinite() {
780-
// non-finite t is not NaN if a/b different
781-
assert!(!f64::lerp(f64::INFINITY, f64::MIN, f64::MAX).is_nan());
782-
assert!(!f64::lerp(f64::NEG_INFINITY, f64::MIN, f64::MAX).is_nan());
783-
}
784-
785-
#[test]
786-
fn test_lerp_values() {
787-
// just a few basic values
788-
assert_eq!(f64::lerp(0.25, 1.0, 2.0), 1.25);
789-
assert_eq!(f64::lerp(0.50, 1.0, 2.0), 1.50);
790-
assert_eq!(f64::lerp(0.75, 1.0, 2.0), 1.75);
791-
}
792-
793-
#[test]
794-
fn test_lerp_monotonic() {
795-
// near 0
796-
let below_zero = f64::lerp(-f64::EPSILON, f64::MIN, f64::MAX);
797-
let zero = f64::lerp(0.0, f64::MIN, f64::MAX);
798-
let above_zero = f64::lerp(f64::EPSILON, f64::MIN, f64::MAX);
799-
assert!(below_zero <= zero);
800-
assert!(zero <= above_zero);
801-
assert!(below_zero <= above_zero);
802-
803-
// near 1
804-
let below_one = f64::lerp(1.0 - f64::EPSILON, f64::MIN, f64::MAX);
805-
let one = f64::lerp(1.0, f64::MIN, f64::MAX);
806-
let above_one = f64::lerp(1.0 + f64::EPSILON, f64::MIN, f64::MAX);
807-
assert!(below_one <= one);
808-
assert!(one <= above_one);
809-
assert!(below_one <= above_one);
810-
}

Diff for: library/std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@
284284
#![feature(exact_size_is_empty)]
285285
#![feature(exhaustive_patterns)]
286286
#![feature(extend_one)]
287-
#![feature(float_interpolation)]
288287
#![feature(fn_traits)]
289288
#![feature(format_args_nl)]
290289
#![feature(gen_future)]

Diff for: src/librustdoc/json/conversions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ impl FromWithTcx<clean::Type> for Type {
412412
.map(|t| {
413413
clean::GenericBound::TraitBound(t, rustc_hir::TraitBoundModifier::None)
414414
})
415-
.chain(lt.into_iter().map(clean::GenericBound::Outlives))
415+
.chain(lt.map(clean::GenericBound::Outlives))
416416
.map(|bound| bound.into_tcx(tcx))
417417
.collect(),
418418
}
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![feature(type_alias_impl_trait)]
2+
#![feature(generic_associated_types)]
3+
4+
// See https://github.com/rust-lang/rust/issues/87258#issuecomment-883293367
5+
6+
trait Trait1 {}
7+
8+
struct Struct<'b>(&'b ());
9+
10+
impl<'d> Trait1 for Struct<'d> {}
11+
12+
pub trait Trait2 {
13+
type FooFuture<'a>: Trait1;
14+
fn foo<'a>() -> Self::FooFuture<'a>;
15+
}
16+
17+
impl<'c, S: Trait2> Trait2 for &'c mut S {
18+
type FooFuture<'a> = impl Trait1;
19+
fn foo<'a>() -> Self::FooFuture<'a> { //~ ERROR
20+
Struct(unimplemented!())
21+
}
22+
}
23+
24+
fn main() {}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
2+
--> $DIR/issue-87258_a.rs:19:21
3+
|
4+
LL | fn foo<'a>() -> Self::FooFuture<'a> {
5+
| ^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: hidden type `Struct<'_>` captures lifetime '_#7r
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0700`.
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#![feature(type_alias_impl_trait)]
2+
#![feature(generic_associated_types)]
3+
4+
// See https://github.com/rust-lang/rust/issues/87258#issuecomment-883293367
5+
6+
trait Trait1 {}
7+
8+
struct Struct<'b>(&'b ());
9+
10+
impl<'d> Trait1 for Struct<'d> {}
11+
12+
pub trait Trait2 {
13+
type FooFuture<'a>: Trait1;
14+
fn foo<'a>() -> Self::FooFuture<'a>;
15+
}
16+
17+
type Helper<'xenon, 'yttrium, KABOOM: Trait2> = impl Trait1;
18+
19+
impl<'c, S: Trait2> Trait2 for &'c mut S {
20+
type FooFuture<'a> = Helper<'c, 'a, S>;
21+
fn foo<'a>() -> Self::FooFuture<'a> { //~ ERROR
22+
Struct(unimplemented!())
23+
}
24+
}
25+
26+
fn main() {}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
2+
--> $DIR/issue-87258_b.rs:21:21
3+
|
4+
LL | fn foo<'a>() -> Self::FooFuture<'a> {
5+
| ^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: hidden type `Struct<'_>` captures lifetime '_#7r
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0700`.

Diff for: src/test/ui/typeck/issue-90164.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
fn copy<R: Unpin, W>(_: R, _: W) {}
2+
3+
fn f<T>(r: T) {
4+
let w = ();
5+
copy(r, w);
6+
//~^ ERROR [E0277]
7+
}
8+
9+
fn main() {}

Diff for: src/test/ui/typeck/issue-90164.stderr

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error[E0277]: `T` cannot be unpinned
2+
--> $DIR/issue-90164.rs:5:10
3+
|
4+
LL | copy(r, w);
5+
| ---- ^ the trait `Unpin` is not implemented for `T`
6+
| |
7+
| required by a bound introduced by this call
8+
|
9+
= note: consider using `Box::pin`
10+
note: required by a bound in `copy`
11+
--> $DIR/issue-90164.rs:1:12
12+
|
13+
LL | fn copy<R: Unpin, W>(_: R, _: W) {}
14+
| ^^^^^ required by this bound in `copy`
15+
help: consider restricting type parameter `T`
16+
|
17+
LL | fn f<T: std::marker::Unpin>(r: T) {
18+
| ++++++++++++++++++++
19+
20+
error: aborting due to previous error
21+
22+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)