Repository navigation
thread::LocalKey: document meaning of 'inner' function argument - #163398
Conversation
|
r? @clarfonthey rustbot has assigned @clarfonthey. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| // thread: if it is not yet initialized, and if the argument is `Some(&mut Some(val))`, the | ||
| // inner `val` should be `take`en out and used as the initial value instead of the default. This | ||
| // is purely an optimization for the case where the value will be immediately overwritten; it is | ||
| // okay for `inner` to always ignore `init`. |
There was a problem hiding this comment.
That's not always true, this only applies in the case of const-initialisers. In other cases, init must not be ignored as LocalKey::set guarantees that it will succeed even if the initialiser panics.
There was a problem hiding this comment.
Ah! The contract is quite subtle then. I updated the comment.
FWIW, if the destructor of the default value panics, that could still cause LocalKey::set to panic.
There was a problem hiding this comment.
Hmm, true. This seems almost impossible to prevent, and such behaviour isn't that surprising – but we should probably document it...
There was a problem hiding this comment.
Well we could prevent the unwind part of that panic with rust-lang/rfcs#3288... but some sort of failure (like abort) cannot really be prevented, yeah. It's also normal in Rust that seting a value drops the old value which can fail.
There was a problem hiding this comment.
@joboet I updated the comment based on your feedback, is there anything else you'd like me to change?
c9c2f66 to
e62fd11
Compare
|
r? joboet since you seem to understand this better than I do. I'd just be guessing like Ralf is. |
|
|
|
@bors squash |
This comment has been minimized.
This comment has been minimized.
* thread::LocalKey: document meaning of 'inner' function argument * nit Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
|
🔨 2 commits were squashed into 47e5c89. |
742efae to
47e5c89
Compare
|
@bors r=joboet |
|
@bors rollup |
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 7211ea5 (parent) -> 0617e57 (this PR) Test differencesShow 56 test diffs56 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 0617e57afe33d3afb1d5d5489030cae802f6c17e --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (0617e57): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis perf run didn't have relevant results for this metric. Max RSS (memory usage)Results (primary 2.8%, secondary 4.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -2.3%, secondary 1.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 492.622s -> 487.225s (-1.10%) |
#92123 gave this function an argument, but without documenting what the argument means or does. I hope I reverse engineered this correctly.
Cc @m-ou-se @joboet