Add info about undefined behavior to as_ref suggestions
This commit is contained in:
parent
d82fd9ecd3
commit
c221e93fcd
2 changed files with 4 additions and 0 deletions
|
@ -331,6 +331,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
err.note("try using `<*const T>::as_ref()` to get a reference to the \
|
err.note("try using `<*const T>::as_ref()` to get a reference to the \
|
||||||
type behind the pointer: https://doc.rust-lang.org/std/\
|
type behind the pointer: https://doc.rust-lang.org/std/\
|
||||||
primitive.pointer.html#method.as_ref");
|
primitive.pointer.html#method.as_ref");
|
||||||
|
err.note("using `<*const T>::as_ref()` on a pointer \
|
||||||
|
which is unaligned or points to invalid \
|
||||||
|
or uninitialized memory is undefined behavior");
|
||||||
}
|
}
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ LL | println!("{}", z.to_string());
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: try using `<*const T>::as_ref()` to get a reference to the type behind the pointer: https://doc.rust-lang.org/std/primitive.pointer.html#method.as_ref
|
= note: try using `<*const T>::as_ref()` to get a reference to the type behind the pointer: https://doc.rust-lang.org/std/primitive.pointer.html#method.as_ref
|
||||||
|
= note: using `<*const T>::as_ref()` on a pointer which is unaligned or points to invalid or uninitialized memory is undefined behavior
|
||||||
= note: the method `to_string` exists but the following trait bounds were not satisfied:
|
= note: the method `to_string` exists but the following trait bounds were not satisfied:
|
||||||
`*const u8 : std::string::ToString`
|
`*const u8 : std::string::ToString`
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue