Skip to content

Linear interpolation (lerp) implementation #71016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

vertexclique
Copy link
Member

Implements lerp with feature flag: #71015

@rust-highfive
Copy link
Contributor

r? @cramertj

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 11, 2020
@rust-highfive
Copy link
Contributor

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-04-11T01:12:26.5486902Z ========================== Starting Command Output ===========================
2020-04-11T01:12:26.5489404Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/ce3250cf-fd03-4a30-bf16-1cff52bc938d.sh
2020-04-11T01:12:26.5489677Z 
2020-04-11T01:12:26.5493163Z ##[section]Finishing: Disable git automatic line ending conversion
2020-04-11T01:12:26.5512338Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/71016/merge to s
2020-04-11T01:12:26.5515594Z Task         : Get sources
2020-04-11T01:12:26.5515912Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-11T01:12:26.5516234Z Version      : 1.0.0
2020-04-11T01:12:26.5516440Z Author       : Microsoft
---
2020-04-11T01:12:27.5454619Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-04-11T01:12:27.5460564Z ##[command]git config gc.auto 0
2020-04-11T01:12:27.5465286Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-04-11T01:12:27.5469641Z ##[command]git config --get-all http.proxy
2020-04-11T01:12:27.5479981Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/71016/merge:refs/remotes/pull/71016/merge
---
2020-04-11T01:14:24.0449736Z Looks like docker image is the same as before, not uploading
2020-04-11T01:14:31.9682452Z [CI_JOB_NAME=x86_64-gnu-llvm-7]
2020-04-11T01:14:31.9948296Z [CI_JOB_NAME=x86_64-gnu-llvm-7]
2020-04-11T01:14:31.9975246Z == clock drift check ==
2020-04-11T01:14:31.9984586Z   local time: Sat Apr 11 01:14:31 UTC 2020
2020-04-11T01:14:32.1791434Z   network time: Sat, 11 Apr 2020 01:14:32 GMT
2020-04-11T01:14:32.1818542Z Starting sccache server...
2020-04-11T01:14:32.2685160Z configure: processing command line
2020-04-11T01:14:32.2686263Z configure: 
2020-04-11T01:14:32.2697452Z configure: rust.dist-src        := False
---
2020-04-11T01:19:22.8045502Z    Compiling rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-11T01:19:24.0817849Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-11T01:19:25.5095983Z    Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-11T01:19:26.4261407Z    Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-11T01:19:34.4038462Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-11T01:19:36.5927302Z    Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-11T01:19:40.6505333Z    Compiling rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-11T01:19:44.3647720Z    Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-11T01:19:52.8318663Z    Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-11T01:40:37.6042862Z    Compiling rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-11T01:40:39.3125775Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-11T01:40:41.2575185Z    Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-11T01:40:42.3138252Z    Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-11T01:40:53.2297213Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-11T01:40:55.4023844Z    Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-11T01:41:00.5644795Z    Compiling rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-11T01:41:05.8322110Z    Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-11T01:41:17.0785214Z    Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-11T02:05:13.6670892Z .................................................................................................... 1600/9884
2020-04-11T02:05:19.5806063Z .................................................................................................... 1700/9884
2020-04-11T02:05:23.9478785Z .................................................................................................... 1800/9884
2020-04-11T02:05:32.8510127Z .................................................................................................... 1900/9884
2020-04-11T02:05:40.9561371Z ..i................................................................................................. 2000/9884
2020-04-11T02:05:47.3260454Z ............................................................................................iiiii... 2100/9884
2020-04-11T02:06:07.6334643Z .................................................................................................... 2300/9884
2020-04-11T02:06:09.7448434Z .................................................................................................... 2400/9884
2020-04-11T02:06:11.9496677Z .................................................................................................... 2500/9884
2020-04-11T02:06:17.6257344Z .................................................................................................... 2600/9884
---
2020-04-11T02:09:11.1462381Z .................................................................................................... 5100/9884
2020-04-11T02:09:18.4624957Z .................................................................................................... 5200/9884
2020-04-11T02:09:23.2989316Z ...........i........................................................................................ 5300/9884
2020-04-11T02:09:32.8975630Z .................................................................................................... 5400/9884
2020-04-11T02:09:37.4929002Z ii.ii........i...i.................................................................................. 5500/9884
2020-04-11T02:09:44.8965537Z .............................................i...................................................... 5700/9884
2020-04-11T02:09:54.6397592Z .................................................................ii................................. 5800/9884
2020-04-11T02:10:00.8910263Z ....i............................................................................................... 5900/9884
2020-04-11T02:10:06.1000254Z .................................................................................................... 6000/9884
2020-04-11T02:10:06.1000254Z .................................................................................................... 6000/9884
2020-04-11T02:10:15.4378241Z ..................................................................................................ii 6100/9884
2020-04-11T02:10:26.2066930Z ...i..ii...........i................................................................................ 6200/9884
2020-04-11T02:10:38.3940772Z .................................................................................................... 6400/9884
2020-04-11T02:10:41.4961332Z .................................................................................................... 6500/9884
2020-04-11T02:10:41.4961332Z .................................................................................................... 6500/9884
2020-04-11T02:10:53.1326979Z ............................i..ii................................................................... 6600/9884
2020-04-11T02:11:12.9701791Z .................................................................................................... 6800/9884
2020-04-11T02:11:14.9234037Z ............................i....................................................................... 6900/9884
2020-04-11T02:11:16.8976808Z .................................................................................................... 7000/9884
2020-04-11T02:11:18.9671277Z ...................................................................i................................ 7100/9884
---
2020-04-11T02:12:50.9223151Z .................................................................................................... 7800/9884
2020-04-11T02:12:54.6824466Z .................................................................................................... 7900/9884
2020-04-11T02:13:00.9472421Z .................................................................................................... 8000/9884
2020-04-11T02:13:07.6136679Z ................................i................................................................... 8100/9884
2020-04-11T02:13:15.8254465Z ................................................................................iiiiii.iiiii.i...... 8200/9884
2020-04-11T02:13:30.6754275Z ..........................i......i.................................................................. 8400/9884
2020-04-11T02:13:34.2202687Z .................................................................................................... 8500/9884
2020-04-11T02:13:44.6072360Z .................................................................................................... 8600/9884
2020-04-11T02:13:56.3254323Z .................................................................................................... 8700/9884
---
2020-04-11T02:16:13.3923731Z Suite("src/test/codegen") not skipped for "bootstrap::test::Codegen" -- not in ["src/tools/tidy"]
2020-04-11T02:16:13.4125603Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-11T02:16:13.6155847Z 
2020-04-11T02:16:13.6178690Z running 185 tests
2020-04-11T02:16:16.1896429Z iiii......i............ii.i..iiii....i....i...........i............i..i..................i....i..... 100/185
2020-04-11T02:16:18.6163007Z .......i.i.i...iii..iiiiiiiiiiiiiiii.......................iii...............ii......
2020-04-11T02:16:18.6165822Z 
2020-04-11T02:16:18.6170377Z  finished in 5.204
2020-04-11T02:16:18.6184961Z Suite("src/test/codegen-units") not skipped for "bootstrap::test::CodegenUnits" -- not in ["src/tools/tidy"]
2020-04-11T02:16:18.6369378Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-11T02:16:20.6178938Z Suite("src/test/assembly") not skipped for "bootstrap::test::Assembly" -- not in ["src/tools/tidy"]
2020-04-11T02:16:20.6365738Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-11T02:16:20.7890137Z 
2020-04-11T02:16:20.7890645Z running 9 tests
2020-04-11T02:16:20.7892497Z iiiiiiiii
2020-04-11T02:16:20.7894606Z 
2020-04-11T02:16:20.7895028Z  finished in 0.151
2020-04-11T02:16:20.7896140Z Suite("src/test/incremental") not skipped for "bootstrap::test::Incremental" -- not in ["src/tools/tidy"]
2020-04-11T02:16:20.8067054Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-11T02:16:39.8274863Z Suite("src/test/debuginfo") not skipped for "bootstrap::test::Debuginfo" -- not in ["src/tools/tidy"]
2020-04-11T02:16:39.8483258Z Check compiletest suite=debuginfo mode=debuginfo (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-11T02:16:40.0388115Z 
2020-04-11T02:16:40.0388430Z running 115 tests
2020-04-11T02:16:52.5511867Z iiiii..i.....i..i...i..i.i.i..i..i..ii....i.i....ii..........iiii.........i.....i..i.......ii.i.ii.. 100/115
2020-04-11T02:16:54.1979222Z ...iiii.....ii.
2020-04-11T02:16:54.1984455Z 
2020-04-11T02:16:54.1985081Z  finished in 14.349
2020-04-11T02:16:54.2036324Z Suite("src/test/ui-fulldeps") not skipped for Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-11T02:16:54.2037222Z Copying stage2 rustc from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
---
2020-04-11T02:28:11.9529474Z 
2020-04-11T02:28:11.9530714Z    Doc-tests core
2020-04-11T02:28:16.1382283Z 
2020-04-11T02:28:16.1414625Z running 2490 tests
2020-04-11T02:28:24.5165297Z ......iiiii......................................................................................... 100/2490
2020-04-11T02:28:32.9894685Z .....................................................................................ii............. 200/2490
2020-04-11T02:28:52.1296887Z ....................i............................................................................... 400/2490
2020-04-11T02:28:52.1296887Z ....................i............................................................................... 400/2490
2020-04-11T02:29:01.0805385Z ..........................................................................i..i..................iiii 500/2490
2020-04-11T02:29:16.1454567Z .................................................................................................... 700/2490
2020-04-11T02:29:23.7541705Z .................................................................................................... 800/2490
2020-04-11T02:29:31.4615676Z .................................................................................................... 900/2490
2020-04-11T02:29:39.1920874Z .................................................................................................... 1000/2490
---
2020-04-11T02:32:42.6125885Z .................................................................................................... 500/764
2020-04-11T02:32:42.6430014Z ......................thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:2741:22
2020-04-11T02:32:42.6445216Z ....thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:2778:21
2020-04-11T02:32:42.6453681Z thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "SendError(..)"', src/libstd/sync/mpsc/mod.rs:2766:17
2020-04-11T02:32:42.6470379Z .......thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:2645:13
2020-04-11T02:32:43.0425021Z ..........................................thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:1997:22
2020-04-11T02:32:43.0459254Z .....thread '<unnamed>.' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:2034:21
2020-04-11T02:32:43.0473301Z .....thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:1916:13
2020-04-11T02:32:45.1030381Z ........................thread '<unnamed>' panicked at 'explicit panic', src/libstd/sync/mutex.rs:633:13
2020-04-11T02:32:45.1031540Z thread '<unnamed>' panicked at 'test panic in inner thread to poison mutex', src/libstd/sync/mutex.rs:587:13
2020-04-11T02:32:45.1032261Z thread '<unnamed>' panicked at 'test panic in inner thread to poison mutex', src/libstd/sync/mutex.rs:563:13
2020-04-11T02:32:45.1032915Z thread '<unnamed>' panicked at 'explicit panic', src/libstd/sync/mutex.rs:694:......13
---
2020-04-11T02:32:54.0227649Z 
2020-04-11T02:32:54.0228034Z running 1021 tests
2020-04-11T02:33:09.4261379Z i................................................................................................... 100/1021
2020-04-11T02:33:18.2584502Z .............................................................F...................................... 200/1021
2020-04-11T02:33:24.9684151Z ..F..................iii.....i......i...i......i.................................................... 300/1021
2020-04-11T02:33:35.0230312Z .....................................................i....i......................................ii. 500/1021
2020-04-11T02:33:41.8952633Z .................................................................................................... 600/1021
2020-04-11T02:33:46.1089874Z .................................................................................................... 700/1021
2020-04-11T02:33:46.1089874Z .................................................................................................... 700/1021
2020-04-11T02:33:52.5482519Z ...............................................iiii................................................. 800/1021
2020-04-11T02:34:04.8846275Z .................................................................................................... 900/1021
2020-04-11T02:34:10.2353967Z .....................................................................iiii........................... 1000/1021
2020-04-11T02:34:11.4023067Z failures:
2020-04-11T02:34:11.4023307Z 
2020-04-11T02:34:11.4023307Z 
2020-04-11T02:34:11.4026528Z ---- f32.rs - f32::f32::lerp (line 922) stdout ----
2020-04-11T02:34:11.4027411Z error[E0658]: use of unstable library feature 'lerp'
2020-04-11T02:34:11.4028400Z  --> f32.rs:928:14
2020-04-11T02:34:11.4028632Z   |
2020-04-11T02:34:11.4028846Z 9 | let lerp = x.lerp(y, pol);
2020-04-11T02:34:11.4029193Z   |
2020-04-11T02:34:11.4029193Z   |
2020-04-11T02:34:11.4029849Z   = note: see issue #71015 <***/issues/71015> for more information
2020-04-11T02:34:11.4030198Z   = help: add `#![feature(lerp)]` to the crate attributes to enable
2020-04-11T02:34:11.4033923Z error: aborting due to previous error
2020-04-11T02:34:11.4034103Z 
2020-04-11T02:34:11.4034667Z For more information about this error, try `rustc --explain E0658`.
2020-04-11T02:34:11.4035081Z Couldn't compile the test.
2020-04-11T02:34:11.4035081Z Couldn't compile the test.
2020-04-11T02:34:11.4035542Z ---- f64.rs - f64::f64::lerp (line 924) stdout ----
2020-04-11T02:34:11.4036020Z error[E0658]: use of unstable library feature 'lerp'
2020-04-11T02:34:11.4036628Z  --> f64.rs:930:14
2020-04-11T02:34:11.4036801Z   |
2020-04-11T02:34:11.4036966Z 9 | let lerp = x.lerp(y, pol);
2020-04-11T02:34:11.4095161Z   |
2020-04-11T02:34:11.4095161Z   |
2020-04-11T02:34:11.4096112Z   = note: see issue #71015 <***/issues/71015> for more information
2020-04-11T02:34:11.4096466Z   = help: add `#![feature(lerp)]` to the crate attributes to enable
2020-04-11T02:34:11.4096865Z error: aborting due to previous error
2020-04-11T02:34:11.4097021Z 
2020-04-11T02:34:11.4097457Z For more information about this error, try `rustc --explain E0658`.
2020-04-11T02:34:11.4097886Z Couldn't compile the test.
2020-04-11T02:34:11.4097886Z Couldn't compile the test.
2020-04-11T02:34:11.4098024Z 
2020-04-11T02:34:11.4098148Z failures:
2020-04-11T02:34:11.4098529Z     f32.rs - f32::f32::lerp (line 922)
2020-04-11T02:34:11.4098994Z     f64.rs - f64::f64::lerp (line 924)
2020-04-11T02:34:11.4099415Z test result: FAILED. 999 passed; 2 failed; 20 ignored; 0 measured; 0 filtered out
2020-04-11T02:34:11.4099670Z 
2020-04-11T02:34:11.4116705Z error: test failed, to rerun pass '--doc'
2020-04-11T02:34:11.4127012Z 
---
2020-04-11T02:34:11.4130283Z 
2020-04-11T02:34:11.4176234Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --exclude src/tools/tidy
2020-04-11T02:34:11.4176757Z Build completed unsuccessfully in 1:18:05
2020-04-11T02:34:11.4194130Z == clock drift check ==
2020-04-11T02:34:11.4211133Z   local time: Sat Apr 11 02:34:11 UTC 2020
2020-04-11T02:34:11.5559960Z   network time: Sat, 11 Apr 2020 02:34:11 GMT
2020-04-11T02:34:11.9130857Z 
2020-04-11T02:34:11.9130857Z 
2020-04-11T02:34:11.9205461Z ##[error]Bash exited with code '1'.
2020-04-11T02:34:11.9218568Z ##[section]Finishing: Run build
2020-04-11T02:34:11.9268024Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/71016/merge to s
2020-04-11T02:34:11.9272783Z Task         : Get sources
2020-04-11T02:34:11.9273108Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-11T02:34:11.9273406Z Version      : 1.0.0
2020-04-11T02:34:11.9273637Z Author       : Microsoft
2020-04-11T02:34:11.9273637Z Author       : Microsoft
2020-04-11T02:34:11.9273968Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-04-11T02:34:11.9274350Z ==============================================================================
2020-04-11T02:34:12.2369040Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-04-11T02:34:12.2409660Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/71016/merge to s
2020-04-11T02:34:12.2493487Z Cleaning up task key
2020-04-11T02:34:12.2494928Z Start cleaning up orphan processes.
2020-04-11T02:34:12.2666893Z Terminate orphan process: pid (3452) (python)
2020-04-11T02:34:12.2921648Z ##[section]Finishing: Finalize Job

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @rust-lang/infra. (Feature Requests)

@vertexclique vertexclique force-pushed the vcq/lerp-impl branch 3 times, most recently from 2038ab8 to 9983502 Compare April 11, 2020 14:09
@rust-highfive
Copy link
Contributor

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-04-11T14:10:26.8582197Z ========================== Starting Command Output ===========================
2020-04-11T14:10:26.8584651Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/1b887fbe-4f0f-4175-ac1e-1cdd0a2fc378.sh
2020-04-11T14:10:26.8584865Z 
2020-04-11T14:10:26.8587922Z ##[section]Finishing: Disable git automatic line ending conversion
2020-04-11T14:10:26.8606378Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/71016/merge to s
2020-04-11T14:10:26.8609273Z Task         : Get sources
2020-04-11T14:10:26.8609506Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-11T14:10:26.8609732Z Version      : 1.0.0
2020-04-11T14:10:26.8609934Z Author       : Microsoft
---
2020-04-11T14:10:28.0763131Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-04-11T14:10:28.0768309Z ##[command]git config gc.auto 0
2020-04-11T14:10:28.0771407Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-04-11T14:10:28.0774484Z ##[command]git config --get-all http.proxy
2020-04-11T14:10:28.0780788Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/71016/merge:refs/remotes/pull/71016/merge
---
2020-04-11T14:12:40.8536641Z Looks like docker image is the same as before, not uploading
2020-04-11T14:12:48.4854889Z [CI_JOB_NAME=x86_64-gnu-llvm-7]
2020-04-11T14:12:48.5184789Z [CI_JOB_NAME=x86_64-gnu-llvm-7]
2020-04-11T14:12:48.5211613Z == clock drift check ==
2020-04-11T14:12:48.5221538Z   local time: Sat Apr 11 14:12:48 UTC 2020
2020-04-11T14:12:48.5420541Z   network time: Sat, 11 Apr 2020 14:12:48 GMT
2020-04-11T14:12:48.5443602Z Starting sccache server...
2020-04-11T14:12:48.6231813Z configure: processing command line
2020-04-11T14:12:48.6232540Z configure: 
2020-04-11T14:12:48.6233653Z configure: rust.dist-src        := False
---
2020-04-11T14:18:01.8396946Z    Compiling rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-11T14:18:03.3626671Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-11T14:18:05.0591399Z    Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-11T14:18:07.4512524Z    Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-11T14:18:15.3577319Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-11T14:18:19.5014556Z    Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-11T14:18:24.1813511Z    Compiling rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-11T14:18:28.4321030Z    Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-11T14:18:36.5568665Z    Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-11T14:41:43.7867271Z    Compiling rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-11T14:41:45.6261550Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-11T14:41:47.6650449Z    Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-11T14:41:49.7695414Z    Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-11T14:41:59.9556346Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-11T14:42:03.6720550Z    Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-11T14:42:08.9745555Z    Compiling rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-11T14:42:14.5988793Z    Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-11T14:42:24.8699062Z    Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-11T15:08:17.9648325Z .................................................................................................... 1700/9886
2020-04-11T15:08:22.2200996Z .................................................................................................... 1800/9886
2020-04-11T15:08:30.7996106Z .................................................................................................... 1900/9886
2020-04-11T15:08:39.0763362Z .....i.............................................................................................. 2000/9886
2020-04-11T15:08:45.4517460Z ..............................................................................................iiiii. 2100/9886
2020-04-11T15:09:07.1127310Z .................................................................................................... 2300/9886
2020-04-11T15:09:09.2975199Z .................................................................................................... 2400/9886
2020-04-11T15:09:11.5194376Z .................................................................................................... 2500/9886
2020-04-11T15:09:17.2019038Z .................................................................................................... 2600/9886
---
2020-04-11T15:12:19.4534685Z .................................................................................................... 5100/9886
2020-04-11T15:12:27.2134377Z .................................................................................................... 5200/9886
2020-04-11T15:12:32.4338836Z .............i...................................................................................... 5300/9886
2020-04-11T15:12:42.5198896Z .................................................................................................... 5400/9886
2020-04-11T15:12:47.7400076Z ..ii.ii........i...i................................................................................ 5500/9886
2020-04-11T15:12:55.4980787Z ...............................................i.................................................... 5700/9886
2020-04-11T15:13:05.9366048Z ...................................................................ii............................... 5800/9886
2020-04-11T15:13:12.3964228Z ......i............................................................................................. 5900/9886
2020-04-11T15:13:18.2510745Z .................................................................................................... 6000/9886
2020-04-11T15:13:18.2510745Z .................................................................................................... 6000/9886
2020-04-11T15:13:28.1874179Z .................................................................................................... 6100/9886
2020-04-11T15:13:39.6692187Z ii...i..ii...........i.............................................................................. 6200/9886
2020-04-11T15:13:55.1778028Z .................................................................................................... 6400/9886
2020-04-11T15:14:01.6076114Z .................................................................................................... 6500/9886
2020-04-11T15:14:01.6076114Z .................................................................................................... 6500/9886
2020-04-11T15:14:14.0052259Z ..............................i..ii................................................................. 6600/9886
2020-04-11T15:14:35.2384735Z .................................................................................................... 6800/9886
2020-04-11T15:14:37.2991432Z ..............................i..................................................................... 6900/9886
2020-04-11T15:14:39.4769873Z .................................................................................................... 7000/9886
2020-04-11T15:14:41.7422645Z .....................................................................i.............................. 7100/9886
---
2020-04-11T15:16:21.4670722Z .................................................................................................... 7800/9886
2020-04-11T15:16:25.8149424Z .................................................................................................... 7900/9886
2020-04-11T15:16:32.6105084Z .................................................................................................... 8000/9886
2020-04-11T15:16:39.6970458Z ..................................i................................................................. 8100/9886
2020-04-11T15:16:48.7159384Z ..................................................................................iiiiii.iiiii.i.... 8200/9886
2020-04-11T15:17:04.8582116Z ............................i......i................................................................ 8400/9886
2020-04-11T15:17:08.2601948Z .................................................................................................... 8500/9886
2020-04-11T15:17:19.4852232Z .................................................................................................... 8600/9886
2020-04-11T15:17:32.4926415Z .................................................................................................... 8700/9886
---
2020-04-11T15:19:59.7706148Z Suite("src/test/codegen") not skipped for "bootstrap::test::Codegen" -- not in ["src/tools/tidy"]
2020-04-11T15:19:59.8016084Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-11T15:20:00.0339556Z 
2020-04-11T15:20:00.0340704Z running 185 tests
2020-04-11T15:20:02.8504292Z iiii......i............ii.i..iiii.....i...i...........i............i..i..................i....i..... 100/185
2020-04-11T15:20:05.4638834Z .......i.i.i...iii..iiiiiiiiiiiiiiii.......................i.ii..............ii......
2020-04-11T15:20:05.4641391Z 
2020-04-11T15:20:05.4647379Z  finished in 5.663
2020-04-11T15:20:05.4658535Z Suite("src/test/codegen-units") not skipped for "bootstrap::test::CodegenUnits" -- not in ["src/tools/tidy"]
2020-04-11T15:20:05.4851182Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-11T15:20:07.6014860Z Suite("src/test/assembly") not skipped for "bootstrap::test::Assembly" -- not in ["src/tools/tidy"]
2020-04-11T15:20:07.6208212Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-11T15:20:07.7845901Z 
2020-04-11T15:20:07.7846430Z running 9 tests
2020-04-11T15:20:07.7847780Z iiiiiiiii
2020-04-11T15:20:07.7851229Z 
2020-04-11T15:20:07.7851646Z  finished in 0.164
2020-04-11T15:20:07.7857226Z Suite("src/test/incremental") not skipped for "bootstrap::test::Incremental" -- not in ["src/tools/tidy"]
2020-04-11T15:20:07.8067352Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-11T15:20:28.3451680Z Suite("src/test/debuginfo") not skipped for "bootstrap::test::Debuginfo" -- not in ["src/tools/tidy"]
2020-04-11T15:20:28.3686345Z Check compiletest suite=debuginfo mode=debuginfo (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-11T15:20:28.5850662Z 
2020-04-11T15:20:28.5851025Z running 115 tests
2020-04-11T15:20:41.9448032Z iiiii..i.....i..i...i..i.i.i..i..i..ii....i.i....ii..........iiii.........i.....i..i.......ii.i.ii.. 100/115
2020-04-11T15:20:43.6658593Z ...iiii.....ii.
2020-04-11T15:20:43.6662165Z 
2020-04-11T15:20:43.6662319Z  finished in 15.297
2020-04-11T15:20:43.6681802Z Suite("src/test/ui-fulldeps") not skipped for "bootstrap::test::UiFullDeps" -- not in ["src/tools/tidy"]
2020-04-11T15:20:43.6682438Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-11T15:33:37.5458912Z 
2020-04-11T15:33:37.5459798Z    Doc-tests core
2020-04-11T15:33:42.3742868Z 
2020-04-11T15:33:42.3743912Z running 2490 tests
2020-04-11T15:33:51.5981679Z ......iiiii......................................................................................... 100/2490
2020-04-11T15:34:00.4094731Z .....................................................................................ii............. 200/2490
2020-04-11T15:34:20.9903957Z ....................i............................................................................... 400/2490
2020-04-11T15:34:20.9903957Z ....................i............................................................................... 400/2490
2020-04-11T15:34:31.2307566Z ..........................................................................i..i..................iiii 500/2490
2020-04-11T15:34:47.6726069Z .................................................................................................... 700/2490
2020-04-11T15:34:56.2428623Z .................................................................................................... 800/2490
2020-04-11T15:35:04.9689810Z .................................................................................................... 900/2490
2020-04-11T15:35:13.4245938Z .................................................................................................... 1000/2490
---
2020-04-11T15:38:33.3211719Z .................................................thread '<unnamed>' panicked at 'explicit panic', src/libstd/io/stdio.rs:888:13
2020-04-11T15:38:33.3215339Z . 300/764
2020-04-11T15:38:33.3939128Z .................................................................................................... 400/764
2020-04-11T15:38:35.4547045Z .................................................................................................... 500/764
2020-04-11T15:38:35.4892231Z ......................thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:2741:22
2020-04-11T15:38:35.4905300Z ....thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "SendError(..)"', src/libstd/sync/mpsc/mod.rs:2766:17
2020-04-11T15:38:35.4912100Z .thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:2778:21
2020-04-11T15:38:35.4927206Z ......thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:2645:13
2020-04-11T15:38:35.7516447Z ..........................................thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:1997:22
2020-04-11T15:38:35.7576359Z ....thread '.<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', .src/libstd/sync/mpsc/mod.rs:2034:.21
2020-04-11T15:38:35.7596452Z ....thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:1916:13
2020-04-11T15:38:37.7996326Z ........................thread '<unnamed>' panicked at 'explicit panic', src/libstd/sync/mutex.rs:633:13
2020-04-11T15:38:37.7998493Z thread '<unnamed>' panicked at 'test panic in inner thread to poison mutex', src/libstd/sync/mutex.rs:587:13
2020-04-11T15:38:37.8010438Z .....thread '<unnamed>' panicked at 'test panic in inner thread to poison mutex', src/libstd/sync/mutex.rs:563:13
2020-04-11T15:38:37.8011077Z thread '<unnamed>' panicked at 'explicit panic', src/libstd/sync/mutex.rs:694:13
---
2020-04-11T15:38:46.8339352Z 
2020-04-11T15:38:46.8339660Z running 1021 tests
2020-04-11T15:39:04.4500902Z i................................................................................................... 100/1021
2020-04-11T15:39:15.0208457Z .............................................................F...................................... 200/1021
2020-04-11T15:39:22.6594340Z ....................iii......i......i...i......i.................................................... 300/1021
2020-04-11T15:39:34.0663922Z .....................................................i....i......................................ii. 500/1021
2020-04-11T15:39:41.7937801Z .................................................................................................... 600/1021
2020-04-11T15:39:46.5994345Z .................................................................................................... 700/1021
2020-04-11T15:39:46.5994345Z .................................................................................................... 700/1021
2020-04-11T15:39:53.6670063Z ...............................................iiii................................................. 800/1021
2020-04-11T15:40:07.5159586Z .................................................................................................... 900/1021
2020-04-11T15:40:13.5642225Z .....................................................................iiii........................... 1000/1021
2020-04-11T15:40:14.8812010Z failures:
2020-04-11T15:40:14.8812200Z 
2020-04-11T15:40:14.8812200Z 
2020-04-11T15:40:14.8813052Z ---- f32.rs - f32::f32::lerp (line 922) stdout ----
2020-04-11T15:40:14.8814008Z   --> f32.rs:931:17
2020-04-11T15:40:14.8814278Z    |
2020-04-11T15:40:14.8814278Z    |
2020-04-11T15:40:14.8814460Z 12 | assert!(lerp == 15.0_f64);
2020-04-11T15:40:14.8814800Z    |                 ^^^^^^^^ expected `f32`, found `f64`
2020-04-11T15:40:14.8815082Z    |
2020-04-11T15:40:14.8815315Z help: change the type of the numeric literal from `f64` to `f32`
2020-04-11T15:40:14.8815624Z    |
2020-04-11T15:40:14.8815803Z 12 | assert!(lerp == 15.0_f32);
2020-04-11T15:40:14.8816152Z 
2020-04-11T15:40:14.8816416Z error: aborting due to previous error
2020-04-11T15:40:14.8816806Z 
2020-04-11T15:40:14.8817279Z For more information about this error, try `rustc --explain E0308`.
2020-04-11T15:40:14.8817279Z For more information about this error, try `rustc --explain E0308`.
2020-04-11T15:40:14.8817656Z Couldn't compile the test.
2020-04-11T15:40:14.8817779Z 
2020-04-11T15:40:14.8817891Z failures:
2020-04-11T15:40:14.8818405Z     f32.rs - f32::f32::lerp (line 922)
2020-04-11T15:40:14.8819164Z test result: FAILED. 1000 passed; 1 failed; 20 ignored; 0 measured; 0 filtered out
2020-04-11T15:40:14.8819479Z 
2020-04-11T15:40:14.8910327Z error: test failed, to rerun pass '--doc'
2020-04-11T15:40:14.8919883Z 
---
2020-04-11T15:40:14.8923643Z 
2020-04-11T15:40:14.8938625Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --exclude src/tools/tidy
2020-04-11T15:40:14.8939102Z Build completed unsuccessfully in 1:25:55
2020-04-11T15:40:14.8997274Z == clock drift check ==
2020-04-11T15:40:14.9023620Z   local time: Sat Apr 11 15:40:14 UTC 2020
2020-04-11T15:40:15.1734410Z   network time: Sat, 11 Apr 2020 15:40:15 GMT
2020-04-11T15:40:15.5160353Z 
2020-04-11T15:40:15.5160353Z 
2020-04-11T15:40:15.5239282Z ##[error]Bash exited with code '1'.
2020-04-11T15:40:15.5255592Z ##[section]Finishing: Run build
2020-04-11T15:40:15.5313307Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/71016/merge to s
2020-04-11T15:40:15.5319173Z Task         : Get sources
2020-04-11T15:40:15.5319518Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-11T15:40:15.5319853Z Version      : 1.0.0
2020-04-11T15:40:15.5320075Z Author       : Microsoft
2020-04-11T15:40:15.5320075Z Author       : Microsoft
2020-04-11T15:40:15.5320428Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-04-11T15:40:15.5320864Z ==============================================================================
2020-04-11T15:40:15.8561143Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-04-11T15:40:15.8618426Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/71016/merge to s
2020-04-11T15:40:15.8712324Z Cleaning up task key
2020-04-11T15:40:15.8713694Z Start cleaning up orphan processes.
2020-04-11T15:40:15.9087838Z Terminate orphan process: pid (3994) (python)
2020-04-11T15:40:15.9144264Z ##[section]Finishing: Finalize Job

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @rust-lang/infra. (Feature Requests)

Enable feature flag for the use of it
@ebarnard
Copy link
Contributor

The (1 - t) * a + t * b form of linear interpolation is only guarenteed to be monotonic if a * b < 0.

I've used the implementation from http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0811r2.html#linear-interpolation elsewhere, but this has the drawback that it is quite branch heavy.

@hanna-kruppe
Copy link
Contributor

I find it hard to believe that the C++ version would see much use, given that it's much slower than the simpler alternatives and monotonicity does not seem useful for the most common uses of lerp that I'm familiar with.

I'd like to hear about applications where monotonicity matters, but regardless of whether a monotonic lerp is useful, I think it's valuable to have the fast and numerically stable (1 - t) a + t b readily available to non-experts. When people keep copying and pasting their own implementations for performance, some percentage of them will probably use the unstable a + t (b - a) instead.

I'm already worried that the proposed implementation might be eschewed by performance-minded users because it does not use FMA operations where available (which, to be fair, is currently difficult to do in libstd).

@ebarnard
Copy link
Contributor

I agree that there are probably a limited number of stiuations that require strict monotinicity. However, there are undoubtedly some that do (I have seen a case where I think it mattered, and chaging to a monotonic implementation seemed to help fix the issue I was seeing).

Given that is the case, it seems odd for the standard library to include this implementation of lerp when there isn't a clear best implementation, and when choosing between implementations depends what the application is.

I would expect a game engine to use the (1 - t) * a + t * b form, while a mathematical library might use something more similar to the implementation I linked above.

@hanna-kruppe
Copy link
Contributor

You could argue that the standard library should not include any lerp implementation, I don't feel strongly about that either way. But I think if it's going to be added at all, then the fast and reasonably-well-behaved variant is going to be more helpful to more people.

@XAMPPRocky
Copy link
Member

Given that is the case, it seems odd for the standard library to include this implementation of lerp when there isn't a clear best implementation, and when choosing between implementations depends what the application is.

The standard library often doesn't have the "best" implementation of a particular problem. There's usually always some trade-off. That being said, the guarantee should probably be mentioned in the documentation so that people are aware of the trade-offs being made.

@ebarnard
Copy link
Contributor

ebarnard commented Apr 14, 2020

Maybe my wording wasn't very clear - by best I mean an implementation that is both correct and as fast as possible. Elsewhere, the standard library seems to favour correctness over speed (e.g. HashMap using SipHash by default). It would be odd for it not to do so here.

If we have a slower but correct implementation here, it is very easy for someone to profile their software and discover that this implementation is causing a slowdown. The converse, discovering that f64::lerp is not monotonic even with documentation, is not so easy.

@ebarnard
Copy link
Contributor

ebarnard commented Apr 14, 2020

For reference here is the implementation used in LLVM's libcxx. It is very similar to the one from P0811R3.

Whatever implementation is decided on it ought to pass the same tests as libcxx.

@hanna-kruppe
Copy link
Contributor

Reality is a lot more complicated than a "correctness over speed" slogan suggests. Just one example thematically related to this PR: Iterator::sum with float elements performs naive serial summation, not anything more numerically robust such as compensated summation.

Furthermore, your arguments are based on a relatively arbitrary and contestable definition of correctness. For example, why does it matter if results are monotonic in t but it doesn't matter if results are correctly rounded? Why do the trade-offs w.r.t. numeric stability not factor into the conditions included in the C++ standard, other than the (literal, in the canonical implementation) special case of requiring lerp(a, b, 1) == b? There is a value judgement and trade-off underlying the decision to enshrine one property and disregard the others. Sometimes the right thing is to defer to experts or prior art on such decisions, but the C++ standard is not exactly an unimpeachable authority on numerics and std::lerp in particular has been highly controversial.

Finally, once again: if the end result is that libstd provides a function that most prospective users avoid over performance concerns, then little of value is gained. So in my view, your comments at most provide reasons to not provide lerp at all.

@crlf0710
Copy link
Member

Let me reassign this to T-libs to make the decision here.
r? @Amanieu

@rust-highfive rust-highfive assigned Amanieu and unassigned cramertj Apr 24, 2020
@crlf0710 crlf0710 added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Apr 24, 2020
@Amanieu
Copy link
Member

Amanieu commented Apr 24, 2020

I feel that if we do decide to include lerp in the standard library then we should use the "correct but slow" version of the function and have a separate fast_lerp for the fast but less precise version.

I have concerns regarding the argument order however: a.lerp(b, t) breaks the symmetry between the two values being interpolated over. I feel that t.lerp(a, b) would make much more sense. Alternatively we could also remove the method syntax and force all arguments to be specified: lerp(a, b, t).

@ranma42
Copy link
Contributor

ranma42 commented Apr 24, 2020

Would it make sense to have lerp as a method on Range<f32> (or RangeInclusive<f32>)?

@cramertj
Copy link
Member

r? @Amanieu

@vertexclique
Copy link
Member Author

@cramertj Oh sorry I forgot to update you all. This is not ready for review yet, I need to refactor a couple of things. This version won't compile to the expected intrinsic in every rust project. So will use suboptimal non-fma ops. I will ping again. Thanks :)

@joelpalmer joelpalmer added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 5, 2020
@jdahlstrom
Copy link

It would make sense to me for lerp to mirror clamp, which is to say, t.lerp(a, b). The asymmetry of a.lerp(b, t) does not feel right to me.

@joelpalmer joelpalmer added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 19, 2020
@Elinvynia Elinvynia added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 27, 2020
Comment on lines 249 to 251
#![feature(clamp)]
#![feature(lerp)]
#![feature(concat_idents)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be put in sorted order per the NB at the top and bottom of this feature list.
abcdefghijklmnopqrstuvwxyz

@@ -912,6 +912,30 @@ impl f32 {
}
x
}

/// Computes `self + step(upper - pol)` the linear interpolation between
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what step refers to but this description doesn't look like it matches the implementation. In particular pol is dimensionless and upper is not so upper - pol is not an expression that would make sense.

@Elinvynia Elinvynia added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 3, 2020
@Elinvynia Elinvynia added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 25, 2020
@crlf0710 crlf0710 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 17, 2020
@Dylan-DPC-zz
Copy link

@vertexclique any updates?

@bors
Copy link
Collaborator

bors commented Jul 28, 2020

☔ The latest upstream changes (presumably #73265) made this pull request unmergeable. Please resolve the merge conflicts.

@vertexclique
Copy link
Member Author

Ok, I have no disk space left for compiling the compiler. I will carry on when I have a good machine at handy.

@clarfonthey clarfonthey mentioned this pull request Jun 13, 2021
5 tasks
m-ou-se added a commit to m-ou-se/rust that referenced this pull request Jun 17, 2021
Linear interpolation

rust-lang#71016 is a previous attempt at implementation that was closed by the author. I decided to reuse the feature request issue (rust-lang#71015) as a tracking issue. A member of the rust-lang org will have to edit the original post to be formatted correctly as I am not the issue's original author.

The common name `lerp` is used because it is the term used by most code in a wide variety of contexts; it also happens to be the recently chosen name of the function that was added to C++20.

To ensure symmetry as a method, this breaks the usual ordering of the method from `lerp(a, b, t)` to `t.lerp(a, b)`. This makes the most sense to me personally, and there will definitely be discussion before stabilisation anyway.

Implementing lerp "correctly" is very dififcult even though it's a very common building-block used in all sorts of applications. A good prior reading is [this proposal](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0811r2.html#linear-interpolation) for the C++20 lerp which talks about the various guarantees, which I've simplified down to:

1. Exactness: `(0.0).lerp(start, end) == start` and `(1.0).lerp(start, end) == end`
2. Consistency: `anything.lerp(x, x) == x`
3. Monotonicity: once you go up don't go down

Fun story: the version provided in that proposal, from what I understand, isn't actually monotonic.

I messed around with a *lot* of different lerp implementations because I kind of got a bit obsessed and I ultimately landed on one that uses the fused `mul_add` instruction. Floating-point lerp lore is hard to come by, so, just trust me when I say that this ticks all the boxes. I'm only 90% certain that it's monotonic, but I'm sure that people who care deeply about this will be there to discuss before stabilisation.

The main reason for using `mul_add` is that, in general, it ticks more boxes with fewer branches to be "correct." Although it will be slower on architectures without the fused `mul_add`, that's becoming more and more rare and I have a feeling that most people who will find themselves needing `lerp` will also have an efficient `mul_add` instruction available.
@dtolnay dtolnay assigned dtolnay and unassigned Amanieu Mar 24, 2024
github-actions bot pushed a commit to tautschnig/verify-rust-std that referenced this pull request Mar 11, 2025
Linear interpolation

rust-lang#71016 is a previous attempt at implementation that was closed by the author. I decided to reuse the feature request issue (rust-lang#71015) as a tracking issue. A member of the rust-lang org will have to edit the original post to be formatted correctly as I am not the issue's original author.

The common name `lerp` is used because it is the term used by most code in a wide variety of contexts; it also happens to be the recently chosen name of the function that was added to C++20.

To ensure symmetry as a method, this breaks the usual ordering of the method from `lerp(a, b, t)` to `t.lerp(a, b)`. This makes the most sense to me personally, and there will definitely be discussion before stabilisation anyway.

Implementing lerp "correctly" is very dififcult even though it's a very common building-block used in all sorts of applications. A good prior reading is [this proposal](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0811r2.html#linear-interpolation) for the C++20 lerp which talks about the various guarantees, which I've simplified down to:

1. Exactness: `(0.0).lerp(start, end) == start` and `(1.0).lerp(start, end) == end`
2. Consistency: `anything.lerp(x, x) == x`
3. Monotonicity: once you go up don't go down

Fun story: the version provided in that proposal, from what I understand, isn't actually monotonic.

I messed around with a *lot* of different lerp implementations because I kind of got a bit obsessed and I ultimately landed on one that uses the fused `mul_add` instruction. Floating-point lerp lore is hard to come by, so, just trust me when I say that this ticks all the boxes. I'm only 90% certain that it's monotonic, but I'm sure that people who care deeply about this will be there to discuss before stabilisation.

The main reason for using `mul_add` is that, in general, it ticks more boxes with fewer branches to be "correct." Although it will be slower on architectures without the fused `mul_add`, that's becoming more and more rare and I have a feeling that most people who will find themselves needing `lerp` will also have an efficient `mul_add` instruction available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.