Skip to content
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

Scope format! temporaries #64856

Open
wants to merge 5 commits into
base: master
from

Conversation

@jonhoo
Copy link
Contributor

jonhoo commented Sep 27, 2019

This places the temporaries that format! generates to refer to its arguments (through &dyn Trait) in a short-lived scope surrounding just the invocation of format!. This enables format! to be used in generators without the temporaries preventing the generator from being Send (due to dyn Trait not being Sync).

See #64477 for details.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Sep 27, 2019

r? @sfackler

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

@jonhoo

This comment has been minimized.

Copy link
Contributor Author

jonhoo commented Sep 27, 2019

See in particular @nikomatsakis' description of the problem in #64477 (comment) and @Nemo157's proposed solution in #64477 (comment) (which this PR implements).

src/test/ui/fmt/issue-64477.rs Outdated Show resolved Hide resolved
This places the temporaries that `format!` generates to refer to its
arguments (through `&dyn Trait`) in a short-lived scope surrounding just
the invocation of `format!`. This enables `format!` to be used in
generators without the temporaries preventing the generator from being
`Send` (due to `dyn Trait` not being `Sync`).

See #64477 for details.
@jonhoo jonhoo force-pushed the jonhoo:format-temporaries branch from 6ab3f04 to 06e4ff4 Sep 27, 2019
@Centril

This comment has been minimized.

Copy link
Member

Centril commented Sep 27, 2019

This is a breaking change (that may only be noticed in the dynamic semantics rather than the static semantics). By inserting the let you are changing the drop order:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=3231f995544ca8cf48045a108a28ac78

@jonhoo

This comment has been minimized.

Copy link
Contributor Author

jonhoo commented Sep 27, 2019

That is true — I hadn't considered that. I wonder if there's an easy way for us to just cause the created &dyn Trait items to be dropped, and not the inputs. I can't immediately think of one 🤔

@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

rust-highfive commented Sep 27, 2019

