Libs Meetings
Minutes
Meeting Link: https://meet.jit.si/rust-libs-meeting-crxoz2at8hiccp7b3ixf89qgxfymlbwr
Attendees: Amanieu, David, Josh Triplett, Mara, The 8472, TC, Sarah Quiñones, martinomburajr
17 rust-lang/rust T-libs-api FCPs
compiler-errors (1), dtolnay (3), spastorino (1), scottmcm (1), joshtriplett (9), m-ou-se (11), BurntSushi (15), jackh726 (1), nikomatsakis (2), the8472 (1), Amanieu (10), thomcc (1)
C and C++ don't have this, but this is a useful constant.
Mara: I'm a big tau fan, but 2pi
makes more sense as this is how most people will know this constant.
ACP accepted for the 2pi
name.
JoshT: Open question is if this should be 'exhaustive'.
JoshT: We can't really compute that, but we can require a _ => {}
case.
TC: Happy with the cfg_match
name (instead of cfg_if
), but then we should give it a 'match' flavor.
Amanieu: How can we force exhaustiveness?
TC: Just throw compiler error when it falls through.
JoshT: Proposal was not to require _ => {}
, but to be noisy when it falls through.
Amanieu: An implicit _ => compiler_error!()
JoshT: I'd advocate for 'compiler_warning' instead.
Amanieu: prefer error
The 8472: if some impl is missing, it'd result in an error anyway.
TC: prefer error
Mara: prefer error
JoshT: mildly prefer warning, would not object to error.
Amanieu: another concern was: maybe this should be a language feature?
JoshT: we shouldn't delay this further
Amanieu: how does this interact with the cfg(true)/cfg(false) rfc?
JoshT: we should support that here too. should support the exact same as cfg()
Mara: You'd have true =>
and false =>
which is.. eh. we should maybe lint about that.
JoshT: &&
and ||
seem fine too.
Amanieu: Don't really mind, but it's looking less and less like match
..
Amanieu: Bevy is using switch
as the name..
The 8472: cases
?
Straw poll:
cfg_case!
cfg_cases!
cfg_cond!
cfg_many!
cfg_match!
cfg_select!
cfg_match!
we have already")cfg_cascade!
cfg_one!
cfg_first!
(picks the first matching one)
cfg!
(add to existing macro)
cfg_if!
(old syntax??)
cfg_if!
(new syntax)
cfgs!
Sarah: don't like that cfg_match!() doesn't look like a match: arms are boolean conditions. cfg_if!() looks more like regular rust code.
Amanieu: issue is that match
is for pattern matching. This has nothing to do with pattern matching.
Mara: I might be more in favor if we wrote #[cfg(..)] =>
rather than .. =>
. Clearer that it's the same cfg() syntax.
Sarah: what if we had a if cfg
block. e.g. if cfg { any(unix, windows) } { ... } else if cfg { macos } { ... } else { ... }
.
Amanieu: very close to if cfg!(..)
which is similar but very different.
Sarah: Usually if people write if cfg!()
they don't want the code to be checked on non-matching platforms.
Sarah: maybe something like #[cfg_match] if cfg { ... }
Mara: Attributes on stmts are not yet stable.
Sarah: Close to stabilization, i think
Amanieu: I think it'd be weird for an attribute to change how the language is parsed like that.
JoshT: I think we should be finding a name, not finding a new syntax.
Amanieu: In the future we can easily deprecate the libs feature if there's a language feature to replace it. Like try!()
and ?
TC: Back to the syntax bikeshed..
Amanieu: I like cfg_select
because we are selecting one. cfg_cond
also fine. Everything else feels random.
TC: I could get behind cfg_select
. I didn't like this initially for the reasons other people brought up, but I've warmed to it.
JoshT: match
is a lang feature, but select
is not. no one will confuse it with the ecosystem select
s. The 8472: do you object to select
?
The 8472: Already what tokio uses for futures, for extracting one value. Not a blocking objection though.
TC: Looking at the list above, it seems to come down to cond
and select
. Either seems OK. select
carries some baggage but it is more familiar. cond
would be new jargon (to Rust) but carries no baggage.
Mara: between those two, select
is miles better for me: "cond" could mean anything, but "select" is clearer about selecting exactly one case.
Martin: For cond, we have the CondVar type in std::sync
.
JoshT: Select is a verb. cond, case, etc. are not.
Amanieu: So… consensus on cfg_select
?
Amanieu: Cancel fcp and restart on new name
TC: Let's include the 'error on no match' in the FCP.
TC: It's pretty bad in expression position. We shouldn't stabilize the {{}}
syntax; that's weird.
Mara, Josh: Agree on double braces.
JoshT: Happy to stabilize the version for item position first, add expression version later.
JoshT: We should probably apologize as part of the re-FCP. We went from select to match to select.
Mara: Part of the re-fcp was new information: the cfg() syntax RFCs.
TC: For later future work, Sarah raised an interesting point. cfg!() works in static initializer, so is const evaluated. we can pull this into some kind of 'const if' feature.
Sarah: Fine in expression position, but not sure otherwise.
TC: Consensus (proposed) here is that we restart FCP with cfg_select!
and specifying that:
We explain to people our updated reasoning, we refile the existing concern about let
.
TC: Right now it always returns a block. Probably we don't want that. Would we consider it a breaking change to no longer return a block? People could of course tell that in stable code.
Mara: Also because of Rust 2024, a block has different temporary behavior.
Amanieu: I'd be happy to block this until it's turned into a built-in macro.
Josh: Do people have a blocking objection to shipping one that only supports item position?
Mara: That's fine. especially since {cfg_select!(..)}
just works as expression.
Amanieu: Are we happy requiring the braces on each arm?
Mara: For items, non-braces gets really weird: _ => struct Item();,
with comma? without comma?
Amanieu: We could have separate macros for items and exprs.
Josh: cfg_expr!
?
Mara: Let's just ship this aimed at items. We can add more functionality or another macro later.
TC: I'll leave a comment with the outcome here.
FCP started.
We'll plan to do some design work on this at the all hands.
https://github.com/rust-lang/rust/issues/130994#issuecomment-2849282463
Josh: The new API is not ergonomic.
Amanieu: If you call try_lock
and it fails to acquire the lock, it shouldn't be returning an Ok(_)
variant. You could be calling try_lock
because you want to try once and not block, and then bail on any failure.
TC: We could add a convenience method to io::Result
that would pull out WouldBlock
. This would be helpful in other cases (as would such a helper for Interrupted
).
Amanieu: Maybe we could make a more general method on Result
.
Amanieu: Or maybe we could have a method that does:
TC: In terms of a generic method on Result
, I actually this is the one we'd want, if we wanted one:
Code pattern 1: try_lock()
and bail on error or on lock acquisition failure
Code pattern 2: try_lock()
and bail on errors except lock acquisition failure, handle the lock acquisition failure specifically
Amanieu: In conclusion, we'll return an io::Result<()>
.
Josh: I'll write it up on the issue.
FCP started.
FCP started.
We started the proposed FCP after discussion.
FCP started.
To be discussed in all-hands.
FCP started.
Just opened, defer to next week.
This seems OK. ACP accepted.
We already had accepted Vec::push_mut
. We'll accept Vec::insert_mut
and track them together.
Deferred to next meeting
Generated by fully-automatic-rust-libs-team-triage-meeting-agenda-generator