quasi icon indicating copy to clipboard operation
quasi copied to clipboard

&[u8] is not interned but taken as individual u8

Open oli-obk opened this issue 10 years ago • 2 comments

let x: &[u8] = b"hi";
let y = quote_stmt!(cx, let z = $x;);

may cause unreadable errors with broken spans in similar code and in this code causes z to have type u8 instead of &[u8]

my workaround is to manually create the LitBinary:

let x = syntax::ast::LitBinary(std::rc::Rc::new(x.iter().cloned().collect()));
let x = Spanned {
    node: x,
    span: sp,
};

oli-obk avatar May 12 '15 10:05 oli-obk

Maybe these implementations https://github.com/erickt/rust-quasi/blob/master/src/lib.rs#L37-49 could be changed to an impl for Iterator<Item=T>

oli-obk avatar May 12 '15 10:05 oli-obk

Yuck. That's a good point and unfortunate that this happened. Given that this was just trying to simplify inlining a Vec, perhaps we should just pull this impl and replace it with a [u8] impl for byte strings.

erickt avatar May 19 '15 05:05 erickt