Stream: t-compiler/wg-rls-2.0

Topic: semi-local-items ?


Edwin Cheng (Apr 30 2020 at 14:44, on Zulip):

I am checking why serde-derive do not works in RA, I just find it expanded to something like this:

#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
const _IMPL_SERIALIZE_FOR_Foo: () = {
    #[allow(unknown_lints)]
    #[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
    #[allow(rust_2018_idioms)]
    extern crate serde as _serde;
    #[allow(unused_macros)]
    macro_rules! try {
        ($__expr:expr) => {
            match $__expr {
                _serde::export::Ok(__val) => __val,
                _serde::export::Err(__err) => {
                    return _serde::export::Err(__err);
                }
            }
        };
    }
    #[automatically_derived]
    impl _serde::Serialize for Foo {
        fn serialize<__S>(&self, __serializer: __S) -> _serde::export::Result<__S::Ok, __S::Error>
        where
            __S: _serde::Serializer,
        {
            let __serde_state = try!(_serde::Serializer::serialize_struct(
                __serializer,
                "Foo",
                false as usize
            ));
            _serde::ser::SerializeStruct::end(__serde_state)
        }
    }
};

Note that the trait implementation is inside a block which is the RHS of const item. I don't think we handle this case in our collector phase, right ?

Florian Diebold (Apr 30 2020 at 15:27, on Zulip):

nope. It's not really semi-local, it's just as local as items local to a function ;)

Last update: Sep 30 2020 at 16:00UTC