Impl rustc_ast::mut_visit

I am implementing a mut_visitor over rustc_ast, I got a compiler error with this code:

fn flat_map_item(&mut self, item: P<Item>) -> SmallVec<[P<Item>; 1]> {
        let item = item.into_inner();
        smallvec![P(item)]
    }

I have imported smallvec, however, I don't understand how this error is reported:

error[E0053]: method `flat_map_item` has an incompatible type for trait
  --> prusti-interface/src/specs/export_spec_checker.rs:18:51
   |
18 |     fn flat_map_item(&mut self, item: P<Item>) -> SmallVec<[P<Item>; 1]> {
   |                                                   ^^^^^^^^^^^^^^^^^^^^^^
   |                                                   |
   |                                                   expected struct `smallvec::SmallVec`, found struct `SmallVec`
   |                                                   help: change the output type to match the trait: `smallvec::SmallVec<[P<rustc_ast::Item>; 1]>`
   |
   = note: expected fn pointer `fn(&mut ExportSpecChecker, P<_>) -> smallvec::SmallVec<[P<rustc_ast::Item>; 1]>`
              found fn pointer `fn(&mut ExportSpecChecker, P<_>) -> SmallVec<[P<rustc_ast::Item>; 1]>`

Can anyone point out what I have done wrong here?

I suspect the SmallVec you've imported isn't the same one used by rustc. There may be a version mismatch or they may have created their own version of `SmallVec that you can import.

My import for smallvec in Cargo.toml:

smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }

It's the same as in rustc_ast source code: rust/Cargo.toml at master · rust-lang/rust · GitHub

What happens if you replace SmallVec with smallvec::SmallVec in the code above? (Where is SmallVec imported from in that module?)

Is it possible you're using a version of prusti that includes something like this hack to link to smallvec without Cargo?

I did try replacing the SmallVec with smallvec::SmallVec, the error is still reported as the same.

I am developing inside the prusti, but I haven't noticed this hack, I will need to talk to a team member for that.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.