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

Add undo_leak to reset RefCell borrow state #69528

Merged
merged 1 commit into from Mar 15, 2020

Conversation

@HeroicKatora
Copy link
Contributor

HeroicKatora commented Feb 27, 2020

This method is complementary for the feature cell_leak added in an
earlier PR. It allows safely reverting the effects of leaking a borrow guard by
statically proving that such a guard could not longer exist. This was
not added to the existing get_mut out of concern of impacting the
complexity of the otherwise pure pointer cast and because the name
get_mut poorly communicates the intent of resetting remaining borrows.

This is a follow-up to #68712 and uses the same tracking issue, #69099,
as these methods deal with the same mechanism and the idea came up
in a review comment.

@dtolnay who reviewed the prior PR.
cc @RalfJung

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Feb 27, 2020

r? @kennytm

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

@HeroicKatora

This comment has been minimized.

Copy link
Contributor Author

HeroicKatora commented Feb 27, 2020

@rust-highfive rust-highfive assigned dtolnay and unassigned kennytm Feb 27, 2020
@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented Feb 27, 2020

I would have expected this to not take &mut self, but instead be more like force_unlock_read and force_unlock_write on lock_api/parking_lot's RwLock's.

@HeroicKatora

This comment has been minimized.

Copy link
Contributor Author

HeroicKatora commented Feb 27, 2020

This is a completely safe interface that fully resets the borrows. I just noticed that the name might be suboptimal as the implementation doesn't differentiate between shared and mut borrows and keeping the name unborrow might complicate naming future methods that do. So I'm open for ideas here.

The unsafe API for removing single read/write borrows, force_unock would be possibly but it is less clear to me. It might be better to have a to_raw/from_raw equivalent pair on both Ref and RefMut and then change the borrow state by the usual Drop. This would behave more similar to other types in std such as Box.

@HeroicKatora

This comment has been minimized.

Copy link
Contributor Author

HeroicKatora commented Feb 27, 2020

