Run cargo fix --edition-idioms

This commit is contained in:
Amos Wenger 2022-07-20 15:02:08 +02:00
parent 23d25a3094
commit 816f7fe12a
230 changed files with 888 additions and 888 deletions

View File

@ -17,7 +17,7 @@ pub struct Change {
}
impl fmt::Debug for Change {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut d = fmt.debug_struct("Change");
if let Some(roots) = &self.roots {
d.field("roots", roots);

View File

@ -104,7 +104,7 @@ impl CrateName {
}
impl fmt::Display for CrateName {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
@ -187,7 +187,7 @@ impl From<CrateName> for CrateDisplayName {
}
impl fmt::Display for CrateDisplayName {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.crate_name.fmt(f)
}
}

View File

@ -57,7 +57,7 @@ pub const DEFAULT_LRU_CAP: usize = 128;
pub trait FileLoader {
/// Text of the file.
fn file_text(&self, file_id: FileId) -> Arc<String>;
fn resolve_path(&self, path: AnchoredPath) -> Option<FileId>;
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId>;
fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>>;
}
@ -116,7 +116,7 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
fn file_text(&self, file_id: FileId) -> Arc<String> {
SourceDatabaseExt::file_text(self.0, file_id)
}
fn resolve_path(&self, path: AnchoredPath) -> Option<FileId> {
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
// FIXME: this *somehow* should be platform agnostic...
let source_root = self.0.file_source_root(path.anchor);
let source_root = self.0.source_root(source_root);

View File

@ -85,7 +85,7 @@ impl CfgExpr {
}
}
fn next_cfg_expr(it: &mut SliceIter<tt::TokenTree>) -> Option<CfgExpr> {
fn next_cfg_expr(it: &mut SliceIter<'_, tt::TokenTree>) -> Option<CfgExpr> {
let name = match it.next() {
None => return None,
Some(tt::TokenTree::Leaf(tt::Leaf::Ident(ident))) => ident.text.clone(),

View File

@ -195,7 +195,7 @@ impl GenericParams {
}
}
pub(crate) fn fill(&mut self, lower_ctx: &LowerCtx, node: &dyn HasGenericParams) {
pub(crate) fn fill(&mut self, lower_ctx: &LowerCtx<'_>, node: &dyn HasGenericParams) {
if let Some(params) = node.generic_param_list() {
self.fill_params(lower_ctx, params)
}
@ -206,7 +206,7 @@ impl GenericParams {
pub(crate) fn fill_bounds(
&mut self,
lower_ctx: &LowerCtx,
lower_ctx: &LowerCtx<'_>,
node: &dyn ast::HasTypeBounds,
target: Either<TypeRef, LifetimeRef>,
) {
@ -217,7 +217,7 @@ impl GenericParams {
}
}
fn fill_params(&mut self, lower_ctx: &LowerCtx, params: ast::GenericParamList) {
fn fill_params(&mut self, lower_ctx: &LowerCtx<'_>, params: ast::GenericParamList) {
for type_or_const_param in params.type_or_const_params() {
match type_or_const_param {
ast::TypeOrConstParam::Type(type_param) => {
@ -259,7 +259,7 @@ impl GenericParams {
}
}
fn fill_where_predicates(&mut self, lower_ctx: &LowerCtx, where_clause: ast::WhereClause) {
fn fill_where_predicates(&mut self, lower_ctx: &LowerCtx<'_>, where_clause: ast::WhereClause) {
for pred in where_clause.predicates() {
let target = if let Some(type_ref) = pred.ty() {
Either::Left(TypeRef::from_ast(lower_ctx, type_ref))
@ -293,7 +293,7 @@ impl GenericParams {
fn add_where_predicate_from_bound(
&mut self,
lower_ctx: &LowerCtx,
lower_ctx: &LowerCtx<'_>,
bound: ast::TypeBound,
hrtb_lifetimes: Option<&Box<[Name]>>,
target: Either<TypeRef, LifetimeRef>,

View File

@ -1509,7 +1509,7 @@ impl ModCollector<'_, '_> {
let module = self.def_collector.def_map.module_id(self.module_id);
let def_map = &mut self.def_collector.def_map;
let update_def =
|def_collector: &mut DefCollector, id, name: &Name, vis, has_constructor| {
|def_collector: &mut DefCollector<'_>, id, name: &Name, vis, has_constructor| {
def_collector.def_map.modules[self.module_id].scope.declare(id);
def_collector.update(
self.module_id,

View File

@ -88,7 +88,7 @@ pub enum GenericArg {
impl Path {
/// Converts an `ast::Path` to `Path`. Works with use trees.
/// It correctly handles `$crate` based path from macro call.
pub fn from_src(path: ast::Path, ctx: &LowerCtx) -> Option<Path> {
pub fn from_src(path: ast::Path, ctx: &LowerCtx<'_>) -> Option<Path> {
lower::lower_path(path, ctx)
}
@ -188,7 +188,7 @@ impl<'a> PathSegments<'a> {
}
impl GenericArgs {
pub(crate) fn from_ast(lower_ctx: &LowerCtx, node: ast::GenericArgList) -> Option<GenericArgs> {
pub(crate) fn from_ast(lower_ctx: &LowerCtx<'_>, node: ast::GenericArgList) -> Option<GenericArgs> {
lower::lower_generic_args(lower_ctx, node)
}

View File

@ -15,7 +15,7 @@ use crate::{
/// Converts an `ast::Path` to `Path`. Works with use trees.
/// It correctly handles `$crate` based path from macro call.
pub(super) fn lower_path(mut path: ast::Path, ctx: &LowerCtx) -> Option<Path> {
pub(super) fn lower_path(mut path: ast::Path, ctx: &LowerCtx<'_>) -> Option<Path> {
let mut kind = PathKind::Plain;
let mut type_anchor = None;
let mut segments = Vec::new();
@ -149,7 +149,7 @@ pub(super) fn lower_path(mut path: ast::Path, ctx: &LowerCtx) -> Option<Path> {
}
pub(super) fn lower_generic_args(
lower_ctx: &LowerCtx,
lower_ctx: &LowerCtx<'_>,
node: ast::GenericArgList,
) -> Option<GenericArgs> {
let mut args = Vec::new();
@ -196,7 +196,7 @@ pub(super) fn lower_generic_args(
/// Collect `GenericArgs` from the parts of a fn-like path, i.e. `Fn(X, Y)
/// -> Z` (which desugars to `Fn<(X, Y), Output=Z>`).
fn lower_generic_args_from_fn_path(
ctx: &LowerCtx,
ctx: &LowerCtx<'_>,
params: Option<ast::ParamList>,
ret_type: Option<ast::RetType>,
) -> Option<GenericArgs> {

View File

@ -73,7 +73,7 @@ impl FileLoader for TestDB {
fn file_text(&self, file_id: FileId) -> Arc<String> {
FileLoaderDelegate(self).file_text(file_id)
}
fn resolve_path(&self, path: AnchoredPath) -> Option<FileId> {
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
FileLoaderDelegate(self).resolve_path(path)
}
fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> {

View File

@ -86,7 +86,7 @@ pub struct TraitRef {
impl TraitRef {
/// Converts an `ast::PathType` to a `hir::TraitRef`.
pub(crate) fn from_ast(ctx: &LowerCtx, node: ast::Type) -> Option<Self> {
pub(crate) fn from_ast(ctx: &LowerCtx<'_>, node: ast::Type) -> Option<Self> {
// FIXME: Use `Path::from_src`
match node {
ast::Type::PathType(path) => {
@ -159,7 +159,7 @@ pub enum TraitBoundModifier {
impl TypeRef {
/// Converts an `ast::TypeRef` to a `hir::TypeRef`.
pub fn from_ast(ctx: &LowerCtx, node: ast::Type) -> Self {
pub fn from_ast(ctx: &LowerCtx<'_>, node: ast::Type) -> Self {
match node {
ast::Type::ParenType(inner) => TypeRef::from_ast_opt(ctx, inner.ty()),
ast::Type::TupleType(inner) => {
@ -245,7 +245,7 @@ impl TypeRef {
}
}
pub(crate) fn from_ast_opt(ctx: &LowerCtx, node: Option<ast::Type>) -> Self {
pub(crate) fn from_ast_opt(ctx: &LowerCtx<'_>, node: Option<ast::Type>) -> Self {
match node {
Some(node) => TypeRef::from_ast(ctx, node),
None => TypeRef::Error,
@ -320,7 +320,7 @@ impl TypeRef {
}
pub(crate) fn type_bounds_from_ast(
lower_ctx: &LowerCtx,
lower_ctx: &LowerCtx<'_>,
type_bounds_opt: Option<ast::TypeBoundList>,
) -> Vec<Interned<TypeBound>> {
if let Some(type_bounds) = type_bounds_opt {
@ -331,7 +331,7 @@ pub(crate) fn type_bounds_from_ast(
}
impl TypeBound {
pub(crate) fn from_ast(ctx: &LowerCtx, node: ast::TypeBound) -> Self {
pub(crate) fn from_ast(ctx: &LowerCtx<'_>, node: ast::TypeBound) -> Self {
let lower_path_type = |path_type: ast::PathType| ctx.lower_path(path_type.path()?);
match node.kind() {

View File

@ -102,7 +102,7 @@ impl ModPath {
}
}
pub fn escaped(&self) -> EscapedModPath {
pub fn escaped(&self) -> EscapedModPath<'_> {
EscapedModPath(self)
}

View File

@ -21,7 +21,7 @@ enum Repr {
}
impl fmt::Display for Name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.0 {
Repr::Text(text) => fmt::Display::fmt(&text, f),
Repr::TupleField(idx) => fmt::Display::fmt(&idx, f),
@ -35,7 +35,7 @@ fn is_raw_identifier(name: &str) -> bool {
}
impl<'a> fmt::Display for EscapedName<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.0 .0 {
Repr::Text(text) => {
if is_raw_identifier(text) {
@ -142,7 +142,7 @@ impl Name {
}
}
pub fn escaped(&self) -> EscapedName {
pub fn escaped(&self) -> EscapedName<'_> {
EscapedName(self)
}
}

View File

@ -70,7 +70,7 @@ impl Iterator for Autoderef<'_, '_> {
}
}
pub(crate) fn autoderef_step(table: &mut InferenceTable, ty: Ty) -> Option<(AutoderefKind, Ty)> {
pub(crate) fn autoderef_step(table: &mut InferenceTable<'_>, ty: Ty) -> Option<(AutoderefKind, Ty)> {
if let Some(derefed) = builtin_deref(&ty) {
Some((AutoderefKind::Builtin, table.resolve_ty_shallow(derefed)))
} else {
@ -94,7 +94,7 @@ pub fn autoderef<'a>(
v.into_iter()
}
pub(crate) fn deref(table: &mut InferenceTable, ty: Ty) -> Option<Ty> {
pub(crate) fn deref(table: &mut InferenceTable<'_>, ty: Ty) -> Option<Ty> {
let _p = profile::span("deref");
autoderef_step(table, ty).map(|(_, ty)| ty)
}
@ -107,7 +107,7 @@ fn builtin_deref(ty: &Ty) -> Option<&Ty> {
}
}
fn deref_by_trait(table: &mut InferenceTable, ty: Ty) -> Option<Ty> {
fn deref_by_trait(table: &mut InferenceTable<'_>, ty: Ty) -> Option<Ty> {
let _p = profile::span("deref_by_trait");
if table.resolve_ty_shallow(&ty).inference_var(Interner).is_some() {
// don't try to deref unknown variables

View File

@ -111,7 +111,7 @@ impl<D> TyBuilder<D> {
this
}
pub(crate) fn fill_with_inference_vars(self, table: &mut InferenceTable) -> Self {
pub(crate) fn fill_with_inference_vars(self, table: &mut InferenceTable<'_>) -> Self {
self.fill(|x| match x {
ParamKind::Type => GenericArgData::Ty(table.new_type_var()).intern(Interner),
ParamKind::Const(ty) => {

View File

@ -292,7 +292,7 @@ impl<'a> PatCtxt<'a> {
}
impl HirDisplay for Pat {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match &*self.kind {
PatKind::Wild => write!(f, "_"),
PatKind::Binding { name, subpattern } => {
@ -394,11 +394,11 @@ impl HirDisplay for Pat {
struct WriteWith<F>(F)
where
F: Fn(&mut HirFormatter) -> Result<(), HirDisplayError>;
F: Fn(&mut HirFormatter<'_>) -> Result<(), HirDisplayError>;
impl<F> HirDisplay for WriteWith<F>
where
F: Fn(&mut HirFormatter) -> Result<(), HirDisplayError>,
F: Fn(&mut HirFormatter<'_>) -> Result<(), HirDisplayError>,
{
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
(self.0)(f)

View File

@ -144,7 +144,7 @@ impl IntRange {
}
}
fn to_pat(&self, _cx: &MatchCheckCtx, ty: Ty) -> Pat {
fn to_pat(&self, _cx: &MatchCheckCtx<'_, '_>, ty: Ty) -> Pat {
match ty.kind(Interner) {
TyKind::Scalar(Scalar::Bool) => {
let kind = match self.boundaries() {

View File

@ -45,7 +45,7 @@ pub struct HirFormatter<'a> {
}
pub trait HirDisplay {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError>;
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError>;
/// Returns a `Display`able type that is human-readable.
fn into_displayable<'a>(
@ -162,7 +162,7 @@ impl<'a> HirFormatter<'a> {
}
/// This allows using the `write!` macro directly with a `HirFormatter`.
pub fn write_fmt(&mut self, args: fmt::Arguments) -> Result<(), HirDisplayError> {
pub fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> Result<(), HirDisplayError> {
// We write to a buffer first to track output size
self.buf.clear();
fmt::write(&mut self.buf, args)?;
@ -247,7 +247,7 @@ impl<'a, T> fmt::Display for HirDisplayWrapper<'a, T>
where
T: HirDisplay,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.t.hir_fmt(&mut HirFormatter {
db: self.db,
fmt: f,
@ -270,19 +270,19 @@ where
const TYPE_HINT_TRUNCATION: &str = "";
impl<T: HirDisplay> HirDisplay for &'_ T {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
HirDisplay::hir_fmt(*self, f)
}
}
impl<T: HirDisplay + Internable> HirDisplay for Interned<T> {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
HirDisplay::hir_fmt(self.as_ref(), f)
}
}
impl HirDisplay for ProjectionTy {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
if f.should_truncate() {
return write!(f, "{}", TYPE_HINT_TRUNCATION);
}
@ -302,7 +302,7 @@ impl HirDisplay for ProjectionTy {
}
impl HirDisplay for OpaqueTy {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
if f.should_truncate() {
return write!(f, "{}", TYPE_HINT_TRUNCATION);
}
@ -312,7 +312,7 @@ impl HirDisplay for OpaqueTy {
}
impl HirDisplay for GenericArg {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match self.interned() {
crate::GenericArgData::Ty(ty) => ty.hir_fmt(f),
crate::GenericArgData::Lifetime(lt) => lt.hir_fmt(f),
@ -322,7 +322,7 @@ impl HirDisplay for GenericArg {
}
impl HirDisplay for Const {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
let data = self.interned();
match data.value {
ConstValue::BoundVar(idx) => idx.hir_fmt(f),
@ -339,13 +339,13 @@ impl HirDisplay for Const {
}
impl HirDisplay for BoundVar {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write!(f, "?{}.{}", self.debruijn.depth(), self.index)
}
}
impl HirDisplay for Ty {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
if f.should_truncate() {
return write!(f, "{}", TYPE_HINT_TRUNCATION);
}
@ -790,7 +790,7 @@ impl HirDisplay for Ty {
}
impl HirDisplay for CallableSig {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write!(f, "fn(")?;
f.write_joined(self.params(), ", ")?;
if self.is_varargs {
@ -839,7 +839,7 @@ pub fn write_bounds_like_dyn_trait_with_prefix(
prefix: &str,
predicates: &[QuantifiedWhereClause],
default_sized: SizedByDefault,
f: &mut HirFormatter,
f: &mut HirFormatter<'_>,
) -> Result<(), HirDisplayError> {
write!(f, "{}", prefix)?;
if !predicates.is_empty()
@ -855,7 +855,7 @@ pub fn write_bounds_like_dyn_trait_with_prefix(
fn write_bounds_like_dyn_trait(
predicates: &[QuantifiedWhereClause],
default_sized: SizedByDefault,
f: &mut HirFormatter,
f: &mut HirFormatter<'_>,
) -> Result<(), HirDisplayError> {
// Note: This code is written to produce nice results (i.e.
// corresponding to surface Rust) for types that can occur in
@ -952,7 +952,7 @@ fn write_bounds_like_dyn_trait(
Ok(())
}
fn fmt_trait_ref(tr: &TraitRef, f: &mut HirFormatter, use_as: bool) -> Result<(), HirDisplayError> {
fn fmt_trait_ref(tr: &TraitRef, f: &mut HirFormatter<'_>, use_as: bool) -> Result<(), HirDisplayError> {
if f.should_truncate() {
return write!(f, "{}", TYPE_HINT_TRUNCATION);
}
@ -973,13 +973,13 @@ fn fmt_trait_ref(tr: &TraitRef, f: &mut HirFormatter, use_as: bool) -> Result<()
}
impl HirDisplay for TraitRef {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
fmt_trait_ref(self, f, false)
}
}
impl HirDisplay for WhereClause {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
if f.should_truncate() {
return write!(f, "{}", TYPE_HINT_TRUNCATION);
}
@ -1007,7 +1007,7 @@ impl HirDisplay for WhereClause {
}
impl HirDisplay for LifetimeOutlives {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
self.a.hir_fmt(f)?;
write!(f, ": ")?;
self.b.hir_fmt(f)
@ -1015,13 +1015,13 @@ impl HirDisplay for LifetimeOutlives {
}
impl HirDisplay for Lifetime {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
self.interned().hir_fmt(f)
}
}
impl HirDisplay for LifetimeData {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match self {
LifetimeData::BoundVar(idx) => idx.hir_fmt(f),
LifetimeData::InferenceVar(_) => write!(f, "_"),
@ -1040,7 +1040,7 @@ impl HirDisplay for LifetimeData {
}
impl HirDisplay for DomainGoal {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match self {
DomainGoal::Holds(wc) => {
write!(f, "Holds(")?;
@ -1056,7 +1056,7 @@ impl HirDisplay for DomainGoal {
pub fn write_visibility(
module_id: ModuleId,
vis: Visibility,
f: &mut HirFormatter,
f: &mut HirFormatter<'_>,
) -> Result<(), HirDisplayError> {
match vis {
Visibility::Public => write!(f, "pub "),
@ -1078,7 +1078,7 @@ pub fn write_visibility(
}
impl HirDisplay for TypeRef {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match self {
TypeRef::Never => write!(f, "!")?,
TypeRef::Placeholder => write!(f, "_")?,
@ -1177,7 +1177,7 @@ impl HirDisplay for TypeRef {
}
impl HirDisplay for TypeBound {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match self {
TypeBound::Path(path, modifier) => {
match modifier {
@ -1197,7 +1197,7 @@ impl HirDisplay for TypeBound {
}
impl HirDisplay for Path {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match (self.type_anchor(), self.kind()) {
(Some(anchor), _) => {
write!(f, "<")?;
@ -1301,7 +1301,7 @@ impl HirDisplay for Path {
}
impl HirDisplay for hir_def::path::GenericArg {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match self {
hir_def::path::GenericArg::Type(ty) => ty.hir_fmt(f),
hir_def::path::GenericArg::Const(c) => write!(f, "{}", c),

View File

@ -130,7 +130,7 @@ trait PatLike: Into<ExprOrPatId> + Copy {
type BindingMode: Copy;
fn infer(
this: &mut InferenceContext,
this: &mut InferenceContext<'_>,
id: Self,
expected_ty: &Ty,
default_bm: Self::BindingMode,
@ -140,7 +140,7 @@ trait PatLike: Into<ExprOrPatId> + Copy {
impl PatLike for ExprId {
type BindingMode = ();
fn infer(this: &mut InferenceContext, id: Self, expected_ty: &Ty, _: Self::BindingMode) -> Ty {
fn infer(this: &mut InferenceContext<'_>, id: Self, expected_ty: &Ty, _: Self::BindingMode) -> Ty {
this.infer_assignee_expr(id, expected_ty)
}
}
@ -149,7 +149,7 @@ impl PatLike for PatId {
type BindingMode = BindingMode;
fn infer(
this: &mut InferenceContext,
this: &mut InferenceContext<'_>,
id: Self,
expected_ty: &Ty,
default_bm: Self::BindingMode,
@ -971,7 +971,7 @@ impl Expectation {
/// which still is useful, because it informs integer literals and the like.
/// See the test case `test/ui/coerce-expect-unsized.rs` and #20169
/// for examples of where this comes up,.
fn rvalue_hint(table: &mut unify::InferenceTable, ty: Ty) -> Self {
fn rvalue_hint(table: &mut unify::InferenceTable<'_>, ty: Ty) -> Self {
// FIXME: do struct_tail_without_normalization
match table.resolve_ty_shallow(&ty).kind(Interner) {
TyKind::Slice(_) | TyKind::Str | TyKind::Dyn(_) => Expectation::RValueLikeUnsized(ty),
@ -984,7 +984,7 @@ impl Expectation {
Expectation::None
}
fn resolve(&self, table: &mut unify::InferenceTable) -> Expectation {
fn resolve(&self, table: &mut unify::InferenceTable<'_>) -> Expectation {
match self {
Expectation::None => Expectation::None,
Expectation::HasType(t) => Expectation::HasType(table.resolve_ty_shallow(t)),
@ -994,7 +994,7 @@ impl Expectation {
}
}
fn to_option(&self, table: &mut unify::InferenceTable) -> Option<Ty> {
fn to_option(&self, table: &mut unify::InferenceTable<'_>) -> Option<Ty> {
match self.resolve(table) {
Expectation::None => None,
Expectation::HasType(t) |
@ -1003,7 +1003,7 @@ impl Expectation {
}
}
fn only_has_type(&self, table: &mut unify::InferenceTable) -> Option<Ty> {
fn only_has_type(&self, table: &mut unify::InferenceTable<'_>) -> Option<Ty> {
match self {
Expectation::HasType(t) => Some(table.resolve_ty_shallow(t)),
// Expectation::Castable(_) |
@ -1028,7 +1028,7 @@ impl Expectation {
/// an expected type. Otherwise, we might write parts of the type
/// when checking the 'then' block which are incompatible with the
/// 'else' branch.
fn adjust_for_branches(&self, table: &mut unify::InferenceTable) -> Expectation {
fn adjust_for_branches(&self, table: &mut unify::InferenceTable<'_>) -> Expectation {
match self {
Expectation::HasType(ety) => {
let ety = table.resolve_ty_shallow(ety);

View File

@ -43,7 +43,7 @@ where
impl<T: HasInterner<Interner = Interner>> Canonicalized<T> {
pub(super) fn apply_solution(
&self,
ctx: &mut InferenceTable,
ctx: &mut InferenceTable<'_>,
solution: Canonical<Substitution>,
) {
// the solution may contain new variables, which we need to convert to new inference vars
@ -391,7 +391,7 @@ impl<'a> InferenceTable<'a> {
self.pending_obligations = snapshot.pending_obligations;
}
pub(crate) fn run_in_snapshot<T>(&mut self, f: impl FnOnce(&mut InferenceTable) -> T) -> T {
pub(crate) fn run_in_snapshot<T>(&mut self, f: impl FnOnce(&mut InferenceTable<'_>) -> T) -> T {
let snapshot = self.snapshot();
let result = f(self);
self.rollback_to(snapshot);

View File

@ -168,7 +168,7 @@ impl chalk_ir::interner::Interner for Interner {
}
fn debug_separator_trait_ref(
separator_trait_ref: &chalk_ir::SeparatorTraitRef<Interner>,
separator_trait_ref: &chalk_ir::SeparatorTraitRef<'_, Interner>,
fmt: &mut fmt::Formatter<'_>,
) -> Option<fmt::Result> {
Some(write!(fmt, "{:?}", separator_trait_ref.debug(Interner)))

View File

@ -106,7 +106,7 @@ impl<'a> TyLoweringContext<'a> {
pub fn with_debruijn<T>(
&self,
debruijn: DebruijnIndex,
f: impl FnOnce(&TyLoweringContext) -> T,
f: impl FnOnce(&TyLoweringContext<'_>) -> T,
) -> T {
let opaque_ty_data_vec = self.opaque_type_data.take();
let expander = self.expander.take();
@ -130,7 +130,7 @@ impl<'a> TyLoweringContext<'a> {
pub fn with_shifted_in<T>(
&self,
debruijn: DebruijnIndex,
f: impl FnOnce(&TyLoweringContext) -> T,
f: impl FnOnce(&TyLoweringContext<'_>) -> T,
) -> T {
self.with_debruijn(self.in_binders.shifted_in_from(debruijn), f)
}

View File

@ -492,7 +492,7 @@ pub struct ReceiverAdjustments {
}
impl ReceiverAdjustments {
pub(crate) fn apply(&self, table: &mut InferenceTable, ty: Ty) -> (Ty, Vec<Adjustment>) {
pub(crate) fn apply(&self, table: &mut InferenceTable<'_>, ty: Ty) -> (Ty, Vec<Adjustment>) {
let mut ty = ty;
let mut adjust = Vec::new();
for _ in 0..self.autoderefs {
@ -597,7 +597,7 @@ pub fn lookup_impl_method(
fn find_matching_impl(
mut impls: impl Iterator<Item = ImplId>,
table: &mut InferenceTable,
table: &mut InferenceTable<'_>,
self_ty: &Ty,
) -> Option<Arc<ImplData>> {
let db = table.db;
@ -856,7 +856,7 @@ fn iterate_method_candidates_for_self_ty(
fn iterate_trait_method_candidates(
self_ty: &Ty,
table: &mut InferenceTable,
table: &mut InferenceTable<'_>,
traits_in_scope: &FxHashSet<TraitId>,
name: Option<&Name>,
receiver_ty: Option<&Ty>,
@ -922,7 +922,7 @@ fn iterate_trait_method_candidates(
fn iterate_inherent_methods(
self_ty: &Ty,
table: &mut InferenceTable,
table: &mut InferenceTable<'_>,
name: Option<&Name>,
receiver_ty: Option<&Ty>,
receiver_adjustments: Option<ReceiverAdjustments>,
@ -975,7 +975,7 @@ fn iterate_inherent_methods(
fn impls_for_self_ty(
impls: &InherentImpls,
self_ty: &Ty,
table: &mut InferenceTable,
table: &mut InferenceTable<'_>,
name: Option<&Name>,
receiver_ty: Option<&Ty>,
receiver_adjustments: Option<ReceiverAdjustments>,
@ -1017,7 +1017,7 @@ pub fn resolve_indexing_op(
}
fn is_valid_candidate(
table: &mut InferenceTable,
table: &mut InferenceTable<'_>,
name: Option<&Name>,
receiver_ty: Option<&Ty>,
item: AssocItemId,
@ -1161,7 +1161,7 @@ fn generic_implements_goal(
}
fn autoderef_method_receiver(
table: &mut InferenceTable,
table: &mut InferenceTable<'_>,
ty: Ty,
) -> (Vec<Canonical<Ty>>, Vec<ReceiverAdjustments>) {
let (mut deref_chain, mut adjustments): (Vec<_>, Vec<_>) = (Vec::new(), Vec::new());

View File

@ -77,7 +77,7 @@ impl FileLoader for TestDB {
fn file_text(&self, file_id: FileId) -> Arc<String> {
FileLoaderDelegate(self).file_text(file_id)
}
fn resolve_path(&self, path: AnchoredPath) -> Option<FileId> {
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
FileLoaderDelegate(self).resolve_path(path)
}
fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> {

View File

@ -104,7 +104,7 @@ mod unsafe_tls {
use crate::db::HirDatabase;
use scoped_tls::scoped_thread_local;
scoped_thread_local!(static PROGRAM: DebugContext);
scoped_thread_local!(static PROGRAM: DebugContext<'_>);
pub(crate) fn with_current_program<R>(
op: impl for<'a> FnOnce(Option<&'a DebugContext<'a>>) -> R,
@ -127,7 +127,7 @@ mod unsafe_tls {
// `with_current_program`, which hides the lifetime through the `for`
// type.
let static_p: &DebugContext<'static> =
unsafe { std::mem::transmute::<&DebugContext, &DebugContext<'static>>(&ctx) };
unsafe { std::mem::transmute::<&DebugContext<'_>, &DebugContext<'static>>(&ctx) };
PROGRAM.set(static_p, op)
}
}

View File

@ -130,7 +130,7 @@ pub fn all_super_traits(db: &dyn DefDatabase, trait_: TraitId) -> SmallVec<[Trai
/// `all_super_traits` is that we keep track of type parameters; for example if
/// we have `Self: Trait<u32, i32>` and `Trait<T, U>: OtherTrait<U>` we'll get
/// `Self: OtherTrait<i32>`.
pub(super) fn all_super_trait_refs(db: &dyn HirDatabase, trait_ref: TraitRef) -> SuperTraits {
pub(super) fn all_super_trait_refs(db: &dyn HirDatabase, trait_ref: TraitRef) -> SuperTraits<'_> {
SuperTraits { db, seen: iter::once(trait_ref.trait_id).collect(), stack: vec![trait_ref] }
}

View File

@ -23,7 +23,7 @@ use crate::{
};
impl HirDisplay for Function {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
let data = f.db.function_data(self.id);
write_visibility(self.module(f.db).id, self.visibility(f.db), f)?;
if data.has_default_kw() {
@ -48,7 +48,7 @@ impl HirDisplay for Function {
f.write_char('(')?;
let write_self_param = |ty: &TypeRef, f: &mut HirFormatter| match ty {
let write_self_param = |ty: &TypeRef, f: &mut HirFormatter<'_>| match ty {
TypeRef::Path(p) if p.is_self_type() => f.write_str("self"),
TypeRef::Reference(inner, lifetime, mut_) if matches!(&**inner,TypeRef::Path(p) if p.is_self_type()) =>
{
@ -129,7 +129,7 @@ impl HirDisplay for Function {
}
impl HirDisplay for Adt {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match self {
Adt::Struct(it) => it.hir_fmt(f),
Adt::Union(it) => it.hir_fmt(f),
@ -139,7 +139,7 @@ impl HirDisplay for Adt {
}
impl HirDisplay for Struct {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write_visibility(self.module(f.db).id, self.visibility(f.db), f)?;
f.write_str("struct ")?;
write!(f, "{}", self.name(f.db))?;
@ -151,7 +151,7 @@ impl HirDisplay for Struct {
}
impl HirDisplay for Enum {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write_visibility(self.module(f.db).id, self.visibility(f.db), f)?;
f.write_str("enum ")?;
write!(f, "{}", self.name(f.db))?;
@ -163,7 +163,7 @@ impl HirDisplay for Enum {
}
impl HirDisplay for Union {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write_visibility(self.module(f.db).id, self.visibility(f.db), f)?;
f.write_str("union ")?;
write!(f, "{}", self.name(f.db))?;
@ -175,7 +175,7 @@ impl HirDisplay for Union {
}
impl HirDisplay for Field {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write_visibility(self.parent.module(f.db).id, self.visibility(f.db), f)?;
write!(f, "{}: ", self.name(f.db))?;
self.ty(f.db).hir_fmt(f)
@ -183,7 +183,7 @@ impl HirDisplay for Field {
}
impl HirDisplay for Variant {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write!(f, "{}", self.name(f.db))?;
let data = self.variant_data(f.db);
match &*data {
@ -224,13 +224,13 @@ impl HirDisplay for Variant {
}
impl HirDisplay for Type {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
self.ty.hir_fmt(f)
}
}
impl HirDisplay for GenericParam {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match self {
GenericParam::TypeParam(it) => it.hir_fmt(f),
GenericParam::ConstParam(it) => it.hir_fmt(f),
@ -240,7 +240,7 @@ impl HirDisplay for GenericParam {
}
impl HirDisplay for TypeOrConstParam {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match self.split(f.db) {
either::Either::Left(x) => x.hir_fmt(f),
either::Either::Right(x) => x.hir_fmt(f),
@ -249,7 +249,7 @@ impl HirDisplay for TypeOrConstParam {
}
impl HirDisplay for TypeParam {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write!(f, "{}", self.name(f.db))?;
if f.omit_verbose_types() {
return Ok(());
@ -277,19 +277,19 @@ impl HirDisplay for TypeParam {
}
impl HirDisplay for LifetimeParam {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write!(f, "{}", self.name(f.db))
}
}
impl HirDisplay for ConstParam {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write!(f, "const {}: ", self.name(f.db))?;
self.ty(f.db).hir_fmt(f)
}
}
fn write_generic_params(def: GenericDefId, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn write_generic_params(def: GenericDefId, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
let params = f.db.generic_params(def);
if params.lifetimes.is_empty()
&& params.type_or_consts.iter().all(|x| x.1.const_param().is_none())
@ -304,7 +304,7 @@ fn write_generic_params(def: GenericDefId, f: &mut HirFormatter) -> Result<(), H
f.write_char('<')?;
let mut first = true;
let mut delim = |f: &mut HirFormatter| {
let mut delim = |f: &mut HirFormatter<'_>| {
if first {
first = false;
Ok(())
@ -343,7 +343,7 @@ fn write_generic_params(def: GenericDefId, f: &mut HirFormatter) -> Result<(), H
Ok(())
}
fn write_where_clause(def: GenericDefId, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn write_where_clause(def: GenericDefId, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
let params = f.db.generic_params(def);
// unnamed type targets are displayed inline with the argument itself, e.g. `f: impl Y`.
@ -365,7 +365,7 @@ fn write_where_clause(def: GenericDefId, f: &mut HirFormatter) -> Result<(), Hir
return Ok(());
}
let write_target = |target: &WherePredicateTypeTarget, f: &mut HirFormatter| match target {
let write_target = |target: &WherePredicateTypeTarget, f: &mut HirFormatter<'_>| match target {
WherePredicateTypeTarget::TypeRef(ty) => ty.hir_fmt(f),
WherePredicateTypeTarget::TypeOrConstParam(id) => {
match &params.type_or_consts[*id].name() {
@ -382,7 +382,7 @@ fn write_where_clause(def: GenericDefId, f: &mut HirFormatter) -> Result<(), Hir
if pred_idx == 0 { None } else { Some(&params.where_predicates[pred_idx - 1]) };
let new_predicate =
|f: &mut HirFormatter| f.write_str(if pred_idx == 0 { "\n " } else { ",\n " });
|f: &mut HirFormatter<'_>| f.write_str(if pred_idx == 0 { "\n " } else { ",\n " });
match pred {
WherePredicate::TypeBound { target, .. } if is_unnamed_type_target(target) => {}
@ -438,7 +438,7 @@ fn write_where_clause(def: GenericDefId, f: &mut HirFormatter) -> Result<(), Hir
}
impl HirDisplay for Const {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write_visibility(self.module(f.db).id, self.visibility(f.db), f)?;
let data = f.db.const_data(self.id);
f.write_str("const ")?;
@ -452,7 +452,7 @@ impl HirDisplay for Const {
}
impl HirDisplay for Static {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write_visibility(self.module(f.db).id, self.visibility(f.db), f)?;
let data = f.db.static_data(self.id);
f.write_str("static ")?;
@ -466,7 +466,7 @@ impl HirDisplay for Static {
}
impl HirDisplay for Trait {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write_visibility(self.module(f.db).id, self.visibility(f.db), f)?;
let data = f.db.trait_data(self.id);
if data.is_unsafe {
@ -484,7 +484,7 @@ impl HirDisplay for Trait {
}
impl HirDisplay for TypeAlias {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write_visibility(self.module(f.db).id, self.visibility(f.db), f)?;
let data = f.db.type_alias_data(self.id);
write!(f, "type {}", data.name)?;
@ -501,7 +501,7 @@ impl HirDisplay for TypeAlias {
}
impl HirDisplay for Module {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
// FIXME: Module doesn't have visibility saved in data.
match self.name(f.db) {
Some(name) => write!(f, "mod {}", name),
@ -515,7 +515,7 @@ impl HirDisplay for Module {
}
impl HirDisplay for Macro {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match self.id {
hir_def::MacroId::Macro2Id(_) => f.write_str("macro"),
hir_def::MacroId::MacroRulesId(_) => f.write_str("macro_rules!"),

View File

@ -3028,7 +3028,7 @@ impl Type {
pub fn iterate_method_candidates<T>(
&self,
db: &dyn HirDatabase,
scope: &SemanticsScope,
scope: &SemanticsScope<'_>,
// FIXME this can be retrieved from `scope`, except autoimport uses this
// to specify a different set, so the method needs to be split
traits_in_scope: &FxHashSet<TraitId>,
@ -3061,7 +3061,7 @@ impl Type {
fn iterate_method_candidates_dyn(
&self,
db: &dyn HirDatabase,
scope: &SemanticsScope,
scope: &SemanticsScope<'_>,
traits_in_scope: &FxHashSet<TraitId>,
with_local_impls: Option<Module>,
name: Option<&Name>,
@ -3091,7 +3091,7 @@ impl Type {
pub fn iterate_path_candidates<T>(
&self,
db: &dyn HirDatabase,
scope: &SemanticsScope,
scope: &SemanticsScope<'_>,
traits_in_scope: &FxHashSet<TraitId>,
with_local_impls: Option<Module>,
name: Option<&Name>,
@ -3119,7 +3119,7 @@ impl Type {
fn iterate_path_candidates_dyn(
&self,
db: &dyn HirDatabase,
scope: &SemanticsScope,
scope: &SemanticsScope<'_>,
traits_in_scope: &FxHashSet<TraitId>,
with_local_impls: Option<Module>,
name: Option<&Name>,

View File

@ -124,7 +124,7 @@ impl<DB> fmt::Debug for Semantics<'_, DB> {
}
impl<'db, DB: HirDatabase> Semantics<'db, DB> {
pub fn new(db: &DB) -> Semantics<DB> {
pub fn new(db: &DB) -> Semantics<'_, DB> {
let impl_ = SemanticsImpl::new(db);
Semantics { db, imp: impl_ }
}
@ -1056,7 +1056,7 @@ impl<'db> SemanticsImpl<'db> {
.unwrap_or_default()
}
fn with_ctx<F: FnOnce(&mut SourceToDefCtx) -> T, T>(&self, f: F) -> T {
fn with_ctx<F: FnOnce(&mut SourceToDefCtx<'_, '_>) -> T, T>(&self, f: F) -> T {
let mut cache = self.s2d_cache.borrow_mut();
let mut ctx = SourceToDefCtx { db: self.db, cache: &mut *cache };
f(&mut ctx)
@ -1280,7 +1280,7 @@ impl<'db> SemanticsImpl<'db> {
}
fn macro_call_to_macro_id(
ctx: &mut SourceToDefCtx,
ctx: &mut SourceToDefCtx<'_, '_>,
db: &dyn AstDatabase,
macro_call_id: MacroCallId,
) -> Option<MacroId> {
@ -1302,14 +1302,14 @@ fn macro_call_to_macro_id(
pub trait ToDef: AstNode + Clone {
type Def;
fn to_def(sema: &SemanticsImpl, src: InFile<Self>) -> Option<Self::Def>;
fn to_def(sema: &SemanticsImpl<'_>, src: InFile<Self>) -> Option<Self::Def>;
}
macro_rules! to_def_impls {
($(($def:path, $ast:path, $meth:ident)),* ,) => {$(
impl ToDef for $ast {
type Def = $def;
fn to_def(sema: &SemanticsImpl, src: InFile<Self>) -> Option<Self::Def> {
fn to_def(sema: &SemanticsImpl<'_>, src: InFile<Self>) -> Option<Self::Def> {
sema.with_ctx(|ctx| ctx.$meth(src)).map(<$def>::from)
}
}

View File

@ -32,7 +32,7 @@ pub struct DeclarationLocation {
}
impl DeclarationLocation {
pub fn syntax<DB: HirDatabase>(&self, sema: &Semantics<DB>) -> Option<SyntaxNode> {
pub fn syntax<DB: HirDatabase>(&self, sema: &Semantics<'_, DB>) -> Option<SyntaxNode> {
let root = sema.parse_or_expand(self.hir_file_id)?;
Some(self.ptr.to_node(&root))
}

View File

@ -144,7 +144,7 @@ pub(crate) struct Assists {
}
impl Assists {
pub(crate) fn new(ctx: &AssistContext, resolve: AssistResolveStrategy) -> Assists {
pub(crate) fn new(ctx: &AssistContext<'_>, resolve: AssistResolveStrategy) -> Assists {
Assists {
resolve,
file: ctx.frange.file_id,

View File

@ -19,7 +19,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// let x: i32 = 92;
// }
// ```
pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let (ascribed_ty, expr, pat) = if let Some(let_stmt) = ctx.find_node_at_offset::<LetStmt>() {
let cursor_in_range = {
let eq_range = let_stmt.eq_token()?.text_range();

View File

@ -27,7 +27,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// }
// }
// ```
pub(crate) fn add_label_to_loop(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn add_label_to_loop(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let loop_kw = ctx.find_token_syntax_at_offset(T![loop])?;
let loop_expr = loop_kw.parent().and_then(ast::LoopExpr::cast)?;
if loop_expr.label().is_some() {

View File

@ -19,7 +19,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// y: u32,
// }
// ```
pub(crate) fn add_lifetime_to_type(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn add_lifetime_to_type(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let ref_type_focused = ctx.find_node_at_offset::<ast::RefType>()?;
if ref_type_focused.lifetime().is_some() {
return None;

View File

@ -44,7 +44,7 @@ use crate::{
// }
// }
// ```
pub(crate) fn add_missing_impl_members(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn add_missing_impl_members(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
add_missing_impl_members_inner(
acc,
ctx,
@ -85,7 +85,7 @@ pub(crate) fn add_missing_impl_members(acc: &mut Assists, ctx: &AssistContext) -
// $0fn bar(&self) {}
// }
// ```
pub(crate) fn add_missing_default_members(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn add_missing_default_members(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
add_missing_impl_members_inner(
acc,
ctx,
@ -97,7 +97,7 @@ pub(crate) fn add_missing_default_members(acc: &mut Assists, ctx: &AssistContext
fn add_missing_impl_members_inner(
acc: &mut Assists,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
mode: DefaultMethods,
assist_id: &'static str,
label: &'static str,
@ -164,7 +164,7 @@ fn add_missing_impl_members_inner(
}
fn try_gen_trait_body(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
func: &ast::Fn,
trait_: &hir::Trait,
impl_def: &ast::Impl,

View File

@ -36,7 +36,7 @@ use crate::{
// }
// }
// ```
pub(crate) fn add_missing_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn add_missing_match_arms(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let match_expr = ctx.find_node_at_offset_with_descend::<ast::MatchExpr>()?;
let match_arm_list = match_expr.match_arm_list()?;
let target_range = ctx.sema.original_range(match_expr.syntax()).range;
@ -221,7 +221,7 @@ pub(crate) fn add_missing_match_arms(acc: &mut Assists, ctx: &AssistContext) ->
}
fn cursor_at_trivial_match_arm_list(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
match_expr: &MatchExpr,
match_arm_list: &MatchArmList,
) -> Option<()> {
@ -321,7 +321,7 @@ impl ExtendedEnum {
}
}
fn resolve_enum_def(sema: &Semantics<RootDatabase>, expr: &ast::Expr) -> Option<ExtendedEnum> {
fn resolve_enum_def(sema: &Semantics<'_, RootDatabase>, expr: &ast::Expr) -> Option<ExtendedEnum> {
sema.type_of_expr(expr)?.adjusted().autoderef(sema.db).find_map(|ty| match ty.as_adt() {
Some(Adt::Enum(e)) => Some(ExtendedEnum::Enum(e)),
_ => ty.is_bool().then(|| ExtendedEnum::Bool),
@ -329,7 +329,7 @@ fn resolve_enum_def(sema: &Semantics<RootDatabase>, expr: &ast::Expr) -> Option<
}
fn resolve_tuple_of_enum_def(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
expr: &ast::Expr,
) -> Option<Vec<ExtendedEnum>> {
sema.type_of_expr(expr)?

View File

@ -15,7 +15,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// ```
// fn foo() -> i32 { 42i32 }
// ```
pub(crate) fn add_return_type(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn add_return_type(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let (fn_type, tail_expr, builder_edit_pos) = extract_tail(ctx)?;
let module = ctx.sema.scope(tail_expr.syntax())?.module();
let ty = ctx.sema.type_of_expr(&peel_blocks(tail_expr.clone()))?.original();
@ -132,7 +132,7 @@ fn peel_blocks(mut expr: ast::Expr) -> ast::Expr {
expr
}
fn extract_tail(ctx: &AssistContext) -> Option<(FnType, ast::Expr, InsertOrReplace)> {
fn extract_tail(ctx: &AssistContext<'_>) -> Option<(FnType, ast::Expr, InsertOrReplace)> {
let (fn_type, tail_expr, return_type_range, action) =
if let Some(closure) = ctx.find_node_at_offset::<ast::ClosureExpr>() {
let rpipe = closure.param_list()?.syntax().last_token()?;

View File

@ -24,7 +24,7 @@ use crate::{
// let x = make::<${0:_}>();
// }
// ```
pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let ident = ctx.find_token_syntax_at_offset(SyntaxKind::IDENT).or_else(|| {
let arg_list = ctx.find_node_at_offset::<ast::ArgList>()?;
if arg_list.args().next().is_some() {

View File

@ -22,7 +22,7 @@ use crate::{utils::invert_boolean_expression, AssistContext, AssistId, AssistKin
// if !(x == 4 && y >= 3.14) {}
// }
// ```
pub(crate) fn apply_demorgan(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn apply_demorgan(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let expr = ctx.find_node_at_offset::<ast::BinExpr>()?;
let op = expr.op_kind()?;
let op_range = expr.op_token()?.text_range();

View File

@ -87,7 +87,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists, GroupLabel};
// }
// # pub mod std { pub mod collections { pub struct HashMap { } } }
// ```
pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let (import_assets, syntax_under_caret) = find_importable_node(ctx)?;
let mut proposed_imports =
import_assets.search_for_imports(&ctx.sema, ctx.config.insert_use.prefix_kind);
@ -142,7 +142,7 @@ pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
Some(())
}
pub(super) fn find_importable_node(ctx: &AssistContext) -> Option<(ImportAssets, SyntaxElement)> {
pub(super) fn find_importable_node(ctx: &AssistContext<'_>) -> Option<(ImportAssets, SyntaxElement)> {
if let Some(path_under_caret) = ctx.find_node_at_offset_with_descend::<ast::Path>() {
ImportAssets::for_exact_path(&path_under_caret, &ctx.sema)
.zip(Some(path_under_caret.syntax().clone().into()))
@ -177,7 +177,7 @@ fn group_label(import_candidate: &ImportCandidate) -> GroupLabel {
/// Determine how relevant a given import is in the current context. Higher scores are more
/// relevant.
fn relevance_score(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
import: &LocatedImport,
current_module: Option<&Module>,
) -> i32 {

View File

@ -20,14 +20,14 @@ use crate::{utils::vis_offset, AssistContext, AssistId, AssistKind, Assists};
// ```
// pub(crate) fn frobnicate() {}
// ```
pub(crate) fn change_visibility(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn change_visibility(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
if let Some(vis) = ctx.find_node_at_offset::<ast::Visibility>() {
return change_vis(acc, vis);
}
add_vis(acc, ctx)
}
fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
fn add_vis(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let item_keyword = ctx.token_at_offset().find(|leaf| {
matches!(
leaf.kind(),

View File

@ -37,7 +37,7 @@ use crate::{
// cond.then(|| val)
// }
// ```
pub(crate) fn convert_if_to_bool_then(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn convert_if_to_bool_then(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
// FIXME applies to match as well
let expr = ctx.find_node_at_offset::<ast::IfExpr>()?;
if !expr.if_token()?.text_range().contains_inclusive(ctx.offset()) {
@ -149,7 +149,7 @@ pub(crate) fn convert_if_to_bool_then(acc: &mut Assists, ctx: &AssistContext) ->
// }
// }
// ```
pub(crate) fn convert_bool_then_to_if(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn convert_bool_then_to_if(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let name_ref = ctx.find_node_at_offset::<ast::NameRef>()?;
let mcall = name_ref.syntax().parent().and_then(ast::MethodCallExpr::cast)?;
let receiver = mcall.receiver()?;
@ -219,7 +219,7 @@ pub(crate) fn convert_bool_then_to_if(acc: &mut Assists, ctx: &AssistContext) ->
}
fn option_variants(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
expr: &SyntaxNode,
) -> Option<(hir::Variant, hir::Variant)> {
let fam = FamousDefs(sema, sema.scope(expr)?.krate());
@ -237,7 +237,7 @@ fn option_variants(
/// Traverses the expression checking if it contains `return` or `?` expressions or if any tail is not a `Some(expr)` expression.
/// If any of these conditions are met it is impossible to rewrite this as a `bool::then` call.
fn is_invalid_body(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
some_variant: hir::Variant,
expr: &ast::Expr,
) -> bool {
@ -272,7 +272,7 @@ fn is_invalid_body(
}
fn block_is_none_variant(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
block: &ast::BlockExpr,
none_variant: hir::Variant,
) -> bool {

View File

@ -21,7 +21,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// comment
// */
// ```
pub(crate) fn convert_comment_block(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn convert_comment_block(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let comment = ctx.find_token_at_offset::<ast::Comment>()?;
// Only allow comments which are alone on their line
if let Some(prev) = comment.syntax().prev_token() {

View File

@ -13,7 +13,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists, GroupLabel};
// ```
// const _: i32 = 0b1010;
// ```
pub(crate) fn convert_integer_literal(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn convert_integer_literal(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let literal = ctx.find_node_at_offset::<ast::Literal>()?;
let literal = match literal.kind() {
ast::LiteralKind::IntNumber(it) => it,

View File

@ -31,7 +31,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// }
// }
// ```
pub(crate) fn convert_into_to_from(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn convert_into_to_from(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let impl_ = ctx.find_node_at_offset::<ast::Impl>()?;
let src_type = impl_.self_ty()?;
let ast_trait = impl_.trait_()?;

View File

@ -32,7 +32,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// }
// }
// ```
pub(crate) fn convert_iter_for_each_to_for(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn convert_iter_for_each_to_for(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let method = ctx.find_node_at_offset::<ast::MethodCallExpr>()?;
let closure = match method.arg_list()?.args().next()? {
@ -91,7 +91,7 @@ pub(crate) fn convert_iter_for_each_to_for(acc: &mut Assists, ctx: &AssistContex
// });
// }
// ```
pub(crate) fn convert_for_loop_with_for_each(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn convert_for_loop_with_for_each(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let for_loop = ctx.find_node_at_offset::<ast::ForExpr>()?;
let iterable = for_loop.iterable()?;
let pat = for_loop.pat()?;
@ -136,7 +136,7 @@ pub(crate) fn convert_for_loop_with_for_each(acc: &mut Assists, ctx: &AssistCont
/// returning an Iterator called iter or iter_mut (depending on the type of reference) then return
/// the expression behind the reference and the method name
fn is_ref_and_impls_iter_method(
sema: &hir::Semantics<ide_db::RootDatabase>,
sema: &hir::Semantics<'_, ide_db::RootDatabase>,
iterable: &ast::Expr,
) -> Option<(ast::Expr, hir::Name)> {
let ref_expr = match iterable {
@ -173,7 +173,7 @@ fn is_ref_and_impls_iter_method(
}
/// Whether iterable implements core::Iterator
fn impls_core_iter(sema: &hir::Semantics<ide_db::RootDatabase>, iterable: &ast::Expr) -> bool {
fn impls_core_iter(sema: &hir::Semantics<'_, ide_db::RootDatabase>, iterable: &ast::Expr) -> bool {
(|| {
let it_typ = sema.type_of_expr(iterable)?.adjusted();
@ -188,7 +188,7 @@ fn impls_core_iter(sema: &hir::Semantics<ide_db::RootDatabase>, iterable: &ast::
}
fn validate_method_call_expr(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
expr: ast::MethodCallExpr,
) -> Option<(ast::Expr, ast::Expr)> {
let name_ref = expr.name_ref()?;

View File

@ -9,7 +9,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
fn binders_in_pat(
acc: &mut Vec<(Name, bool)>,
pat: &Pat,
sem: &Semantics<RootDatabase>,
sem: &Semantics<'_, RootDatabase>,
) -> Option<()> {
use Pat::*;
match pat {
@ -115,7 +115,7 @@ fn binders_to_str(binders: &[(Name, bool)], addmut: bool) -> String {
// };
// }
// ```
pub(crate) fn convert_let_else_to_match(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn convert_let_else_to_match(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
// should focus on else token to trigger
let else_token = ctx.find_token_syntax_at_offset(T![else])?;
let let_stmt = LetStmt::cast(else_token.parent()?.parent()?)?;

View File

@ -40,7 +40,7 @@ use crate::{
// bar();
// }
// ```
pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let if_expr: ast::IfExpr = ctx.find_node_at_offset()?;
if if_expr.else_branch().is_some() {
return None;

View File

@ -48,7 +48,7 @@ use crate::{assist_context::AssistBuilder, AssistContext, AssistId, AssistKind,
// ```
pub(crate) fn convert_tuple_struct_to_named_struct(
acc: &mut Assists,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
) -> Option<()> {
let strukt = ctx
.find_node_at_offset::<ast::Struct>()
@ -79,7 +79,7 @@ pub(crate) fn convert_tuple_struct_to_named_struct(
}
fn edit_struct_def(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
edit: &mut AssistBuilder,
strukt: &Either<ast::Struct, ast::Variant>,
tuple_fields: ast::TupleFieldList,
@ -121,7 +121,7 @@ fn edit_struct_def(
}
fn edit_struct_references(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
edit: &mut AssistBuilder,
strukt: Either<hir::Struct, hir::Variant>,
names: &[ast::Name],
@ -202,7 +202,7 @@ fn edit_struct_references(
}
fn edit_field_references(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
edit: &mut AssistBuilder,
fields: impl Iterator<Item = ast::TupleField>,
names: &[ast::Name],

View File

@ -38,7 +38,7 @@ use crate::{
// }
// }
// ```
pub(crate) fn convert_while_to_loop(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn convert_while_to_loop(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let while_kw = ctx.find_token_syntax_at_offset(T![while])?;
let while_expr = while_kw.parent().and_then(ast::WhileExpr::cast)?;
let while_body = while_expr.loop_body()?;

View File

@ -27,7 +27,7 @@ use crate::assist_context::{AssistBuilder, AssistContext, Assists};
// let v = _0;
// }
// ```
pub(crate) fn destructure_tuple_binding(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn destructure_tuple_binding(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
destructure_tuple_binding_impl(acc, ctx, false)
}
@ -51,7 +51,7 @@ pub(crate) fn destructure_tuple_binding(acc: &mut Assists, ctx: &AssistContext)
// ```
pub(crate) fn destructure_tuple_binding_impl(
acc: &mut Assists,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
with_sub_pattern: bool,
) -> Option<()> {
let ident_pat = ctx.find_node_at_offset::<ast::IdentPat>()?;
@ -82,7 +82,7 @@ pub(crate) fn destructure_tuple_binding_impl(
Some(())
}
fn collect_data(ident_pat: IdentPat, ctx: &AssistContext) -> Option<TupleData> {
fn collect_data(ident_pat: IdentPat, ctx: &AssistContext<'_>) -> Option<TupleData> {
if ident_pat.at_token().is_some() {
// Cannot destructure pattern with sub-pattern:
// Only IdentPat can have sub-pattern,
@ -126,7 +126,7 @@ fn collect_data(ident_pat: IdentPat, ctx: &AssistContext) -> Option<TupleData> {
}
fn generate_name(
_ctx: &AssistContext,
_ctx: &AssistContext<'_>,
index: usize,
_tuple_name: &str,
_ident_pat: &IdentPat,
@ -150,7 +150,7 @@ struct TupleData {
usages: Option<UsageSearchResult>,
}
fn edit_tuple_assignment(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
builder: &mut AssistBuilder,
data: &TupleData,
in_sub_pattern: bool,
@ -196,7 +196,7 @@ fn edit_tuple_assignment(
fn edit_tuple_usages(
data: &TupleData,
builder: &mut AssistBuilder,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
in_sub_pattern: bool,
) {
if let Some(usages) = data.usages.as_ref() {
@ -210,7 +210,7 @@ fn edit_tuple_usages(
}
}
fn edit_tuple_usage(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
builder: &mut AssistBuilder,
usage: &FileReference,
data: &TupleData,
@ -238,7 +238,7 @@ fn edit_tuple_usage(
}
fn edit_tuple_field_usage(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
builder: &mut AssistBuilder,
data: &TupleData,
index: TupleIndex,
@ -321,7 +321,7 @@ impl RefData {
}
}
}
fn handle_ref_field_usage(ctx: &AssistContext, field_expr: &FieldExpr) -> RefData {
fn handle_ref_field_usage(ctx: &AssistContext<'_>, field_expr: &FieldExpr) -> RefData {
let s = field_expr.syntax();
let mut ref_data =
RefData { range: s.text_range(), needs_deref: true, needs_parentheses: true };
@ -368,8 +368,8 @@ fn handle_ref_field_usage(ctx: &AssistContext, field_expr: &FieldExpr) -> RefDat
// other combinations (`&value` -> `value`, `&&value` -> `&value`, `&value` -> `&&value`) might or might not be able to auto-ref/deref,
// but there might be trait implementations an added `&` might resolve to
// -> ONLY handle auto-ref from `value` to `&value`
fn is_auto_ref(ctx: &AssistContext, call_expr: &MethodCallExpr) -> bool {
fn impl_(ctx: &AssistContext, call_expr: &MethodCallExpr) -> Option<bool> {
fn is_auto_ref(ctx: &AssistContext<'_>, call_expr: &MethodCallExpr) -> bool {
fn impl_(ctx: &AssistContext<'_>, call_expr: &MethodCallExpr) -> Option<bool> {
let rec = call_expr.receiver()?;
let rec_ty = ctx.sema.type_of_expr(&rec)?.original();
// input must be actual value
@ -426,7 +426,7 @@ mod tests {
// Tests for direct tuple destructure:
// `let $0t = (1,2);` -> `let (_0, _1) = (1,2);`
fn assist(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
fn assist(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
destructure_tuple_binding_impl(acc, ctx, false)
}
@ -1191,10 +1191,10 @@ fn main {
use super::*;
use crate::tests::check_assist_by_label;
fn assist(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
fn assist(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
destructure_tuple_binding_impl(acc, ctx, true)
}
fn in_place_assist(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
fn in_place_assist(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
destructure_tuple_binding_impl(acc, ctx, false)
}
@ -1256,7 +1256,7 @@ fn main() {
#[test]
fn trigger_both_destructure_tuple_assists() {
fn assist(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
fn assist(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
destructure_tuple_binding_impl(acc, ctx, true)
}
let text = r#"

View File

@ -40,7 +40,7 @@ use crate::{
//
// fn qux(bar: Bar, baz: Baz) {}
// ```
pub(crate) fn expand_glob_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn expand_glob_import(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let star = ctx.find_token_syntax_at_offset(T![*])?;
let use_tree = star.parent().and_then(ast::UseTree::cast)?;
let (parent, mod_path) = find_parent_and_path(&star)?;
@ -112,7 +112,7 @@ fn find_parent_and_path(
}
}
fn def_is_referenced_in(def: Definition, ctx: &AssistContext) -> bool {
fn def_is_referenced_in(def: Definition, ctx: &AssistContext<'_>) -> bool {
let search_scope = SearchScope::single_file(ctx.file_id());
def.usages(&ctx.sema).in_scope(search_scope).at_least_one()
}
@ -139,7 +139,7 @@ impl Ref {
struct Refs(Vec<Ref>);
impl Refs {
fn used_refs(&self, ctx: &AssistContext) -> Refs {
fn used_refs(&self, ctx: &AssistContext<'_>) -> Refs {
Refs(
self.0
.clone()
@ -168,7 +168,7 @@ impl Refs {
}
}
fn find_refs_in_mod(ctx: &AssistContext, module: Module, visible_from: Module) -> Option<Refs> {
fn find_refs_in_mod(ctx: &AssistContext<'_>, module: Module, visible_from: Module) -> Option<Refs> {
if !is_mod_visible_from(ctx, module, visible_from) {
return None;
}
@ -178,7 +178,7 @@ fn find_refs_in_mod(ctx: &AssistContext, module: Module, visible_from: Module) -
Some(Refs(refs))
}
fn is_mod_visible_from(ctx: &AssistContext, module: Module, from: Module) -> bool {
fn is_mod_visible_from(ctx: &AssistContext<'_>, module: Module, from: Module) -> bool {
match module.parent(ctx.db()) {
Some(parent) => {
module.visibility(ctx.db()).is_visible_from(ctx.db(), from.into())
@ -202,7 +202,7 @@ fn is_mod_visible_from(ctx: &AssistContext, module: Module, from: Module) -> boo
// use foo::*$0;
// use baz::Baz;
// ↑ ---------------
fn find_imported_defs(ctx: &AssistContext, star: SyntaxToken) -> Option<Vec<Definition>> {
fn find_imported_defs(ctx: &AssistContext<'_>, star: SyntaxToken) -> Option<Vec<Definition>> {
let parent_use_item_syntax = star.parent_ancestors().find_map(|n| {
if ast::Use::can_cast(n.kind()) {
Some(n)
@ -239,7 +239,7 @@ fn find_imported_defs(ctx: &AssistContext, star: SyntaxToken) -> Option<Vec<Defi
}
fn find_names_to_import(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
refs_in_target: Refs,
imported_defs: Vec<Definition>,
) -> Vec<Name> {

View File

@ -60,7 +60,7 @@ use crate::{
// let k = m + n;
// }
// ```
pub(crate) fn extract_function(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn extract_function(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let range = ctx.selection_trimmed();
if range.is_empty() {
return None;
@ -170,7 +170,7 @@ pub(crate) fn extract_function(acc: &mut Assists, ctx: &AssistContext) -> Option
)
}
fn make_function_name(semantics_scope: &hir::SemanticsScope) -> ast::NameRef {
fn make_function_name(semantics_scope: &hir::SemanticsScope<'_>) -> ast::NameRef {
let mut names_in_scope = vec![];
semantics_scope.process_all_names(&mut |name, _| names_in_scope.push(name.to_string()));
@ -366,7 +366,7 @@ struct OutlivedLocal {
struct LocalUsages(ide_db::search::UsageSearchResult);
impl LocalUsages {
fn find_local_usages(ctx: &AssistContext, var: Local) -> Self {
fn find_local_usages(ctx: &AssistContext<'_>, var: Local) -> Self {
Self(
Definition::Local(var)
.usages(&ctx.sema)
@ -381,7 +381,7 @@ impl LocalUsages {
}
impl Function {
fn return_type(&self, ctx: &AssistContext) -> FunType {
fn return_type(&self, ctx: &AssistContext<'_>) -> FunType {
match &self.ret_ty {
RetType::Expr(ty) if ty.is_unit() => FunType::Unit,
RetType::Expr(ty) => FunType::Single(ty.clone()),
@ -396,7 +396,7 @@ impl Function {
}
}
fn self_param_adt(&self, ctx: &AssistContext) -> Option<ast::Adt> {
fn self_param_adt(&self, ctx: &AssistContext<'_>) -> Option<ast::Adt> {
let self_param = self.self_param.as_ref()?;
let def = ctx.sema.to_def(self_param)?;
let adt = def.ty(ctx.db()).strip_references().as_adt()?;
@ -421,7 +421,7 @@ impl Param {
}
}
fn to_arg(&self, ctx: &AssistContext) -> ast::Expr {
fn to_arg(&self, ctx: &AssistContext<'_>) -> ast::Expr {
let var = path_expr_from_local(ctx, self.var);
match self.kind() {
ParamKind::Value | ParamKind::MutValue => var,
@ -430,7 +430,7 @@ impl Param {
}
}
fn to_param(&self, ctx: &AssistContext, module: hir::Module) -> ast::Param {
fn to_param(&self, ctx: &AssistContext<'_>, module: hir::Module) -> ast::Param {
let var = self.var.name(ctx.db()).to_string();
let var_name = make::name(&var);
let pat = match self.kind() {
@ -452,7 +452,7 @@ impl Param {
}
impl TryKind {
fn of_ty(ty: hir::Type, ctx: &AssistContext) -> Option<TryKind> {
fn of_ty(ty: hir::Type, ctx: &AssistContext<'_>) -> Option<TryKind> {
if ty.is_unknown() {
// We favour Result for `expr?`
return Some(TryKind::Result { ty });
@ -485,7 +485,7 @@ impl FlowKind {
}
}
fn expr_ty(&self, ctx: &AssistContext) -> Option<hir::Type> {
fn expr_ty(&self, ctx: &AssistContext<'_>) -> Option<hir::Type> {
match self {
FlowKind::Return(Some(expr)) | FlowKind::Break(_, Some(expr)) => {
ctx.sema.type_of_expr(expr).map(TypeInfo::adjusted)
@ -691,7 +691,7 @@ impl FunctionBody {
/// whether it contains an await expression.
fn analyze(
&self,
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
) -> (FxIndexSet<Local>, Option<ast::SelfParam>) {
let mut self_param = None;
let mut res = FxIndexSet::default();
@ -741,7 +741,7 @@ impl FunctionBody {
(res, self_param)
}
fn analyze_container(&self, sema: &Semantics<RootDatabase>) -> Option<ContainerInfo> {
fn analyze_container(&self, sema: &Semantics<'_, RootDatabase>) -> Option<ContainerInfo> {
let mut ancestors = self.parent()?.ancestors();
let infer_expr_opt = |expr| sema.type_of_expr(&expr?).map(TypeInfo::adjusted);
let mut parent_loop = None;
@ -837,7 +837,7 @@ impl FunctionBody {
})
}
fn return_ty(&self, ctx: &AssistContext) -> Option<RetType> {
fn return_ty(&self, ctx: &AssistContext<'_>) -> Option<RetType> {
match self.tail_expr() {
Some(expr) => ctx.sema.type_of_expr(&expr).map(TypeInfo::original).map(RetType::Expr),
None => Some(RetType::Stmt),
@ -847,7 +847,7 @@ impl FunctionBody {
/// Local variables defined inside `body` that are accessed outside of it
fn ret_values<'a>(
&self,
ctx: &'a AssistContext,
ctx: &'a AssistContext<'_>,
parent: &SyntaxNode,
) -> impl Iterator<Item = OutlivedLocal> + 'a {
let parent = parent.clone();
@ -860,7 +860,7 @@ impl FunctionBody {
/// Analyses the function body for external control flow.
fn external_control_flow(
&self,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
container_info: &ContainerInfo,
) -> Option<ControlFlow> {
let mut ret_expr = None;
@ -950,7 +950,7 @@ impl FunctionBody {
/// Computes additional info that affects param type and mutability
fn extracted_function_params(
&self,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
container_info: &ContainerInfo,
locals: impl Iterator<Item = Local>,
) -> Vec<Param> {
@ -1042,7 +1042,7 @@ fn generic_parents(parent: &SyntaxNode) -> Vec<GenericParent> {
}
/// checks if relevant var is used with `&mut` access inside body
fn has_exclusive_usages(ctx: &AssistContext, usages: &LocalUsages, body: &FunctionBody) -> bool {
fn has_exclusive_usages(ctx: &AssistContext<'_>, usages: &LocalUsages, body: &FunctionBody) -> bool {
usages
.iter()
.filter(|reference| body.contains_range(reference.range))
@ -1053,7 +1053,7 @@ fn has_exclusive_usages(ctx: &AssistContext, usages: &LocalUsages, body: &Functi
fn reference_is_exclusive(
reference: &FileReference,
node: &dyn HasTokenAtOffset,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
) -> bool {
// we directly modify variable with set: `n = 0`, `n += 1`
if reference.category == Some(ReferenceCategory::Write) {
@ -1070,7 +1070,7 @@ fn reference_is_exclusive(
}
/// checks if this expr requires `&mut` access, recurses on field access
fn expr_require_exclusive_access(ctx: &AssistContext, expr: &ast::Expr) -> Option<bool> {
fn expr_require_exclusive_access(ctx: &AssistContext<'_>, expr: &ast::Expr) -> Option<bool> {
if let ast::Expr::MacroExpr(_) = expr {
// FIXME: expand macro and check output for mutable usages of the variable?
return None;
@ -1172,7 +1172,7 @@ fn path_element_of_reference(
/// list local variables defined inside `body`
fn locals_defined_in_body(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
body: &FunctionBody,
) -> FxIndexSet<Local> {
// FIXME: this doesn't work well with macros
@ -1190,7 +1190,7 @@ fn locals_defined_in_body(
/// Returns usage details if local variable is used after(outside of) body
fn local_outlives_body(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
body_range: TextRange,
local: Local,
parent: &SyntaxNode,
@ -1215,7 +1215,7 @@ fn local_outlives_body(
/// checks if the relevant local was defined before(outside of) body
fn is_defined_outside_of_body(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
body: &FunctionBody,
src: &hir::InFile<Either<ast::IdentPat, ast::SelfParam>>,
) -> bool {
@ -1260,7 +1260,7 @@ fn node_to_insert_after(body: &FunctionBody, anchor: Anchor) -> Option<SyntaxNod
last_ancestor
}
fn make_call(ctx: &AssistContext, fun: &Function, indent: IndentLevel) -> String {
fn make_call(ctx: &AssistContext<'_>, fun: &Function, indent: IndentLevel) -> String {
let ret_ty = fun.return_type(ctx);
let args = make::arg_list(fun.params.iter().map(|param| param.to_arg(ctx)));
@ -1429,13 +1429,13 @@ impl FlowHandler {
}
}
fn path_expr_from_local(ctx: &AssistContext, var: Local) -> ast::Expr {
fn path_expr_from_local(ctx: &AssistContext<'_>, var: Local) -> ast::Expr {
let name = var.name(ctx.db()).to_string();
make::expr_path(make::ext::ident_path(&name))
}
fn format_function(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
module: hir::Module,
fun: &Function,
old_indent: IndentLevel,
@ -1490,7 +1490,7 @@ fn format_function(
}
fn make_generic_params_and_where_clause(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
fun: &Function,
) -> (Option<ast::GenericParamList>, Option<ast::WhereClause>) {
let used_type_params = fun.type_params(ctx);
@ -1502,7 +1502,7 @@ fn make_generic_params_and_where_clause(
}
fn make_generic_param_list(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
fun: &Function,
used_type_params: &[TypeParam],
) -> Option<ast::GenericParamList> {
@ -1525,7 +1525,7 @@ fn make_generic_param_list(
}
fn param_is_required(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
param: &ast::GenericParam,
used_type_params: &[TypeParam],
) -> bool {
@ -1539,7 +1539,7 @@ fn param_is_required(
}
fn make_where_clause(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
fun: &Function,
used_type_params: &[TypeParam],
) -> Option<ast::WhereClause> {
@ -1562,7 +1562,7 @@ fn make_where_clause(
}
fn pred_is_required(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
pred: &ast::WherePred,
used_type_params: &[TypeParam],
) -> bool {
@ -1572,7 +1572,7 @@ fn pred_is_required(
}
}
fn resolved_type_param(ctx: &AssistContext, pred: &ast::WherePred) -> Option<TypeParam> {
fn resolved_type_param(ctx: &AssistContext<'_>, pred: &ast::WherePred) -> Option<TypeParam> {
let path = match pred.ty()? {
ast::Type::PathType(path_type) => path_type.path(),
_ => None,
@ -1586,7 +1586,7 @@ fn resolved_type_param(ctx: &AssistContext, pred: &ast::WherePred) -> Option<Typ
impl Function {
/// Collect all the `TypeParam`s used in the `body` and `params`.
fn type_params(&self, ctx: &AssistContext) -> Vec<TypeParam> {
fn type_params(&self, ctx: &AssistContext<'_>) -> Vec<TypeParam> {
let type_params_in_descendant_paths =
self.body.descendant_paths().filter_map(|it| match ctx.sema.resolve_path(&it) {
Some(PathResolution::TypeParam(type_param)) => Some(type_param),
@ -1596,13 +1596,13 @@ impl Function {
type_params_in_descendant_paths.chain(type_params_in_params).collect()
}
fn make_param_list(&self, ctx: &AssistContext, module: hir::Module) -> ast::ParamList {
fn make_param_list(&self, ctx: &AssistContext<'_>, module: hir::Module) -> ast::ParamList {
let self_param = self.self_param.clone();
let params = self.params.iter().map(|param| param.to_param(ctx, module));
make::param_list(self_param, params)
}
fn make_ret_ty(&self, ctx: &AssistContext, module: hir::Module) -> Option<ast::RetType> {
fn make_ret_ty(&self, ctx: &AssistContext<'_>, module: hir::Module) -> Option<ast::RetType> {
let fun_ty = self.return_type(ctx);
let handler = if self.mods.is_in_tail {
FlowHandler::None
@ -1649,7 +1649,7 @@ impl Function {
}
impl FunType {
fn make_ty(&self, ctx: &AssistContext, module: hir::Module) -> ast::Type {
fn make_ty(&self, ctx: &AssistContext<'_>, module: hir::Module) -> ast::Type {
match self {
FunType::Unit => make::ty_unit(),
FunType::Single(ty) => make_ty(ty, ctx, module),
@ -1672,7 +1672,7 @@ impl FunType {
}
fn make_body(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
old_indent: IndentLevel,
new_indent: IndentLevel,
fun: &Function,
@ -1821,17 +1821,17 @@ fn with_tail_expr(block: ast::BlockExpr, tail_expr: ast::Expr) -> ast::BlockExpr
make::block_expr(stmts, Some(tail_expr))
}
fn format_type(ty: &hir::Type, ctx: &AssistContext, module: hir::Module) -> String {
fn format_type(ty: &hir::Type, ctx: &AssistContext<'_>, module: hir::Module) -> String {
ty.display_source_code(ctx.db(), module.into()).ok().unwrap_or_else(|| "_".to_string())
}
fn make_ty(ty: &hir::Type, ctx: &AssistContext, module: hir::Module) -> ast::Type {
fn make_ty(ty: &hir::Type, ctx: &AssistContext<'_>, module: hir::Module) -> ast::Type {
let ty_str = format_type(ty, ctx, module);
make::ty(&ty_str)
}
fn rewrite_body_segment(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
params: &[Param],
handler: &FlowHandler,
syntax: &SyntaxNode,
@ -1842,7 +1842,7 @@ fn rewrite_body_segment(
}
/// change all usages to account for added `&`/`&mut` for some params
fn fix_param_usages(ctx: &AssistContext, params: &[Param], syntax: &SyntaxNode) -> SyntaxNode {
fn fix_param_usages(ctx: &AssistContext<'_>, params: &[Param], syntax: &SyntaxNode) -> SyntaxNode {
let mut usages_for_param: Vec<(&Param, Vec<ast::Expr>)> = Vec::new();
let tm = TreeMutator::new(syntax);

View File

@ -53,7 +53,7 @@ use super::remove_unused_param::range_to_remove;
// name + 2
// }
// ```
pub(crate) fn extract_module(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn extract_module(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
if ctx.has_empty_selection() {
return None;
}
@ -234,7 +234,7 @@ fn extract_target(node: &SyntaxNode, selection_range: TextRange) -> Option<Modul
impl Module {
fn get_usages_and_record_fields(
&self,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
) -> (HashMap<FileId, Vec<(TextRange, String)>>, Vec<SyntaxNode>) {
let mut adt_fields = Vec::new();
let mut refs: HashMap<FileId, Vec<(TextRange, String)>> = HashMap::new();
@ -318,7 +318,7 @@ impl Module {
fn expand_and_group_usages_file_wise(
&self,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
node_def: Definition,
refs_in_files: &mut HashMap<FileId, Vec<(TextRange, String)>>,
) {
@ -396,7 +396,7 @@ impl Module {
fn resolve_imports(
&mut self,
curr_parent_module: Option<ast::Module>,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
) -> Vec<TextRange> {
let mut import_paths_to_be_removed: Vec<TextRange> = vec![];
let mut node_set: HashSet<String> = HashSet::new();
@ -471,7 +471,7 @@ impl Module {
def: Definition,
node_syntax: &SyntaxNode,
curr_parent_module: &Option<ast::Module>,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
) -> Option<TextRange> {
//We only need to find in the current file
let selection_range = ctx.selection_trimmed();
@ -684,7 +684,7 @@ fn check_intersection_and_push(
fn does_source_exists_outside_sel_in_same_mod(
def: Definition,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
curr_parent_module: &Option<ast::Module>,
selection_range: TextRange,
curr_file_id: FileId,
@ -904,7 +904,7 @@ fn add_change_vis(vis: Option<ast::Visibility>, node_or_token_opt: Option<syntax
fn compare_hir_and_ast_module(
ast_module: &ast::Module,
hir_module: hir::Module,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
) -> Option<()> {
let hir_mod_name = hir_module.name(ctx.db())?;
let ast_mod_name = ast_module.name()?;

View File

@ -37,7 +37,7 @@ use crate::{assist_context::AssistBuilder, AssistContext, AssistId, AssistKind,
// ```
pub(crate) fn extract_struct_from_enum_variant(
acc: &mut Assists,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
) -> Option<()> {
let variant = ctx.find_node_at_offset::<ast::Variant>()?;
let field_list = extract_field_list_if_applicable(&variant)?;
@ -373,7 +373,7 @@ fn apply_references(
}
fn process_references(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
builder: &mut AssistBuilder,
visited_modules: &mut FxHashSet<Module>,
enum_module_def: &ModuleDef,
@ -407,7 +407,7 @@ fn process_references(
}
fn reference_to_node(
sema: &hir::Semantics<RootDatabase>,
sema: &hir::Semantics<'_, RootDatabase>,
reference: FileReference,
) -> Option<(ast::PathSegment, SyntaxNode, hir::Module)> {
let segment =

View File

@ -25,7 +25,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// field: Type,
// }
// ```
pub(crate) fn extract_type_alias(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn extract_type_alias(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
if ctx.has_empty_selection() {
return None;
}

View File

@ -27,7 +27,7 @@ use crate::{utils::suggest_name, AssistContext, AssistId, AssistKind, Assists};
// var_name * 4;
// }
// ```
pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
if ctx.has_empty_selection() {
return None;
}
@ -164,7 +164,7 @@ fn valid_target_expr(node: SyntaxNode) -> Option<ast::Expr> {
}
}
fn get_receiver_type(ctx: &AssistContext, expression: &ast::Expr) -> Option<hir::Type> {
fn get_receiver_type(ctx: &AssistContext<'_>, expression: &ast::Expr) -> Option<hir::Type> {
let receiver = get_receiver(expression.clone())?;
Some(ctx.sema.type_of_expr(&receiver)?.original())
}

View File

@ -30,12 +30,12 @@ use crate::{utils::vis_offset, AssistContext, AssistId, AssistKind, Assists};
// m::frobnicate() {}
// }
// ```
pub(crate) fn fix_visibility(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn fix_visibility(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
add_vis_to_referenced_module_def(acc, ctx)
.or_else(|| add_vis_to_referenced_record_field(acc, ctx))
}
fn add_vis_to_referenced_module_def(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
fn add_vis_to_referenced_module_def(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let path: ast::Path = ctx.find_node_at_offset()?;
let path_res = ctx.sema.resolve_path(&path)?;
let def = match path_res {
@ -82,7 +82,7 @@ fn add_vis_to_referenced_module_def(acc: &mut Assists, ctx: &AssistContext) -> O
})
}
fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let record_field: ast::RecordExprField = ctx.find_node_at_offset()?;
let (record_field_def, _, _) = ctx.sema.resolve_record_field(&record_field)?;

View File

@ -17,7 +17,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// let _ = 2 + 90;
// }
// ```
pub(crate) fn flip_binexpr(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn flip_binexpr(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let expr = ctx.find_node_at_offset::<BinExpr>()?;
let lhs = expr.lhs()?.syntax().clone();
let rhs = expr.rhs()?.syntax().clone();

View File

@ -17,7 +17,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// ((3, 4), (1, 2));
// }
// ```
pub(crate) fn flip_comma(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn flip_comma(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let comma = ctx.find_token_syntax_at_offset(T![,])?;
let prev = non_trivia_sibling(comma.clone().into(), Direction::Prev)?;
let next = non_trivia_sibling(comma.clone().into(), Direction::Next)?;

View File

@ -17,7 +17,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// ```
// fn foo<T: Copy + Clone>() { }
// ```
pub(crate) fn flip_trait_bound(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn flip_trait_bound(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
// We want to replicate the behavior of `flip_binexpr` by only suggesting
// the assist when the cursor is on a `+`
let plus = ctx.find_token_syntax_at_offset(T![+])?;

View File

@ -31,7 +31,7 @@ use syntax::{
// }
// ```
pub(crate) fn generate_constant(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn generate_constant(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let constant_token = ctx.find_node_at_offset::<ast::NameRef>()?;
if constant_token.to_string().chars().any(|it| !(it.is_uppercase() || it == '_')) {
cov_mark::hit!(not_constant_name);
@ -113,7 +113,7 @@ fn get_text_for_generate_constant(
}
fn target_data_for_generate_constant(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
current_module: Module,
constant_module: Module,
) -> Option<(TextSize, IndentLevel, Option<FileId>, String)> {

View File

@ -30,7 +30,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// ```
pub(crate) fn generate_default_from_enum_variant(
acc: &mut Assists,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
) -> Option<()> {
let variant = ctx.find_node_at_offset::<ast::Variant>()?;
let variant_name = variant.name()?;

View File

@ -40,7 +40,7 @@ use crate::{
// }
// }
// ```
pub(crate) fn generate_default_from_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn generate_default_from_new(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let fn_node = ctx.find_node_at_offset::<ast::Fn>()?;
let fn_name = fn_node.name()?;
@ -122,7 +122,7 @@ fn generate_trait_impl_text_from_impl(impl_: &ast::Impl, trait_text: &str, code:
buf
}
fn is_default_implemented(ctx: &AssistContext, impl_: &Impl) -> bool {
fn is_default_implemented(ctx: &AssistContext<'_>, impl_: &Impl) -> bool {
let db = ctx.sema.db;
let impl_ = ctx.sema.to_def(impl_);
let impl_def = match impl_ {

View File

@ -42,7 +42,7 @@ use syntax::ast::edit::AstNodeEdit;
// }
// }
// ```
pub(crate) fn generate_delegate_methods(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn generate_delegate_methods(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let strukt = ctx.find_node_at_offset::<ast::Struct>()?;
let strukt_name = strukt.name()?;
let current_module = ctx.sema.scope(strukt.syntax())?.module();

View File

@ -39,11 +39,11 @@ use crate::{
// }
// }
// ```
pub(crate) fn generate_deref(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn generate_deref(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
generate_record_deref(acc, ctx).or_else(|| generate_tuple_deref(acc, ctx))
}
fn generate_record_deref(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
fn generate_record_deref(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let strukt = ctx.find_node_at_offset::<ast::Struct>()?;
let field = ctx.find_node_at_offset::<ast::RecordField>()?;
@ -80,7 +80,7 @@ fn generate_record_deref(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
)
}
fn generate_tuple_deref(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
fn generate_tuple_deref(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let strukt = ctx.find_node_at_offset::<ast::Struct>()?;
let field = ctx.find_node_at_offset::<ast::TupleField>()?;
let field_list = ctx.find_node_at_offset::<ast::TupleFieldList>()?;

View File

@ -24,7 +24,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// y: u32,
// }
// ```
pub(crate) fn generate_derive(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn generate_derive(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let cap = ctx.config.snippet_cap?;
let nominal = ctx.find_node_at_offset::<ast::Adt>()?;
let node_start = derive_insertion_offset(&nominal)?;

View File

@ -42,7 +42,7 @@ use crate::assist_context::{AssistContext, Assists};
// ```
pub(crate) fn generate_documentation_template(
acc: &mut Assists,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
) -> Option<()> {
let name = ctx.find_node_at_offset::<ast::Name>()?;
let ast_func = name.syntax().parent().and_then(ast::Fn::cast)?;
@ -94,7 +94,7 @@ pub(crate) fn generate_documentation_template(
// /// ```
// pub fn add(a: i32, b: i32) -> i32 { a + b }
// ```
pub(crate) fn generate_doc_example(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn generate_doc_example(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let tok: ast::Comment = ctx.find_token_at_offset()?;
let node = tok.syntax().parent()?;
let last_doc_token =
@ -126,7 +126,7 @@ pub(crate) fn generate_doc_example(acc: &mut Assists, ctx: &AssistContext) -> Op
)
}
fn make_example_for_fn(ast_func: &ast::Fn, ctx: &AssistContext) -> Option<String> {
fn make_example_for_fn(ast_func: &ast::Fn, ctx: &AssistContext<'_>) -> Option<String> {
if !is_public(ast_func, ctx)? {
// Doctests for private items can't actually name the item, so they're pretty useless.
return None;
@ -176,7 +176,7 @@ fn make_example_for_fn(ast_func: &ast::Fn, ctx: &AssistContext) -> Option<String
Some(example)
}
fn introduction_builder(ast_func: &ast::Fn, ctx: &AssistContext) -> Option<String> {
fn introduction_builder(ast_func: &ast::Fn, ctx: &AssistContext<'_>) -> Option<String> {
let hir_func = ctx.sema.to_def(ast_func)?;
let container = hir_func.as_assoc_item(ctx.db())?.container(ctx.db());
if let hir::AssocItemContainer::Impl(imp) = container {
@ -270,7 +270,7 @@ fn safety_builder(ast_func: &ast::Fn) -> Option<Vec<String>> {
}
/// Checks if the function is public / exported
fn is_public(ast_func: &ast::Fn, ctx: &AssistContext) -> Option<bool> {
fn is_public(ast_func: &ast::Fn, ctx: &AssistContext<'_>) -> Option<bool> {
let hir_func = ctx.sema.to_def(ast_func)?;
Some(
hir_func.visibility(ctx.db()) == Visibility::Public
@ -279,7 +279,7 @@ fn is_public(ast_func: &ast::Fn, ctx: &AssistContext) -> Option<bool> {
}
/// Checks that all parent modules of the function are public / exported
fn all_parent_mods_public(hir_func: &hir::Function, ctx: &AssistContext) -> bool {
fn all_parent_mods_public(hir_func: &hir::Function, ctx: &AssistContext<'_>) -> bool {
let mut module = hir_func.module(ctx.db());
loop {
if let Some(parent) = module.parent(ctx.db()) {
@ -294,7 +294,7 @@ fn all_parent_mods_public(hir_func: &hir::Function, ctx: &AssistContext) -> bool
}
/// Returns the name of the current crate
fn crate_name(ast_func: &ast::Fn, ctx: &AssistContext) -> Option<String> {
fn crate_name(ast_func: &ast::Fn, ctx: &AssistContext<'_>) -> Option<String> {
let krate = ctx.sema.scope(ast_func.syntax())?.krate();
Some(krate.display_name(ctx.db())?.to_string())
}
@ -351,7 +351,7 @@ fn self_partial_type(ast_func: &ast::Fn) -> Option<String> {
}
/// Helper function to determine if the function is in a trait implementation
fn is_in_trait_impl(ast_func: &ast::Fn, ctx: &AssistContext) -> bool {
fn is_in_trait_impl(ast_func: &ast::Fn, ctx: &AssistContext<'_>) -> bool {
ctx.sema
.to_def(ast_func)
.and_then(|hir_func| hir_func.as_assoc_item(ctx.db()))
@ -360,7 +360,7 @@ fn is_in_trait_impl(ast_func: &ast::Fn, ctx: &AssistContext) -> bool {
}
/// Helper function to determine if the function definition is in a trait definition
fn is_in_trait_def(ast_func: &ast::Fn, ctx: &AssistContext) -> bool {
fn is_in_trait_def(ast_func: &ast::Fn, ctx: &AssistContext<'_>) -> bool {
ctx.sema
.to_def(ast_func)
.and_then(|hir_func| hir_func.as_assoc_item(ctx.db()))
@ -462,7 +462,7 @@ fn string_vec_from(string_array: &[&str]) -> Vec<String> {
}
/// Helper function to build the path of the module in the which is the node
fn build_path(ast_func: &ast::Fn, ctx: &AssistContext) -> Option<String> {
fn build_path(ast_func: &ast::Fn, ctx: &AssistContext<'_>) -> Option<String> {
let crate_name = crate_name(ast_func, ctx)?;
let leaf = self_partial_type(ast_func)
.or_else(|| ast_func.name().map(|n| n.to_string()))
@ -480,7 +480,7 @@ fn return_type(ast_func: &ast::Fn) -> Option<ast::Type> {
}
/// Helper function to determine if the function returns some data
fn returns_a_value(ast_func: &ast::Fn, ctx: &AssistContext) -> bool {
fn returns_a_value(ast_func: &ast::Fn, ctx: &AssistContext<'_>) -> bool {
ctx.sema
.to_def(ast_func)
.map(|hir_func| hir_func.ret_type(ctx.db()))

View File

@ -37,7 +37,7 @@ use crate::{
// }
// }
// ```
pub(crate) fn generate_enum_is_method(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn generate_enum_is_method(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let variant = ctx.find_node_at_offset::<ast::Variant>()?;
let variant_name = variant.name()?;
let parent_enum = ast::Adt::Enum(variant.parent_enum());

View File

@ -36,7 +36,7 @@ use crate::{
// }
// }
// ```
pub(crate) fn generate_enum_try_into_method(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn generate_enum_try_into_method(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
generate_enum_projection_method(
acc,
ctx,
@ -80,7 +80,7 @@ pub(crate) fn generate_enum_try_into_method(acc: &mut Assists, ctx: &AssistConte
// }
// }
// ```
pub(crate) fn generate_enum_as_method(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn generate_enum_as_method(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
generate_enum_projection_method(
acc,
ctx,
@ -108,7 +108,7 @@ struct ProjectionProps {
fn generate_enum_projection_method(
acc: &mut Assists,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
assist_id: &'static str,
assist_description: &str,
props: ProjectionProps,

View File

@ -31,7 +31,7 @@ use crate::assist_context::{AssistContext, Assists};
// let country = Countries::Lesotho;
// }
// ```
pub(crate) fn generate_enum_variant(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn generate_enum_variant(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let path_expr: ast::PathExpr = ctx.find_node_at_offset()?;
let path = path_expr.path()?;
@ -58,7 +58,7 @@ pub(crate) fn generate_enum_variant(acc: &mut Assists, ctx: &AssistContext) -> O
fn add_variant_to_accumulator(
acc: &mut Assists,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
target: syntax::TextRange,
adt: hir::Enum,
name_ref: &ast::NameRef,

View File

@ -20,7 +20,7 @@ use crate::{utils::generate_trait_impl_text, AssistContext, AssistId, AssistKind
// }
// }
// ```
pub(crate) fn generate_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn generate_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let variant = ctx.find_node_at_offset::<ast::Variant>()?;
let variant_name = variant.name()?;
let enum_ = ast::Adt::Enum(variant.parent_enum());

View File

@ -46,11 +46,11 @@ use crate::{
// }
//
// ```
pub(crate) fn generate_function(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn generate_function(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
gen_fn(acc, ctx).or_else(|| gen_method(acc, ctx))
}
fn gen_fn(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
fn gen_fn(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let path_expr: ast::PathExpr = ctx.find_node_at_offset()?;
let call = path_expr.syntax().parent().and_then(ast::CallExpr::cast)?;
let path = path_expr.path()?;
@ -113,7 +113,7 @@ fn gen_fn(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
)
}
fn gen_method(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
fn gen_method(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let call: ast::MethodCallExpr = ctx.find_node_at_offset()?;
if ctx.sema.resolve_method_call(&call).is_some() {
return None;
@ -149,7 +149,7 @@ fn gen_method(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
fn add_func_to_accumulator(
acc: &mut Assists,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
text_range: TextRange,
function_builder: FunctionBuilder,
insert_offset: TextSize,
@ -172,7 +172,7 @@ fn add_func_to_accumulator(
}
fn get_adt_source(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
adt: &hir::Adt,
fn_name: &str,
) -> Option<(Option<ast::Impl>, FileId)> {
@ -229,7 +229,7 @@ impl FunctionBuilder {
/// Prepares a generated function that matches `call`.
/// The function is generated in `target_module` or next to `call`
fn from_call(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
call: &ast::CallExpr,
fn_name: &str,
target_module: Option<hir::Module>,
@ -261,7 +261,7 @@ impl FunctionBuilder {
}
fn from_method_call(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
call: &ast::MethodCallExpr,
name: &ast::NameRef,
target_module: Module,
@ -344,7 +344,7 @@ impl FunctionBuilder {
/// * If we could infer the return type, don't focus it (and thus focus the function body) so the
/// user can change the `todo!` function body.
fn make_return_type(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
call: &ast::Expr,
target_module: Module,
) -> (Option<ast::RetType>, bool) {
@ -367,7 +367,7 @@ fn make_return_type(
}
fn get_fn_target(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
target_module: &Option<Module>,
call: CallExpr,
) -> Option<(GeneratedFunctionTarget, FileId, TextSize)> {
@ -385,7 +385,7 @@ fn get_fn_target(
}
fn get_method_target(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
target_module: &Module,
impl_: &Option<ast::Impl>,
) -> Option<(GeneratedFunctionTarget, TextSize)> {
@ -423,7 +423,7 @@ impl GeneratedFunctionTarget {
/// Computes the type variables and arguments required for the generated function
fn fn_args(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
target_module: hir::Module,
call: ast::CallableExpr,
) -> Option<(Option<ast::GenericParamList>, ast::ParamList)> {
@ -482,7 +482,7 @@ fn deduplicate_arg_names(arg_names: &mut Vec<String>) {
}
}
fn fn_arg_name(sema: &Semantics<RootDatabase>, arg_expr: &ast::Expr) -> String {
fn fn_arg_name(sema: &Semantics<'_, RootDatabase>, arg_expr: &ast::Expr) -> String {
let name = (|| match arg_expr {
ast::Expr::CastExpr(cast_expr) => Some(fn_arg_name(sema, &cast_expr.expr()?)),
expr => {
@ -510,9 +510,9 @@ fn fn_arg_name(sema: &Semantics<RootDatabase>, arg_expr: &ast::Expr) -> String {
}
}
fn fn_arg_type(ctx: &AssistContext, target_module: hir::Module, fn_arg: &ast::Expr) -> String {
fn fn_arg_type(ctx: &AssistContext<'_>, target_module: hir::Module, fn_arg: &ast::Expr) -> String {
fn maybe_displayed_type(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
target_module: hir::Module,
fn_arg: &ast::Expr,
) -> Option<String> {
@ -593,7 +593,7 @@ fn next_space_for_fn_in_impl(impl_: &ast::Impl) -> Option<GeneratedFunctionTarge
}
}
fn module_is_descendant(module: &hir::Module, ans: &hir::Module, ctx: &AssistContext) -> bool {
fn module_is_descendant(module: &hir::Module, ans: &hir::Module, ctx: &AssistContext<'_>) -> bool {
if module == ans {
return true;
}

View File

@ -43,7 +43,7 @@ use crate::{
// }
// }
// ```
pub(crate) fn generate_getter(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn generate_getter(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
generate_getter_impl(acc, ctx, false)
}
@ -68,13 +68,13 @@ pub(crate) fn generate_getter(acc: &mut Assists, ctx: &AssistContext) -> Option<
// }
// }
// ```
pub(crate) fn generate_getter_mut(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn generate_getter_mut(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
generate_getter_impl(acc, ctx, true)
}
pub(crate) fn generate_getter_impl(
acc: &mut Assists,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
mutable: bool,
) -> Option<()> {
let strukt = ctx.find_node_at_offset::<ast::Struct>()?;

View File

@ -21,7 +21,7 @@ use crate::{utils::generate_impl_text, AssistContext, AssistId, AssistKind, Assi
// $0
// }
// ```
pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let nominal = ctx.find_node_at_offset::<ast::Adt>()?;
let name = nominal.name()?;
let target = nominal.syntax().text_range();

View File

@ -39,7 +39,7 @@ use crate::{
// }
// }
// ```
pub(crate) fn generate_is_empty_from_len(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn generate_is_empty_from_len(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let fn_node = ctx.find_node_at_offset::<ast::Fn>()?;
let fn_name = fn_node.name()?;
@ -86,7 +86,7 @@ pub(crate) fn generate_is_empty_from_len(acc: &mut Assists, ctx: &AssistContext)
}
fn get_impl_method(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
impl_: &ast::Impl,
fn_name: &Name,
) -> Option<hir::Function> {

View File

@ -29,7 +29,7 @@ use crate::{
// fn $0new(data: T) -> Self { Self { data } }
// }
// ```
pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let strukt = ctx.find_node_at_offset::<ast::Struct>()?;
// We want to only apply this to non-union structs with named fields

View File

@ -27,7 +27,7 @@ use crate::{
// }
// }
// ```
pub(crate) fn generate_setter(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn generate_setter(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let strukt = ctx.find_node_at_offset::<ast::Struct>()?;
let field = ctx.find_node_at_offset::<ast::RecordField>()?;

View File

@ -59,7 +59,7 @@ use crate::{
// };
// }
// ```
pub(crate) fn inline_into_callers(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn inline_into_callers(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let def_file = ctx.file_id();
let name = ctx.find_node_at_offset::<ast::Name>()?;
let ast_func = name.syntax().parent().and_then(ast::Fn::cast)?;
@ -174,7 +174,7 @@ pub(crate) fn inline_into_callers(acc: &mut Assists, ctx: &AssistContext) -> Opt
// };
// }
// ```
pub(crate) fn inline_call(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn inline_call(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let name_ref: ast::NameRef = ctx.find_node_at_offset()?;
let call_info = CallInfo::from_name_ref(name_ref.clone())?;
let (function, label) = match &call_info.node {
@ -294,7 +294,7 @@ fn get_fn_params(
}
fn inline(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
function_def_file_id: FileId,
function: hir::Function,
fn_body: &ast::BlockExpr,

View File

@ -32,7 +32,7 @@ use crate::{
// (1 + 2) * 4;
// }
// ```
pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let file_id = ctx.file_id();
let range = ctx.selection_trimmed();
let InlineData { let_stmt, delete_let, references, target } =
@ -149,7 +149,7 @@ struct InlineData {
}
fn inline_let(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
let_stmt: ast::LetStmt,
range: TextRange,
file_id: FileId,
@ -184,7 +184,7 @@ fn inline_let(
}
fn inline_usage(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
path_expr: ast::PathExpr,
range: TextRange,
file_id: FileId,

View File

@ -35,7 +35,7 @@ use crate::{
// let a: Vec<u32>;
// }
// ```
pub(crate) fn inline_type_alias(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn inline_type_alias(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
enum Replacement {
Generic { lifetime_map: LifetimeMap, const_and_type_map: ConstAndTypeMap },
Plain,
@ -252,7 +252,7 @@ fn create_replacement(
updated_concrete_type.to_string()
}
fn get_type_alias(ctx: &AssistContext, path: &ast::PathType) -> Option<ast::TypeAlias> {
fn get_type_alias(ctx: &AssistContext<'_>, path: &ast::PathType) -> Option<ast::TypeAlias> {
let resolved_path = ctx.sema.resolve_path(&path.path()?)?;
// We need the generics in the correct order to be able to map any provided

View File

@ -16,7 +16,7 @@ use crate::{utils::suggest_name, AssistContext, AssistId, AssistKind, Assists};
// ```
// fn foo<B: Bar>(bar: B) {}
// ```
pub(crate) fn introduce_named_generic(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn introduce_named_generic(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let impl_trait_type = ctx.find_node_at_offset::<ast::ImplTraitType>()?;
let param = impl_trait_type.syntax().parent().and_then(ast::Param::cast)?;
let fn_ = param.syntax().ancestors().find_map(ast::Fn::cast)?;

View File

@ -33,7 +33,7 @@ static ASSIST_LABEL: &str = "Introduce named lifetime";
// }
// }
// ```
pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
// FIXME: How can we handle renaming any one of multiple anonymous lifetimes?
// FIXME: should also add support for the case fun(f: &Foo) -> &$0Foo
let lifetime =

View File

@ -26,7 +26,7 @@ use crate::{
// if y { B } else { A }
// }
// ```
pub(crate) fn invert_if(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn invert_if(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let if_keyword = ctx.find_token_syntax_at_offset(T![if])?;
let expr = ast::IfExpr::cast(if_keyword.parent()?)?;
let if_range = if_keyword.text_range();

View File

@ -22,7 +22,7 @@ use Edit::*;
// ```
// use std::{fmt::Formatter, io};
// ```
pub(crate) fn merge_imports(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn merge_imports(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let (target, edits) = if ctx.has_empty_selection() {
// Merge a neighbor
let tree: ast::UseTree = ctx.find_node_at_offset()?;

View File

@ -32,7 +32,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists, TextRange};
// }
// }
// ```
pub(crate) fn merge_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn merge_match_arms(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let current_arm = ctx.find_node_at_offset::<ast::MatchArm>()?;
// Don't try to handle arms with guards for now - can add support for this later
if current_arm.guard().is_some() {
@ -97,7 +97,7 @@ fn contains_placeholder(a: &ast::MatchArm) -> bool {
fn are_same_types(
current_arm_types: &HashMap<String, Option<TypeInfo>>,
arm: &ast::MatchArm,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
) -> bool {
let arm_types = get_arm_types(ctx, arm);
for (other_arm_type_name, other_arm_type) in arm_types {
@ -112,14 +112,14 @@ fn are_same_types(
}
fn get_arm_types(
context: &AssistContext,
context: &AssistContext<'_>,
arm: &ast::MatchArm,
) -> HashMap<String, Option<TypeInfo>> {
let mut mapping: HashMap<String, Option<TypeInfo>> = HashMap::new();
fn recurse(
map: &mut HashMap<String, Option<TypeInfo>>,
ctx: &AssistContext,
ctx: &AssistContext<'_>,
pat: &Option<ast::Pat>,
) {
if let Some(local_pat) = pat {

View File

@ -20,7 +20,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// f(x)
// }
// ```
pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let type_param_list = ctx.find_node_at_offset::<ast::GenericParamList>()?;
let mut type_params = type_param_list.type_or_const_params();

View File

@ -23,7 +23,7 @@ use crate::{
// ```
// fn t() {}
// ```
pub(crate) fn move_from_mod_rs(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn move_from_mod_rs(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let source_file = ctx.find_node_at_offset::<ast::SourceFile>()?;
let module = ctx.sema.to_module_def(ctx.file_id())?;
// Enable this assist if the user select all "meaningful" content in the source file

View File

@ -32,7 +32,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// }
// }
// ```
pub(crate) fn move_guard_to_arm_body(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn move_guard_to_arm_body(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let match_arm = ctx.find_node_at_offset::<MatchArm>()?;
let guard = match_arm.guard()?;
if ctx.offset() > guard.syntax().text_range().end() {
@ -91,7 +91,7 @@ pub(crate) fn move_guard_to_arm_body(acc: &mut Assists, ctx: &AssistContext) ->
// }
// }
// ```
pub(crate) fn move_arm_cond_to_match_guard(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn move_arm_cond_to_match_guard(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let match_arm: MatchArm = ctx.find_node_at_offset::<MatchArm>()?;
let match_pat = match_arm.pat()?;
let arm_body = match_arm.expr()?;

View File

@ -24,7 +24,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// ```
// mod foo;
// ```
pub(crate) fn move_module_to_file(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn move_module_to_file(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let module_ast = ctx.find_node_at_offset::<ast::Module>()?;
let module_items = module_ast.item_list()?;

View File

@ -23,7 +23,7 @@ use crate::{
// ```
// fn t() {}
// ```
pub(crate) fn move_to_mod_rs(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn move_to_mod_rs(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let source_file = ctx.find_node_at_offset::<ast::SourceFile>()?;
let module = ctx.sema.to_module_def(ctx.file_id())?;
// Enable this assist if the user select all "meaningful" content in the source file

View File

@ -15,7 +15,7 @@ const MIN_NUMBER_OF_DIGITS_TO_FORMAT: usize = 5;
// ```
// const _: i32 = 1_012_345;
// ```
pub(crate) fn reformat_number_literal(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn reformat_number_literal(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let literal = ctx.find_node_at_offset::<ast::Literal>()?;
let literal = match literal.kind() {
ast::LiteralKind::IntNumber(it) => it,

View File

@ -44,7 +44,7 @@ use crate::{
// }
// }
// ```
pub(crate) fn promote_local_to_const(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn promote_local_to_const(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let pat = ctx.find_node_at_offset::<ast::IdentPat>()?;
let name = pat.name()?;
if !pat.is_simple_ident() {
@ -95,7 +95,7 @@ pub(crate) fn promote_local_to_const(acc: &mut Assists, ctx: &AssistContext) ->
)
}
fn is_body_const(sema: &Semantics<RootDatabase>, expr: &ast::Expr) -> bool {
fn is_body_const(sema: &Semantics<'_, RootDatabase>, expr: &ast::Expr) -> bool {
let mut is_const = true;
preorder_expr(expr, &mut |ev| {
let expr = match ev {

View File

@ -35,7 +35,7 @@ use crate::{
// };
// }
// ```
pub(crate) fn pull_assignment_up(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn pull_assignment_up(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let assign_expr = ctx.find_node_at_offset::<ast::BinExpr>()?;
let op_kind = assign_expr.op_kind()?;
@ -151,7 +151,7 @@ impl<'a> AssignmentsCollector<'a> {
}
fn is_equivalent(
sema: &hir::Semantics<ide_db::RootDatabase>,
sema: &hir::Semantics<'_, ide_db::RootDatabase>,
expr0: &ast::Expr,
expr1: &ast::Expr,
) -> bool {

View File

@ -32,7 +32,7 @@ use crate::{
// Foo::foo(&foo);
// }
// ```
pub(crate) fn qualify_method_call(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn qualify_method_call(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let name: ast::NameRef = ctx.find_node_at_offset()?;
let call = name.syntax().parent().and_then(ast::MethodCallExpr::cast)?;

View File

@ -35,7 +35,7 @@ use crate::{
// }
// # pub mod std { pub mod collections { pub struct HashMap { } } }
// ```
pub(crate) fn qualify_path(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn qualify_path(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let (import_assets, syntax_under_caret) = find_importable_node(ctx)?;
let mut proposed_imports = import_assets.search_for_relative_paths(&ctx.sema);
if proposed_imports.is_empty() {

View File

@ -19,7 +19,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// r#"Hello, World!"#;
// }
// ```
pub(crate) fn make_raw_string(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn make_raw_string(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let token = ctx.find_token_at_offset::<ast::String>()?;
if token.is_raw() {
return None;
@ -61,7 +61,7 @@ pub(crate) fn make_raw_string(acc: &mut Assists, ctx: &AssistContext) -> Option<
// "Hello, \"World!\"";
// }
// ```
pub(crate) fn make_usual_string(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn make_usual_string(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let token = ctx.find_token_at_offset::<ast::String>()?;
if !token.is_raw() {
return None;
@ -103,7 +103,7 @@ pub(crate) fn make_usual_string(acc: &mut Assists, ctx: &AssistContext) -> Optio
// r##"Hello, World!"##;
// }
// ```
pub(crate) fn add_hash(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn add_hash(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let token = ctx.find_token_at_offset::<ast::String>()?;
if !token.is_raw() {
return None;
@ -131,7 +131,7 @@ pub(crate) fn add_hash(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
// r"Hello, World!";
// }
// ```
pub(crate) fn remove_hash(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn remove_hash(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let token = ctx.find_token_at_offset::<ast::String>()?;
if !token.is_raw() {
return None;

View File

@ -21,7 +21,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// 92;
// }
// ```
pub(crate) fn remove_dbg(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn remove_dbg(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let macro_call = ctx.find_node_at_offset::<ast::MacroCall>()?;
let tt = macro_call.token_tree()?;
let r_delim = NodeOrToken::Token(tt.right_delimiter_token()?);

View File

@ -17,7 +17,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// fn feed(&self, amount: u32) {}
// }
// ```
pub(crate) fn remove_mut(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn remove_mut(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let mut_token = ctx.find_token_syntax_at_offset(T![mut])?;
let delete_from = mut_token.text_range().start();
let delete_to = match mut_token.next_token() {

View File

@ -30,7 +30,7 @@ use crate::{
// frobnicate();
// }
// ```
pub(crate) fn remove_unused_param(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn remove_unused_param(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let param: ast::Param = ctx.find_node_at_offset()?;
let ident_pat = match param.pat()? {
ast::Pat::IdentPat(it) => it,
@ -87,7 +87,7 @@ pub(crate) fn remove_unused_param(acc: &mut Assists, ctx: &AssistContext) -> Opt
}
fn process_usages(
ctx: &AssistContext,
ctx: &AssistContext<'_>,
builder: &mut AssistBuilder,
file_id: FileId,
references: Vec<FileReference>,

View File

@ -19,7 +19,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// struct Foo {foo: i32, bar: i32};
// const test: Foo = Foo {foo: 1, bar: 0}
// ```
pub(crate) fn reorder_fields(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
pub(crate) fn reorder_fields(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let record = ctx
.find_node_at_offset::<ast::RecordExpr>()
.map(Either::Left)
@ -86,7 +86,7 @@ fn replace<T: AstNode + PartialEq>(
});
}
fn compute_fields_ranks(path: &ast::Path, ctx: &AssistContext) -> Option<FxHashMap<String, usize>> {
fn compute_fields_ranks(path: &ast::Path, ctx: &AssistContext<'_>) -> Option<FxHashMap<String, usize>> {
let strukt = match ctx.sema.resolve_path(path) {
Some(hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Struct(it)))) => it,
_ => return None,

Some files were not shown because too many files have changed in this diff Show More