Fix new nightly lints

This commit is contained in:
Lukas Wirth 2024-10-22 11:02:41 +02:00
parent 5e3561ea06
commit 76368b805d
24 changed files with 81 additions and 51 deletions

View File

@ -34,7 +34,7 @@ fn new(ctx: &'a LowerCtx<'a>, impl_trait: bool) -> Self {
}
}
impl<'a> Drop for OuterImplTraitGuard<'a> {
impl Drop for OuterImplTraitGuard<'_> {
fn drop(&mut self) {
self.ctx.outer_impl_trait.replace(self.old);
}

View File

@ -227,7 +227,7 @@ struct SyntaxContextDebug<'a>(
&'a SyntaxContextData,
);
impl<'a> std::fmt::Debug for SyntaxContextDebug<'a> {
impl std::fmt::Debug for SyntaxContextDebug<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fancy_debug(self.2, self.1, self.0, f)
}

View File

@ -114,7 +114,7 @@ pub(crate) fn new_no_tracking(
}
#[allow(private_bounds)]
impl<'table, 'db, T: TrackAutoderefSteps> Autoderef<'table, 'db, T> {
impl<T: TrackAutoderefSteps> Autoderef<'_, '_, T> {
pub(crate) fn step_count(&self) -> usize {
self.steps.len()
}

View File

@ -521,7 +521,7 @@ fn unification_database(&self) -> &dyn chalk_ir::UnificationDatabase<Interner> {
}
}
impl<'a> ChalkContext<'a> {
impl ChalkContext<'_> {
fn edition(&self) -> Edition {
self.db.crate_graph()[self.krate].edition
}

View File

@ -519,7 +519,7 @@ fn complexity_exceeded(&self) -> Result<(), Self::Error> {
}
}
impl<'db> fmt::Debug for MatchCheckCtx<'db> {
impl fmt::Debug for MatchCheckCtx<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("MatchCheckCtx").finish()
}

View File

@ -266,7 +266,7 @@ struct IllegalSelfTypeVisitor<'a> {
trait_self_param_idx: usize,
allow_self_projection: AllowSelfProjection,
}
impl<'a> TypeVisitor<Interner> for IllegalSelfTypeVisitor<'a> {
impl TypeVisitor<Interner> for IllegalSelfTypeVisitor<'_> {
type BreakTy = ();
fn as_dyn(&mut self) -> &mut dyn TypeVisitor<Interner, BreakTy = Self::BreakTy> {

View File

@ -1022,7 +1022,7 @@ struct TypeAliasImplTraitCollector<'a, 'b> {
non_assocs: FxHashMap<OpaqueTyId, Ty>,
}
impl<'a, 'b> TypeVisitor<Interner> for TypeAliasImplTraitCollector<'a, 'b> {
impl TypeVisitor<Interner> for TypeAliasImplTraitCollector<'_, '_> {
type BreakTy = ();
fn as_dyn(&mut self) -> &mut dyn TypeVisitor<Interner, BreakTy = Self::BreakTy> {

View File

@ -879,7 +879,8 @@ pub enum Rvalue {
///
/// **Needs clarification**: Are there weird additional semantics here related to the runtime
/// nature of this operation?
//ThreadLocalRef(DefId),
// ThreadLocalRef(DefId),
ThreadLocalRef(std::convert::Infallible),
/// Creates a pointer with the indicated mutability to the place.
///
@ -888,7 +889,8 @@ pub enum Rvalue {
///
/// Like with references, the semantics of this operation are heavily dependent on the aliasing
/// model.
//AddressOf(Mutability, Place),
// AddressOf(Mutability, Place),
AddressOf(std::convert::Infallible),
/// Yields the length of the place, as a `usize`.
///
@ -906,19 +908,21 @@ pub enum Rvalue {
Cast(CastKind, Operand, Ty),
// FIXME link to `pointer::offset` when it hits stable.
// /// * `Offset` has the same semantics as `pointer::offset`, except that the second
// /// parameter may be a `usize` as well.
// /// * The comparison operations accept `bool`s, `char`s, signed or unsigned integers, floats,
// /// raw pointers, or function pointers and return a `bool`. The types of the operands must be
// /// matching, up to the usual caveat of the lifetimes in function pointers.
// /// * Left and right shift operations accept signed or unsigned integers not necessarily of the
// /// same type and return a value of the same type as their LHS. Like in Rust, the RHS is
// /// truncated as needed.
// /// * The `Bit*` operations accept signed integers, unsigned integers, or bools with matching
// /// types and return a value of that type.
// /// * The remaining operations accept signed integers, unsigned integers, or floats with
// /// matching types and return a value of that type.
/// * `Offset` has the same semantics as `pointer::offset`, except that the second
/// parameter may be a `usize` as well.
/// * The comparison operations accept `bool`s, `char`s, signed or unsigned integers, floats,
/// raw pointers, or function pointers and return a `bool`. The types of the operands must be
/// matching, up to the usual caveat of the lifetimes in function pointers.
/// * Left and right shift operations accept signed or unsigned integers not necessarily of the
/// same type and return a value of the same type as their LHS. Like in Rust, the RHS is
/// truncated as needed.
/// * The `Bit*` operations accept signed integers, unsigned integers, or bools with matching
/// types and return a value of that type.
/// * The remaining operations accept signed integers, unsigned integers, or floats with
/// matching types and return a value of that type.
//BinaryOp(BinOp, Box<(Operand, Operand)>),
BinaryOp(std::convert::Infallible),
/// Same as `BinaryOp`, but yields `(T, bool)` with a `bool` indicating an error condition.
///
/// When overflow checking is disabled and we are generating run-time code, the error condition
@ -937,6 +941,7 @@ pub enum Rvalue {
/// Computes a value as described by the operation.
//NullaryOp(NullOp, Ty),
NullaryOp(std::convert::Infallible),
/// Exactly like `BinaryOp`, but less operands.
///
@ -1095,6 +1100,10 @@ fn for_operand(
for_operand(op, &mut f, &mut self.projection_store);
}
}
Rvalue::ThreadLocalRef(n)
| Rvalue::AddressOf(n)
| Rvalue::BinaryOp(n)
| Rvalue::NullaryOp(n) => match *n {},
}
}
StatementKind::FakeRead(p) | StatementKind::Deinit(p) => {

View File

@ -167,6 +167,10 @@ fn moved_out_of_ref(db: &dyn HirDatabase, body: &MirBody) -> Vec<MovedOutOfRef>
for_operand(op, statement.span);
}
}
Rvalue::ThreadLocalRef(n)
| Rvalue::AddressOf(n)
| Rvalue::BinaryOp(n)
| Rvalue::NullaryOp(n) => match *n {},
},
StatementKind::FakeRead(_)
| StatementKind::Deinit(_)
@ -253,6 +257,10 @@ fn partially_moved(db: &dyn HirDatabase, body: &MirBody) -> Vec<PartiallyMoved>
for_operand(op, statement.span);
}
}
Rvalue::ThreadLocalRef(n)
| Rvalue::AddressOf(n)
| Rvalue::BinaryOp(n)
| Rvalue::NullaryOp(n) => match *n {},
},
StatementKind::FakeRead(_)
| StatementKind::Deinit(_)
@ -548,6 +556,10 @@ fn mutability_of_locals(
}
}
Rvalue::ShallowInitBox(_, _) | Rvalue::ShallowInitBoxWithAlloc(_) => (),
Rvalue::ThreadLocalRef(n)
| Rvalue::AddressOf(n)
| Rvalue::BinaryOp(n)
| Rvalue::NullaryOp(n) => match *n {},
}
if let Rvalue::Ref(
BorrowKind::Mut {

View File

@ -1628,6 +1628,10 @@ fn eval_rvalue(&mut self, r: &Rvalue, locals: &mut Locals) -> Result<IntervalOrO
}
CastKind::FnPtrToPtr => not_supported!("fn ptr to ptr cast"),
},
Rvalue::ThreadLocalRef(n)
| Rvalue::AddressOf(n)
| Rvalue::BinaryOp(n)
| Rvalue::NullaryOp(n) => match *n {},
})
}
@ -2703,17 +2707,15 @@ fn exec_fn_trait(
TyKind::Function(_) => {
self.exec_fn_pointer(func_data, destination, &args[1..], locals, target_bb, span)
}
TyKind::Closure(closure, subst) => {
return self.exec_closure(
*closure,
func_data,
&Substitution::from_iter(Interner, ClosureSubst(subst).parent_subst()),
destination,
&args[1..],
locals,
span,
);
}
TyKind::Closure(closure, subst) => self.exec_closure(
*closure,
func_data,
&Substitution::from_iter(Interner, ClosureSubst(subst).parent_subst()),
destination,
&args[1..],
locals,
span,
),
_ => {
// try to execute the manual impl of `FnTrait` for structs (nightly feature used in std)
let arg0 = func;

View File

@ -258,6 +258,10 @@ fn fill_body(&mut self, body: &mut MirBody) -> Result<(), MirLowerError> {
| Rvalue::UnaryOp(_, _)
| Rvalue::Discriminant(_)
| Rvalue::CopyForDeref(_) => (),
Rvalue::ThreadLocalRef(n)
| Rvalue::AddressOf(n)
| Rvalue::BinaryOp(n)
| Rvalue::NullaryOp(n) => match *n {},
},
StatementKind::Deinit(_)
| StatementKind::FakeRead(_)

View File

@ -459,6 +459,10 @@ fn rvalue(&mut self, r: &Rvalue) {
self.place(p);
w!(self, ")");
}
Rvalue::ThreadLocalRef(n)
| Rvalue::AddressOf(n)
| Rvalue::BinaryOp(n)
| Rvalue::NullaryOp(n) => match *n {},
}
}

View File

@ -123,7 +123,7 @@ pub(super) struct ClauseElaborator<'a> {
seen: FxHashSet<WhereClause>,
}
impl<'a> ClauseElaborator<'a> {
impl ClauseElaborator<'_> {
fn extend_deduped(&mut self, clauses: impl IntoIterator<Item = WhereClause>) {
self.stack.extend(clauses.into_iter().filter(|c| self.seen.insert(c.clone())))
}

View File

@ -154,7 +154,7 @@ fn deref(&self) -> &Self::Target {
}
}
impl<'db, DB: HirDatabase> Semantics<'db, DB> {
impl<DB: HirDatabase> Semantics<'_, DB> {
pub fn new(db: &DB) -> Semantics<'_, DB> {
let impl_ = SemanticsImpl::new(db);
Semantics { db, imp: impl_ }

View File

@ -40,9 +40,6 @@ pub(super) fn pattern_top_r(p: &mut Parser<'_>, recovery_set: TokenSet) {
pattern_r(p, recovery_set);
}
/// Parses a pattern list separated by pipes `|`, with no leading `|`,using the
/// given `recovery_set`.
// test or_pattern
// fn main() {
// match () {
@ -52,6 +49,8 @@ pub(super) fn pattern_top_r(p: &mut Parser<'_>, recovery_set: TokenSet) {
// [_ | _,] => (),
// }
// }
/// Parses a pattern list separated by pipes `|`, with no leading `|`,using the
/// given `recovery_set`.
fn pattern_r(p: &mut Parser<'_>, recovery_set: TokenSet) {
let m = p.start();
pattern_single_r(p, recovery_set);

View File

@ -401,7 +401,7 @@ struct Writer<'a, 'span, S: InternableSpan> {
text: Vec<String>,
}
impl<'a, 'span, S: InternableSpan> Writer<'a, 'span, S> {
impl<'a, S: InternableSpan> Writer<'a, '_, S> {
fn write(&mut self, root: &'a tt::Subtree<S>) {
self.enqueue(root);
while let Some((idx, subtree)) = self.work.pop_front() {
@ -524,7 +524,7 @@ struct Reader<'span, S: InternableSpan> {
span_data_table: &'span S::Table,
}
impl<'span, S: InternableSpan> Reader<'span, S> {
impl<S: InternableSpan> Reader<'_, S> {
pub(crate) fn read(self) -> tt::Subtree<S> {
let mut res: Vec<Option<tt::Subtree<S>>> = vec![None; self.subtree.len()];
let read_span = |id| S::span_for_token_id(self.span_data_table, id);

View File

@ -616,7 +616,7 @@ fn overwrite_placeholder(&mut self, wait_result: WaitResult, opt_memo: Option<Me
}
}
impl<'me, Q> Drop for PanicGuard<'me, Q>
impl<Q> Drop for PanicGuard<'_, Q>
where
Q: QueryFunction,
Q::Value: Eq,

View File

@ -666,7 +666,7 @@ fn overwrite_placeholder(&mut self, wait_result: WaitResult, opt_memo: Option<Me
}
}
impl<'me, Q, MP> Drop for PanicGuard<'me, Q, MP>
impl<Q, MP> Drop for PanicGuard<'_, Q, MP>
where
Q: QueryFunction,
MP: MemoizationPolicy<Q>,

View File

@ -493,7 +493,7 @@ fn is_static<T: 'static>() {}
is_static::<Slot<K>>();
}
impl<'me, Q> QueryTable<'me, Q>
impl<Q> QueryTable<'_, Q>
where
Q: Query<Storage = InternedStorage<Q>>,
Q::Key: InternValue,

View File

@ -149,7 +149,7 @@ struct EventDebug<'me, D: ?Sized>
db: &'me D,
}
impl<'me, D: ?Sized> fmt::Debug for EventDebug<'me, D>
impl<D: ?Sized> fmt::Debug for EventDebug<'_, D>
where
D: plumbing::DatabaseOps,
{
@ -242,7 +242,7 @@ struct EventKindDebug<'me, D: ?Sized>
db: &'me D,
}
impl<'me, D: ?Sized> fmt::Debug for EventKindDebug<'me, D>
impl<D: ?Sized> fmt::Debug for EventKindDebug<'_, D>
where
D: plumbing::DatabaseOps,
{
@ -729,7 +729,7 @@ struct UnexpectedCycleDebug<'me> {
db: &'me dyn Database,
}
impl<'me> std::fmt::Debug for UnexpectedCycleDebug<'me> {
impl std::fmt::Debug for UnexpectedCycleDebug<'_> {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fmt.debug_struct("UnexpectedCycle")
.field("all_participants", &self.c.all_participants(self.db))

View File

@ -489,12 +489,12 @@ pub(crate) fn handle_document_symbol(
tags.push(SymbolTag::DEPRECATED)
};
#[allow(deprecated)]
let doc_symbol = lsp_types::DocumentSymbol {
name: symbol.label,
detail: symbol.detail,
kind: to_proto::structure_node_kind(symbol.kind),
tags: Some(tags),
#[allow(deprecated)]
deprecated: Some(symbol.deprecated),
range: to_proto::range(&line_index, symbol.node_range),
selection_range: to_proto::range(&line_index, symbol.navigation_range),
@ -539,11 +539,11 @@ fn flatten_document_symbol(
url: &Url,
res: &mut Vec<SymbolInformation>,
) {
#[allow(deprecated)]
res.push(SymbolInformation {
name: symbol.name.clone(),
kind: symbol.kind,
tags: symbol.tags.clone(),
#[allow(deprecated)]
deprecated: symbol.deprecated,
location: Location::new(url.clone(), symbol.range),
container_name,

View File

@ -120,7 +120,7 @@ pub struct DataVisitor<'a> {
string: &'a mut String,
}
impl<'a> Visit for DataVisitor<'a> {
impl Visit for DataVisitor<'_> {
fn record_debug(&mut self, field: &Field, value: &dyn std::fmt::Debug) {
write!(self.string, "{} = {:?} ", field.name(), value).unwrap();
}

View File

@ -134,7 +134,7 @@ pub enum TokenTreeRef<'a, Span> {
Leaf(&'a Leaf<Span>, &'a TokenTree<Span>),
}
impl<'a, Span: Copy> TokenTreeRef<'a, Span> {
impl<Span: Copy> TokenTreeRef<'_, Span> {
pub fn span(&self) -> Span {
match self {
TokenTreeRef::Subtree(subtree, _) => subtree.delimiter.open,

View File

@ -79,7 +79,7 @@ fn extract_untagged(text: &str) -> Vec<CommentBlock> {
let mut block = dummy_block.clone();
for (line_num, line) in lines.enumerate() {
match line.strip_prefix("//") {
Some(mut contents) => {
Some(mut contents) if !contents.starts_with('/') => {
if let Some('/' | '!') = contents.chars().next() {
contents = &contents[1..];
block.is_doc = true;
@ -89,7 +89,7 @@ fn extract_untagged(text: &str) -> Vec<CommentBlock> {
}
block.contents.push(contents.to_owned());
}
None => {
_ => {
if !block.contents.is_empty() {
let block = mem::replace(&mut block, dummy_block.clone());
res.push(block);