10135: minor: fix some clippy lints r=lnicola a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-09-03 14:28:27 +00:00 committed by GitHub
commit ac2520128d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 102 additions and 138 deletions

View File

@ -521,8 +521,8 @@ impl fmt::Display for CyclicDependenciesError {
write!( write!(
f, f,
"cyclic deps: {} -> {}, alternative path: {}", "cyclic deps: {} -> {}, alternative path: {}",
render(&self.from()), render(self.from()),
render(&self.to()), render(self.to()),
path path
) )
} }

View File

@ -339,12 +339,7 @@ impl CargoActor {
cargo_metadata::Message::CompilerMessage(msg) => { cargo_metadata::Message::CompilerMessage(msg) => {
self.sender.send(CargoMessage::Diagnostic(msg.message)).unwrap() 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) => { JsonMessage::Rustc(message) => {
self.sender.send(CargoMessage::Diagnostic(message)).unwrap() self.sender.send(CargoMessage::Diagnostic(message)).unwrap()

View File

@ -60,9 +60,9 @@ impl HasSource for Adt {
type Ast = ast::Adt; type Ast = ast::Adt;
fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> { fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
match self { match self {
Adt::Struct(s) => Some(s.source(db)?.map(|s| ast::Adt::Struct(s))), Adt::Struct(s) => Some(s.source(db)?.map(ast::Adt::Struct)),
Adt::Union(u) => Some(u.source(db)?.map(|u| ast::Adt::Union(u))), Adt::Union(u) => Some(u.source(db)?.map(ast::Adt::Union)),
Adt::Enum(e) => Some(e.source(db)?.map(|e| ast::Adt::Enum(e))), Adt::Enum(e) => Some(e.source(db)?.map(ast::Adt::Enum)),
} }
} }
} }

View File

@ -2960,9 +2960,9 @@ impl ScopeDef {
impl From<ItemInNs> for ScopeDef { impl From<ItemInNs> for ScopeDef {
fn from(item: ItemInNs) -> Self { fn from(item: ItemInNs) -> Self {
match item { match item {
ItemInNs::Types(id) => ScopeDef::ModuleDef(id.into()), ItemInNs::Types(id) => ScopeDef::ModuleDef(id),
ItemInNs::Values(id) => ScopeDef::ModuleDef(id.into()), ItemInNs::Values(id) => ScopeDef::ModuleDef(id),
ItemInNs::Macros(id) => ScopeDef::MacroDef(id.into()), ItemInNs::Macros(id) => ScopeDef::MacroDef(id),
} }
} }
} }

View File

@ -872,7 +872,7 @@ impl<'db> SemanticsImpl<'db> {
} }
fn is_unsafe_ident_pat(&self, ident_pat: &ast::IdentPat) -> bool { 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; return false;
} }

View File

@ -264,8 +264,7 @@ impl<'a> Ctx<'a> {
let name = Name::new_tuple_field(idx); let name = Name::new_tuple_field(idx);
let visibility = self.lower_visibility(field); let visibility = self.lower_visibility(field);
let type_ref = self.lower_type_ref_opt(field.ty()); let type_ref = self.lower_type_ref_opt(field.ty());
let res = Field { name, type_ref, visibility }; Field { name, type_ref, visibility }
res
} }
fn lower_union(&mut self, union: &ast::Union) -> Option<FileItemTreeId<Union>> { fn lower_union(&mut self, union: &ast::Union) -> Option<FileItemTreeId<Union>> {

View File

@ -384,7 +384,7 @@ impl DefCollector<'_> {
self.unresolved_imports.extend(partial_resolved); self.unresolved_imports.extend(partial_resolved);
self.resolve_imports(); 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 // show unresolved imports in completion, etc
for directive in &unresolved_imports { for directive in &unresolved_imports {
self.record_resolved_import(directive) self.record_resolved_import(directive)
@ -417,7 +417,7 @@ impl DefCollector<'_> {
fn reseed_with_unresolved_attribute(&mut self) -> ReachedFixedPoint { fn reseed_with_unresolved_attribute(&mut self) -> ReachedFixedPoint {
cov_mark::hit!(unresolved_attribute_fallback); 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| { let pos = unresolved_macros.iter().position(|directive| {
if let MacroDirectiveKind::Attr { ast_id, mod_item, attr } = &directive.kind { 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); 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. /// Tries to resolve every currently unresolved import.
fn resolve_imports(&mut self) -> ReachedFixedPoint { fn resolve_imports(&mut self) -> ReachedFixedPoint {
let mut res = ReachedFixedPoint::Yes; 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 let imports = imports
.into_iter() .into_iter()
.filter_map(|mut directive| { .filter_map(|mut directive| {
@ -1005,7 +1005,7 @@ impl DefCollector<'_> {
} }
fn resolve_macros(&mut self) -> ReachedFixedPoint { 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 resolved = Vec::new();
let mut res = ReachedFixedPoint::Yes; let mut res = ReachedFixedPoint::Yes;
macros.retain(|directive| { macros.retain(|directive| {
@ -1279,14 +1279,13 @@ impl DefCollector<'_> {
for directive in &self.unresolved_imports { for directive in &self.unresolved_imports {
if let ImportSource::Import { id: import, use_tree } = &directive.import.source { if let ImportSource::Import { id: import, use_tree } = &directive.import.source {
match (directive.import.path.segments().first(), &directive.import.path.kind) { if let (Some(krate), PathKind::Plain | PathKind::Abs) =
(Some(krate), PathKind::Plain | PathKind::Abs) => { (directive.import.path.segments().first(), &directive.import.path.kind)
{
if diagnosed_extern_crates.contains(krate) { if diagnosed_extern_crates.contains(krate) {
continue; continue;
} }
} }
_ => {}
}
self.def_map.diagnostics.push(DefDiagnostic::unresolved_import( self.def_map.diagnostics.push(DefDiagnostic::unresolved_import(
directive.module_id, directive.module_id,
@ -1579,13 +1578,13 @@ impl ModCollector<'_, '_> {
{ {
Ok((file_id, is_mod_rs, mod_dir)) => { Ok((file_id, is_mod_rs, mod_dir)) => {
let item_tree = db.file_item_tree(file_id.into()); 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) .top_level_attrs(db, self.def_collector.def_map.krate)
.cfg() .cfg()
.map_or(true, |cfg| { .map_or(true, |cfg| {
self.def_collector.cfg_options.check(&cfg) != Some(false) self.def_collector.cfg_options.check(&cfg) != Some(false)
}) });
{ if is_enabled {
let module_id = self.push_child_module( let module_id = self.push_child_module(
module.name.clone(), module.name.clone(),
ast_id, ast_id,

View File

@ -107,7 +107,7 @@ pub fn expand_eager_macro(
mut diagnostic_sink: &mut dyn FnMut(mbe::ExpandError), mut diagnostic_sink: &mut dyn FnMut(mbe::ExpandError),
) -> Result<MacroCallId, ErrorEmitted> { ) -> Result<MacroCallId, ErrorEmitted> {
let parsed_args = diagnostic_sink.option_with( let parsed_args = diagnostic_sink.option_with(
|| Some(mbe::syntax_node_to_token_tree(&macro_call.value.token_tree()?.syntax()).0), || Some(mbe::syntax_node_to_token_tree(macro_call.value.token_tree()?.syntax()).0),
|| err("malformed macro invocation"), || err("malformed macro invocation"),
)?; )?;

View File

@ -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 (datas, binders) = (*datas).as_ref().into_value_and_skipped_binders();
let data = &datas.impl_traits[idx as usize]; let data = &datas.impl_traits[idx as usize];
let bound = OpaqueTyDatumBound { let bound = OpaqueTyDatumBound {
bounds: make_only_type_binders( bounds: make_only_type_binders(1, data.bounds.skip_binders().to_vec()),
1,
data.bounds.skip_binders().iter().cloned().collect(),
),
where_clauses: make_only_type_binders(0, vec![]), where_clauses: make_only_type_binders(0, vec![]),
}; };
chalk_ir::Binders::new(binders, bound) 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_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 sig = &sig_ty.callable_sig(self.db).expect("first closure param should be fn ptr");
let io = rust_ir::FnDefInputsAndOutputDatum { let io = rust_ir::FnDefInputsAndOutputDatum {
argument_types: sig.params().iter().cloned().collect(), argument_types: sig.params().to_vec(),
return_type: sig.ret().clone(), return_type: sig.ret().clone(),
}; };
make_only_type_binders(0, io.shifted_in(&Interner)) 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( inputs_and_output: make_only_type_binders(
0, 0,
rust_ir::FnDefInputsAndOutputDatum { rust_ir::FnDefInputsAndOutputDatum {
argument_types: sig.params().iter().cloned().collect(), argument_types: sig.params().to_vec(),
return_type: sig.ret().clone(), return_type: sig.ret().clone(),
} }
.shifted_in(&Interner), .shifted_in(&Interner),

View File

@ -242,7 +242,7 @@ impl TyExt for Ty {
let substs = TyBuilder::type_params_subst(db, id.parent); let substs = TyBuilder::type_params_subst(db, id.parent);
let predicates = db let predicates = db
.generic_predicates(id.parent) .generic_predicates(id.parent)
.into_iter() .iter()
.map(|pred| pred.clone().substitute(&Interner, &substs)) .map(|pred| pred.clone().substitute(&Interner, &substs))
.filter(|wc| match &wc.skip_binders() { .filter(|wc| match &wc.skip_binders() {
WhereClause::Implemented(tr) => { WhereClause::Implemented(tr) => {

View File

@ -63,7 +63,7 @@ impl<'a> DeclValidator<'a> {
ModuleDefId::AdtId(adt) => self.validate_adt(adt), ModuleDefId::AdtId(adt) => self.validate_adt(adt),
ModuleDefId::ConstId(const_id) => self.validate_const(const_id), ModuleDefId::ConstId(const_id) => self.validate_const(const_id),
ModuleDefId::StaticId(static_id) => self.validate_static(static_id), ModuleDefId::StaticId(static_id) => self.validate_static(static_id),
_ => return, _ => (),
} }
} }

View File

@ -82,10 +82,10 @@ pub(super) struct IntRange {
impl IntRange { impl IntRange {
#[inline] #[inline]
fn is_integral(ty: &Ty) -> bool { fn is_integral(ty: &Ty) -> bool {
match ty.kind(&Interner) { matches!(
TyKind::Scalar(Scalar::Char | Scalar::Int(_) | Scalar::Uint(_) | Scalar::Bool) => true, ty.kind(&Interner),
_ => false, TyKind::Scalar(Scalar::Char | Scalar::Int(_) | Scalar::Uint(_) | Scalar::Bool)
} )
} }
fn is_singleton(&self) -> bool { fn is_singleton(&self) -> bool {
@ -729,8 +729,7 @@ impl Fields {
}) })
.collect(); .collect();
if let Some((adt, substs)) = pcx.ty.as_adt() { if let Some((hir_def::AdtId::EnumId(_), substs)) = pcx.ty.as_adt() {
if let hir_def::AdtId::EnumId(_) = adt {
let enum_variant = match ctor { let enum_variant = match ctor {
&Variant(id) => id, &Variant(id) => id,
_ => unreachable!(), _ => unreachable!(),
@ -739,9 +738,6 @@ impl Fields {
} else { } else {
PatKind::Leaf { subpatterns } PatKind::Leaf { subpatterns }
} }
} else {
PatKind::Leaf { subpatterns }
}
} }
// Note: given the expansion of `&str` patterns done in `expand_pattern`, we should // Note: given the expansion of `&str` patterns done in `expand_pattern`, we should
// be careful to reconstruct the correct constant pattern here. However a string // be careful to reconstruct the correct constant pattern here. However a string

View File

@ -686,17 +686,17 @@ impl SubPatSet {
SubPatSet::Empty => panic!("bug"), SubPatSet::Empty => panic!("bug"),
SubPatSet::Full => {} SubPatSet::Full => {}
SubPatSet::Seq { subpats } => { SubPatSet::Seq { subpats } => {
for (_, sub_set) in subpats { for sub_set in subpats.values() {
fill_subpats(sub_set, unreachable_pats, cx); fill_subpats(sub_set, unreachable_pats, cx);
} }
} }
SubPatSet::Alt { subpats, pat, alt_count, .. } => { SubPatSet::Alt { subpats, pat, alt_count, .. } => {
let expanded = pat.expand_or_pat(cx); 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); let sub_set = subpats.get(&i).unwrap_or(&SubPatSet::Empty);
if sub_set.is_empty() { if sub_set.is_empty() {
// Found an unreachable subpattern. // Found an unreachable subpattern.
unreachable_pats.push(expanded[i]); unreachable_pats.push(expanded);
} else { } else {
fill_subpats(sub_set, unreachable_pats, cx); fill_subpats(sub_set, unreachable_pats, cx);
} }

View File

@ -666,7 +666,7 @@ impl HirDisplay for Ty {
let substs = generics.type_params_subst(f.db); let substs = generics.type_params_subst(f.db);
let bounds = let bounds =
f.db.generic_predicates(id.parent) f.db.generic_predicates(id.parent)
.into_iter() .iter()
.map(|pred| pred.clone().substitute(&Interner, &substs)) .map(|pred| pred.clone().substitute(&Interner, &substs))
.filter(|wc| match &wc.skip_binders() { .filter(|wc| match &wc.skip_binders() {
WhereClause::Implemented(tr) => { WhereClause::Implemented(tr) => {

View File

@ -1,6 +1,6 @@
//! Inference of closure parameter types based on the closure's expected type. //! 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 hir_def::{expr::ExprId, HasModule};
use smallvec::SmallVec; use smallvec::SmallVec;
@ -42,16 +42,16 @@ impl InferenceContext<'_> {
let fn_traits: SmallVec<[ChalkTraitId; 3]> = let fn_traits: SmallVec<[ChalkTraitId; 3]> =
utils::fn_traits(self.db.upcast(), self.owner.module(self.db.upcast()).krate()) 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(); .collect();
let self_ty = TyKind::Error.intern(&Interner); let self_ty = TyKind::Error.intern(&Interner);
let bounds = dyn_ty.bounds.clone().substitute(&Interner, &[self_ty.cast(&Interner)]); let bounds = dyn_ty.bounds.clone().substitute(&Interner, &[self_ty.cast(&Interner)]);
for bound in bounds.iter(&Interner) { for bound in bounds.iter(&Interner) {
// NOTE(skip_binders): the extracted types are rebound by the returned `FnPointer` // NOTE(skip_binders): the extracted types are rebound by the returned `FnPointer`
match bound.skip_binders() { if let WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(projection), ty }) =
WhereClause::AliasEq(eq) => match &eq.alias { bound.skip_binders()
AliasTy::Projection(projection) => { {
let assoc_data = self.db.associated_ty_data(projection.associated_ty_id); let assoc_data = self.db.associated_ty_data(projection.associated_ty_id);
if !fn_traits.contains(&assoc_data.trait_id) { if !fn_traits.contains(&assoc_data.trait_id) {
return None; return None;
@ -65,24 +65,16 @@ impl InferenceContext<'_> {
for arg in generic_args { for arg in generic_args {
sig_tys.push(arg.ty(&Interner)?.clone()); sig_tys.push(arg.ty(&Interner)?.clone());
} }
sig_tys.push(eq.ty.clone()); sig_tys.push(ty.clone());
cov_mark::hit!(dyn_fn_param_informs_call_site_closure_signature); cov_mark::hit!(dyn_fn_param_informs_call_site_closure_signature);
return Some(FnPointer { return Some(FnPointer {
num_binders: bound.len(&Interner), num_binders: bound.len(&Interner),
sig: FnSig { sig: FnSig { abi: (), safety: chalk_ir::Safety::Safe, variadic: false },
abi: (),
safety: chalk_ir::Safety::Safe,
variadic: false,
},
substitution: FnSubst(Substitution::from_iter(&Interner, sig_tys)), substitution: FnSubst(Substitution::from_iter(&Interner, sig_tys)),
}); });
} }
} }
AliasTy::Opaque(_) => {}
},
_ => {}
}
} }
None None

View File

@ -63,7 +63,7 @@ impl<'a> InferenceContext<'a> {
/// Return the type after possible coercion. /// Return the type after possible coercion.
pub(super) fn infer_expr_coerce(&mut self, expr: ExprId, expected: &Expectation) -> Ty { pub(super) fn infer_expr_coerce(&mut self, expr: ExprId, expected: &Expectation) -> Ty {
let ty = self.infer_expr_inner(expr, expected); 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) { match self.coerce(Some(expr), &ty, &target) {
Ok(res) => res.value, Ok(res) => res.value,
Err(_) => { Err(_) => {
@ -77,9 +77,7 @@ impl<'a> InferenceContext<'a> {
} }
} else { } else {
ty ty
}; }
ty
} }
fn callable_sig_from_fn_trait(&mut self, ty: &Ty, num_args: usize) -> Option<(Vec<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()) { if let Some(builtin_rhs) = self.builtin_binary_op_rhs_expectation(op, lhs_ty.clone()) {
self.unify(&builtin_rhs, &rhs_ty); self.unify(&builtin_rhs, &rhs_ty);
} }
if let Some(builtin_ret) = if let Some(builtin_ret) = self.builtin_binary_op_return_ty(op, lhs_ty, rhs_ty) {
self.builtin_binary_op_return_ty(op, lhs_ty.clone(), rhs_ty.clone())
{
self.unify(&builtin_ret, &ret_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) self.infer_expr_coerce(expr, expected)
} else { } else {
// Citing rustc: if there is no explicit tail expression, // Citing rustc: if there is no explicit tail expression,
@ -961,8 +957,7 @@ impl<'a> InferenceContext<'a> {
} }
TyBuilder::unit() TyBuilder::unit()
} }
}; }
ty
} }
fn infer_method_call( fn infer_method_call(
@ -1032,7 +1027,7 @@ impl<'a> InferenceContext<'a> {
inputs: Vec<Ty>, inputs: Vec<Ty>,
) -> Vec<Ty> { ) -> Vec<Ty> {
if let Some(expected_ty) = expected_output.to_option(&mut self.table) { 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() { if table.try_unify(&expected_ty, &output).is_ok() {
table.resolve_with_fallback(inputs, |var, kind, _, _| match kind { table.resolve_with_fallback(inputs, |var, kind, _, _| match kind {
chalk_ir::VariableKind::Ty(tk) => var.to_ty(&Interner, tk).cast(&Interner), chalk_ir::VariableKind::Ty(tk) => var.to_ty(&Interner, tk).cast(&Interner),
@ -1046,8 +1041,7 @@ impl<'a> InferenceContext<'a> {
} else { } else {
Vec::new() Vec::new()
} }
}); })
result
} else { } else {
Vec::new() Vec::new()
} }

View File

@ -245,8 +245,7 @@ impl<'a> InferenceContext<'a> {
Pat::Wild => expected.clone(), Pat::Wild => expected.clone(),
Pat::Range { start, end } => { Pat::Range { start, end } => {
let start_ty = self.infer_expr(*start, &Expectation::has_type(expected.clone())); let start_ty = self.infer_expr(*start, &Expectation::has_type(expected.clone()));
let end_ty = self.infer_expr(*end, &Expectation::has_type(start_ty)); self.infer_expr(*end, &Expectation::has_type(start_ty))
end_ty
} }
Pat::Lit(expr) => self.infer_expr(*expr, &Expectation::has_type(expected.clone())), Pat::Lit(expr) => self.infer_expr(*expr, &Expectation::has_type(expected.clone())),
Pat::Box { inner } => match self.resolve_boxed_box() { 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. // FIXME: ConstBlock/Path/Lit might actually evaluate to ref, but inference is unimplemented.
Pat::Path(..) => true, Pat::Path(..) => true,
Pat::ConstBlock(..) => true, Pat::ConstBlock(..) => true,
Pat::Lit(expr) => match body[*expr] { Pat::Lit(expr) => !matches!(body[*expr], Expr::Literal(Literal::String(..))),
Expr::Literal(Literal::String(..)) => false,
_ => true,
},
Pat::Bind { Pat::Bind {
mode: BindingAnnotation::Mutable | BindingAnnotation::Unannotated, mode: BindingAnnotation::Mutable | BindingAnnotation::Unannotated,
subpat: Some(subpat), subpat: Some(subpat),

View File

@ -460,12 +460,9 @@ impl<'a> InferenceTable<'a> {
self.new_type_var().inference_var(&Interner).expect("inference_var"); self.new_type_var().inference_var(&Interner).expect("inference_var");
let result = f(self); let result = f(self);
self.rollback_to(snapshot); self.rollback_to(snapshot);
let result = result
.fold_with(&mut VarFudger { table: self, highest_known_var }, DebruijnIndex::INNERMOST)
.expect("fold_with with VarFudger");
result 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` /// This checks whether any of the free variables in the `canonicalized`

View File

@ -387,15 +387,17 @@ impl<'a> TyLoweringContext<'a> {
res: Option<TypeNs>, res: Option<TypeNs>,
remaining_segments: PathSegments<'_>, remaining_segments: PathSegments<'_>,
) -> (Ty, Option<TypeNs>) { ) -> (Ty, Option<TypeNs>) {
if remaining_segments.len() == 1 { match remaining_segments.len() {
0 => (ty, res),
1 => {
// resolve unselected assoc types // resolve unselected assoc types
let segment = remaining_segments.first().unwrap(); let segment = remaining_segments.first().unwrap();
(self.select_associated_type(res, segment), None) (self.select_associated_type(res, segment), None)
} else if remaining_segments.len() > 1 { }
_ => {
// FIXME report error (ambiguous associated type) // FIXME report error (ambiguous associated type)
(TyKind::Error.intern(&Interner), None) (TyKind::Error.intern(&Interner), None)
} else { }
(ty, res)
} }
} }

View File

@ -141,7 +141,7 @@ impl TraitImpls {
let crate_def_map = db.crate_def_map(krate); let crate_def_map = db.crate_def_map(krate);
impls.collect_def_map(db, &crate_def_map); impls.collect_def_map(db, &crate_def_map);
return Arc::new(impls); Arc::new(impls)
} }
pub(crate) fn trait_impls_in_block_query( pub(crate) fn trait_impls_in_block_query(
@ -154,7 +154,7 @@ impl TraitImpls {
let block_def_map = db.block_def_map(block)?; let block_def_map = db.block_def_map(block)?;
impls.collect_def_map(db, &block_def_map); 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) { fn collect_def_map(&mut self, db: &dyn HirDatabase, def_map: &DefMap) {

View File

@ -130,8 +130,7 @@ fn solve(
let solution = if is_chalk_print() { let solution = if is_chalk_print() {
let logging_db = let logging_db =
LoggingRustIrDatabaseLoggingOnDrop(LoggingRustIrDatabase::new(context)); LoggingRustIrDatabaseLoggingOnDrop(LoggingRustIrDatabase::new(context));
let solution = solver.solve_limited(&logging_db.0, goal, &should_continue); solver.solve_limited(&logging_db.0, goal, &should_continue)
solution
} else { } else {
solver.solve_limited(&context, goal, &should_continue) 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 // don't set the TLS for Chalk unless Chalk debugging is active, to make
// extra sure we only use it for debugging // extra sure we only use it for debugging
let solution = if is_chalk_debug() {
if is_chalk_debug() { crate::tls::set_current_program(db, solve) } else { solve() }; crate::tls::set_current_program(db, solve)
} else {
solution solve()
}
} }
struct LoggingRustIrDatabaseLoggingOnDrop<'a>(LoggingRustIrDatabase<Interner, ChalkContext<'a>>); struct LoggingRustIrDatabaseLoggingOnDrop<'a>(LoggingRustIrDatabase<Interner, ChalkContext<'a>>);

View File

@ -86,12 +86,9 @@ impl TypeWalk for AliasTy {
impl TypeWalk for GenericArg { impl TypeWalk for GenericArg {
fn walk(&self, f: &mut impl FnMut(&Ty)) { fn walk(&self, f: &mut impl FnMut(&Ty)) {
match &self.interned() { if let GenericArgData::Ty(ty) = &self.interned() {
GenericArgData::Ty(ty) => {
ty.walk(f); ty.walk(f);
} }
_ => {}
}
} }
} }

View File

@ -241,7 +241,7 @@ struct Struct {
field: () 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 item = source_file.items().next().unwrap();
let attr = item.attrs().nth(1).unwrap(); let attr = item.attrs().nth(1).unwrap();
@ -258,7 +258,7 @@ struct Struct {
field: () 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 item = source_file.items().next().unwrap();
let attr = item.attrs().nth(1).unwrap(); let attr = item.attrs().nth(1).unwrap();