The job x86_64-gnu-llvm-6.0 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.
2019-09-27T21:51:17.3168809Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-09-27T21:51:17.3380469Z ##[command]git config gc.auto 0
2019-09-27T21:51:17.3452223Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-09-27T21:51:17.3526501Z ##[command]git config --get-all http.proxy
2019-09-27T21:51:17.3661091Z ##[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/64856/merge:refs/remotes/pull/64856/merge
---
2019-09-27T22:55:46.7034151Z .................................................................................................... 1500/9047
2019-09-27T22:55:52.9767431Z .................................................................................................... 1600/9047
2019-09-27T22:56:05.6844016Z .........................................................................i...............i.......... 1700/9047
2019-09-27T22:56:12.9983631Z .................................................................................................... 1800/9047
2019-09-27T22:56:22.0116588Z ................................................................iiiii............................... 1900/9047
2019-09-27T22:56:41.8989910Z .................................................................................................... 2100/9047
2019-09-27T22:56:44.5167621Z .................................................................................................... 2200/9047
2019-09-27T22:56:47.8979223Z .................................................................................................... 2300/9047
2019-09-27T22:56:56.5347848Z .................................................................................................... 2400/9047
---
2019-09-27T23:00:03.7611204Z .....................................................i...............i.............................. 4700/9047
2019-09-27T23:00:13.3034917Z .................................................................................................... 4800/9047
2019-09-27T23:00:22.0979048Z .................................................................................................... 4900/9047
2019-09-27T23:00:29.9461624Z .................................................................................................... 5000/9047
2019-09-27T23:00:39.9951799Z .........................................ii.ii...................................................... 5100/9047
2019-09-27T23:00:50.4455972Z .................................................................................................... 5300/9047
2019-09-27T23:01:01.1503641Z .................................................................................................... 5400/9047
2019-09-27T23:01:08.9648116Z ......i............................................................................................. 5500/9047
2019-09-27T23:01:14.6753102Z .................................................................................................... 5600/9047
2019-09-27T23:01:14.6753102Z .................................................................................................... 5600/9047
2019-09-27T23:01:26.9088010Z .................................................................................................... 5700/9047
2019-09-27T23:01:40.5306113Z .ii...i..ii...........i............................................................................. 5800/9047
2019-09-27T23:02:02.9098668Z .................................................................................................... 6000/9047
2019-09-27T23:02:08.5872489Z .................................................................................................... 6100/9047
2019-09-27T23:02:08.5872489Z .................................................................................................... 6100/9047
2019-09-27T23:02:22.8029304Z ....i..ii........................................................................................... 6200/9047
2019-09-27T23:02:42.3567851Z ................................................................i................................... 6400/9047
2019-09-27T23:02:44.6965056Z .................................................................................................... 6500/9047
2019-09-27T23:02:47.3392269Z ....................................i............................................................... 6600/9047
2019-09-27T23:02:51.5035911Z .................................................................................................... 6700/9047
---
2019-09-27T23:07:01.8461498Z failures:
2019-09-27T23:07:01.8494339Z 
2019-09-27T23:07:01.8496065Z ---- [ui] ui/fmt/issue-64477.rs stdout ----
2019-09-27T23:07:01.8499581Z normalized stderr:
2019-09-27T23:07:01.8499640Z error[E0670]: `async fn` is not permitted in the 2015 edition
2019-09-27T23:07:01.8499977Z   --> $DIR/issue-64477.rs:6:1
2019-09-27T23:07:01.8500021Z    |
2019-09-27T23:07:01.8500222Z LL | async fn foo(_: String) {}
2019-09-27T23:07:01.8500317Z 
2019-09-27T23:07:01.8500317Z 
2019-09-27T23:07:01.8500362Z error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `move`
2019-09-27T23:07:01.8500608Z   --> $DIR/issue-64477.rs:9:11
2019-09-27T23:07:01.8500703Z LL |     async move {
2019-09-27T23:07:01.8500744Z    |           ^^^^ expected one of 8 possible tokens here
2019-09-27T23:07:01.8500770Z 
2019-09-27T23:07:01.8500823Z error: aborting due to 2 previous errors
2019-09-27T23:07:01.8500823Z error: aborting due to 2 previous errors
2019-09-27T23:07:01.8500847Z 
2019-09-27T23:07:01.8501065Z For more information about this error, try `rustc --explain E0670`.
2019-09-27T23:07:01.8501093Z 
2019-09-27T23:07:01.8501131Z 
2019-09-27T23:07:01.8501152Z 
2019-09-27T23:07:01.8501191Z The actual stderr differed from the expected stderr.
2019-09-27T23:07:01.8501443Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/fmt/issue-64477/issue-64477.stderr
2019-09-27T23:07:01.8501678Z To update references, rerun the tests and pass the `--bless` flag
2019-09-27T23:07:01.8501898Z To only update this specific test, also pass `--test-args fmt/issue-64477.rs`
2019-09-27T23:07:01.8501988Z error: 1 errors occurred comparing output.
2019-09-27T23:07:01.8502027Z status: exit code: 1
2019-09-27T23:07:01.8502027Z status: exit code: 1
2019-09-27T23:07:01.8502625Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/fmt/issue-64477.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/fmt/issue-64477" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/fmt/issue-64477/auxiliary" "-A" "unused"
2019-09-27T23:07:01.8503500Z ------------------------------------------
2019-09-27T23:07:01.8503569Z 
2019-09-27T23:07:01.8503798Z ------------------------------------------
2019-09-27T23:07:01.8503844Z stderr:
2019-09-27T23:07:01.8503844Z stderr:
2019-09-27T23:07:01.8504070Z ------------------------------------------
2019-09-27T23:07:01.8504141Z error[E0670]: `async fn` is not permitted in the 2015 edition
2019-09-27T23:07:01.8504375Z   --> /checkout/src/test/ui/fmt/issue-64477.rs:6:1
2019-09-27T23:07:01.8504423Z    |
2019-09-27T23:07:01.8504485Z LL | async fn foo(_: String) {}
2019-09-27T23:07:01.8504556Z 
2019-09-27T23:07:01.8504556Z 
2019-09-27T23:07:01.8504606Z error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `move`
2019-09-27T23:07:01.8504862Z   --> /checkout/src/test/ui/fmt/issue-64477.rs:9:11
2019-09-27T23:07:01.8504952Z LL |     async move {
2019-09-27T23:07:01.8505017Z    |           ^^^^ expected one of 8 possible tokens here
2019-09-27T23:07:01.8505047Z 
2019-09-27T23:07:01.8505090Z error: aborting due to 2 previous errors
---
2019-09-27T23:07:01.8537372Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:537:22
2019-09-27T23:07:01.8537476Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-09-27T23:07:01.8556689Z 
2019-09-27T23:07:01.8556765Z 
2019-09-27T23:07:01.8558433Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2019-09-27T23:07:01.8558694Z 
2019-09-27T23:07:01.8558722Z 
2019-09-27T23:07:01.8567463Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-09-27T23:07:01.8567526Z Build completed unsuccessfully in 1:08:10
2019-09-27T23:07:01.8567526Z Build completed unsuccessfully in 1:08:10
2019-09-27T23:07:01.8620217Z == clock drift check ==
2019-09-27T23:07:01.8639948Z   local time: Fri Sep 27 23:07:01 UTC 2019
2019-09-27T23:07:02.0160637Z   network time: Fri, 27 Sep 2019 23:07:02 GMT
2019-09-27T23:07:02.0165859Z == end clock drift check ==
2019-09-27T23:07:03.4607752Z ##[error]Bash exited with code '1'.
2019-09-27T23:07:03.4693207Z ##[section]Starting: Checkout
2019-09-27T23:07:03.4695088Z ==============================================================================
2019-09-27T23:07:03.4695145Z Task         : Get sources
2019-09-27T23:07:03.4695215Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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 @TimNN. (Feature Requests)

@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

rust-highfive commented Sep 28, 2019

The job x86_64-gnu-llvm-6.0 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.
2019-09-28T03:20:26.2082027Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-09-28T03:20:26.2305002Z ##[command]git config gc.auto 0
2019-09-28T03:20:26.2375729Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-09-28T03:20:26.2423567Z ##[command]git config --get-all http.proxy
2019-09-28T03:20:26.9207003Z ##[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/64856/merge:refs/remotes/pull/64856/merge
---
2019-09-28T04:26:18.3303367Z .................................................................................................... 1500/9047
2019-09-28T04:26:24.6634101Z .................................................................................................... 1600/9047
2019-09-28T04:26:37.7894625Z ..........................................................................i...............i......... 1700/9047
2019-09-28T04:26:44.8388064Z .................................................................................................... 1800/9047
2019-09-28T04:26:53.8594311Z .................................................................iiiii.............................. 1900/9047
2019-09-28T04:27:14.6821596Z .................................................................................................... 2100/9047
2019-09-28T04:27:17.4271865Z .................................................................................................... 2200/9047
2019-09-28T04:27:20.7515056Z .................................................................................................... 2300/9047
2019-09-28T04:27:29.9396978Z .................................................................................................... 2400/9047
---
2019-09-28T04:30:38.8168978Z .....................................................i...............i.............................. 4700/9047
2019-09-28T04:30:48.7628877Z .................................................................................................... 4800/9047
2019-09-28T04:30:57.7072417Z .................................................................................................... 4900/9047
2019-09-28T04:31:05.5162386Z .................................................................................................... 5000/9047
2019-09-28T04:31:15.6991096Z .........................................ii.ii...................................................... 5100/9047
2019-09-28T04:31:26.3302948Z .................................................................................................... 5300/9047
2019-09-28T04:31:37.4005443Z .................................................................................................... 5400/9047
2019-09-28T04:31:45.1091485Z ......i............................................................................................. 5500/9047
2019-09-28T04:31:50.8447353Z .................................................................................................... 5600/9047
2019-09-28T04:31:50.8447353Z .................................................................................................... 5600/9047
2019-09-28T04:32:03.3620578Z .................................................................................................... 5700/9047
2019-09-28T04:32:17.0265485Z .ii...i..ii...........i............................................................................. 5800/9047
2019-09-28T04:32:39.5640827Z .................................................................................................... 6000/9047
2019-09-28T04:32:49.1795645Z .................................................................................................... 6100/9047
2019-09-28T04:32:49.1795645Z .................................................................................................... 6100/9047
2019-09-28T04:33:08.3355599Z ....i..ii........................................................................................... 6200/9047
2019-09-28T04:33:29.2670239Z ................................................................i................................... 6400/9047
2019-09-28T04:33:31.5912496Z .................................................................................................... 6500/9047
2019-09-28T04:33:34.7824019Z ....................................i............................................................... 6600/9047
2019-09-28T04:33:38.6144286Z .................................................................................................... 6700/9047
---
2019-09-28T04:38:23.4323724Z  finished in 5.960
2019-09-28T04:38:23.4522561Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-09-28T04:38:23.6407633Z 
2019-09-28T04:38:23.6408958Z running 150 tests
2019-09-28T04:38:27.1883525Z i....iii......iii..iiii....i.............................i..i..................i....i.........ii.i.i 100/150
2019-09-28T04:38:29.2966628Z ..iiii..............i.........iii.i.......ii......
2019-09-28T04:38:29.2968108Z 
2019-09-28T04:38:29.2975234Z  finished in 5.845
2019-09-28T04:38:29.3193715Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-09-28T04:38:30.3778149Z 
---
2019-09-28T04:38:31.6596522Z  finished in 2.340
2019-09-28T04:38:31.6798337Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-09-28T04:38:31.8461910Z 
2019-09-28T04:38:31.8462727Z running 9 tests
2019-09-28T04:38:31.8463699Z iiiiiiiii
2019-09-28T04:38:31.8464563Z 
2019-09-28T04:38:31.8467298Z  finished in 0.166
2019-09-28T04:38:31.8668437Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-09-28T04:38:32.8783703Z 
---
2019-09-28T04:38:51.2034416Z  finished in 19.336
2019-09-28T04:38:51.2251182Z Check compiletest suite=debuginfo mode=debuginfo-gdb+lldb (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-09-28T04:38:51.3978140Z 
2019-09-28T04:38:51.3978280Z running 123 tests
2019-09-28T04:39:17.8445783Z .iiiii...i.....i..i...i..i.i.i..i.ii..i.i.....i..i....ii..........iiii..........i...ii...i.......ii. 100/123
2019-09-28T04:39:23.1159760Z i.i.i......iii.i.....ii
2019-09-28T04:39:23.1162003Z 
2019-09-28T04:39:23.1163099Z  finished in 31.891
2019-09-28T04:39:23.1175016Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-09-28T04:39:23.1176229Z Copying stage2 rustc from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
---
2019-09-28T04:47:40.8204415Z 
2019-09-28T04:47:40.8205259Z error: pretty-printed source does not match expected source
2019-09-28T04:47:40.8205649Z expected:
2019-09-28T04:47:40.8206430Z ------------------------------------------
2019-09-28T04:47:40.8206501Z #[prelude_import]
2019-09-28T04:47:40.8207124Z use ::std::prelude::v1::*;
2019-09-28T04:47:40.8207220Z #[macro_use]
2019-09-28T04:47:40.8207286Z extern crate std;
2019-09-28T04:47:40.8208303Z // pretty-compare-only
2019-09-28T04:47:40.8208854Z // pretty-mode:hir,typed
2019-09-28T04:47:40.8209826Z // pp-exact:issue-4264.pp
2019-09-28T04:47:40.8210598Z 
2019-09-28T04:47:40.8211650Z // #4264 fixed-length vector types
2019-09-28T04:47:40.8211858Z 
2019-09-28T04:47:40.8211914Z pub fn foo(_: [i32; (3 as usize)]) ({ } as ())
2019-09-28T04:47:40.8212020Z pub fn bar() ({
2019-09-28T04:47:40.8212020Z pub fn bar() ({
2019-09-28T04:47:40.8213708Z                   const FOO: usize = ((5 as usize) - (4 as usize) as usize);
2019-09-28T04:47:40.8213800Z                   let _: [(); (FOO as usize)] = ([(() as ())] as [(); 1]);
2019-09-28T04:47:40.8213836Z 
2019-09-28T04:47:40.8213918Z                   let _: [(); (1 as usize)] = ([(() as ())] as [(); 1]);
2019-09-28T04:47:40.8213998Z                   let _ =
2019-09-28T04:47:40.8213998Z                   let _ =
2019-09-28T04:47:40.8214070Z                       (((&([(1 as i32), (2 as i32), (3 as i32)] as [i32; 3])
2019-09-28T04:47:40.8214508Z                             as &[i32; 3]) as *const _ as *const [i32; 3]) as
2019-09-28T04:47:40.8214570Z                           *const [i32; (3 as usize)] as *const [i32; 3]);
2019-09-28T04:47:40.8214665Z 
2019-09-28T04:47:40.8214694Z 
2019-09-28T04:47:40.8214721Z 
2019-09-28T04:47:40.8214749Z 
2019-09-28T04:47:40.8214749Z 
2019-09-28T04:47:40.8214775Z 
2019-09-28T04:47:40.8214802Z 
2019-09-28T04:47:40.8214848Z 
2019-09-28T04:47:40.8214875Z 
2019-09-28T04:47:40.8214923Z                   ((::alloc::fmt::format as
2019-09-28T04:47:40.8215704Z                        for<'r> fn(std::fmt::Arguments<'r>) -> std::string::String {std::fmt::format})(((<::core::fmt::Arguments>::new_v1
2019-09-28T04:47:40.8216157Z                                                                                                            as
2019-09-28T04:47:40.8217040Z                                                                                                            fn(&[&str], &[std::fmt::ArgumentV1<'_>]) -> std::fmt::Arguments<'_> {std::fmt::Arguments::<'_>::new_v1})((&([("test"
2019-09-28T04:47:40.8217745Z                                                                                                                                                                                                                             &'static str)]
2019-09-28T04:47:40.8217867Z                                                                                                                                                                                                                           as
2019-09-28T04:47:40.8217867Z                                                                                                                                                                                                                           as
2019-09-28T04:47:40.8218203Z                                                                                                                                                                                                                           [&str; 1])
2019-09-28T04:47:40.8218336Z                                                                                                                                                                                                                         as
2019-09-28T04:47:40.8218451Z                                                                                                                                                                                                                         &[&str; 1]),
2019-09-28T04:47:40.8218545Z                                                                                                                                                                                                                     (&(match (()
2019-09-28T04:47:40.8218756Z                                                                                                                                                                                                                                  ())
2019-09-28T04:47:40.8218946Z                                                                                                                                                                                                                            {
2019-09-28T04:47:40.8219036Z                                                                                                                                                                                                                            ()
2019-09-28T04:47:40.8219150Z                                                                                                                                                                                                                            =>
2019-09-28T04:47:40.8219150Z                                                                                                                                                                                                                            =>
2019-09-28T04:47:40.8219237Z                                                                                                                                                                                                                            ([]
2019-09-28T04:47:40.8219353Z                                                                                                                                                                                                                                as
2019-09-28T04:47:40.8219898Z                                                                                                                                                                                                                                [std::fmt::ArgumentV1<'_>; 0]),
2019-09-28T04:47:40.8220467Z                                                                                                                                                                                                                           as
2019-09-28T04:47:40.8220467Z                                                                                                                                                                                                                           as
2019-09-28T04:47:40.8221828Z                                                                                                                                                                                                                           [std::fmt::ArgumentV1<'_>; 0])
2019-09-28T04:47:40.8221949Z                                                                                                                                                                                                                         as
2019-09-28T04:47:40.8222644Z                                                                                                                                                                                                                         &[std::fmt::ArgumentV1<'_>; 0]))
2019-09-28T04:47:40.8223501Z                                                                                                           std::fmt::Arguments<'_>))
2019-09-28T04:47:40.8223578Z                       as std::string::String);
2019-09-28T04:47:40.8223578Z                       as std::string::String);
2019-09-28T04:47:40.8223629Z               } as ())
2019-09-28T04:47:40.8223679Z pub type Foo = [i32; (3 as usize)];
2019-09-28T04:47:40.8223745Z pub struct Bar {
2019-09-28T04:47:40.8223793Z     pub x: [i32; (3 as usize)],
2019-09-28T04:47:40.8223840Z }
2019-09-28T04:47:40.8223907Z pub struct TupleBar([i32; (4 as usize)]);
2019-09-28T04:47:40.8223959Z pub enum Baz { BazVariant([i32; (5 as usize)]), }
2019-09-28T04:47:40.8224214Z pub fn id<T>(x: T) -> T ({ (x as T) } as T)
2019-09-28T04:47:40.8224283Z pub fn use_id() ({
2019-09-28T04:47:40.8224344Z                      let _ =
2019-09-28T04:47:40.8224397Z                          ((id::<[i32; (3 as usize)]> as
2019-09-28T04:47:40.8224709Z                               fn([i32; 3]) -> [i32; 3] {id::<[i32; 3]>})(([(1
2019-09-28T04:47:40.8224996Z                                                                                i32),
2019-09-28T04:47:40.8225072Z                                                                            (2
2019-09-28T04:47:40.8225132Z                                                                                as
2019-09-28T04:47:40.8225193Z                                                                                i32),
2019-09-28T04:47:40.8225193Z                                                                                i32),
2019-09-28T04:47:40.8225272Z                                                                            (3
2019-09-28T04:47:40.8225332Z                                                                                as
2019-09-28T04:47:40.8225401Z                                                                                i32)]
2019-09-28T04:47:40.8225479Z                                                                              as
2019-09-28T04:47:40.8225549Z                                                                              [i32; 3]))
2019-09-28T04:47:40.8225602Z                              as [i32; 3]);
2019-09-28T04:47:40.8225670Z                  } as ())
2019-09-28T04:47:40.8225718Z fn main() ({ } as ())
2019-09-28T04:47:40.8226044Z ------------------------------------------
2019-09-28T04:47:40.8226118Z actual:
2019-09-28T04:47:40.8226359Z ------------------------------------------
2019-09-28T04:47:40.8226359Z ------------------------------------------
2019-09-28T04:47:40.8226410Z #[prelude_import]
2019-09-28T04:47:40.8226477Z use ::std::prelude::v1::*;
2019-09-28T04:47:40.8226525Z #[macro_use]
2019-09-28T04:47:40.8226571Z extern crate std;
2019-09-28T04:47:40.8226790Z // pretty-compare-only
2019-09-28T04:47:40.8227029Z // pretty-mode:hir,typed
2019-09-28T04:47:40.8227260Z // pp-exact:issue-4264.pp
2019-09-28T04:47:40.8227293Z 
2019-09-28T04:47:40.8227530Z // #4264 fixed-length vector types
2019-09-28T04:47:40.8227583Z 
2019-09-28T04:47:40.8227642Z pub fn foo(_: [i32; (3 as usize)]) ({ } as ())
2019-09-28T04:47:40.8227720Z pub fn bar() ({
2019-09-28T04:47:40.8227720Z pub fn bar() ({
2019-09-28T04:47:40.8228025Z                   const FOO: usize = ((5 as usize) - (4 as usize) as usize);
2019-09-28T04:47:40.8228087Z                   let _: [(); (FOO as usize)] = ([(() as ())] as [(); 1]);
2019-09-28T04:47:40.8228123Z 
2019-09-28T04:47:40.8246463Z                   let _: [(); (1 as usize)] = ([(() as ())] as [(); 1]);
2019-09-28T04:47:40.8246619Z                   let _ =
2019-09-28T04:47:40.8246619Z                   let _ =
2019-09-28T04:47:40.8246675Z                       (((&([(1 as i32), (2 as i32), (3 as i32)] as [i32; 3])
2019-09-28T04:47:40.8246748Z                             as &[i32; 3]) as *const _ as *const [i32; 3]) as
2019-09-28T04:47:40.8246995Z                           *const [i32; (3 as usize)] as *const [i32; 3]);
2019-09-28T04:47:40.8247073Z 
2019-09-28T04:47:40.8247108Z 
2019-09-28T04:47:40.8247136Z 
2019-09-28T04:47:40.8247164Z 
2019-09-28T04:47:40.8247164Z 
2019-09-28T04:47:40.8247203Z 
2019-09-28T04:47:40.8247231Z 
2019-09-28T04:47:40.8247257Z 
2019-09-28T04:47:40.8247296Z 
2019-09-28T04:47:40.8247342Z                   ({
2019-09-28T04:47:40.8247391Z                        let res =
2019-09-28T04:47:40.8247453Z                            ((::alloc::fmt::format as
2019-09-28T04:47:40.8248045Z                                 for<'r> fn(std::fmt::Arguments<'r>) -> std::string::String {std::fmt::format})(((<::core::fmt::Arguments>::new_v1
2019-09-28T04:47:40.8248124Z                                                                                                                     as
2019-09-28T04:47:40.8248617Z                                                                                                                     fn(&[&str], &[std::fmt::ArgumentV1<'_>]) -> std::fmt::Arguments<'_> {std::fmt::Arguments::<'_>::new_v1})((&([("test"
2019-09-28T04:47:40.8249504Z                                                                                                                                                                                                                                      &'static str)]
2019-09-28T04:47:40.8249605Z                                                                                                                                                                                                                                    as
2019-09-28T04:47:40.8249605Z                                                                                                                                                                                                                                    as
2019-09-28T04:47:40.8250046Z                                                                                                                                                                                                                                    [&str; 1])
2019-09-28T04:47:40.8250233Z                                                                                                                                                                                                                                  as
2019-09-28T04:47:40.8250335Z                                                                                                                                                                                                                                  &[&str; 1]),
2019-09-28T04:47:40.8250433Z                                                                                                                                                                                                                              (&(match (()
2019-09-28T04:47:40.8250848Z                                                                                                                                                                                                                                           ())
2019-09-28T04:47:40.8251154Z                                                                                                                                                                                                                                     {
2019-09-28T04:47:40.8251265Z                                                                                                                                                                                                                                     ()
2019-09-28T04:47:40.8251490Z                                                                                                                                                                                                                                     =>
2019-09-28T04:47:40.8251490Z                                                                                                                                                                                                                                     =>
2019-09-28T04:47:40.8251603Z                                                                                                                                                                                                                                     ([]
2019-09-28T04:47:40.8251928Z                                                                                                                                                                                                                                         as
2019-09-28T04:47:40.8252577Z                                                                                                                                                                                                                                         [std::fmt::ArgumentV1<'_>; 0]),
2019-09-28T04:47:40.8253974Z                                                                                                                                                                                                                                    as
2019-09-28T04:47:40.8253974Z                                                                                                                                                                                                                                    as
2019-09-28T04:47:40.8254633Z                                                                                                                                                                                                                                    [std::fmt::ArgumentV1<'_>; 0])
2019-09-28T04:47:40.8254745Z                                                                                                                                                                                                                                  as
2019-09-28T04:47:40.8255248Z                                                                                                                                                                                                                                  &[std::fmt::ArgumentV1<'_>; 0]))
2019-09-28T04:47:40.8255714Z                                                                                                                    std::fmt::Arguments<'_>))
2019-09-28T04:47:40.8255779Z                                as std::string::String);
2019-09-28T04:47:40.8255842Z                        (res as std::string::String)
2019-09-28T04:47:40.8255895Z                    } as std::string::String);
2019-09-28T04:47:40.8255895Z                    } as std::string::String);
2019-09-28T04:47:40.8255945Z               } as ())
2019-09-28T04:47:40.8256000Z pub type Foo = [i32; (3 as usize)];
2019-09-28T04:47:40.8256048Z pub struct Bar {
2019-09-28T04:47:40.8256096Z     pub x: [i32; (3 as usize)],
2019-09-28T04:47:40.8256152Z }
2019-09-28T04:47:40.8256208Z pub struct TupleBar([i32; (4 as usize)]);
2019-09-28T04:47:40.8256260Z pub enum Baz { BazVariant([i32; (5 as usize)]), }
2019-09-28T04:47:40.8256523Z pub fn id<T>(x: T) -> T ({ (x as T) } as T)
2019-09-28T04:47:40.8256583Z pub fn use_id() ({
2019-09-28T04:47:40.8256631Z                      let _ =
2019-09-28T04:47:40.8256685Z                          ((id::<[i32; (3 as usize)]> as
2019-09-28T04:47:40.8256979Z                               fn([i32; 3]) -> [i32; 3] {id::<[i32; 3]>})(([(1
2019-09-28T04:47:40.8257101Z                                                                                i32),
2019-09-28T04:47:40.8257168Z                                                                            (2
2019-09-28T04:47:40.8257226Z                                                                                as
2019-09-28T04:47:40.8257464Z                                                                                i32),
2019-09-28T04:47:40.8257464Z                                                                                i32),
2019-09-28T04:47:40.8257543Z                                                                            (3
2019-09-28T04:47:40.8257612Z                                                                                as
2019-09-28T04:47:40.8257671Z                                                                                i32)]
2019-09-28T04:47:40.8257737Z                                                                              as
2019-09-28T04:47:40.8257797Z                                                                              [i32; 3]))
2019-09-28T04:47:40.8257851Z                              as [i32; 3]);
2019-09-28T04:47:40.8257907Z                  } as ())
2019-09-28T04:47:40.8257953Z fn main() ({ } as ())
2019-09-28T04:47:40.8258284Z ------------------------------------------
2019-09-28T04:47:40.8258328Z 
2019-09-28T04:47:40.8258356Z 
2019-09-28T04:47:40.8258356Z 
2019-09-28T04:47:40.8279706Z [ERROR compiletest::runtest] fatal error, panic: "pretty-printed source does not match expected source\nexpected:\n------------------------------------------\n#[prelude_import]\nuse ::std::prelude::v1::*;\n#[macro_use]\nextern crate std;\n// pretty-compare-only\n// pretty-mode:hir,typed\n// pp-exact:issue-4264.pp\n\n// #4264 fixed-length vector types\n\npub fn foo(_: [i32; (3 as usize)]) ({ } as ())\n\npub fn bar() ({\n                  const FOO: usize = ((5 as usize) - (4 as usize) as usize);\n                  let _: [(); (FOO as usize)] = ([(() as ())] as [(); 1]);\n\n                  let _: [(); (1 as usize)] = ([(() as ())] as [(); 1]);\n\n                  let _ =\n                      (((&([(1 as i32), (2 as i32), (3 as i32)] as [i32; 3])\n                            as &[i32; 3]) as *const _ as *const [i32; 3]) as\n                          *const [i32; (3 as usize)] as *const [i32; 3]);\n\n\n\n\n\n\n\n\n\n                  ((::alloc::fmt::format as\n                       for<\'r> fn(std::fmt::Arguments<\'r>) -> std::string::String {std::fmt::format})(((<::core::fmt::Arguments>::new_v1\n                                                                                                           as\n                                                                                                           fn(&[&str], &[std::fmt::ArgumentV1<\'_>]) -> std::fmt::Arguments<\'_> {std::fmt::Arguments::<\'_>::new_v1})((&([(\"test\"\n                                                                                                                                                                                                                            as\n                                                                                                                                                                                                                            &\'static str)]\n                                                                                                                                                                                                                          as\n                                                                                                                                                                                                                          [&str; 1])\n                                                                                                                                                                                                                        as\n                                                                                                                                                                                                                        &[&str; 1]),\n                                                                                                                                                                                                                    (&(match (()\n                                                                                                                                                                                                                                 as\n                                                                                                                                                                                                                                 ())\n                                                                                                                                                                                                                           {\n                                                                                                                                                                                                                           ()\n                                                                                                                                                                                                                           =>\n                                                                                                                                                                                                                           ([]\n                                                                                                                                                                                                                               as\n                                                                                                                                                                                                                               [std::fmt::ArgumentV1<\'_>; 0]),\n                                                                                                                                                                                                                       }\n                                                                                                                                                                                                                          as\n                                                                                                                                                                                                                          [std::fmt::ArgumentV1<\'_>; 0])\n                                                                                                                                                                                                                        as\n                                                                                                                                                                                                                        &[std::fmt::ArgumentV1<\'_>; 0]))\n                                                                                                          as\n                                                                                                          std::fmt::Arguments<\'_>))\n                      as std::string::String);\n              } as ())\npub type Foo = [i32; (3 as usize)];\npub struct Bar {\n    pub x: [i32; (3 as usize)],\n}\npub struct TupleBar([i32; (4 as usize)]);\npub enum Baz { BazVariant([i32; (5 as usize)]), }\npub fn id<T>(x: T) -> T ({ (x as T) } as T)\npub fn use_id() ({\n                     let _ =\n                         ((id::<[i32; (3 as usize)]> as\n                              fn([i32; 3]) -> [i32; 3] {id::<[i32; 3]>})(([(1\n                                                                               as\n                                                                               i32),\n                                                                           (2\n                                                                               as\n                                                                               i32),\n                                                                           (3\n                                                                               as\n                                                                               i32)]\n                                                                             as\n                                                                             [i32; 3]))\n                             as [i32; 3]);\n                 } as ())\nfn main() ({ } as ())\n\n------------------------------------------\nactual:\n------------------------------------------\n#[prelude_import]\nuse ::std::prelude::v1::*;\n#[macro_use]\nextern crate std;\n// pretty-compare-only\n// pretty-mode:hir,typed\n// pp-exact:issue-4264.pp\n\n// #4264 fixed-length vector types\n\npub fn foo(_: [i32; (3 as usize)]) ({ } as ())\n\npub fn bar() ({\n                  const FOO: usize = ((5 as usize) - (4 as usize) as usize);\n                  let _: [(); (FOO as usize)] = ([(() as ())] as [(); 1]);\n\n                  let _: [(); (1 as usize)] = ([(() as ())] as [(); 1]);\n\n                  let _ =\n                      (((&([(1 as i32), (2 as i32), (3 as i32)] as [i32; 3])\n                            as &[i32; 3]) as *const _ as *const [i32; 3]) as\n                          *const [i32; (3 as usize)] as *const [i32; 3]);\n\n\n\n\n\n\n\n\n\n                  ({\n                       let res =\n                           ((::alloc::fmt::format as\n                                for<\'r> fn(std::fmt::Arguments<\'r>) -> std::string::String {std::fmt::format})(((<::core::fmt::Arguments>::new_v1\n                                                                                                                    as\n                                                                                                                    fn(&[&str], &[std::fmt::ArgumentV1<\'_>]) -> std::fmt::Arguments<\'_> {std::fmt::Arguments::<\'_>::new_v1})((&([(\"test\"\n                                                                                                                                                                                                                                     as\n                                                                                                                                                                                                                                     &\'static str)]\n                                                                                                                                                                                                                                   as\n                                                                                                                                                                                                                                   [&str; 1])\n                                                                                                                                                                                                                                 as\n                                                                                                                                                                                                                                 &[&str; 1]),\n                                                                                                                                                                                                                             (&(match (()\n                                                                                                                                                                                                                                          as\n                                                                                                                                                                                                                                          ())\n                                                                                                                                                                                                                                    {\n                                                                                                                                                                                                                                    ()\n                                                                                                                                                                                                                                    =>\n                                                                                                                                                                                                                                    ([]\n                                                                                                                                                                                                                                        as\n                                                                                                                                                                                                                                        [std::fmt::ArgumentV1<\'_>; 0]),\n                                                                                                                                                                                                                                }\n                                                                                                                                                                                                                                   as\n                                                                                                                                                                                                                                   [std::fmt::ArgumentV1<\'_>; 0])\n                                                                                                                                                                                                                                 as\n                                                                                                                                                                                                                                 &[std::fmt::ArgumentV1<\'_>; 0]))\n                                                                                                                   as\n                                                                                                                   std::fmt::Arguments<\'_>))\n                               as std::string::String);\n                       (res as std::string::String)\n                   } as std::string::String);\n              } as ())\npub type Foo = [i32; (3 as usize)];\npub struct Bar {\n    pub x: [i32; (3 as usize)],\n}\npub struct TupleBar([i32; (4 as usize)]);\npub enum Baz { BazVariant([i32; (5 as usize)]), }\npub fn id<T>(x: T) -> T ({ (x as T) } as T)\npub fn use_id() ({\n                     let _ =\n                         ((id::<[i32; (3 as usize)]> as\n                              fn([i32; 3]) -> [i32; 3] {id::<[i32; 3]>})(([(1\n                                                                               as\n                                                                               i32),\n                                                                           (2\n                                                                               as\n                                                                               i32),\n                                                                           (3\n                                                                               as\n                                                                               i32)]\n                                                                             as\n                                                                             [i32; 3]))\n                             as [i32; 3]);\n                 } as ())\nfn main() ({ } as ())\n\n------------------------------------------\n\n"
2019-09-28T04:47:40.8284417Z thread '[pretty] pretty/issue-4264.rs' panicked at 'fatal error', src/tools/compiletest/src/runtest.rs:2254:9
2019-09-28T04:47:40.8284562Z 
2019-09-28T04:47:40.8298406Z 
2019-09-28T04:47:40.8298548Z failures:
2019-09-28T04:47:40.8299018Z     [pretty] pretty/issue-4264.rs
2019-09-28T04:47:40.8299018Z     [pretty] pretty/issue-4264.rs
2019-09-28T04:47:40.8299059Z 
2019-09-28T04:47:40.8299367Z test result: FAILED. 54 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out
2019-09-28T04:47:40.8299418Z 
2019-09-28T04:47:40.8299726Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:537:22
2019-09-28T04:47:40.8299768Z 
2019-09-28T04:47:40.8299796Z 
2019-09-28T04:47:40.8302059Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/pretty" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/pretty" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "pretty" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2019-09-28T04:47:40.8302325Z 
2019-09-28T04:47:40.8302359Z 
2019-09-28T04:47:40.8302426Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-09-28T04:47:40.8302483Z Build completed unsuccessfully in 1:19:32
2019-09-28T04:47:40.8302483Z Build completed unsuccessfully in 1:19:32
2019-09-28T04:47:40.8326809Z == clock drift check ==
2019-09-28T04:47:40.8341580Z   local time: Sat Sep 28 04:47:40 UTC 2019
2019-09-28T04:47:40.9842096Z   network time: Sat, 28 Sep 2019 04:47:40 GMT
2019-09-28T04:47:40.9845729Z == end clock drift check ==
2019-09-28T04:47:43.1403730Z ##[error]Bash exited with code '1'.
2019-09-28T04:47:43.1468824Z ##[section]Starting: Checkout
2019-09-28T04:47:43.1472843Z ==============================================================================
2019-09-28T04:47:43.1472900Z Task         : Get sources
2019-09-28T04:47:43.1472963Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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 @TimNN. (Feature Requests)

@jonhoo

This comment has been minimized.

Copy link
Contributor Author

jonhoo commented Sep 28, 2019

@Centril thinking some more about this, I don't think there's a way to get out of changing the drop order except by making format! actually parse its arguments and ensure that it takes a reference to each one somehow. I toyed around with something like

macro_rules! format {
    ($($arg:tt)*) => ((|| {$crate::fmt::format($crate::__export::format_args!($($arg)*))})())
}

But the closure tries to move arguments passed to format! without & (despite not having a move annotation), so that won't work.

In #64477 (comment), @nikomatsakis said:

Unfortunately, the format! temporaries include dyn Trait objects that are not Send. So the error is correct. The shorter-term fix would I think be to alter the desugaring of format! so that its intermediate values are Send, I'm afraid.

I'm not sure how we could go about doing that without adding additional bounds on types passed to format! (which would definitely be a breaking change). If you have suggestions though, I'm all ears.

Ultimately, my guess at the moment is that we will either have to change drop order, have format! fully parse its arguments so it can drop only the references, or change the bounds of format!. I think the last one is out. The second one would probably be a fairly large change (possibly even making format! a proc-macro), and would be error-prone as we'd have to replicate the parsing from format_args! and then appropriately transform all inputs. The original suggestion seems like a neat compromise, but we would then have to decide whether the change in drop order is acceptable.

@Centril

This comment was marked as outdated.

Copy link
Member

Centril commented Sep 28, 2019

@bors try

@bors

This comment was marked as outdated.

Copy link
Contributor

bors commented Sep 28, 2019

⌛️ Trying commit 8990f7d with merge 4465d00...

bors added a commit that referenced this pull request Sep 28, 2019
Scope format! temporaries

This places the temporaries that `format!` generates to refer to its arguments (through `&dyn Trait`) in a short-lived scope surrounding just the invocation of `format!`. This enables `format!` to be used in generators without the temporaries preventing the generator from being `Send` (due to `dyn Trait` not being `Sync`).

See #64477 for details.
@bors

This comment was marked as outdated.

Copy link
Contributor

bors commented Sep 28, 2019

☀️ Try build successful - checks-azure
Build commit: 4465d00 (4465d0049bf00b9224f1908770f277c145361aed)

@Centril

This comment was marked as outdated.

Copy link
Member

Centril commented Sep 28, 2019

@craterbot run mode=check-only

@craterbot

This comment was marked as outdated.

Copy link
Collaborator

craterbot commented Sep 28, 2019

👌 Experiment pr-64856 created and queued.
🤖 Automatically detected try build 4465d00
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@Centril

This comment was marked as outdated.

Copy link
Member

Centril commented Sep 28, 2019

@craterbot abort

@craterbot

This comment was marked as outdated.

Copy link
Collaborator

craterbot commented Sep 28, 2019

🗑 Experiment pr-64856 deleted!

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@Centril

This comment has been minimized.

Copy link
Member

Centril commented Sep 28, 2019

@craterbot run mode=build-and-test

(Changes dynamic semantics possibly.)

@craterbot

This comment has been minimized.

Copy link
Collaborator

craterbot commented Sep 28, 2019

👌 Experiment pr-64856 created and queued.
🤖 Automatically detected try build 4465d00
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@jonhoo

This comment has been minimized.

Copy link
Contributor Author

jonhoo commented Oct 19, 2019

@vorner sorry, I meant @varkor !

@jonhoo

This comment has been minimized.

Copy link
Contributor Author

jonhoo commented Oct 21, 2019

@Centril what are the next steps here?

@Centril

This comment has been minimized.

Copy link
Member

Centril commented Oct 21, 2019

^--- @rust-lang/libs

@dtolnay

This comment has been minimized.

Copy link
Member

dtolnay commented Oct 21, 2019

Regression minimized:

fn args(_: impl IntoIterator<Item = impl AsRef<str>>) {
    unimplemented!()
}

fn main() {
    let cow = std::borrow::Cow::Borrowed("");
    args(&[&cow, "", &String::new()]); // okay
    args(&[&cow, "", &{ String::new() }]); // not okay
}
error[E0308]: mismatched types
 --> src/main.rs:8:25
  |
8 |     args(&[&cow, "", &{ String::new() }]); // not okay
  |                         ^^^^^^^^^^^^^ expected enum `std::borrow::Cow`, found struct `std::string::String`
  |
  = note: expected type `std::borrow::Cow<'_, str>`
             found type `std::string::String`
@JohnCSimon

This comment has been minimized.

Copy link
Member

JohnCSimon commented Oct 26, 2019

Pinging from triage
Is this PR ready for the review process?
CC: @Centril @dtolnay @sfackler @varkor @jonhoo

Thanks

@jonhoo

This comment has been minimized.

Copy link
Contributor Author

jonhoo commented Oct 26, 2019

From my perspective, the PR is done and ready for review. The crater run revealed only one regression, and it is essentially the one @dtolnay gave above. Review will need to determine whether that's acceptable or not. I don't think there's a way to fix that one regression while also fixing the original problem the PR was designed to fix.

@KodrAus

This comment has been minimized.

Copy link
Contributor

KodrAus commented Oct 28, 2019

Personally, this change looks ok to me because that papercut of having to explicitly type the array or cast the first element in order to type check does already come up sometimes:

args(&[&cow as &str, "", &{ String::new() }]); // okay
let a: &[&str] = &[&cow as &str, "", &{ String::new() }]; // okay
args(a);

It seems like we’re working with odd behaviour on either side of the fence; unexpected long borrows on one side and inference issues with blocks on the other (does anybody know why &{ String::new() } is different from &String::new() here?

@KodrAus

This comment has been minimized.

Copy link
Contributor

KodrAus commented Oct 28, 2019

@rfcbot fcp merge

EDIT: Oh you still don’t like me @rfcbot?

@JohnCSimon

This comment has been minimized.

Copy link
Member

JohnCSimon commented Nov 2, 2019

Ping from triage:
@jonhoo Seems we have a merge conflict.
cc: @KodrAus @sfackler
Thanks!

@sfackler sfackler added the T-libs label Nov 2, 2019
@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Nov 2, 2019

@rfcbot fcp merge

@rfcbot

This comment has been minimized.

Copy link

rfcbot commented Nov 2, 2019

Team member @sfackler has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@jonhoo

This comment has been minimized.

Copy link
Contributor Author

jonhoo commented Nov 2, 2019

@JohnCSimon conflict has now been resolved

Hexilee added a commit to Hexilee/interfacer-http that referenced this pull request Nov 6, 2019
@JohnCSimon

This comment has been minimized.

Copy link
Member

JohnCSimon commented Nov 9, 2019

Ping from triage:
@sfackler Merge conflict has been resolved, is this ready for review + merge?
cc: @KodrAus @jonhoo @dtolnay @Centril
Thanks!

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Nov 9, 2019

@SimonSapin

This comment has been minimized.

Copy link
Contributor

SimonSapin commented Nov 15, 2019

Should println! and other macros that use format_args! do the same?

@rfcbot

This comment has been minimized.

Copy link

rfcbot commented Nov 15, 2019

🔔 This is now entering its final comment period, as per the review above. 🔔

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Nov 15, 2019

println expressions aren't usually kept alive across a yield point, so I don't think it's an issue there like it is here.

@jonhoo

This comment has been minimized.

Copy link
Contributor Author

jonhoo commented Nov 15, 2019

@sfackler The tricky part is that all arguments to println are still borrowed within the same scope. For example, this also won't compile:

async fn foo() {}

fn bar() -> impl Send {
    async move {
        let x = std::rc::Rc::new(1);
        println!("{}", x);
        foo().await;
    }
}

We could do the same fix for println and friends, though I think that would warrant another crater run.

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Nov 15, 2019

That has nothing to do with println - if you remove the line it still doesn't compile. x itself lives past the await so the Rc has to be stored in the future.

@jonhoo

This comment has been minimized.

Copy link
Contributor Author

jonhoo commented Nov 15, 2019

@sfackler Ah, yes, of course, you're right. I don't think the value has to be included in the future though. Isn't the whole reason why this issue arises with format! in the first place that format! creates temporaries in the surrounding scope that aren't Send? println! does the same, no?

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Nov 15, 2019

Not including x in the future would change its drop order with respect to normal synchronous functions, and there was an explicit decision to not differ there.

No, the problem with format! is that it introduces temporaries in the containing expression. If that expression contains a yield then you have a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.