Stream: t-compiler/rust-analyzer

Topic: local-items in serde

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: () = {
    #[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
    extern crate serde as _serde;
    macro_rules! try {
        ($__expr:expr) => {
            match $__expr {
                _serde::export::Ok(__val) => __val,
                _serde::export::Err(__err) => {
                    return _serde::export::Err(__err);
    impl _serde::Serialize for Foo {
        fn serialize<__S>(&self, __serializer: __S) -> _serde::export::Result<__S::Ok, __S::Error>
            __S: _serde::Serializer,
            let __serde_state = try!(_serde::Serializer::serialize_struct(
                false as usize

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 ;)

Edwin Cheng (Apr 30 2020 at 15:40, on Zulip):

oic, I changed the topic name ;)

Edwin Cheng (Apr 30 2020 at 15:41, on Zulip):


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

and of course impls in blocks are pretty much the worst-case for local items...

Last update: Jul 29 2021 at 09:45UTC