Other names that are possible and come to mind:

  • reset_borrows
  • reset
  • clear
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Feb 27, 2020

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-02-27T21:03:19.2140245Z ========================== Starting Command Output ===========================
2020-02-27T21:03:19.2144643Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/254f02f5-eb73-4b79-ac9f-312aa9f90caa.sh
2020-02-27T21:03:19.2145136Z 
2020-02-27T21:03:19.2152688Z ##[section]Finishing: Disable git automatic line ending conversion
2020-02-27T21:03:19.2179619Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/69528/merge to s
2020-02-27T21:03:19.2183083Z Task         : Get sources
2020-02-27T21:03:19.2183405Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-02-27T21:03:19.2183722Z Version      : 1.0.0
2020-02-27T21:03:19.2183951Z Author       : Microsoft
---
2020-02-27T21:03:20.2140031Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-02-27T21:03:20.2148892Z ##[command]git config gc.auto 0
2020-02-27T21:03:20.2155049Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-02-27T21:03:20.2160851Z ##[command]git config --get-all http.proxy
2020-02-27T21:03:20.2171350Z ##[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/69528/merge:refs/remotes/pull/69528/merge
---
2020-02-27T22:02:49.7676259Z .................................................................................................... 1700/9733
2020-02-27T22:02:54.0665979Z .................................................................................................... 1800/9733
2020-02-27T22:03:05.3830517Z ....................................................................i............................... 1900/9733
2020-02-27T22:03:12.2365109Z .................................................................................................... 2000/9733
2020-02-27T22:03:26.7518765Z ..........................................................iiiii..................................... 2100/9733
2020-02-27T22:03:37.0693080Z .................................................................................................... 2300/9733
2020-02-27T22:03:39.3017178Z .................................................................................................... 2400/9733
2020-02-27T22:03:42.3271685Z .................................................................................................... 2500/9733
2020-02-27T22:04:03.2841205Z .................................................................................................... 2600/9733
---
2020-02-27T22:06:35.6392003Z ..................i...............i................................................................. 5000/9733
2020-02-27T22:06:44.8909908Z .................................................................................................... 5100/9733
2020-02-27T22:06:50.2589074Z .............................................................i...................................... 5200/9733
2020-02-27T22:06:56.5280335Z .................................................................................................... 5300/9733
2020-02-27T22:07:04.9451278Z ......................................ii.ii........i...i............................................ 5400/9733
2020-02-27T22:07:13.2591071Z .................................................................................................... 5600/9733
2020-02-27T22:07:22.3272776Z .................................................................................................... 5700/9733
2020-02-27T22:07:28.9737261Z .............................i...................................................................... 5800/9733
2020-02-27T22:07:34.8732968Z .................................................................................................... 5900/9733
2020-02-27T22:07:34.8732968Z .................................................................................................... 5900/9733
2020-02-27T22:07:45.5212657Z .................................................................................................... 6000/9733
2020-02-27T22:07:54.9975142Z ....................ii...i..ii...........i.......................................................... 6100/9733
2020-02-27T22:08:10.4642128Z .................................................................................................... 6300/9733
2020-02-27T22:08:14.0616754Z .................................................................................................... 6400/9733
2020-02-27T22:08:14.0616754Z .................................................................................................... 6400/9733
2020-02-27T22:08:23.3390161Z ...................................................i..ii............................................ 6500/9733
2020-02-27T22:08:46.3464100Z .................................................................................................... 6700/9733
2020-02-27T22:08:48.5634227Z ...........................................i........................................................ 6800/9733
2020-02-27T22:08:50.6270281Z .................................................................................................... 6900/9733
2020-02-27T22:08:52.7688189Z .........................................................................i.......................... 7000/9733
---
2020-02-27T22:10:26.7707358Z .................................................................................................... 7700/9733
2020-02-27T22:10:31.7598562Z .................................................................................................... 7800/9733
2020-02-27T22:10:36.5366614Z .................................................................................................... 7900/9733
2020-02-27T22:10:44.2500605Z ..................i................................................................................. 8000/9733
2020-02-27T22:10:52.6379628Z ...................................................................iiiiiii.i........................ 8100/9733
2020-02-27T22:11:07.2405742Z ........i......i.................................................................................... 8300/9733
2020-02-27T22:11:12.3144573Z .................................................................................................... 8400/9733
2020-02-27T22:11:25.0152054Z .................................................................................................... 8500/9733
2020-02-27T22:11:34.0682543Z .................................................................................................... 8600/9733
---
2020-02-27T22:13:50.7647954Z  finished in 7.314
2020-02-27T22:13:50.7846333Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-02-27T22:13:50.9437325Z 
2020-02-27T22:13:50.9438232Z running 178 tests
2020-02-27T22:13:53.7107011Z iiii......i...........ii..iiii...i....i...........i............i..i..................i....i......... 100/178
2020-02-27T22:13:55.8665039Z ...i.i.i...iii..iiiiiiiiiiiiiiii.......................iii............ii......
2020-02-27T22:13:55.8670882Z 
2020-02-27T22:13:55.8671060Z  finished in 5.082
2020-02-27T22:13:55.8855496Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-02-27T22:13:56.0407969Z 
---
2020-02-27T22:13:57.8646786Z  finished in 1.978
2020-02-27T22:13:57.8834709Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-02-27T22:13:58.0375483Z 
2020-02-27T22:13:58.0376856Z running 9 tests
2020-02-27T22:13:58.0379030Z iiiiiiiii
2020-02-27T22:13:58.0380118Z 
2020-02-27T22:13:58.0380276Z  finished in 0.154
2020-02-27T22:13:58.0575323Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-02-27T22:13:58.2155127Z 
---
2020-02-27T22:14:17.1968763Z  finished in 19.131
2020-02-27T22:14:17.2088621Z Check compiletest suite=debuginfo mode=debuginfo (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-02-27T22:14:17.3639985Z 
2020-02-27T22:14:17.3640312Z running 116 tests
2020-02-27T22:14:30.5878197Z iiiii..i.....i..i...i..i.i.i..i..i..ii....i.i....ii..........iiii..........i.....i..i.......ii.i.ii. 100/116
2020-02-27T22:14:32.4465197Z ....iiii.....ii.
2020-02-27T22:14:32.4466745Z 
2020-02-27T22:14:32.4469406Z  finished in 15.238
2020-02-27T22:14:32.4476278Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-02-27T22:14:32.4477066Z Copying stage2 rustc from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
---
2020-02-27T22:26:44.9786036Z 
2020-02-27T22:26:44.9786996Z    Doc-tests core
2020-02-27T22:26:49.3380097Z 
2020-02-27T22:26:49.3380992Z running 2481 tests
2020-02-27T22:26:57.9471063Z ......iiiii.........................................................F............................... 100/2481
2020-02-27T22:27:05.9954893Z .....................................................................................ii............. 200/2481
2020-02-27T22:27:25.1871312Z ....................i............................................................................... 400/2481
2020-02-27T22:27:25.1871312Z ....................i............................................................................... 400/2481
2020-02-27T22:27:34.2885361Z .........................................................................i..i..................iiii. 500/2481
2020-02-27T22:27:49.4453172Z .................................................................................................... 700/2481
2020-02-27T22:27:57.3040918Z .................................................................................................... 800/2481
2020-02-27T22:28:05.1632110Z .................................................................................................... 900/2481
2020-02-27T22:28:13.1096590Z .................................................................................................... 1000/2481
---
2020-02-27T22:30:08.5565951Z .....................................................................................i.............. 2400/2481
2020-02-27T22:30:15.2479401Z ....................i............................................................
2020-02-27T22:30:15.2480884Z failures:
2020-02-27T22:30:15.2484670Z 
2020-02-27T22:30:15.2486500Z ---- cell.rs - cell::RefCell<T>::unborrow (line 969) stdout ----
2020-02-27T22:30:15.2488664Z error[E0599]: no method named `is_err` found for struct `std::cell::Ref<'_, {integer}>` in the current scope
2020-02-27T22:30:15.2490116Z   --> cell.rs:976:20
2020-02-27T22:30:15.2490781Z    |
2020-02-27T22:30:15.2491549Z 10 | assert!(c.borrow().is_err());
2020-02-27T22:30:15.2492669Z    |                    ^^^^^^ method not found in `std::cell::Ref<'_, {integer}>`
2020-02-27T22:30:15.2493281Z error: aborting due to previous error
2020-02-27T22:30:15.2569985Z 
2020-02-27T22:30:15.2571316Z For more information about this error, try `rustc --explain E0599`.
2020-02-27T22:30:15.2572500Z Couldn't compile the test.
---
2020-02-27T22:30:15.2774976Z   local time: Thu Feb 27 22:30:15 UTC 2020
2020-02-27T22:30:15.8193111Z   network time: Thu, 27 Feb 2020 22:30:15 GMT
2020-02-27T22:30:15.8193661Z == end clock drift check ==
2020-02-27T22:30:16.3658669Z 
2020-02-27T22:30:16.3727646Z ##[error]Bash exited with code '1'.
2020-02-27T22:30:16.3742381Z ##[section]Finishing: Run build
2020-02-27T22:30:16.3793629Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/69528/merge to s
2020-02-27T22:30:16.3798936Z Task         : Get sources
2020-02-27T22:30:16.3799300Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-02-27T22:30:16.3799656Z Version      : 1.0.0
2020-02-27T22:30:16.3799893Z Author       : Microsoft
2020-02-27T22:30:16.3799893Z Author       : Microsoft
2020-02-27T22:30:16.3800278Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-02-27T22:30:16.3800723Z ==============================================================================
2020-02-27T22:30:16.7155062Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-02-27T22:30:16.7209643Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/69528/merge to s
2020-02-27T22:30:16.7298585Z Cleaning up task key
2020-02-27T22:30:16.7299916Z Start cleaning up orphan processes.
2020-02-27T22:30:16.7486503Z Terminate orphan process: pid (3599) (python)
2020-02-27T22:30:16.7720088Z ##[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 @TimNN. (Feature Requests)

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented Feb 27, 2020

I'm not really opposed to this interface but I personally suspect almost everyone will want the raw unsafe API rather than this.

@RalfJung

This comment has been minimized.

Copy link
Member

RalfJung commented Feb 27, 2020

Maybe emphasize in the PR description that this allows safely reverting the effects of leaking a borrow.

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Feb 28, 2020

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-02-28T00:50:22.4812630Z ========================== Starting Command Output ===========================
2020-02-28T00:50:22.4815118Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/98d21357-7c70-4349-9215-ac810745c11d.sh
2020-02-28T00:50:22.4815412Z 
2020-02-28T00:50:22.4818606Z ##[section]Finishing: Disable git automatic line ending conversion
2020-02-28T00:50:22.4838661Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/69528/merge to s
2020-02-28T00:50:22.4842033Z Task         : Get sources
2020-02-28T00:50:22.4842360Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-02-28T00:50:22.4842673Z Version      : 1.0.0
2020-02-28T00:50:22.4842886Z Author       : Microsoft
---
2020-02-28T00:50:23.4761573Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-02-28T00:50:23.4766818Z ##[command]git config gc.auto 0
2020-02-28T00:50:23.4770511Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-02-28T00:50:23.4773905Z ##[command]git config --get-all http.proxy
2020-02-28T00:50:23.4779871Z ##[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/69528/merge:refs/remotes/pull/69528/merge
---
2020-02-28T01:52:15.2449697Z .................................................................................................... 1700/9735
2020-02-28T01:52:19.6402436Z .................................................................................................... 1800/9735
2020-02-28T01:52:31.3236833Z ......................................................................i............................. 1900/9735
2020-02-28T01:52:38.2098311Z .................................................................................................... 2000/9735
2020-02-28T01:52:53.9939077Z ............................................................iiiii................................... 2100/9735
2020-02-28T01:53:05.1872363Z .................................................................................................... 2300/9735
2020-02-28T01:53:07.6830619Z .................................................................................................... 2400/9735
2020-02-28T01:53:11.1031160Z .................................................................................................... 2500/9735
2020-02-28T01:53:32.0743746Z .................................................................................................... 2600/9735
---
2020-02-28T01:56:17.9784415Z ....................i...............i............................................................... 5000/9735
2020-02-28T01:56:27.9108347Z .................................................................................................... 5100/9735
2020-02-28T01:56:33.4192859Z ...............................................................i.................................... 5200/9735
2020-02-28T01:56:39.9517117Z .................................................................................................... 5300/9735
2020-02-28T01:56:49.1751818Z ........................................ii.ii........i...i.......................................... 5400/9735
2020-02-28T01:56:58.7665272Z .................................................................................................... 5600/9735
2020-02-28T01:57:08.5863781Z .................................................................................................... 5700/9735
2020-02-28T01:57:15.9211260Z ...............................i.................................................................... 5800/9735
2020-02-28T01:57:22.4365353Z .................................................................................................... 5900/9735
2020-02-28T01:57:22.4365353Z .................................................................................................... 5900/9735
2020-02-28T01:57:33.4709809Z .................................................................................................... 6000/9735
2020-02-28T01:57:43.6312843Z ......................ii...i..ii...........i........................................................ 6100/9735
2020-02-28T01:58:00.9965175Z .................................................................................................... 6300/9735
2020-02-28T01:58:04.9089031Z .................................................................................................... 6400/9735
2020-02-28T01:58:04.9089031Z .................................................................................................... 6400/9735
2020-02-28T01:58:12.0714836Z .....................................................i..ii.......................................... 6500/9735
2020-02-28T01:58:38.9288141Z .................................................................................................... 6700/9735
2020-02-28T01:58:41.3773911Z .............................................i...................................................... 6800/9735
2020-02-28T01:58:43.6122553Z .................................................................................................... 6900/9735
2020-02-28T01:58:45.9793682Z ...........................................................................i........................ 7000/9735
---
2020-02-28T02:00:24.9208972Z .................................................................................................... 7700/9735
2020-02-28T02:00:29.7350069Z .................................................................................................... 7800/9735
2020-02-28T02:00:35.2493155Z .................................................................................................... 7900/9735
2020-02-28T02:00:43.4285219Z ....................i............................................................................... 8000/9735
2020-02-28T02:00:52.1011018Z .....................................................................iiiiiii.i...................... 8100/9735
2020-02-28T02:01:07.5957914Z ..........i......i.................................................................................. 8300/9735
2020-02-28T02:01:13.0856143Z .................................................................................................... 8400/9735
2020-02-28T02:01:26.3842964Z .................................................................................................... 8500/9735
2020-02-28T02:01:35.7633770Z .................................................................................................... 8600/9735
---
2020-02-28T02:03:57.8807748Z  finished in 7.062
2020-02-28T02:03:57.9008476Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-02-28T02:03:58.1054820Z 
2020-02-28T02:03:58.1056100Z running 178 tests
2020-02-28T02:04:01.0318789Z iiii......i...........ii..iiii...i....i...........i............i..i..................i....i......... 100/178
2020-02-28T02:04:03.2527379Z ...i.i.i...iii..iiiiiiiiiiiiiiii.......................iii............ii......
2020-02-28T02:04:03.2533957Z 
2020-02-28T02:04:03.2537083Z  finished in 5.353
2020-02-28T02:04:03.2738729Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-02-28T02:04:03.4450408Z 
---
2020-02-28T02:04:05.3734571Z  finished in 2.098
2020-02-28T02:04:05.3928118Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-02-28T02:04:05.5540249Z 
2020-02-28T02:04:05.5540587Z running 9 tests
2020-02-28T02:04:05.5541725Z iiiiiiiii
2020-02-28T02:04:05.5543234Z 
2020-02-28T02:04:05.5543422Z  finished in 0.161
2020-02-28T02:04:05.5750383Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-02-28T02:04:05.7707096Z 
---
2020-02-28T02:04:25.3573875Z  finished in 19.782
2020-02-28T02:04:25.3804419Z Check compiletest suite=debuginfo mode=debuginfo (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-02-28T02:04:25.5753604Z 
2020-02-28T02:04:25.5754327Z running 116 tests
2020-02-28T02:04:39.4996931Z iiiii..i.....i..i...i..i.i.i..i..i..ii....i.i....ii..........iiii..........i.....i..i.......ii.i.ii. 100/116
2020-02-28T02:04:41.3803106Z ....iiii.....ii.
2020-02-28T02:04:41.3804465Z 
2020-02-28T02:04:41.3811107Z  finished in 16.000
2020-02-28T02:04:41.3817972Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-02-28T02:04:41.3818804Z Copying stage2 rustc from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
---
2020-02-28T02:17:30.5653156Z 
2020-02-28T02:17:30.5654051Z    Doc-tests core
2020-02-28T02:17:35.1871498Z 
2020-02-28T02:17:35.1876518Z running 2481 tests
2020-02-28T02:17:44.4872688Z ......iiiii......................................................................................... 100/2481
2020-02-28T02:17:53.5398605Z .....................................................................................ii............. 200/2481
2020-02-28T02:18:14.1891844Z ....................i............................................................................... 400/2481
2020-02-28T02:18:14.1891844Z ....................i............................................................................... 400/2481
2020-02-28T02:18:24.2295329Z .........................................................................i..i..................iiii. 500/2481
2020-02-28T02:18:40.3626013Z .................................................................................................... 700/2481
2020-02-28T02:18:48.7269679Z .................................................................................................... 800/2481
2020-02-28T02:18:57.1508569Z .................................................................................................... 900/2481
2020-02-28T02:19:06.2810832Z .................................................................................................... 1000/2481
---
2020-02-28T02:22:47.7977617Z 
2020-02-28T02:22:47.7978823Z running 1009 tests
2020-02-28T02:23:05.1125546Z i................................................................................................... 100/1009
2020-02-28T02:23:14.8684913Z .................................................................................................... 200/1009
2020-02-28T02:23:21.7244361Z ..................iii......i......i...i......i...................................................... 300/1009
2020-02-28T02:23:26.6312213Z .................................................................................................... 400/1009
2020-02-28T02:23:33.3132401Z ............................................i..i.....................................ii............. 500/1009
2020-02-28T02:23:45.7510790Z .................................................................................................... 700/1009
2020-02-28T02:23:45.7510790Z .................................................................................................... 700/1009
2020-02-28T02:23:52.2614963Z ...................................iiii............................................................. 800/1009
2020-02-28T02:24:05.8619237Z .................................................................................................... 900/1009
2020-02-28T02:24:12.4888156Z .........................................................iiii....................................... 1000/1009
2020-02-28T02:24:12.8676113Z test result: ok. 989 passed; 0 failed; 20 ignored; 0 measured; 0 filtered out
2020-02-28T02:24:12.8676428Z 
2020-02-28T02:24:12.8786409Z  finished in 163.463
2020-02-28T02:24:12.8798491Z Testing term stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-02-28T02:41:37.5951501Z  Documenting core v0.0.0 (/checkout/src/libcore)
2020-02-28T02:41:50.0789096Z error: `[get_mut]` cannot be resolved, ignoring it.
2020-02-28T02:41:50.0791707Z    --> src/libcore/cell.rs:963:39
2020-02-28T02:41:50.0794829Z     |
2020-02-28T02:41:50.0795673Z 963 |     /// This call is very similar to [`get_mut`] but even more specialized. It borrows `RefCell`
2020-02-28T02:41:50.0797759Z     |
2020-02-28T02:41:50.0798509Z note: the lint level is defined here
2020-02-28T02:41:50.0799343Z    --> src/libcore/lib.rs:64:9
2020-02-28T02:41:50.0800078Z     |
2020-02-28T02:41:50.0800078Z     |
2020-02-28T02:41:50.0801036Z 64  | #![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings
2020-02-28T02:41:50.0803216Z     = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
2020-02-28T02:41:50.0803801Z 
2020-02-28T02:41:50.5297463Z error: aborting due to previous error
2020-02-28T02:41:50.5297779Z 
2020-02-28T02:41:50.5297779Z 
2020-02-28T02:41:50.5627364Z error: Could not document `core`.
2020-02-28T02:41:50.5627670Z 
2020-02-28T02:41:50.5627827Z Caused by:
2020-02-28T02:41:50.5630447Z   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustdoc --edition=2018 --crate-type lib --crate-name core src/libcore/lib.rs --target x86_64-unknown-linux-gnu -o /checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-linux-gnu/doc --error-format=json --json=diagnostic-rendered-ansi --markdown-css rust.css --markdown-no-toc --generate-redirect-pages --resource-suffix 1.43.0 --index-page /checkout/src/doc/index.md -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/release/deps` (exit code: 1)
2020-02-28T02:41:50.5670932Z 
2020-02-28T02:41:50.5670932Z 
2020-02-28T02:41:50.5673063Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "rustdoc" "-Zconfig-profile" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "2" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "/checkout/src/libtest/Cargo.toml" "-Z" "unstable-options" "-p" "core" "--" "--markdown-css" "rust.css" "--markdown-no-toc" "--generate-redirect-pages" "--resource-suffix" "1.43.0" "--index-page" "/checkout/src/doc/index.md"
2020-02-28T02:41:50.5674551Z 
2020-02-28T02:41:50.5674686Z 
2020-02-28T02:41:50.5674964Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2020-02-28T02:41:50.5675321Z Build completed unsuccessfully in 1:44:53
2020-02-28T02:41:50.5675321Z Build completed unsuccessfully in 1:44:53
2020-02-28T02:41:50.5730789Z == clock drift check ==
2020-02-28T02:41:50.5752904Z   local time: Fri Feb 28 02:41:50 UTC 2020
2020-02-28T02:41:50.8666524Z   network time: Fri, 28 Feb 2020 02:41:50 GMT
2020-02-28T02:41:50.8666926Z == end clock drift check ==
2020-02-28T02:41:51.8216695Z 
2020-02-28T02:41:51.8306252Z ##[error]Bash exited with code '1'.
2020-02-28T02:41:51.8322132Z ##[section]Finishing: Run build
2020-02-28T02:41:51.8371828Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/69528/merge to s
2020-02-28T02:41:51.8377156Z Task         : Get sources
2020-02-28T02:41:51.8377535Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-02-28T02:41:51.8377897Z Version      : 1.0.0
2020-02-28T02:41:51.8378323Z Author       : Microsoft
2020-02-28T02:41:51.8378323Z Author       : Microsoft
2020-02-28T02:41:51.8378707Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-02-28T02:41:51.8379161Z ==============================================================================
2020-02-28T02:41:52.2973708Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-02-28T02:41:52.3018885Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/69528/merge to s
2020-02-28T02:41:52.3113957Z Cleaning up task key
2020-02-28T02:41:52.3115447Z Start cleaning up orphan processes.
2020-02-28T02:41:52.3385855Z Terminate orphan process: pid (3566) (python)
2020-02-28T02:41:52.3758697Z ##[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 @TimNN. (Feature Requests)

@HeroicKatora HeroicKatora force-pushed the HeroicKatora:finalize-ref-cell branch from 2c9ff08 to dbd9847 Feb 28, 2020
Copy link
Member

dtolnay left a comment

I am on board with adding a safe unborrow API but we will need to pay attention during stabilization that we have been able to identify some concrete examples where using this API is the best solution.

The most important consideration when adding niche methods is how to keep them from being a distraction when people are looking for the non-niche behaviors they care about. I think unborrow isn't great in that aspect. Instead I would expect something like:

fn undo_leak(&mut self);

// later, if needed:
unsafe fn force_undo_leak(&self);

From these names it is clear that if someone isn't planning on leaking refs then these methods are not going to be relevant to them.

This method is complementary for the feature refcell_leak added in an
earlier PR. It allows reverting the effects of leaking a borrow guard by
statically proving that such a guard could not longer exist. This was
not added to the existing `get_mut` out of concern of impacting the
complexity of the otherwise pure pointer cast and because the name
`get_mut` poorly communicates the intent of resetting remaining borrows.
@HeroicKatora HeroicKatora force-pushed the HeroicKatora:finalize-ref-cell branch from dbd9847 to 51b9396 Mar 4, 2020
@HeroicKatora

This comment has been minimized.

Copy link
Contributor Author

HeroicKatora commented Mar 5, 2020

The name suggestion seems very clearly motivated and convincing to me, so I changed the PR.

@HeroicKatora HeroicKatora changed the title Add unborrow to reset RefCell borrow state Add undo_leak to reset RefCell borrow state Mar 6, 2020
@HeroicKatora

This comment has been minimized.

Copy link
Contributor Author

HeroicKatora commented Mar 14, 2020

The commit above my comment addresses the review (I think), I'm not sure why this is now tagged as S-waiting-on-author?

@RalfJung

This comment has been minimized.

Copy link
Member

RalfJung commented Mar 14, 2020

@dtolnay this is awaiting your (re-)review.

/// assert!(c.try_borrow().is_ok());
/// ```
#[unstable(feature = "cell_leak", issue = "69099")]
pub fn undo_leak(&mut self) -> &mut T {

This comment has been minimized.

Copy link
@RalfJung

RalfJung Mar 14, 2020

Member

What is the motivation for returning a reference here? The example does not even make use of that.

This comment has been minimized.

Copy link
@HeroicKatora

HeroicKatora Mar 14, 2020

Author Contributor

I had previously seen it as a strengthened version of get_mut. It could be fine fully separating the two methods tough.

Copy link
Member

dtolnay left a comment

Looks good!

@dtolnay

This comment has been minimized.

Copy link
Member

dtolnay commented Mar 15, 2020

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Mar 15, 2020

📌 Commit 51b9396 has been approved by dtolnay

bors added a commit that referenced this pull request Mar 15, 2020
Rollup of 8 pull requests

Successful merges:

 - #69528 (Add undo_leak to reset RefCell borrow state)
 - #69589 (ast: `Mac`/`Macro` -> `MacCall`)
 - #69661 (Implement From<&mut str> for String)
 - #69988 (rustc_metadata: Remove `rmeta::MacroDef`)
 - #70006 (resolve: Fix two issues in fresh binding disambiguation)
 - #70011 (def_collector: Fully visit async functions)
 - #70013 (Return feature gate as a `Symbol` )
 - #70018 (Fix "since" field for `Once::is_complete`'s `#[stable]` attribute)

Failed merges:

r? @ghost
@bors bors merged commit 83aad6b into rust-lang:master Mar 15, 2020
4 checks passed
4 checks passed
pr Build #20200304.44 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-7) Linux x86_64-gnu-llvm-7 succeeded
Details
pr (Linux x86_64-gnu-tools) Linux x86_64-gnu-tools succeeded
Details
@HeroicKatora HeroicKatora deleted the HeroicKatora:finalize-ref-cell branch Mar 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

8 participants
You can’t perform that action at this time.