mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Auto merge of #15312 - alexkirsz:alexkirsz/resolve-deref-raw-follow-up, r=lnicola
Don't follow raw pointer derefs when considering method receiver candidates In https://github.com/rust-lang/rust-analyzer/pull/15118, I enabled following raw pointer derefs when considering self type candidates. However, I also inadvertently enabled it for receiver type candidates, which is invalid and causes false positives (see new test).
This commit is contained in:
commit
cecbd3f84a
@ -1504,7 +1504,7 @@ fn autoderef_method_receiver(
|
||||
ty: Ty,
|
||||
) -> Vec<(Canonical<Ty>, ReceiverAdjustments)> {
|
||||
let mut deref_chain: Vec<_> = Vec::new();
|
||||
let mut autoderef = autoderef::Autoderef::new(table, ty, true);
|
||||
let mut autoderef = autoderef::Autoderef::new(table, ty, false);
|
||||
while let Some((ty, derefs)) = autoderef.next() {
|
||||
deref_chain.push((
|
||||
autoderef.table.canonicalize(ty).value,
|
||||
|
@ -1236,6 +1236,27 @@ fn main() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inherent_method_ref_self_deref_raw() {
|
||||
check_types(
|
||||
r#"
|
||||
struct Val;
|
||||
|
||||
impl Val {
|
||||
pub fn method(&self) -> u32 {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let foo: *const Val;
|
||||
foo.method();
|
||||
// ^^^^^^^^^^^^ {unknown}
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn trait_method_deref_raw() {
|
||||
check_types(
|
||||
|
Loading…
Reference in New Issue
Block a user