mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 13:18:47 +00:00
Run cargo +nightly fix --clippy -Z unstable-options
This commit is contained in:
parent
eab80cd961
commit
b8ddcb0652
48 changed files with 132 additions and 149 deletions
|
@ -45,7 +45,7 @@ pub(crate) fn add_custom_impl(ctx: AssistCtx) -> Option<Assist> {
|
|||
let trait_token =
|
||||
ctx.token_at_offset().filter(|t| t.kind() == IDENT && *t.text() != attr_name).next()?;
|
||||
|
||||
let annotated = attr.syntax().siblings(Direction::Next).find_map(|s| ast::Name::cast(s))?;
|
||||
let annotated = attr.syntax().siblings(Direction::Next).find_map(ast::Name::cast)?;
|
||||
let annotated_name = annotated.syntax().text().to_string();
|
||||
let start_offset = annotated.syntax().parent()?.text_range().end();
|
||||
|
||||
|
@ -62,7 +62,7 @@ pub(crate) fn add_custom_impl(ctx: AssistCtx) -> Option<Assist> {
|
|||
.filter_map(|t| t.into_token().map(|t| t.text().clone()))
|
||||
.filter(|t| t != trait_token.text())
|
||||
.collect::<Vec<SmolStr>>();
|
||||
let has_more_derives = new_attr_input.len() > 0;
|
||||
let has_more_derives = !new_attr_input.is_empty();
|
||||
let new_attr_input =
|
||||
join(new_attr_input.iter()).separator(", ").surround_with("(", ")").to_string();
|
||||
let new_attr_input_len = new_attr_input.len();
|
||||
|
|
|
@ -53,7 +53,7 @@ pub(crate) fn add_new(ctx: AssistCtx) -> Option<Assist> {
|
|||
}
|
||||
|
||||
let vis = strukt.visibility().map(|v| format!("{} ", v.syntax()));
|
||||
let vis = vis.as_ref().map(String::as_str).unwrap_or("");
|
||||
let vis = vis.as_deref().unwrap_or("");
|
||||
write!(&mut buf, " {}fn new(", vis).unwrap();
|
||||
|
||||
join(field_list.fields().filter_map(|f| {
|
||||
|
|
|
@ -61,7 +61,7 @@ pub(crate) fn replace_if_let_with_match(ctx: AssistCtx) -> Option<Assist> {
|
|||
|
||||
edit.target(if_expr.syntax().text_range());
|
||||
edit.set_cursor(if_expr.syntax().text_range().start());
|
||||
edit.replace_ast::<ast::Expr>(if_expr.into(), match_expr.into());
|
||||
edit.replace_ast::<ast::Expr>(if_expr.into(), match_expr);
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ pub struct GroupLabel(pub String);
|
|||
impl AssistLabel {
|
||||
pub(crate) fn new(label: String, id: AssistId) -> AssistLabel {
|
||||
// FIXME: make fields private, so that this invariant can't be broken
|
||||
assert!(label.chars().nth(0).unwrap().is_uppercase());
|
||||
AssistLabel { label: label.into(), id }
|
||||
assert!(label.chars().next().unwrap().is_uppercase());
|
||||
AssistLabel { label, id }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -234,7 +234,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
|
|||
let child = map_rust_child_diagnostic(&child, workspace_root);
|
||||
match child {
|
||||
MappedRustChildDiagnostic::Related(related) => related_information.push(related),
|
||||
MappedRustChildDiagnostic::SuggestedFix(code_action) => fixes.push(code_action.into()),
|
||||
MappedRustChildDiagnostic::SuggestedFix(code_action) => fixes.push(code_action),
|
||||
MappedRustChildDiagnostic::MessageLine(message_line) => {
|
||||
write!(&mut message, "\n{}", message_line).unwrap();
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ impl FromStr for Edition {
|
|||
let res = match s {
|
||||
"2015" => Edition::Edition2015,
|
||||
"2018" => Edition::Edition2018,
|
||||
_ => Err(ParseEditionError { invalid_input: s.to_string() })?,
|
||||
_ => return Err(ParseEditionError { invalid_input: s.to_string() }),
|
||||
};
|
||||
Ok(res)
|
||||
}
|
||||
|
|
|
@ -283,7 +283,7 @@ impl StructField {
|
|||
};
|
||||
let substs = Substs::type_params(db, generic_def_id);
|
||||
let ty = db.field_types(var_id)[self.id].clone().subst(&substs);
|
||||
Type::new(db, self.parent.module(db).id.krate.into(), var_id, ty)
|
||||
Type::new(db, self.parent.module(db).id.krate, var_id, ty)
|
||||
}
|
||||
|
||||
pub fn parent_def(&self, _db: &impl HirDatabase) -> VariantDef {
|
||||
|
@ -315,11 +315,11 @@ impl Struct {
|
|||
}
|
||||
|
||||
pub fn name(self, db: &impl DefDatabase) -> Name {
|
||||
db.struct_data(self.id.into()).name.clone()
|
||||
db.struct_data(self.id).name.clone()
|
||||
}
|
||||
|
||||
pub fn fields(self, db: &impl HirDatabase) -> Vec<StructField> {
|
||||
db.struct_data(self.id.into())
|
||||
db.struct_data(self.id)
|
||||
.variant_data
|
||||
.fields()
|
||||
.iter()
|
||||
|
@ -332,7 +332,7 @@ impl Struct {
|
|||
}
|
||||
|
||||
fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
|
||||
db.struct_data(self.id.into()).variant_data.clone()
|
||||
db.struct_data(self.id).variant_data.clone()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1049,7 +1049,7 @@ impl Type {
|
|||
// FIXME check that?
|
||||
let canonical = Canonical { value: self.ty.value.clone(), num_vars: 0 };
|
||||
let environment = self.ty.environment.clone();
|
||||
let ty = InEnvironment { value: canonical, environment: environment.clone() };
|
||||
let ty = InEnvironment { value: canonical, environment };
|
||||
autoderef(db, Some(self.krate), ty)
|
||||
.map(|canonical| canonical.value)
|
||||
.map(move |ty| self.derived(ty))
|
||||
|
|
|
@ -361,9 +361,8 @@ impl SourceAnalyzer {
|
|||
db: &impl HirDatabase,
|
||||
macro_call: InFile<&ast::MacroCall>,
|
||||
) -> Option<Expansion> {
|
||||
let macro_call_id = macro_call.as_call_id(db, |path| {
|
||||
self.resolver.resolve_path_as_macro(db, &path).map(|it| it.into())
|
||||
})?;
|
||||
let macro_call_id =
|
||||
macro_call.as_call_id(db, |path| self.resolver.resolve_path_as_macro(db, &path))?;
|
||||
Some(Expansion { macro_call_id })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -448,7 +448,7 @@ where
|
|||
// FIXME expand to statements in statement position
|
||||
ast::Expr::MacroCall(e) => {
|
||||
let macro_call = self.expander.to_source(AstPtr::new(&e));
|
||||
match self.expander.enter_expand(self.db, e.clone()) {
|
||||
match self.expander.enter_expand(self.db, e) {
|
||||
Some((mark, expansion)) => {
|
||||
self.source_map
|
||||
.expansions
|
||||
|
|
|
@ -71,7 +71,7 @@ impl GenericParams {
|
|||
db: &impl DefDatabase,
|
||||
def: GenericDefId,
|
||||
) -> Arc<GenericParams> {
|
||||
let (params, _source_map) = GenericParams::new(db, def.into());
|
||||
let (params, _source_map) = GenericParams::new(db, def);
|
||||
Arc::new(params)
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ impl ItemScope {
|
|||
|
||||
pub(crate) fn push_res(&mut self, name: Name, def: PerNs) -> bool {
|
||||
let mut changed = false;
|
||||
let existing = self.visible.entry(name.clone()).or_default();
|
||||
let existing = self.visible.entry(name).or_default();
|
||||
|
||||
if existing.types.is_none() && def.types.is_some() {
|
||||
existing.types = def.types;
|
||||
|
|
|
@ -156,7 +156,7 @@ impl ModuleOrigin {
|
|||
ModuleOrigin::File { definition, .. } | ModuleOrigin::CrateRoot { definition } => {
|
||||
let file_id = *definition;
|
||||
let sf = db.parse(file_id).tree();
|
||||
return InFile::new(file_id.into(), ModuleSource::SourceFile(sf));
|
||||
InFile::new(file_id.into(), ModuleSource::SourceFile(sf))
|
||||
}
|
||||
ModuleOrigin::Inline { definition } => {
|
||||
InFile::new(definition.file_id, ModuleSource::Module(definition.to_node(db)))
|
||||
|
|
|
@ -357,9 +357,7 @@ impl RawItemsCollector {
|
|||
let visibility =
|
||||
RawVisibility::from_ast_with_hygiene(extern_crate.visibility(), &self.hygiene);
|
||||
let alias = extern_crate.alias().map(|a| {
|
||||
a.name()
|
||||
.map(|it| it.as_name())
|
||||
.map_or(ImportAlias::Underscore, |a| ImportAlias::Alias(a))
|
||||
a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias)
|
||||
});
|
||||
let attrs = self.parse_attrs(&extern_crate);
|
||||
// FIXME: cfg_attr
|
||||
|
|
|
@ -116,7 +116,7 @@ fn typing_inside_a_macro_should_not_invalidate_def_map() {
|
|||
let events = db.log_executed(|| {
|
||||
let crate_def_map = db.crate_def_map(krate);
|
||||
let (_, module_data) = crate_def_map.modules.iter().last().unwrap();
|
||||
assert_eq!(module_data.scope.resolutions().collect::<Vec<_>>().len(), 1);
|
||||
assert_eq!(module_data.scope.resolutions().count(), 1);
|
||||
});
|
||||
assert!(format!("{:?}", events).contains("crate_def_map"), "{:#?}", events)
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ fn typing_inside_a_macro_should_not_invalidate_def_map() {
|
|||
let events = db.log_executed(|| {
|
||||
let crate_def_map = db.crate_def_map(krate);
|
||||
let (_, module_data) = crate_def_map.modules.iter().last().unwrap();
|
||||
assert_eq!(module_data.scope.resolutions().collect::<Vec<_>>().len(), 1);
|
||||
assert_eq!(module_data.scope.resolutions().count(), 1);
|
||||
});
|
||||
assert!(!format!("{:?}", events).contains("crate_def_map"), "{:#?}", events)
|
||||
}
|
||||
|
|
|
@ -32,9 +32,7 @@ pub(crate) fn lower_use_tree(
|
|||
}
|
||||
} else {
|
||||
let alias = tree.alias().map(|a| {
|
||||
a.name()
|
||||
.map(|it| it.as_name())
|
||||
.map_or(ImportAlias::Underscore, |a| ImportAlias::Alias(a))
|
||||
a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias)
|
||||
});
|
||||
let is_glob = tree.has_star();
|
||||
if let Some(ast_path) = tree.path() {
|
||||
|
|
|
@ -474,7 +474,7 @@ impl Scope {
|
|||
f(name.clone(), ScopeDef::PerNs(PerNs::macros(macro_, Visibility::Public)));
|
||||
});
|
||||
m.crate_def_map.extern_prelude.iter().for_each(|(name, &def)| {
|
||||
f(name.clone(), ScopeDef::PerNs(PerNs::types(def.into(), Visibility::Public)));
|
||||
f(name.clone(), ScopeDef::PerNs(PerNs::types(def, Visibility::Public)));
|
||||
});
|
||||
if let Some(prelude) = m.crate_def_map.prelude {
|
||||
let prelude_def_map = db.crate_def_map(prelude.krate);
|
||||
|
@ -499,10 +499,10 @@ impl Scope {
|
|||
}
|
||||
}
|
||||
Scope::ImplBlockScope(i) => {
|
||||
f(name![Self], ScopeDef::ImplSelfType((*i).into()));
|
||||
f(name![Self], ScopeDef::ImplSelfType(*i));
|
||||
}
|
||||
Scope::AdtScope(i) => {
|
||||
f(name![Self], ScopeDef::AdtSelfType((*i).into()));
|
||||
f(name![Self], ScopeDef::AdtSelfType(*i));
|
||||
}
|
||||
Scope::ExprScope(scope) => {
|
||||
scope.expr_scopes.entries(scope.scope_id).iter().for_each(|e| {
|
||||
|
|
|
@ -235,7 +235,7 @@ mod tests {
|
|||
let (db, file_id) = TestDB::with_single_file(&s);
|
||||
let parsed = db.parse(file_id);
|
||||
let items: Vec<_> =
|
||||
parsed.syntax_node().descendants().filter_map(|it| ast::ModuleItem::cast(it)).collect();
|
||||
parsed.syntax_node().descendants().filter_map(ast::ModuleItem::cast).collect();
|
||||
|
||||
let ast_id_map = db.ast_id_map(file_id.into());
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ fn compile_error_expand(
|
|||
match &tt.token_trees[0] {
|
||||
tt::TokenTree::Leaf(tt::Leaf::Literal(it)) => {
|
||||
let s = it.text.as_str();
|
||||
if s.contains(r#"""#) {
|
||||
if s.contains('"') {
|
||||
return Ok(quote! { loop { #it }});
|
||||
}
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ mod tests {
|
|||
let (db, file_id) = TestDB::with_single_file(&s);
|
||||
let parsed = db.parse(file_id);
|
||||
let macro_calls: Vec<_> =
|
||||
parsed.syntax_node().descendants().filter_map(|it| ast::MacroCall::cast(it)).collect();
|
||||
parsed.syntax_node().descendants().filter_map(ast::MacroCall::cast).collect();
|
||||
|
||||
let ast_id_map = db.ast_id_map(file_id.into());
|
||||
|
||||
|
|
|
@ -259,8 +259,7 @@ mod tests {
|
|||
// }
|
||||
let struct_name = mk_ident("Foo");
|
||||
let fields = [mk_ident("name"), mk_ident("id")];
|
||||
let fields =
|
||||
fields.iter().map(|it| quote!(#it: self.#it.clone(), ).token_trees.clone()).flatten();
|
||||
let fields = fields.iter().map(|it| quote!(#it: self.#it.clone(), ).token_trees).flatten();
|
||||
|
||||
let list = tt::Subtree {
|
||||
delimiter: Some(tt::Delimiter {
|
||||
|
|
|
@ -225,14 +225,14 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
|||
coerce_unsized_map: Self::init_coerce_unsized_map(db, &resolver),
|
||||
db,
|
||||
owner,
|
||||
body: db.body(owner.into()),
|
||||
body: db.body(owner),
|
||||
resolver,
|
||||
}
|
||||
}
|
||||
|
||||
fn resolve_all(mut self) -> InferenceResult {
|
||||
// FIXME resolve obligations as well (use Guidance if necessary)
|
||||
let mut result = mem::replace(&mut self.result, InferenceResult::default());
|
||||
let mut result = std::mem::take(&mut self.result);
|
||||
for ty in result.type_of_expr.values_mut() {
|
||||
let resolved = self.table.resolve_ty_completely(mem::replace(ty, Ty::Unknown));
|
||||
*ty = resolved;
|
||||
|
@ -261,7 +261,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
|||
}
|
||||
|
||||
fn write_assoc_resolution(&mut self, id: ExprOrPatId, item: AssocItemId) {
|
||||
self.result.assoc_resolutions.insert(id, item.into());
|
||||
self.result.assoc_resolutions.insert(id, item);
|
||||
}
|
||||
|
||||
fn write_pat_ty(&mut self, pat: PatId, ty: Ty) {
|
||||
|
@ -312,9 +312,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
|||
for obligation in obligations {
|
||||
let in_env = InEnvironment::new(self.trait_env.clone(), obligation.clone());
|
||||
let canonicalized = self.canonicalizer().canonicalize_obligation(in_env);
|
||||
let solution = self
|
||||
.db
|
||||
.trait_solve(self.resolver.krate().unwrap().into(), canonicalized.value.clone());
|
||||
let solution =
|
||||
self.db.trait_solve(self.resolver.krate().unwrap(), canonicalized.value.clone());
|
||||
|
||||
match solution {
|
||||
Some(Solution::Unique(substs)) => {
|
||||
|
|
|
@ -44,10 +44,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
|||
resolver: &Resolver,
|
||||
) -> FxHashMap<(TypeCtor, TypeCtor), usize> {
|
||||
let krate = resolver.krate().unwrap();
|
||||
let impls = match db.lang_item(krate.into(), "coerce_unsized".into()) {
|
||||
Some(LangItemTarget::TraitId(trait_)) => {
|
||||
db.impls_for_trait(krate.into(), trait_.into())
|
||||
}
|
||||
let impls = match db.lang_item(krate, "coerce_unsized".into()) {
|
||||
Some(LangItemTarget::TraitId(trait_)) => db.impls_for_trait(krate, trait_),
|
||||
_ => return FxHashMap::default(),
|
||||
};
|
||||
|
||||
|
|
|
@ -127,10 +127,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
|||
TypeCtor::FnPtr { num_args: sig_tys.len() as u16 - 1 },
|
||||
Substs(sig_tys.into()),
|
||||
);
|
||||
let closure_ty = Ty::apply_one(
|
||||
TypeCtor::Closure { def: self.owner.into(), expr: tgt_expr },
|
||||
sig_ty,
|
||||
);
|
||||
let closure_ty =
|
||||
Ty::apply_one(TypeCtor::Closure { def: self.owner, expr: tgt_expr }, sig_ty);
|
||||
|
||||
// Eagerly try to relate the closure type with the expected
|
||||
// type, otherwise we often won't have enough information to
|
||||
|
@ -165,7 +163,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
|||
Expr::Match { expr, arms } => {
|
||||
let input_ty = self.infer_expr(*expr, &Expectation::none());
|
||||
|
||||
let mut result_ty = if arms.len() == 0 {
|
||||
let mut result_ty = if arms.is_empty() {
|
||||
Ty::simple(TypeCtor::Never)
|
||||
} else {
|
||||
self.table.new_type_var()
|
||||
|
@ -188,7 +186,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
|||
}
|
||||
Expr::Path(p) => {
|
||||
// FIXME this could be more efficient...
|
||||
let resolver = resolver_for_expr(self.db, self.owner.into(), tgt_expr);
|
||||
let resolver = resolver_for_expr(self.db, self.owner, tgt_expr);
|
||||
self.infer_path(&resolver, p, tgt_expr.into()).unwrap_or(Ty::Unknown)
|
||||
}
|
||||
Expr::Continue => Ty::simple(TypeCtor::Never),
|
||||
|
@ -217,8 +215,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
|||
self.unify(&ty, &expected.ty);
|
||||
|
||||
let substs = ty.substs().unwrap_or_else(Substs::empty);
|
||||
let field_types =
|
||||
def_id.map(|it| self.db.field_types(it.into())).unwrap_or_default();
|
||||
let field_types = def_id.map(|it| self.db.field_types(it)).unwrap_or_default();
|
||||
let variant_data = def_id.map(|it| variant_data(self.db, it));
|
||||
for (field_idx, field) in fields.iter().enumerate() {
|
||||
let field_def =
|
||||
|
@ -264,7 +261,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
|||
.and_then(|idx| a_ty.parameters.0.get(idx).cloned()),
|
||||
TypeCtor::Adt(AdtId::StructId(s)) => {
|
||||
self.db.struct_data(s).variant_data.field(name).map(|local_id| {
|
||||
let field = StructFieldId { parent: s.into(), local_id }.into();
|
||||
let field = StructFieldId { parent: s.into(), local_id };
|
||||
self.write_field_resolution(tgt_expr, field);
|
||||
self.db.field_types(s.into())[field.local_id]
|
||||
.clone()
|
||||
|
@ -700,10 +697,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
|||
// construct a TraitDef
|
||||
let substs =
|
||||
a_ty.parameters.prefix(generics(self.db, trait_.into()).len());
|
||||
self.obligations.push(Obligation::Trait(TraitRef {
|
||||
trait_: trait_.into(),
|
||||
substs,
|
||||
}));
|
||||
self.obligations.push(Obligation::Trait(TraitRef { trait_, substs }));
|
||||
}
|
||||
}
|
||||
CallableDef::StructId(_) | CallableDef::EnumVariantId(_) => {}
|
||||
|
|
|
@ -28,7 +28,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
|||
|
||||
let substs = ty.substs().unwrap_or_else(Substs::empty);
|
||||
|
||||
let field_tys = def.map(|it| self.db.field_types(it.into())).unwrap_or_default();
|
||||
let field_tys = def.map(|it| self.db.field_types(it)).unwrap_or_default();
|
||||
|
||||
for (i, &subpat) in subpats.iter().enumerate() {
|
||||
let expected_ty = var_data
|
||||
|
@ -60,7 +60,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
|||
|
||||
let substs = ty.substs().unwrap_or_else(Substs::empty);
|
||||
|
||||
let field_tys = def.map(|it| self.db.field_types(it.into())).unwrap_or_default();
|
||||
let field_tys = def.map(|it| self.db.field_types(it)).unwrap_or_default();
|
||||
for subpat in subpats {
|
||||
let matching_field = var_data.as_ref().and_then(|it| it.field(&subpat.name));
|
||||
let expected_ty =
|
||||
|
|
|
@ -104,8 +104,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
|||
let segment =
|
||||
remaining_segments.last().expect("there should be at least one segment here");
|
||||
let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver);
|
||||
let trait_ref =
|
||||
TraitRef::from_resolved_path(&ctx, trait_.into(), resolved_segment, None);
|
||||
let trait_ref = TraitRef::from_resolved_path(&ctx, trait_, resolved_segment, None);
|
||||
self.resolve_trait_assoc_item(trait_ref, segment, id)
|
||||
}
|
||||
(def, _) => {
|
||||
|
@ -144,30 +143,32 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
|||
id: ExprOrPatId,
|
||||
) -> Option<(ValueNs, Option<Substs>)> {
|
||||
let trait_ = trait_ref.trait_;
|
||||
let item = self
|
||||
.db
|
||||
.trait_data(trait_)
|
||||
.items
|
||||
.iter()
|
||||
.map(|(_name, id)| (*id).into())
|
||||
.find_map(|item| match item {
|
||||
AssocItemId::FunctionId(func) => {
|
||||
if segment.name == &self.db.function_data(func).name {
|
||||
Some(AssocItemId::FunctionId(func))
|
||||
} else {
|
||||
None
|
||||
let item =
|
||||
self.db.trait_data(trait_).items.iter().map(|(_name, id)| (*id)).find_map(|item| {
|
||||
match item {
|
||||
AssocItemId::FunctionId(func) => {
|
||||
if segment.name == &self.db.function_data(func).name {
|
||||
Some(AssocItemId::FunctionId(func))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AssocItemId::ConstId(konst) => {
|
||||
if self.db.const_data(konst).name.as_ref().map_or(false, |n| n == segment.name)
|
||||
{
|
||||
Some(AssocItemId::ConstId(konst))
|
||||
} else {
|
||||
None
|
||||
AssocItemId::ConstId(konst) => {
|
||||
if self
|
||||
.db
|
||||
.const_data(konst)
|
||||
.name
|
||||
.as_ref()
|
||||
.map_or(false, |n| n == segment.name)
|
||||
{
|
||||
Some(AssocItemId::ConstId(konst))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
AssocItemId::TypeAliasId(_) => None,
|
||||
}
|
||||
AssocItemId::TypeAliasId(_) => None,
|
||||
})?;
|
||||
let def = match item {
|
||||
AssocItemId::FunctionId(f) => ValueNs::FunctionId(f),
|
||||
|
@ -233,7 +234,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
|||
AssocContainerId::ContainerId(_) => None,
|
||||
};
|
||||
|
||||
self.write_assoc_resolution(id, item.into());
|
||||
self.write_assoc_resolution(id, item);
|
||||
Some((def, substs))
|
||||
},
|
||||
)
|
||||
|
|
|
@ -167,7 +167,7 @@ impl TypeCtor {
|
|||
| TypeCtor::Closure { .. } // 1 param representing the signature of the closure
|
||||
=> 1,
|
||||
TypeCtor::Adt(adt) => {
|
||||
let generic_params = generics(db, AdtId::from(adt).into());
|
||||
let generic_params = generics(db, adt.into());
|
||||
generic_params.len()
|
||||
}
|
||||
TypeCtor::FnDef(callable) => {
|
||||
|
@ -247,7 +247,7 @@ pub struct ProjectionTy {
|
|||
|
||||
impl ProjectionTy {
|
||||
pub fn trait_ref(&self, db: &impl HirDatabase) -> TraitRef {
|
||||
TraitRef { trait_: self.trait_(db).into(), substs: self.parameters.clone() }
|
||||
TraitRef { trait_: self.trait_(db), substs: self.parameters.clone() }
|
||||
}
|
||||
|
||||
fn trait_(&self, db: &impl HirDatabase) -> TraitId {
|
||||
|
|
|
@ -361,10 +361,8 @@ impl Ty {
|
|||
for t in traits {
|
||||
if let Some(associated_ty) = ctx.db.trait_data(t).associated_type_by_name(&segment.name)
|
||||
{
|
||||
let substs = Substs::build_for_def(ctx.db, t)
|
||||
.push(self_ty.clone())
|
||||
.fill_with_unknown()
|
||||
.build();
|
||||
let substs =
|
||||
Substs::build_for_def(ctx.db, t).push(self_ty).fill_with_unknown().build();
|
||||
// FIXME handle type parameters on the segment
|
||||
return Ty::Projection(ProjectionTy { associated_ty, parameters: substs });
|
||||
}
|
||||
|
@ -428,7 +426,7 @@ pub(super) fn substs_from_path_segment(
|
|||
_add_self_param: bool,
|
||||
) -> Substs {
|
||||
let mut substs = Vec::new();
|
||||
let def_generics = def_generic.map(|def| generics(ctx.db, def.into()));
|
||||
let def_generics = def_generic.map(|def| generics(ctx.db, def));
|
||||
|
||||
let (parent_params, self_params, type_params, impl_trait_params) =
|
||||
def_generics.map_or((0, 0, 0, 0), |g| g.provenance_split());
|
||||
|
@ -459,7 +457,7 @@ pub(super) fn substs_from_path_segment(
|
|||
|
||||
// handle defaults
|
||||
if let Some(def_generic) = def_generic {
|
||||
let default_substs = ctx.db.generic_defaults(def_generic.into());
|
||||
let default_substs = ctx.db.generic_defaults(def_generic);
|
||||
assert_eq!(substs.len(), default_substs.len());
|
||||
|
||||
for (i, default_ty) in default_substs.iter().enumerate() {
|
||||
|
@ -483,7 +481,7 @@ impl TraitRef {
|
|||
_ => return None,
|
||||
};
|
||||
let segment = path.segments().last().expect("path should have at least one segment");
|
||||
Some(TraitRef::from_resolved_path(ctx, resolved.into(), segment, explicit_self_ty))
|
||||
Some(TraitRef::from_resolved_path(ctx, resolved, segment, explicit_self_ty))
|
||||
}
|
||||
|
||||
pub(crate) fn from_resolved_path(
|
||||
|
@ -728,7 +726,7 @@ pub(crate) fn generic_predicates_query(
|
|||
pub(crate) fn generic_defaults_query(db: &impl HirDatabase, def: GenericDefId) -> Substs {
|
||||
let resolver = def.resolver(db);
|
||||
let ctx = TyLoweringContext::new(db, &resolver);
|
||||
let generic_params = generics(db, def.into());
|
||||
let generic_params = generics(db, def);
|
||||
|
||||
let defaults = generic_params
|
||||
.iter()
|
||||
|
@ -792,7 +790,7 @@ fn type_for_builtin(def: BuiltinType) -> Ty {
|
|||
}
|
||||
|
||||
fn fn_sig_for_struct_constructor(db: &impl HirDatabase, def: StructId) -> PolyFnSig {
|
||||
let struct_data = db.struct_data(def.into());
|
||||
let struct_data = db.struct_data(def);
|
||||
let fields = struct_data.variant_data.fields();
|
||||
let resolver = def.resolver(db);
|
||||
let ctx =
|
||||
|
@ -805,7 +803,7 @@ fn fn_sig_for_struct_constructor(db: &impl HirDatabase, def: StructId) -> PolyFn
|
|||
|
||||
/// Build the type of a tuple struct constructor.
|
||||
fn type_for_struct_constructor(db: &impl HirDatabase, def: StructId) -> Binders<Ty> {
|
||||
let struct_data = db.struct_data(def.into());
|
||||
let struct_data = db.struct_data(def);
|
||||
if let StructKind::Unit = struct_data.variant_data.kind() {
|
||||
return type_for_adt(db, def.into());
|
||||
}
|
||||
|
@ -836,7 +834,7 @@ fn type_for_enum_variant_constructor(db: &impl HirDatabase, def: EnumVariantId)
|
|||
}
|
||||
let generics = generics(db, def.parent.into());
|
||||
let substs = Substs::bound_vars(&generics);
|
||||
Binders::new(substs.len(), Ty::apply(TypeCtor::FnDef(EnumVariantId::from(def).into()), substs))
|
||||
Binders::new(substs.len(), Ty::apply(TypeCtor::FnDef(def.into()), substs))
|
||||
}
|
||||
|
||||
fn type_for_adt(db: &impl HirDatabase, adt: AdtId) -> Binders<Ty> {
|
||||
|
@ -964,6 +962,6 @@ pub(crate) fn impl_trait_query(
|
|||
let target_trait = impl_data.target_trait.as_ref()?;
|
||||
Some(Binders::new(
|
||||
self_ty.num_binders,
|
||||
TraitRef::from_hir(&ctx, target_trait, Some(self_ty.value.clone()))?,
|
||||
TraitRef::from_hir(&ctx, target_trait, Some(self_ty.value))?,
|
||||
))
|
||||
}
|
||||
|
|
|
@ -214,7 +214,7 @@ pub fn iterate_method_candidates<T>(
|
|||
// the methods by autoderef order of *receiver types*, not *self
|
||||
// types*.
|
||||
|
||||
let deref_chain: Vec<_> = autoderef::autoderef(db, Some(krate), ty.clone()).collect();
|
||||
let deref_chain: Vec<_> = autoderef::autoderef(db, Some(krate), ty).collect();
|
||||
for i in 0..deref_chain.len() {
|
||||
if let Some(result) = iterate_method_candidates_with_autoref(
|
||||
&deref_chain[i..],
|
||||
|
@ -290,7 +290,7 @@ fn iterate_method_candidates_with_autoref<T>(
|
|||
&ref_muted,
|
||||
deref_chain,
|
||||
db,
|
||||
env.clone(),
|
||||
env,
|
||||
krate,
|
||||
&traits_in_scope,
|
||||
name,
|
||||
|
@ -391,17 +391,17 @@ fn iterate_trait_method_candidates<T>(
|
|||
// iteration
|
||||
let mut known_implemented = false;
|
||||
for (_name, item) in data.items.iter() {
|
||||
if !is_valid_candidate(db, name, receiver_ty, (*item).into(), self_ty) {
|
||||
if !is_valid_candidate(db, name, receiver_ty, *item, self_ty) {
|
||||
continue;
|
||||
}
|
||||
if !known_implemented {
|
||||
let goal = generic_implements_goal(db, env.clone(), t, self_ty.clone());
|
||||
if db.trait_solve(krate.into(), goal).is_none() {
|
||||
if db.trait_solve(krate, goal).is_none() {
|
||||
continue 'traits;
|
||||
}
|
||||
}
|
||||
known_implemented = true;
|
||||
if let Some(result) = callback(&self_ty.value, (*item).into()) {
|
||||
if let Some(result) = callback(&self_ty.value, *item) {
|
||||
return Some(result);
|
||||
}
|
||||
}
|
||||
|
@ -521,7 +521,7 @@ pub fn implements_trait(
|
|||
return true;
|
||||
}
|
||||
let goal = generic_implements_goal(db, env, trait_, ty.clone());
|
||||
let solution = db.trait_solve(krate.into(), goal);
|
||||
let solution = db.trait_solve(krate, goal);
|
||||
|
||||
solution.is_some()
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ fn closure_fn_trait_impl_datum(
|
|||
// the existence of the Fn trait has been checked before
|
||||
.expect("fn trait for closure impl missing");
|
||||
|
||||
let num_args: u16 = match &db.body(data.def.into())[data.expr] {
|
||||
let num_args: u16 = match &db.body(data.def)[data.expr] {
|
||||
Expr::Lambda { args, .. } => args.len() as u16,
|
||||
_ => {
|
||||
log::warn!("closure for closure type {:?} not found", data);
|
||||
|
@ -118,7 +118,7 @@ fn closure_fn_trait_impl_datum(
|
|||
let self_ty = Ty::apply_one(TypeCtor::Closure { def: data.def, expr: data.expr }, sig_ty);
|
||||
|
||||
let trait_ref = TraitRef {
|
||||
trait_: trait_.into(),
|
||||
trait_,
|
||||
substs: Substs::build_for_def(db, trait_).push(self_ty).push(arg_ty).build(),
|
||||
};
|
||||
|
||||
|
@ -139,7 +139,7 @@ fn closure_fn_trait_output_assoc_ty_value(
|
|||
) -> BuiltinImplAssocTyValueData {
|
||||
let impl_ = Impl::ClosureFnTraitImpl(data.clone());
|
||||
|
||||
let num_args: u16 = match &db.body(data.def.into())[data.expr] {
|
||||
let num_args: u16 = match &db.body(data.def)[data.expr] {
|
||||
Expr::Lambda { args, .. } => args.len() as u16,
|
||||
_ => {
|
||||
log::warn!("closure for closure type {:?} not found", data);
|
||||
|
|
|
@ -565,10 +565,10 @@ where
|
|||
// and will panic if the trait can't be resolved.
|
||||
let mut result: Vec<_> = self
|
||||
.db
|
||||
.impls_for_trait(self.krate, trait_.into())
|
||||
.impls_for_trait(self.krate, trait_)
|
||||
.iter()
|
||||
.copied()
|
||||
.map(|it| Impl::ImplBlock(it.into()))
|
||||
.map(Impl::ImplBlock)
|
||||
.map(|impl_| impl_.to_chalk(self.db))
|
||||
.collect();
|
||||
|
||||
|
@ -586,7 +586,7 @@ where
|
|||
false // FIXME
|
||||
}
|
||||
fn associated_ty_value(&self, id: AssociatedTyValueId) -> Arc<AssociatedTyValue> {
|
||||
self.db.associated_ty_value(self.krate.into(), id)
|
||||
self.db.associated_ty_value(self.krate, id)
|
||||
}
|
||||
fn custom_clauses(&self) -> Vec<chalk_ir::ProgramClause<TypeFamily>> {
|
||||
vec![]
|
||||
|
@ -674,7 +674,7 @@ pub(crate) fn struct_datum_query(
|
|||
let where_clauses = type_ctor
|
||||
.as_generic_def()
|
||||
.map(|generic_def| {
|
||||
let generic_params = generics(db, generic_def.into());
|
||||
let generic_params = generics(db, generic_def);
|
||||
let bound_vars = Substs::bound_vars(&generic_params);
|
||||
convert_where_clauses(db, generic_def, &bound_vars)
|
||||
})
|
||||
|
@ -805,7 +805,7 @@ fn type_alias_associated_ty_value(
|
|||
let ty = db.ty(type_alias.into());
|
||||
let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: ty.value.to_chalk(db) };
|
||||
let value = chalk_rust_ir::AssociatedTyValue {
|
||||
impl_id: Impl::ImplBlock(impl_id.into()).to_chalk(db),
|
||||
impl_id: Impl::ImplBlock(impl_id).to_chalk(db),
|
||||
associated_ty_id: assoc_ty.to_chalk(db),
|
||||
value: make_binders(value_bound, ty.num_binders),
|
||||
};
|
||||
|
|
|
@ -44,7 +44,7 @@ impl fmt::Debug for AnalysisChange {
|
|||
if !self.libraries_added.is_empty() {
|
||||
d.field("libraries_added", &self.libraries_added.len());
|
||||
}
|
||||
if !self.crate_graph.is_none() {
|
||||
if self.crate_graph.is_some() {
|
||||
d.field("crate_graph", &self.crate_graph);
|
||||
}
|
||||
d.finish()
|
||||
|
|
|
@ -101,7 +101,7 @@ fn match_subtree(
|
|||
tt::Leaf::Literal(tt::Literal { text: lhs, .. }),
|
||||
tt::Leaf::Literal(tt::Literal { text: rhs, .. }),
|
||||
) if lhs == rhs => (),
|
||||
_ => Err(ExpandError::UnexpectedToken)?,
|
||||
_ => return Err(ExpandError::UnexpectedToken),
|
||||
}
|
||||
}
|
||||
Op::TokenTree(tt::TokenTree::Subtree(lhs)) => {
|
||||
|
|
|
@ -100,7 +100,7 @@ fn next_op<'a>(
|
|||
Op::Repeat { subtree, separator, kind }
|
||||
}
|
||||
tt::TokenTree::Leaf(leaf) => match leaf {
|
||||
tt::Leaf::Punct(..) => Err(ExpandError::UnexpectedToken)?,
|
||||
tt::Leaf::Punct(..) => return Err(ExpandError::UnexpectedToken),
|
||||
tt::Leaf::Ident(ident) => {
|
||||
let name = &ident.text;
|
||||
let kind = eat_fragment_kind(src, mode)?;
|
||||
|
@ -147,15 +147,15 @@ fn parse_repeat(src: &mut TtIter) -> Result<(Option<Separator>, RepeatKind), Exp
|
|||
for tt in src {
|
||||
let tt = match tt {
|
||||
tt::TokenTree::Leaf(leaf) => leaf,
|
||||
tt::TokenTree::Subtree(_) => Err(ExpandError::InvalidRepeat)?,
|
||||
tt::TokenTree::Subtree(_) => return Err(ExpandError::InvalidRepeat),
|
||||
};
|
||||
let has_sep = match &separator {
|
||||
Separator::Puncts(puncts) => puncts.len() != 0,
|
||||
Separator::Puncts(puncts) => !puncts.is_empty(),
|
||||
_ => true,
|
||||
};
|
||||
match tt {
|
||||
tt::Leaf::Ident(_) | tt::Leaf::Literal(_) if has_sep => {
|
||||
Err(ExpandError::InvalidRepeat)?
|
||||
return Err(ExpandError::InvalidRepeat)
|
||||
}
|
||||
tt::Leaf::Ident(ident) => separator = Separator::Ident(ident.clone()),
|
||||
tt::Leaf::Literal(lit) => separator = Separator::Literal(lit.clone()),
|
||||
|
@ -168,11 +168,11 @@ fn parse_repeat(src: &mut TtIter) -> Result<(Option<Separator>, RepeatKind), Exp
|
|||
match &mut separator {
|
||||
Separator::Puncts(puncts) => {
|
||||
if puncts.len() == 3 {
|
||||
Err(ExpandError::InvalidRepeat)?
|
||||
return Err(ExpandError::InvalidRepeat);
|
||||
}
|
||||
puncts.push(punct.clone())
|
||||
}
|
||||
_ => Err(ExpandError::InvalidRepeat)?,
|
||||
_ => return Err(ExpandError::InvalidRepeat),
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ fn convert_delim(d: Option<tt::DelimiterKind>, closing: bool) -> TtToken {
|
|||
|
||||
let idx = closing as usize;
|
||||
let kind = kinds[idx];
|
||||
let text = if texts.len() > 0 { &texts[idx..texts.len() - (1 - idx)] } else { "" };
|
||||
let text = if !texts.is_empty() { &texts[idx..texts.len() - (1 - idx)] } else { "" };
|
||||
TtToken { kind, is_joint_to_next: false, text: SmolStr::new(text) }
|
||||
}
|
||||
|
||||
|
|
|
@ -230,10 +230,8 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker {
|
|||
p.eat(T![async]);
|
||||
p.eat(T![move]);
|
||||
params::param_list_closure(p);
|
||||
if opt_fn_ret_type(p) {
|
||||
if !p.at(T!['{']) {
|
||||
p.error("expected `{`");
|
||||
}
|
||||
if opt_fn_ret_type(p) && !p.at(T!['{']) {
|
||||
p.error("expected `{`");
|
||||
}
|
||||
|
||||
if p.at_ts(EXPR_FIRST) {
|
||||
|
|
|
@ -94,7 +94,7 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) {
|
|||
|
||||
fn opt_path_type_args(p: &mut Parser, mode: Mode) {
|
||||
match mode {
|
||||
Mode::Use => return,
|
||||
Mode::Use => {}
|
||||
Mode::Type => {
|
||||
// test path_fn_trait_args
|
||||
// type F = Box<Fn(i32) -> ()>;
|
||||
|
|
|
@ -214,7 +214,7 @@ impl Drop for Profiler {
|
|||
let start = stack.starts.pop().unwrap();
|
||||
let duration = start.elapsed();
|
||||
let level = stack.starts.len();
|
||||
stack.messages.push(Message { level, duration, label: label });
|
||||
stack.messages.push(Message { level, duration, label });
|
||||
if level == 0 {
|
||||
let stdout = stderr();
|
||||
let longer_than = stack.filter_data.longer_than;
|
||||
|
|
|
@ -164,7 +164,7 @@ impl CargoWorkspace {
|
|||
// FIXME: `NoDefaultFeatures` is mutual exclusive with `SomeFeatures`
|
||||
// https://github.com/oli-obk/cargo_metadata/issues/79
|
||||
meta.features(CargoOpt::NoDefaultFeatures);
|
||||
} else if cargo_features.features.len() > 0 {
|
||||
} else if !cargo_features.features.is_empty() {
|
||||
meta.features(CargoOpt::SomeFeatures(cargo_features.features.clone()));
|
||||
}
|
||||
if let Some(parent) = cargo_toml.parent() {
|
||||
|
|
|
@ -409,7 +409,7 @@ fn find_cargo_toml(path: &Path) -> Result<PathBuf> {
|
|||
}
|
||||
curr = path.parent();
|
||||
}
|
||||
Err(CargoTomlNotFoundError(path.to_path_buf()))?
|
||||
Err(CargoTomlNotFoundError(path.to_path_buf()).into())
|
||||
}
|
||||
|
||||
pub fn get_rustc_cfg_options() -> CfgOptions {
|
||||
|
|
|
@ -95,16 +95,17 @@ pub fn diff(from: &SyntaxNode, to: &SyntaxNode) -> TreeDiff {
|
|||
lhs: SyntaxElement,
|
||||
rhs: SyntaxElement,
|
||||
) {
|
||||
if lhs.kind() == rhs.kind() && lhs.text_range().len() == rhs.text_range().len() {
|
||||
if match (&lhs, &rhs) {
|
||||
if lhs.kind() == rhs.kind()
|
||||
&& lhs.text_range().len() == rhs.text_range().len()
|
||||
&& match (&lhs, &rhs) {
|
||||
(NodeOrToken::Node(lhs), NodeOrToken::Node(rhs)) => {
|
||||
lhs.green() == rhs.green() || lhs.text() == rhs.text()
|
||||
}
|
||||
(NodeOrToken::Token(lhs), NodeOrToken::Token(rhs)) => lhs.text() == rhs.text(),
|
||||
_ => false,
|
||||
} {
|
||||
return;
|
||||
}
|
||||
{
|
||||
return;
|
||||
}
|
||||
if let (Some(lhs), Some(rhs)) = (lhs.as_node(), rhs.as_node()) {
|
||||
if lhs.children_with_tokens().count() == rhs.children_with_tokens().count() {
|
||||
|
|
|
@ -30,7 +30,7 @@ pub enum ElseBranch {
|
|||
|
||||
impl ast::IfExpr {
|
||||
pub fn then_branch(&self) -> Option<ast::BlockExpr> {
|
||||
self.blocks().nth(0)
|
||||
self.blocks().next()
|
||||
}
|
||||
pub fn else_branch(&self) -> Option<ElseBranch> {
|
||||
let res = match self.blocks().nth(1) {
|
||||
|
@ -208,7 +208,7 @@ impl ast::BinExpr {
|
|||
}
|
||||
|
||||
pub fn lhs(&self) -> Option<ast::Expr> {
|
||||
children(self).nth(0)
|
||||
children(self).next()
|
||||
}
|
||||
|
||||
pub fn rhs(&self) -> Option<ast::Expr> {
|
||||
|
@ -271,7 +271,7 @@ impl ast::RangeExpr {
|
|||
|
||||
impl ast::IndexExpr {
|
||||
pub fn base(&self) -> Option<ast::Expr> {
|
||||
children(self).nth(0)
|
||||
children(self).next()
|
||||
}
|
||||
pub fn index(&self) -> Option<ast::Expr> {
|
||||
children(self).nth(1)
|
||||
|
@ -287,7 +287,7 @@ impl ast::ArrayExpr {
|
|||
pub fn kind(&self) -> ArrayExprKind {
|
||||
if self.is_repeat() {
|
||||
ArrayExprKind::Repeat {
|
||||
initializer: children(self).nth(0),
|
||||
initializer: children(self).next(),
|
||||
repeat: children(self).nth(1),
|
||||
}
|
||||
} else {
|
||||
|
@ -328,10 +328,10 @@ impl ast::Literal {
|
|||
}
|
||||
|
||||
pub fn kind(&self) -> LiteralKind {
|
||||
const INT_SUFFIXES: [&'static str; 12] = [
|
||||
const INT_SUFFIXES: [&str; 12] = [
|
||||
"u64", "u32", "u16", "u8", "usize", "isize", "i64", "i32", "i16", "i8", "u128", "i128",
|
||||
];
|
||||
const FLOAT_SUFFIXES: [&'static str; 2] = ["f32", "f64"];
|
||||
const FLOAT_SUFFIXES: [&str; 2] = ["f32", "f64"];
|
||||
|
||||
let token = self.token();
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ pub fn match_arm_list(arms: impl IntoIterator<Item = ast::MatchArm>) -> ast::Mat
|
|||
format!(" {}{}\n", arm.syntax(), comma)
|
||||
})
|
||||
.collect::<String>();
|
||||
return from_text(&format!("{}", arms_str));
|
||||
return from_text(&arms_str);
|
||||
|
||||
fn from_text(text: &str) -> ast::MatchArmList {
|
||||
ast_from_text(&format!("fn f() {{ match () {{\n{}}} }}", text))
|
||||
|
|
|
@ -48,7 +48,7 @@ impl<'t> TokenSource for TextTokenSource<'t> {
|
|||
|
||||
fn is_keyword(&self, kw: &str) -> bool {
|
||||
let pos = self.curr.1;
|
||||
if !(pos < self.tokens.len()) {
|
||||
if pos >= self.tokens.len() {
|
||||
return false;
|
||||
}
|
||||
let range = TextRange::offset_len(self.start_offsets[pos], self.tokens[pos].len);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
mod args;
|
||||
|
||||
use lsp_server::Connection;
|
||||
use ra_prof;
|
||||
|
||||
use rust_analyzer::{cli, from_json, show_message, Result, ServerConfig};
|
||||
|
||||
use crate::args::HelpPrinted;
|
||||
|
|
|
@ -130,7 +130,7 @@ pub fn analysis_stats(
|
|||
write!(msg, " ({:?} {})", path, syntax_range).unwrap();
|
||||
}
|
||||
if verbosity.is_spammy() {
|
||||
bar.println(format!("{}", msg));
|
||||
bar.println(msg.to_string());
|
||||
}
|
||||
bar.set_message(&msg);
|
||||
let f_id = FunctionId::from(f);
|
||||
|
|
|
@ -206,17 +206,17 @@ pub fn main_loop(
|
|||
let event = select! {
|
||||
recv(&connection.receiver) -> msg => match msg {
|
||||
Ok(msg) => Event::Msg(msg),
|
||||
Err(RecvError) => Err("client exited without shutdown")?,
|
||||
Err(RecvError) => return Err("client exited without shutdown".into()),
|
||||
},
|
||||
recv(task_receiver) -> task => Event::Task(task.unwrap()),
|
||||
recv(world_state.task_receiver) -> task => match task {
|
||||
Ok(task) => Event::Vfs(task),
|
||||
Err(RecvError) => Err("vfs died")?,
|
||||
Err(RecvError) => return Err("vfs died".into()),
|
||||
},
|
||||
recv(libdata_receiver) -> data => Event::Lib(data.unwrap()),
|
||||
recv(world_state.check_watcher.task_recv) -> task => match task {
|
||||
Ok(task) => Event::CheckWatcher(task),
|
||||
Err(RecvError) => Err("check watcher died")?,
|
||||
Err(RecvError) => return Err("check watcher died".into()),
|
||||
}
|
||||
};
|
||||
if let Event::Msg(Message::Request(req)) = &event {
|
||||
|
|
|
@ -17,7 +17,7 @@ use test_utils::skip_slow_tests;
|
|||
|
||||
use crate::support::{project, Project};
|
||||
|
||||
const PROFILE: &'static str = "";
|
||||
const PROFILE: &str = "";
|
||||
// const PROFILE: &'static str = "*@3>100";
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -52,7 +52,7 @@ impl<'a> Project<'a> {
|
|||
let tmp_dir = self.tmp_dir.unwrap_or_else(|| TempDir::new().unwrap());
|
||||
static INIT: Once = Once::new();
|
||||
INIT.call_once(|| {
|
||||
let _ = env_logger::builder().is_test(true).try_init().unwrap();
|
||||
env_logger::builder().is_test(true).try_init().unwrap();
|
||||
ra_prof::set_filter(if crate::PROFILE.is_empty() {
|
||||
ra_prof::Filter::disabled()
|
||||
} else {
|
||||
|
|
|
@ -279,7 +279,7 @@ pub fn find_mismatch<'a>(expected: &'a Value, actual: &'a Value) -> Option<(&'a
|
|||
return Some((expected, actual));
|
||||
}
|
||||
|
||||
l.values().zip(r.values()).filter_map(|(l, r)| find_mismatch(l, r)).nth(0)
|
||||
l.values().zip(r.values()).filter_map(|(l, r)| find_mismatch(l, r)).next()
|
||||
}
|
||||
(&Null, &Null) => None,
|
||||
// magic string literal "{...}" acts as wildcard for any sub-JSON
|
||||
|
|
Loading…
Reference in a new issue