Limit scope of unsafe to & instead of all ref exprs, add test showing missing support for autoref behavior
This commit is contained in:
parent
fd30134cf8
commit
4a4b1f48ef
@ -565,7 +565,7 @@ fn highlight_element(
|
||||
_ => h,
|
||||
}
|
||||
}
|
||||
REF_EXPR => {
|
||||
T![&] => {
|
||||
let ref_expr = element.into_node().and_then(ast::RefExpr::cast)?;
|
||||
let expr = ref_expr.expr()?;
|
||||
let field_expr = match expr {
|
||||
|
@ -299,6 +299,23 @@ struct Packed {
|
||||
c: u32,
|
||||
}
|
||||
|
||||
trait DoTheAutoref {
|
||||
fn calls_autoref(&self);
|
||||
}
|
||||
|
||||
struct NeedsAlign {
|
||||
a: u16
|
||||
}
|
||||
|
||||
#[repr(packed)]
|
||||
struct HasAligned {
|
||||
a: NeedsAlign
|
||||
}
|
||||
|
||||
impl DoTheAutoref for NeedsAlign {
|
||||
fn calls_autored(&self) {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = &5 as *const usize;
|
||||
let u = Union { b: 0 };
|
||||
@ -317,6 +334,8 @@ fn main() {
|
||||
let a = &packed.a;
|
||||
let b = &packed.b;
|
||||
let c = &packed.c;
|
||||
let h = HasAligned{ a: NeedsAlign { a: 1 } };
|
||||
h.a.calls_autoref();
|
||||
}
|
||||
}
|
||||
"#
|
||||
|
Loading…
Reference in New Issue
Block a user