Skip to content

Can't use same self expression in macro in two methods with differing self mutability #7911

Closed
@jdm

Description

@jdm
macro_rules! generate_node_base(($type_:path, $field:expr) => (
    impl<View> NodeBase<View> for $type_ {
        fn base_node(&self) -> &Node<View> {
            unsafe { cast::transmute(&$field) }
        }

        fn base_node_mut(&mut self) -> &mut Node<View> {
            unsafe { cast::transmute(&mut $field) }
        }
    }
))

This macro causes an ICE of No type for local variable 49656 when invoked like generate_node_base!(Comment, self.parent.parent). When I make the macro take two different expressions (using the second in the second method) and invoke it like generate_node_base!(Comment, self.parent.parent, self.parent.parent), it works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions