#rust-lang

/

      • Noldorin
        is that current syntax?
      • centril
        Noldorin: try fn, async fn
      • Noldorin: no; I made it up :P
      • except for async fn
      • Noldorin
        yeah
      • how would `try` work?
      • I agree it works well for `async` though
      • centril
        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)
      • eddyb
      • rustbot
        [Issue 24111] <open> const fn tracking issue (RFC 911) <https://github.com/rust-lang/rust/issues/24111>;
      • Noldorin
        centril, yeah, so monomorphised twice, I guess :-)
      • centril
        Noldorin: correct :)
      • Noldorin: but.. I would go with the more wordy const fn foo<T: const Bar> at first ("Stroustrup rule") and sugar later
      • Noldorin
        centril, perhaps... I'm not against going straight to the shorthand syntax, but I see you reason
      • centril, anyway, if we're going to have negative effect bounds, that pretty much decides the syntax for possible effect bounds as `?const` (e.g.)
      • centril
        Noldorin: I think we can gain some experience with the longer one first and see how bad it is
      • Noldorin
        fair
      • rkruppe
        eddyb: i'm cackling
      • centril
        Noldorin: having '?const mod { .. }' eventually could be nice
      • or even: "make all the shit in this crate ?const"
      • rkruppe
        eddyb: "float bullshit" ranks surprisingly highly on the list of things giving rust developers migraines
      • centril
        rkruppe: the gift that keeps giving!
      • Noldorin: so negative effect bounds is far from a given;
      • Noldorin
        centril, hah! yeah, the stuff of dreams...
      • what do you mean "a given"?
      • centril
        Noldorin: remove 'a' :P
      • Noldorin
        still not sure I get you
      • centril
        Noldorin: it is not a done deal that we'll get negative effect bounds; far from it.
      • Noldorin
        centril, oh :(
      • centril, well if we implement the shorthand syntax, we need it... otherwise not necessarily
      • centril
        Noldorin: yep
      • Noldorin
        eddyb, what... `const unsafe fn` is allowed?! https://github.com/rust-lang/rust/issues/24111
      • eddyb
        Noldorin: I did say they're orthogonal things...
      • 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
      • Noldorin
        yeah, so it disallows it ;-)
      • eddyb, okay, I'm on the same page as you now
      • all is good
      • Noldorin slinks away
      • eddyb
        I should've linked that post earlier
      • Noldorin
        no worries
      • est31
        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
      • I've given up on that btw
      • I just want "extract from body"
      • cc scott on Lean's similar features
      • est31
        eddyb: about this example
      • eddyb
        (derive properties from functions' bodies)
      • oln has quit
      • est31
        what is the problem here? you write yourself that miri fails to compile
      • that it gives you a miri error*
      • eddyb
        est31: it fails to *interpret*
      • you might not attempt that at compile-time
      • but at runtime instead
      • and it breaks referential transparency
      • centril
        eddyb: expand on "extract from body"?
      • est31
        eddyb: I see
      • eddyb: so your statement is that safe const fn rust should guarantee referential transparency aka same outcome runtime as well as compile time?
      • eddyb
        est31: I'm not saying it should. I'm saying that some people want that and I am discussing the conditions for it being upheld