Noldorin: like fn, but -> impl Try + ok-wrapping [rathole: find consensus that we want this...]
Noldorin: might surprise users of async fn tho?
Noldorin
oh I see
so would `try` auto-generate a hidden return type?
centril
also; if you say async fn foo<T: Bar>() ==> async fn foo<T: async Bar>(), then what is the explicit syntax for getting rid of 'async Bar' and literally having T: Bar but not T: async Bar?
Noldorin: oh no sorry; try fn would require that the return type is Try and 'return expr' would Ok-wrap 'expr'
Noldorin
ah
centril, but it would only work for infallible fns?
centril
Noldorin: "infallible fns"?
Noldorin
functions that would never return e.g. None or Err
centril, surely that would be `async fn foo<T: async? Bar>()`, unless I misunderstand your syntax?
centril
Noldorin: async? would mean possibly-async
oh yes, you'd say async fn foo<T: !async Bar>()
Noldorin
yes, I was just going to type that heh
centril
Ok, seems like this could work
Noldorin
so for "possibly async" there the fn would be monomorphised, right?
centril
Noldorin: yeah, you'd get two different monomorphic functions, one sync and one async (assuming you use both variants somewhere)
Noldorin: the unsafe checker checks whether unsafe blocks wrap unsafe operations including calls to unsafe functions
Noldorin
[23:06:14] <eddyb>but even the old const eval ignored unsafe blocks
[23:06:24] <eddyb>which is the correct thing to do
est31
but does it actually make sense
niconii joined the channel
Noldorin
eddyb, you seem to be saying there that unsafe blocks should be ignored/disallowed in const eval
est31
I mean... what is const undefined behaviour :p
eddyb
Noldorin: "const eval" doesn't exist anymore. MIR doesn't have unsafe blocks explicitly, miri won't see them unless it looks at the scope in SourceInfo
Noldorin
eddyb, again, you know what I mean... miri evaluation in const context :-P
but okay... if MIR ignores them, fine
eddyb
if you look at the MIR, there's nothing about "push unsafe"/"pop unsafe" or anything like that
alercah
I can't really think of a reason to disallow const unsafe fns
Noldorin
though I don't see the point of permitting `const unsafe` then... it could be misleading to users who think their unsafe code would work in const contexts
alercah
It would, though
eddyb
only the unsafety checking pass cares about the presence of unsafe code
Noldorin: you're missing what "ignoring" means here :P
Noldorin: for a long time now, the "unsafe" in `unsafe {...}` has been ignored by basically everything but the unsafety checking pass
Noldorin
okay...
eddyb
so everyone, including miri, sees a regular block (well, it's not even a block in MIR) with a regular call in it
est31 is desperately trying to come up with an argument against allowing unsafe for const eval
sorry I guess the type-checker also has to look at the (un)safety in fn types
est31
but somehow I fail
eddyb
Noldorin: note that miri was designed to support unsafe Rust
est31
I guess I'm changing my opinion on this subject to "why not"
Noldorin
eddyb, but unsafe Rust can be non-deterministic...
eddyb
if we didn't want to, we could've went with something that allows symbolic interpretation
Noldorin: not under miri
Noldorin
so it disallows FFI?
eddyb
miri can't even do FFI anyway
but yeah, any FFI static access/fn call is disallowed
there was this flying proposal about adding a C frontend to MIR
so that you can const eval C libraries :p
suggestion by eddyb iirc
eddyb
/kban est31
how dare you! :P
(but yeah it'd be neat)
est31 hides under a rusty wheel
Noldorin
centril, so, are you thinking of writing up your const effect work into a new RFC soon then?
centril
Noldorin: there are other unresolved issues... const impl or impl const
-> impl const Foo
-> const impl Foo
eddyb
Noldorin: miri can enforce determinism for CTFE, and that's all fine and dandy, but if we want some form of purity / referential transparency out of const fn, that is preserved at runtime, it gets harder
Noldorin
ahh, classic bikeshedding :P
centril
unsafe impl, impl unsafe
eddyb doesn't think an effect system will win anything in Rust any time soon
est31
can we just simply get "normal" stable const rust?
centril
eddyb: "win anything"?
Noldorin
eddyb, it will just be limited to the const effect to start. it's pretty much necessary for sound, workable const trait bounds
est31
impl const vs const impl seem like niche features for me
centril
est31: if that is niche, then I don't know what niche means...
est31
important to discuss but is it worth for them to slow down stuff?
Noldorin
eddyb, it's the same feature, just different syntax, I think
right, centril ?
centril
Noldorin: right
est31: dont mind stabilizing const fn when we figure out referential transparency
est31
centril: right now const eval is super restricted. Impl trait is a highly advanced feature that's not needed in 99% of cases... after all rust worked well without it
centril
const effect polymorphism can be added later
Noldorin
centril, `const/unsafe impl` makes more sense to me, since the effect can be seen as a modifier of sorts
centril
est31: oh... impl const Foo for X { .. } is the major feature
alercah
imo, only the bikeshedding and potential backwards-compatibility issues it produces are the only blockers
Noldorin
alercah, agreed
alercah, but I think centril has thought about potential backwards-compatibility issues of the future, and is becoming more convinced they won't be a problem, as we add more effects... (if we do)
centril
Yeah; I just want to be sure that we're going into this clear-eyed and introduce something conservative
but which we can extend upon
so we don't walk into future-compat hazards
Noldorin: re. const impl vs. impl const I was pro const impl but im going over to impl const
Noldorin
centril, hmm, why's that?
centril
Noldorin: See it this way:
T: const Foo
impl const Foo for X
(note the added whitespace and grouping)
emerentius has quit
it also works better with -> impl const Foo
Ericson2314_ has quit
alercah
I agree with this
centril
-> impl (Bar + const Foo)
eddyb
> it's pretty much necessary for sound, workable const trait bounds