-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust: Extract SelfParam
s from crate graph
#19369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -383,25 +383,54 @@ fn emit_function( | |
assert_eq!(sig.binders.len(Interner), parameters.len()); | ||
let sig = sig.skip_binders(); | ||
let ty_vars = &[parameters]; | ||
let function_data = db.function_data(function); | ||
let mut self_param = None; | ||
let params = sig | ||
.params() | ||
.iter() | ||
.map(|p| { | ||
.enumerate() | ||
.filter_map(|(idx, p)| { | ||
let type_repr = emit_hir_ty(trap, db, ty_vars, p); | ||
trap.emit(generated::Param { | ||
id: trap::TrapId::Star, | ||
attrs: vec![], | ||
type_repr, | ||
pat: None, | ||
}) | ||
|
||
if idx == 0 && function_data.has_self_param() { | ||
// Check if the self parameter is a reference | ||
let (is_ref, is_mut) = match p.kind(Interner) { | ||
chalk_ir::TyKind::Ref(mutability, _, _) => { | ||
(true, matches!(mutability, chalk_ir::Mutability::Mut)) | ||
} | ||
chalk_ir::TyKind::Raw(mutability, _) => { | ||
(false, matches!(mutability, chalk_ir::Mutability::Mut)) | ||
} | ||
_ => (false, false), | ||
}; | ||
|
||
self_param = Some(trap.emit(generated::SelfParam { | ||
id: trap::TrapId::Star, | ||
attrs: vec![], | ||
type_repr, | ||
is_ref, | ||
is_mut, | ||
lifetime: None, | ||
name: None, | ||
Comment on lines
+413
to
+414
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I decided to not populate the name, since we also don't do that for non- |
||
})); | ||
None | ||
} else { | ||
Some(trap.emit(generated::Param { | ||
id: trap::TrapId::Star, | ||
attrs: vec![], | ||
type_repr, | ||
pat: None, | ||
})) | ||
} | ||
}) | ||
.collect(); | ||
|
||
let ret_type = emit_hir_ty(trap, db, ty_vars, sig.ret()); | ||
|
||
let param_list = trap.emit(generated::ParamList { | ||
id: trap::TrapId::Star, | ||
params, | ||
self_param: None, | ||
self_param, | ||
}); | ||
let ret_type = ret_type.map(|ret_type| { | ||
trap.emit(generated::RetTypeRepr { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
multipleMethodCallTargets | ||
| sqlx.rs:65:30:65:52 | unsafe_query_2.as_str() | file://:0:0:0:0 | fn as_str | | ||
| sqlx.rs:65:30:65:52 | unsafe_query_2.as_str() | file://:0:0:0:0 | fn as_str | | ||
| sqlx.rs:65:30:65:52 | unsafe_query_2.as_str() | file://:0:0:0:0 | fn as_str | | ||
| sqlx.rs:65:30:65:52 | unsafe_query_2.as_str() | file://:0:0:0:0 | fn as_str | | ||
| sqlx.rs:65:30:65:52 | unsafe_query_2.as_str() | file://:0:0:0:0 | fn as_str | | ||
| sqlx.rs:65:30:65:52 | unsafe_query_2.as_str() | file://:0:0:0:0 | fn as_str | | ||
| sqlx.rs:76:29:76:51 | unsafe_query_2.as_str() | file://:0:0:0:0 | fn as_str | | ||
| sqlx.rs:76:29:76:51 | unsafe_query_2.as_str() | file://:0:0:0:0 | fn as_str | | ||
| sqlx.rs:76:29:76:51 | unsafe_query_2.as_str() | file://:0:0:0:0 | fn as_str | | ||
| sqlx.rs:76:29:76:51 | unsafe_query_2.as_str() | file://:0:0:0:0 | fn as_str | | ||
| sqlx.rs:76:29:76:51 | unsafe_query_2.as_str() | file://:0:0:0:0 | fn as_str | | ||
| sqlx.rs:76:29:76:51 | unsafe_query_2.as_str() | file://:0:0:0:0 | fn as_str | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider extracting the self parameter logic into a separate helper function to improve clarity and reduce complexity in the parameter iteration block.
Copilot uses AI. Check for mistakes.