mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
minor: fix some clippy lints
This commit is contained in:
parent
2aee17e556
commit
36a5ce9790
@ -521,8 +521,8 @@ impl fmt::Display for CyclicDependenciesError {
|
||||
write!(
|
||||
f,
|
||||
"cyclic deps: {} -> {}, alternative path: {}",
|
||||
render(&self.from()),
|
||||
render(&self.to()),
|
||||
render(self.from()),
|
||||
render(self.to()),
|
||||
path
|
||||
)
|
||||
}
|
||||
|
@ -339,12 +339,7 @@ impl CargoActor {
|
||||
cargo_metadata::Message::CompilerMessage(msg) => {
|
||||
self.sender.send(CargoMessage::Diagnostic(msg.message)).unwrap()
|
||||
}
|
||||
|
||||
cargo_metadata::Message::CompilerArtifact(_)
|
||||
| cargo_metadata::Message::BuildScriptExecuted(_)
|
||||
| cargo_metadata::Message::BuildFinished(_)
|
||||
| cargo_metadata::Message::TextLine(_)
|
||||
| _ => (),
|
||||
_ => (),
|
||||
},
|
||||
JsonMessage::Rustc(message) => {
|
||||
self.sender.send(CargoMessage::Diagnostic(message)).unwrap()
|
||||
|
@ -60,9 +60,9 @@ impl HasSource for Adt {
|
||||
type Ast = ast::Adt;
|
||||
fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
|
||||
match self {
|
||||
Adt::Struct(s) => Some(s.source(db)?.map(|s| ast::Adt::Struct(s))),
|
||||
Adt::Union(u) => Some(u.source(db)?.map(|u| ast::Adt::Union(u))),
|
||||
Adt::Enum(e) => Some(e.source(db)?.map(|e| ast::Adt::Enum(e))),
|
||||
Adt::Struct(s) => Some(s.source(db)?.map(ast::Adt::Struct)),
|
||||
Adt::Union(u) => Some(u.source(db)?.map(ast::Adt::Union)),
|
||||
Adt::Enum(e) => Some(e.source(db)?.map(ast::Adt::Enum)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2960,9 +2960,9 @@ impl ScopeDef {
|
||||
impl From<ItemInNs> for ScopeDef {
|
||||
fn from(item: ItemInNs) -> Self {
|
||||
match item {
|
||||
ItemInNs::Types(id) => ScopeDef::ModuleDef(id.into()),
|
||||
ItemInNs::Values(id) => ScopeDef::ModuleDef(id.into()),
|
||||
ItemInNs::Macros(id) => ScopeDef::MacroDef(id.into()),
|
||||
ItemInNs::Types(id) => ScopeDef::ModuleDef(id),
|
||||
ItemInNs::Values(id) => ScopeDef::ModuleDef(id),
|
||||
ItemInNs::Macros(id) => ScopeDef::MacroDef(id),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -864,7 +864,7 @@ impl<'db> SemanticsImpl<'db> {
|
||||
}
|
||||
|
||||
fn is_unsafe_ident_pat(&self, ident_pat: &ast::IdentPat) -> bool {
|
||||
if !ident_pat.ref_token().is_some() {
|
||||
if ident_pat.ref_token().is_none() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -264,8 +264,7 @@ impl<'a> Ctx<'a> {
|
||||
let name = Name::new_tuple_field(idx);
|
||||
let visibility = self.lower_visibility(field);
|
||||
let type_ref = self.lower_type_ref_opt(field.ty());
|
||||
let res = Field { name, type_ref, visibility };
|
||||
res
|
||||
Field { name, type_ref, visibility }
|
||||
}
|
||||
|
||||
fn lower_union(&mut self, union: &ast::Union) -> Option<FileItemTreeId<Union>> {
|
||||
|
@ -384,7 +384,7 @@ impl DefCollector<'_> {
|
||||
self.unresolved_imports.extend(partial_resolved);
|
||||
self.resolve_imports();
|
||||
|
||||
let unresolved_imports = std::mem::replace(&mut self.unresolved_imports, Vec::new());
|
||||
let unresolved_imports = std::mem::take(&mut self.unresolved_imports);
|
||||
// show unresolved imports in completion, etc
|
||||
for directive in &unresolved_imports {
|
||||
self.record_resolved_import(directive)
|
||||
@ -417,7 +417,7 @@ impl DefCollector<'_> {
|
||||
fn reseed_with_unresolved_attribute(&mut self) -> ReachedFixedPoint {
|
||||
cov_mark::hit!(unresolved_attribute_fallback);
|
||||
|
||||
let mut unresolved_macros = std::mem::replace(&mut self.unresolved_macros, Vec::new());
|
||||
let mut unresolved_macros = std::mem::take(&mut self.unresolved_macros);
|
||||
let pos = unresolved_macros.iter().position(|directive| {
|
||||
if let MacroDirectiveKind::Attr { ast_id, mod_item, attr } = &directive.kind {
|
||||
self.skip_attrs.insert(ast_id.ast_id.with_value(*mod_item), attr.id);
|
||||
@ -689,7 +689,7 @@ impl DefCollector<'_> {
|
||||
/// Tries to resolve every currently unresolved import.
|
||||
fn resolve_imports(&mut self) -> ReachedFixedPoint {
|
||||
let mut res = ReachedFixedPoint::Yes;
|
||||
let imports = std::mem::replace(&mut self.unresolved_imports, Vec::new());
|
||||
let imports = std::mem::take(&mut self.unresolved_imports);
|
||||
let imports = imports
|
||||
.into_iter()
|
||||
.filter_map(|mut directive| {
|
||||
@ -1005,7 +1005,7 @@ impl DefCollector<'_> {
|
||||
}
|
||||
|
||||
fn resolve_macros(&mut self) -> ReachedFixedPoint {
|
||||
let mut macros = std::mem::replace(&mut self.unresolved_macros, Vec::new());
|
||||
let mut macros = std::mem::take(&mut self.unresolved_macros);
|
||||
let mut resolved = Vec::new();
|
||||
let mut res = ReachedFixedPoint::Yes;
|
||||
macros.retain(|directive| {
|
||||
@ -1279,13 +1279,12 @@ impl DefCollector<'_> {
|
||||
|
||||
for directive in &self.unresolved_imports {
|
||||
if let ImportSource::Import { id: import, use_tree } = &directive.import.source {
|
||||
match (directive.import.path.segments().first(), &directive.import.path.kind) {
|
||||
(Some(krate), PathKind::Plain | PathKind::Abs) => {
|
||||
if diagnosed_extern_crates.contains(krate) {
|
||||
continue;
|
||||
}
|
||||
if let (Some(krate), PathKind::Plain | PathKind::Abs) =
|
||||
(directive.import.path.segments().first(), &directive.import.path.kind)
|
||||
{
|
||||
if diagnosed_extern_crates.contains(krate) {
|
||||
continue;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
self.def_map.diagnostics.push(DefDiagnostic::unresolved_import(
|
||||
@ -1579,13 +1578,13 @@ impl ModCollector<'_, '_> {
|
||||
{
|
||||
Ok((file_id, is_mod_rs, mod_dir)) => {
|
||||
let item_tree = db.file_item_tree(file_id.into());
|
||||
if item_tree
|
||||
let is_enabled = item_tree
|
||||
.top_level_attrs(db, self.def_collector.def_map.krate)
|
||||
.cfg()
|
||||
.map_or(true, |cfg| {
|
||||
self.def_collector.cfg_options.check(&cfg) != Some(false)
|
||||
})
|
||||
{
|
||||
});
|
||||
if is_enabled {
|
||||
let module_id = self.push_child_module(
|
||||
module.name.clone(),
|
||||
ast_id,
|
||||
|
@ -107,7 +107,7 @@ pub fn expand_eager_macro(
|
||||
mut diagnostic_sink: &mut dyn FnMut(mbe::ExpandError),
|
||||
) -> Result<MacroCallId, ErrorEmitted> {
|
||||
let parsed_args = diagnostic_sink.option_with(
|
||||
|| Some(mbe::syntax_node_to_token_tree(¯o_call.value.token_tree()?.syntax()).0),
|
||||
|| Some(mbe::syntax_node_to_token_tree(macro_call.value.token_tree()?.syntax()).0),
|
||||
|| err("malformed macro invocation"),
|
||||
)?;
|
||||
|
||||
|
@ -205,10 +205,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
|
||||
let (datas, binders) = (*datas).as_ref().into_value_and_skipped_binders();
|
||||
let data = &datas.impl_traits[idx as usize];
|
||||
let bound = OpaqueTyDatumBound {
|
||||
bounds: make_only_type_binders(
|
||||
1,
|
||||
data.bounds.skip_binders().iter().cloned().collect(),
|
||||
),
|
||||
bounds: make_only_type_binders(1, data.bounds.skip_binders().to_vec()),
|
||||
where_clauses: make_only_type_binders(0, vec![]),
|
||||
};
|
||||
chalk_ir::Binders::new(binders, bound)
|
||||
@ -309,7 +306,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
|
||||
let sig_ty = substs.at(&Interner, 0).assert_ty_ref(&Interner).clone();
|
||||
let sig = &sig_ty.callable_sig(self.db).expect("first closure param should be fn ptr");
|
||||
let io = rust_ir::FnDefInputsAndOutputDatum {
|
||||
argument_types: sig.params().iter().cloned().collect(),
|
||||
argument_types: sig.params().to_vec(),
|
||||
return_type: sig.ret().clone(),
|
||||
};
|
||||
make_only_type_binders(0, io.shifted_in(&Interner))
|
||||
@ -675,7 +672,7 @@ pub(crate) fn fn_def_datum_query(
|
||||
inputs_and_output: make_only_type_binders(
|
||||
0,
|
||||
rust_ir::FnDefInputsAndOutputDatum {
|
||||
argument_types: sig.params().iter().cloned().collect(),
|
||||
argument_types: sig.params().to_vec(),
|
||||
return_type: sig.ret().clone(),
|
||||
}
|
||||
.shifted_in(&Interner),
|
||||
|
@ -242,7 +242,7 @@ impl TyExt for Ty {
|
||||
let substs = TyBuilder::type_params_subst(db, id.parent);
|
||||
let predicates = db
|
||||
.generic_predicates(id.parent)
|
||||
.into_iter()
|
||||
.iter()
|
||||
.map(|pred| pred.clone().substitute(&Interner, &substs))
|
||||
.filter(|wc| match &wc.skip_binders() {
|
||||
WhereClause::Implemented(tr) => {
|
||||
|
@ -63,7 +63,7 @@ impl<'a> DeclValidator<'a> {
|
||||
ModuleDefId::AdtId(adt) => self.validate_adt(adt),
|
||||
ModuleDefId::ConstId(const_id) => self.validate_const(const_id),
|
||||
ModuleDefId::StaticId(static_id) => self.validate_static(static_id),
|
||||
_ => return,
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,10 +82,10 @@ pub(super) struct IntRange {
|
||||
impl IntRange {
|
||||
#[inline]
|
||||
fn is_integral(ty: &Ty) -> bool {
|
||||
match ty.kind(&Interner) {
|
||||
TyKind::Scalar(Scalar::Char | Scalar::Int(_) | Scalar::Uint(_) | Scalar::Bool) => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(
|
||||
ty.kind(&Interner),
|
||||
TyKind::Scalar(Scalar::Char | Scalar::Int(_) | Scalar::Uint(_) | Scalar::Bool)
|
||||
)
|
||||
}
|
||||
|
||||
fn is_singleton(&self) -> bool {
|
||||
@ -729,16 +729,12 @@ impl Fields {
|
||||
})
|
||||
.collect();
|
||||
|
||||
if let Some((adt, substs)) = pcx.ty.as_adt() {
|
||||
if let hir_def::AdtId::EnumId(_) = adt {
|
||||
let enum_variant = match ctor {
|
||||
&Variant(id) => id,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
PatKind::Variant { substs: substs.clone(), enum_variant, subpatterns }
|
||||
} else {
|
||||
PatKind::Leaf { subpatterns }
|
||||
}
|
||||
if let Some((hir_def::AdtId::EnumId(_), substs)) = pcx.ty.as_adt() {
|
||||
let enum_variant = match ctor {
|
||||
&Variant(id) => id,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
PatKind::Variant { substs: substs.clone(), enum_variant, subpatterns }
|
||||
} else {
|
||||
PatKind::Leaf { subpatterns }
|
||||
}
|
||||
|
@ -686,17 +686,17 @@ impl SubPatSet {
|
||||
SubPatSet::Empty => panic!("bug"),
|
||||
SubPatSet::Full => {}
|
||||
SubPatSet::Seq { subpats } => {
|
||||
for (_, sub_set) in subpats {
|
||||
for sub_set in subpats.values() {
|
||||
fill_subpats(sub_set, unreachable_pats, cx);
|
||||
}
|
||||
}
|
||||
SubPatSet::Alt { subpats, pat, alt_count, .. } => {
|
||||
let expanded = pat.expand_or_pat(cx);
|
||||
for i in 0..*alt_count {
|
||||
for (i, &expanded) in expanded.iter().enumerate().take(*alt_count) {
|
||||
let sub_set = subpats.get(&i).unwrap_or(&SubPatSet::Empty);
|
||||
if sub_set.is_empty() {
|
||||
// Found an unreachable subpattern.
|
||||
unreachable_pats.push(expanded[i]);
|
||||
unreachable_pats.push(expanded);
|
||||
} else {
|
||||
fill_subpats(sub_set, unreachable_pats, cx);
|
||||
}
|
||||
|
@ -666,7 +666,7 @@ impl HirDisplay for Ty {
|
||||
let substs = generics.type_params_subst(f.db);
|
||||
let bounds =
|
||||
f.db.generic_predicates(id.parent)
|
||||
.into_iter()
|
||||
.iter()
|
||||
.map(|pred| pred.clone().substitute(&Interner, &substs))
|
||||
.filter(|wc| match &wc.skip_binders() {
|
||||
WhereClause::Implemented(tr) => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! Inference of closure parameter types based on the closure's expected type.
|
||||
|
||||
use chalk_ir::{cast::Cast, AliasTy, FnSubst, WhereClause};
|
||||
use chalk_ir::{cast::Cast, AliasEq, AliasTy, FnSubst, WhereClause};
|
||||
use hir_def::{expr::ExprId, HasModule};
|
||||
use smallvec::SmallVec;
|
||||
|
||||
@ -42,46 +42,38 @@ impl InferenceContext<'_> {
|
||||
|
||||
let fn_traits: SmallVec<[ChalkTraitId; 3]> =
|
||||
utils::fn_traits(self.db.upcast(), self.owner.module(self.db.upcast()).krate())
|
||||
.map(|tid| to_chalk_trait_id(tid))
|
||||
.map(to_chalk_trait_id)
|
||||
.collect();
|
||||
|
||||
let self_ty = TyKind::Error.intern(&Interner);
|
||||
let bounds = dyn_ty.bounds.clone().substitute(&Interner, &[self_ty.cast(&Interner)]);
|
||||
for bound in bounds.iter(&Interner) {
|
||||
// NOTE(skip_binders): the extracted types are rebound by the returned `FnPointer`
|
||||
match bound.skip_binders() {
|
||||
WhereClause::AliasEq(eq) => match &eq.alias {
|
||||
AliasTy::Projection(projection) => {
|
||||
let assoc_data = self.db.associated_ty_data(projection.associated_ty_id);
|
||||
if !fn_traits.contains(&assoc_data.trait_id) {
|
||||
return None;
|
||||
}
|
||||
if let WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(projection), ty }) =
|
||||
bound.skip_binders()
|
||||
{
|
||||
let assoc_data = self.db.associated_ty_data(projection.associated_ty_id);
|
||||
if !fn_traits.contains(&assoc_data.trait_id) {
|
||||
return None;
|
||||
}
|
||||
|
||||
// Skip `Self`, get the type argument.
|
||||
let arg = projection.substitution.as_slice(&Interner).get(1)?;
|
||||
if let Some(subst) = arg.ty(&Interner)?.as_tuple() {
|
||||
let generic_args = subst.as_slice(&Interner);
|
||||
let mut sig_tys = Vec::new();
|
||||
for arg in generic_args {
|
||||
sig_tys.push(arg.ty(&Interner)?.clone());
|
||||
}
|
||||
sig_tys.push(eq.ty.clone());
|
||||
|
||||
cov_mark::hit!(dyn_fn_param_informs_call_site_closure_signature);
|
||||
return Some(FnPointer {
|
||||
num_binders: bound.len(&Interner),
|
||||
sig: FnSig {
|
||||
abi: (),
|
||||
safety: chalk_ir::Safety::Safe,
|
||||
variadic: false,
|
||||
},
|
||||
substitution: FnSubst(Substitution::from_iter(&Interner, sig_tys)),
|
||||
});
|
||||
}
|
||||
// Skip `Self`, get the type argument.
|
||||
let arg = projection.substitution.as_slice(&Interner).get(1)?;
|
||||
if let Some(subst) = arg.ty(&Interner)?.as_tuple() {
|
||||
let generic_args = subst.as_slice(&Interner);
|
||||
let mut sig_tys = Vec::new();
|
||||
for arg in generic_args {
|
||||
sig_tys.push(arg.ty(&Interner)?.clone());
|
||||
}
|
||||
AliasTy::Opaque(_) => {}
|
||||
},
|
||||
_ => {}
|
||||
sig_tys.push(ty.clone());
|
||||
|
||||
cov_mark::hit!(dyn_fn_param_informs_call_site_closure_signature);
|
||||
return Some(FnPointer {
|
||||
num_binders: bound.len(&Interner),
|
||||
sig: FnSig { abi: (), safety: chalk_ir::Safety::Safe, variadic: false },
|
||||
substitution: FnSubst(Substitution::from_iter(&Interner, sig_tys)),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ impl<'a> InferenceContext<'a> {
|
||||
/// Return the type after possible coercion.
|
||||
pub(super) fn infer_expr_coerce(&mut self, expr: ExprId, expected: &Expectation) -> Ty {
|
||||
let ty = self.infer_expr_inner(expr, expected);
|
||||
let ty = if let Some(target) = expected.only_has_type(&mut self.table) {
|
||||
if let Some(target) = expected.only_has_type(&mut self.table) {
|
||||
match self.coerce(Some(expr), &ty, &target) {
|
||||
Ok(res) => res.value,
|
||||
Err(_) => {
|
||||
@ -77,9 +77,7 @@ impl<'a> InferenceContext<'a> {
|
||||
}
|
||||
} else {
|
||||
ty
|
||||
};
|
||||
|
||||
ty
|
||||
}
|
||||
}
|
||||
|
||||
fn callable_sig_from_fn_trait(&mut self, ty: &Ty, num_args: usize) -> Option<(Vec<Ty>, Ty)> {
|
||||
@ -899,9 +897,7 @@ impl<'a> InferenceContext<'a> {
|
||||
if let Some(builtin_rhs) = self.builtin_binary_op_rhs_expectation(op, lhs_ty.clone()) {
|
||||
self.unify(&builtin_rhs, &rhs_ty);
|
||||
}
|
||||
if let Some(builtin_ret) =
|
||||
self.builtin_binary_op_return_ty(op, lhs_ty.clone(), rhs_ty.clone())
|
||||
{
|
||||
if let Some(builtin_ret) = self.builtin_binary_op_return_ty(op, lhs_ty, rhs_ty) {
|
||||
self.unify(&builtin_ret, &ret_ty);
|
||||
}
|
||||
|
||||
@ -942,7 +938,7 @@ impl<'a> InferenceContext<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
let ty = if let Some(expr) = tail {
|
||||
if let Some(expr) = tail {
|
||||
self.infer_expr_coerce(expr, expected)
|
||||
} else {
|
||||
// Citing rustc: if there is no explicit tail expression,
|
||||
@ -961,8 +957,7 @@ impl<'a> InferenceContext<'a> {
|
||||
}
|
||||
TyBuilder::unit()
|
||||
}
|
||||
};
|
||||
ty
|
||||
}
|
||||
}
|
||||
|
||||
fn infer_method_call(
|
||||
@ -1032,7 +1027,7 @@ impl<'a> InferenceContext<'a> {
|
||||
inputs: Vec<Ty>,
|
||||
) -> Vec<Ty> {
|
||||
if let Some(expected_ty) = expected_output.to_option(&mut self.table) {
|
||||
let result = self.table.fudge_inference(|table| {
|
||||
self.table.fudge_inference(|table| {
|
||||
if table.try_unify(&expected_ty, &output).is_ok() {
|
||||
table.resolve_with_fallback(inputs, |var, kind, _, _| match kind {
|
||||
chalk_ir::VariableKind::Ty(tk) => var.to_ty(&Interner, tk).cast(&Interner),
|
||||
@ -1046,8 +1041,7 @@ impl<'a> InferenceContext<'a> {
|
||||
} else {
|
||||
Vec::new()
|
||||
}
|
||||
});
|
||||
result
|
||||
})
|
||||
} else {
|
||||
Vec::new()
|
||||
}
|
||||
|
@ -245,8 +245,7 @@ impl<'a> InferenceContext<'a> {
|
||||
Pat::Wild => expected.clone(),
|
||||
Pat::Range { start, end } => {
|
||||
let start_ty = self.infer_expr(*start, &Expectation::has_type(expected.clone()));
|
||||
let end_ty = self.infer_expr(*end, &Expectation::has_type(start_ty));
|
||||
end_ty
|
||||
self.infer_expr(*end, &Expectation::has_type(start_ty))
|
||||
}
|
||||
Pat::Lit(expr) => self.infer_expr(*expr, &Expectation::has_type(expected.clone())),
|
||||
Pat::Box { inner } => match self.resolve_boxed_box() {
|
||||
@ -297,10 +296,7 @@ fn is_non_ref_pat(body: &hir_def::body::Body, pat: PatId) -> bool {
|
||||
// FIXME: ConstBlock/Path/Lit might actually evaluate to ref, but inference is unimplemented.
|
||||
Pat::Path(..) => true,
|
||||
Pat::ConstBlock(..) => true,
|
||||
Pat::Lit(expr) => match body[*expr] {
|
||||
Expr::Literal(Literal::String(..)) => false,
|
||||
_ => true,
|
||||
},
|
||||
Pat::Lit(expr) => !matches!(body[*expr], Expr::Literal(Literal::String(..))),
|
||||
Pat::Bind {
|
||||
mode: BindingAnnotation::Mutable | BindingAnnotation::Unannotated,
|
||||
subpat: Some(subpat),
|
||||
|
@ -460,12 +460,9 @@ impl<'a> InferenceTable<'a> {
|
||||
self.new_type_var().inference_var(&Interner).expect("inference_var");
|
||||
let result = f(self);
|
||||
self.rollback_to(snapshot);
|
||||
|
||||
let result = result
|
||||
.fold_with(&mut VarFudger { table: self, highest_known_var }, DebruijnIndex::INNERMOST)
|
||||
.expect("fold_with with VarFudger");
|
||||
|
||||
result
|
||||
.fold_with(&mut VarFudger { table: self, highest_known_var }, DebruijnIndex::INNERMOST)
|
||||
.expect("fold_with with VarFudger")
|
||||
}
|
||||
|
||||
/// This checks whether any of the free variables in the `canonicalized`
|
||||
|
@ -387,15 +387,17 @@ impl<'a> TyLoweringContext<'a> {
|
||||
res: Option<TypeNs>,
|
||||
remaining_segments: PathSegments<'_>,
|
||||
) -> (Ty, Option<TypeNs>) {
|
||||
if remaining_segments.len() == 1 {
|
||||
// resolve unselected assoc types
|
||||
let segment = remaining_segments.first().unwrap();
|
||||
(self.select_associated_type(res, segment), None)
|
||||
} else if remaining_segments.len() > 1 {
|
||||
// FIXME report error (ambiguous associated type)
|
||||
(TyKind::Error.intern(&Interner), None)
|
||||
} else {
|
||||
(ty, res)
|
||||
match remaining_segments.len() {
|
||||
0 => (ty, res),
|
||||
1 => {
|
||||
// resolve unselected assoc types
|
||||
let segment = remaining_segments.first().unwrap();
|
||||
(self.select_associated_type(res, segment), None)
|
||||
}
|
||||
_ => {
|
||||
// FIXME report error (ambiguous associated type)
|
||||
(TyKind::Error.intern(&Interner), None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ impl TraitImpls {
|
||||
let crate_def_map = db.crate_def_map(krate);
|
||||
impls.collect_def_map(db, &crate_def_map);
|
||||
|
||||
return Arc::new(impls);
|
||||
Arc::new(impls)
|
||||
}
|
||||
|
||||
pub(crate) fn trait_impls_in_block_query(
|
||||
@ -154,7 +154,7 @@ impl TraitImpls {
|
||||
let block_def_map = db.block_def_map(block)?;
|
||||
impls.collect_def_map(db, &block_def_map);
|
||||
|
||||
return Some(Arc::new(impls));
|
||||
Some(Arc::new(impls))
|
||||
}
|
||||
|
||||
fn collect_def_map(&mut self, db: &dyn HirDatabase, def_map: &DefMap) {
|
||||
|
@ -130,8 +130,7 @@ fn solve(
|
||||
let solution = if is_chalk_print() {
|
||||
let logging_db =
|
||||
LoggingRustIrDatabaseLoggingOnDrop(LoggingRustIrDatabase::new(context));
|
||||
let solution = solver.solve_limited(&logging_db.0, goal, &should_continue);
|
||||
solution
|
||||
solver.solve_limited(&logging_db.0, goal, &should_continue)
|
||||
} else {
|
||||
solver.solve_limited(&context, goal, &should_continue)
|
||||
};
|
||||
@ -143,10 +142,11 @@ fn solve(
|
||||
|
||||
// don't set the TLS for Chalk unless Chalk debugging is active, to make
|
||||
// extra sure we only use it for debugging
|
||||
let solution =
|
||||
if is_chalk_debug() { crate::tls::set_current_program(db, solve) } else { solve() };
|
||||
|
||||
solution
|
||||
if is_chalk_debug() {
|
||||
crate::tls::set_current_program(db, solve)
|
||||
} else {
|
||||
solve()
|
||||
}
|
||||
}
|
||||
|
||||
struct LoggingRustIrDatabaseLoggingOnDrop<'a>(LoggingRustIrDatabase<Interner, ChalkContext<'a>>);
|
||||
|
@ -86,11 +86,8 @@ impl TypeWalk for AliasTy {
|
||||
|
||||
impl TypeWalk for GenericArg {
|
||||
fn walk(&self, f: &mut impl FnMut(&Ty)) {
|
||||
match &self.interned() {
|
||||
GenericArgData::Ty(ty) => {
|
||||
ty.walk(f);
|
||||
}
|
||||
_ => {}
|
||||
if let GenericArgData::Ty(ty) = &self.interned() {
|
||||
ty.walk(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ struct Struct {
|
||||
field: ()
|
||||
}
|
||||
"##;
|
||||
let source_file = ast::SourceFile::parse(&source).ok().unwrap();
|
||||
let source_file = ast::SourceFile::parse(source).ok().unwrap();
|
||||
let item = source_file.items().next().unwrap();
|
||||
let attr = item.attrs().nth(1).unwrap();
|
||||
|
||||
@ -258,7 +258,7 @@ struct Struct {
|
||||
field: ()
|
||||
}
|
||||
"##;
|
||||
let source_file = ast::SourceFile::parse(&source).ok().unwrap();
|
||||
let source_file = ast::SourceFile::parse(source).ok().unwrap();
|
||||
let item = source_file.items().next().unwrap();
|
||||
let attr = item.attrs().nth(1).unwrap();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user