Skip to content

Commit 6daee1b

Browse files
coolreader18youknowone
authored andcommitted
Warn on elided_lifetimes_in_paths
1 parent 8ff856d commit 6daee1b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+232
-225
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ wasm-bindgen = "0.2.100"
189189
[workspace.lints.rust]
190190
unsafe_code = "allow"
191191
unsafe_op_in_unsafe_fn = "deny"
192+
elided_lifetimes_in_paths = "warn"
192193

193194
[workspace.lints.clippy]
194195
perf = "warn"

common/src/borrow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<T: ?Sized> Deref for BorrowedValue<'_, T> {
6868
}
6969

7070
impl fmt::Display for BorrowedValue<'_, str> {
71-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
71+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
7272
fmt::Display::fmt(self.deref(), f)
7373
}
7474
}

common/src/boxvec.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ impl<T> BoxVec<T> {
262262
///
263263
/// **Panics** if the starting point is greater than the end point or if
264264
/// the end point is greater than the length of the vector.
265-
pub fn drain<R>(&mut self, range: R) -> Drain<T>
265+
pub fn drain<R>(&mut self, range: R) -> Drain<'_, T>
266266
where
267267
R: RangeBounds<usize>,
268268
{
@@ -290,7 +290,7 @@ impl<T> BoxVec<T> {
290290
self.drain_range(start, end)
291291
}
292292

293-
fn drain_range(&mut self, start: usize, end: usize) -> Drain<T> {
293+
fn drain_range(&mut self, start: usize, end: usize) -> Drain<'_, T> {
294294
let len = self.len();
295295

296296
// bounds check happens here (before length is changed!)
@@ -438,7 +438,7 @@ impl<T> fmt::Debug for IntoIter<T>
438438
where
439439
T: fmt::Debug,
440440
{
441-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
441+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
442442
f.debug_list().entries(&self.v[self.index..]).finish()
443443
}
444444
}
@@ -658,7 +658,7 @@ impl<T> fmt::Debug for BoxVec<T>
658658
where
659659
T: fmt::Debug,
660660
{
661-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
661+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
662662
(**self).fmt(f)
663663
}
664664
}
@@ -691,13 +691,13 @@ const CAPERROR: &str = "insufficient capacity";
691691
impl<T> std::error::Error for CapacityError<T> {}
692692

693693
impl<T> fmt::Display for CapacityError<T> {
694-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
694+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
695695
write!(f, "{CAPERROR}")
696696
}
697697
}
698698

699699
impl<T> fmt::Debug for CapacityError<T> {
700-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
700+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
701701
write!(f, "capacity error: {CAPERROR}")
702702
}
703703
}

common/src/lock/thread_mutex.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl<R: RawMutex, G: GetThreadId, T> From<T> for ThreadMutex<R, G, T> {
100100
}
101101
}
102102
impl<R: RawMutex, G: GetThreadId, T: ?Sized> ThreadMutex<R, G, T> {
103-
pub fn lock(&self) -> Option<ThreadMutexGuard<R, G, T>> {
103+
pub fn lock(&self) -> Option<ThreadMutexGuard<'_, R, G, T>> {
104104
if self.raw.lock() {
105105
Some(ThreadMutexGuard {
106106
mu: self,
@@ -110,7 +110,7 @@ impl<R: RawMutex, G: GetThreadId, T: ?Sized> ThreadMutex<R, G, T> {
110110
None
111111
}
112112
}
113-
pub fn try_lock(&self) -> Result<ThreadMutexGuard<R, G, T>, TryLockThreadError> {
113+
pub fn try_lock(&self) -> Result<ThreadMutexGuard<'_, R, G, T>, TryLockThreadError> {
114114
match self.raw.try_lock() {
115115
Some(true) => Ok(ThreadMutexGuard {
116116
mu: self,
@@ -218,14 +218,14 @@ impl<R: RawMutex, G: GetThreadId, T: ?Sized> Drop for ThreadMutexGuard<'_, R, G,
218218
impl<R: RawMutex, G: GetThreadId, T: ?Sized + fmt::Display> fmt::Display
219219
for ThreadMutexGuard<'_, R, G, T>
220220
{
221-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
221+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
222222
fmt::Display::fmt(&**self, f)
223223
}
224224
}
225225
impl<R: RawMutex, G: GetThreadId, T: ?Sized + fmt::Debug> fmt::Debug
226226
for ThreadMutexGuard<'_, R, G, T>
227227
{
228-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
228+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
229229
fmt::Debug::fmt(&**self, f)
230230
}
231231
}
@@ -285,14 +285,14 @@ impl<R: RawMutex, G: GetThreadId, T: ?Sized> Drop for MappedThreadMutexGuard<'_,
285285
impl<R: RawMutex, G: GetThreadId, T: ?Sized + fmt::Display> fmt::Display
286286
for MappedThreadMutexGuard<'_, R, G, T>
287287
{
288-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
288+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
289289
fmt::Display::fmt(&**self, f)
290290
}
291291
}
292292
impl<R: RawMutex, G: GetThreadId, T: ?Sized + fmt::Debug> fmt::Debug
293293
for MappedThreadMutexGuard<'_, R, G, T>
294294
{
295-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
295+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
296296
fmt::Debug::fmt(&**self, f)
297297
}
298298
}

compiler/codegen/src/compile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3484,7 +3484,7 @@ mod tests {
34843484
use rustpython_parser_core::source_code::LinearLocator;
34853485

34863486
fn compile_exec(source: &str) -> CodeObject {
3487-
let mut locator: LinearLocator = LinearLocator::new(source);
3487+
let mut locator: LinearLocator<'_> = LinearLocator::new(source);
34883488
use rustpython_parser::ast::fold::Fold;
34893489
let mut compiler: Compiler = Compiler::new(
34903490
CompileOpts::default(),

compiler/codegen/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub enum CodegenErrorType {
3838
impl std::error::Error for CodegenErrorType {}
3939

4040
impl fmt::Display for CodegenErrorType {
41-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
41+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4242
use CodegenErrorType::*;
4343
match self {
4444
Assign(target) => write!(f, "cannot assign to {target}"),

compiler/codegen/src/symboltable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub enum SymbolTableType {
7474
}
7575

7676
impl fmt::Display for SymbolTableType {
77-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
77+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
7878
match self {
7979
SymbolTableType::Module => write!(f, "module"),
8080
SymbolTableType::Class => write!(f, "class"),
@@ -195,7 +195,7 @@ impl SymbolTable {
195195
}
196196

197197
impl std::fmt::Debug for SymbolTable {
198-
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
198+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
199199
write!(
200200
f,
201201
"SymbolTable({:?} symbols, {:?} sub scopes)",

compiler/core/src/bytecode.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ pub trait Constant: Sized {
1515
type Name: AsRef<str>;
1616

1717
/// Transforms the given Constant to a BorrowedConstant
18-
fn borrow_constant(&self) -> BorrowedConstant<Self>;
18+
fn borrow_constant(&self) -> BorrowedConstant<'_, Self>;
1919
}
2020

2121
impl Constant for ConstantData {
2222
type Name = String;
23-
fn borrow_constant(&self) -> BorrowedConstant<Self> {
23+
fn borrow_constant(&self) -> BorrowedConstant<'_, Self> {
2424
use BorrowedConstant::*;
2525
match self {
2626
ConstantData::Integer { value } => Integer { value },
@@ -40,7 +40,7 @@ impl Constant for ConstantData {
4040
/// A Constant Bag
4141
pub trait ConstantBag: Sized + Copy {
4242
type Constant: Constant;
43-
fn make_constant<C: Constant>(&self, constant: BorrowedConstant<C>) -> Self::Constant;
43+
fn make_constant<C: Constant>(&self, constant: BorrowedConstant<'_, C>) -> Self::Constant;
4444
fn make_int(&self, value: BigInt) -> Self::Constant;
4545
fn make_tuple(&self, elements: impl Iterator<Item = Self::Constant>) -> Self::Constant;
4646
fn make_code(&self, code: CodeObject<Self::Constant>) -> Self::Constant;
@@ -65,7 +65,7 @@ pub struct BasicBag;
6565

6666
impl ConstantBag for BasicBag {
6767
type Constant = ConstantData;
68-
fn make_constant<C: Constant>(&self, constant: BorrowedConstant<C>) -> Self::Constant {
68+
fn make_constant<C: Constant>(&self, constant: BorrowedConstant<'_, C>) -> Self::Constant {
6969
constant.to_owned()
7070
}
7171
fn make_int(&self, value: BigInt) -> Self::Constant {
@@ -306,7 +306,7 @@ impl<T: OpArgType> PartialEq for Arg<T> {
306306
impl<T: OpArgType> Eq for Arg<T> {}
307307

308308
impl<T: OpArgType> fmt::Debug for Arg<T> {
309-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
309+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
310310
write!(f, "Arg<{}>", std::any::type_name::<T>())
311311
}
312312
}
@@ -329,7 +329,7 @@ impl OpArgType for Label {
329329
}
330330

331331
impl fmt::Display for Label {
332-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
332+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
333333
self.0.fmt(f)
334334
}
335335
}
@@ -752,7 +752,7 @@ impl<C: Constant> Clone for BorrowedConstant<'_, C> {
752752
}
753753

754754
impl<C: Constant> BorrowedConstant<'_, C> {
755-
pub fn fmt_display(&self, f: &mut fmt::Formatter) -> fmt::Result {
755+
pub fn fmt_display(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
756756
match self {
757757
BorrowedConstant::Integer { value } => write!(f, "{value}"),
758758
BorrowedConstant::Float { value } => write!(f, "{value}"),
@@ -939,7 +939,7 @@ impl<N: AsRef<str>> fmt::Debug for Arguments<'_, N> {
939939
impl<C: Constant> CodeObject<C> {
940940
/// Get all arguments of the code object
941941
/// like inspect.getargs
942-
pub fn arg_names(&self) -> Arguments<C::Name> {
942+
pub fn arg_names(&self) -> Arguments<'_, C::Name> {
943943
let nargs = self.arg_count as usize;
944944
let nkwargs = self.kwonlyarg_count as usize;
945945
let mut varargs_pos = nargs + nkwargs;
@@ -984,7 +984,7 @@ impl<C: Constant> CodeObject<C> {
984984

985985
fn display_inner(
986986
&self,
987-
f: &mut fmt::Formatter,
987+
f: &mut fmt::Formatter<'_>,
988988
expand_code_objects: bool,
989989
level: usize,
990990
) -> fmt::Result {
@@ -1034,7 +1034,7 @@ impl<C: Constant> CodeObject<C> {
10341034
pub fn display_expand_code_objects(&self) -> impl fmt::Display + '_ {
10351035
struct Display<'a, C: Constant>(&'a CodeObject<C>);
10361036
impl<C: Constant> fmt::Display for Display<'_, C> {
1037-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1037+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
10381038
self.0.display_inner(f, true, 1)
10391039
}
10401040
}
@@ -1107,7 +1107,7 @@ impl<C: Constant> CodeObject<C> {
11071107
}
11081108

11091109
impl<C: Constant> fmt::Display for CodeObject<C> {
1110-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1110+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
11111111
self.display_inner(f, false, 1)?;
11121112
for constant in &*self.constants {
11131113
if let BorrowedConstant::Code { code } = constant.borrow_constant() {
@@ -1302,19 +1302,19 @@ impl Instruction {
13021302
ctx: &'a impl InstrDisplayContext,
13031303
) -> impl fmt::Display + 'a {
13041304
struct FmtFn<F>(F);
1305-
impl<F: Fn(&mut fmt::Formatter) -> fmt::Result> fmt::Display for FmtFn<F> {
1306-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1305+
impl<F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result> fmt::Display for FmtFn<F> {
1306+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13071307
(self.0)(f)
13081308
}
13091309
}
1310-
FmtFn(move |f: &mut fmt::Formatter| self.fmt_dis(arg, f, ctx, false, 0, 0))
1310+
FmtFn(move |f: &mut fmt::Formatter<'_>| self.fmt_dis(arg, f, ctx, false, 0, 0))
13111311
}
13121312

13131313
#[allow(clippy::too_many_arguments)]
13141314
fn fmt_dis(
13151315
&self,
13161316
arg: OpArg,
1317-
f: &mut fmt::Formatter,
1317+
f: &mut fmt::Formatter<'_>,
13181318
ctx: &impl InstrDisplayContext,
13191319
expand_code_objects: bool,
13201320
pad: usize,
@@ -1346,7 +1346,7 @@ impl Instruction {
13461346
let cell_name = |i: u32| ctx.get_cell_name(i as usize);
13471347

13481348
let fmt_const =
1349-
|op: &str, arg: OpArg, f: &mut fmt::Formatter, idx: &Arg<u32>| -> fmt::Result {
1349+
|op: &str, arg: OpArg, f: &mut fmt::Formatter<'_>, idx: &Arg<u32>| -> fmt::Result {
13501350
let value = ctx.get_constant(idx.get(arg) as usize);
13511351
match value.borrow_constant() {
13521352
BorrowedConstant::Code { code } if expand_code_objects => {
@@ -1496,13 +1496,13 @@ impl<C: Constant> InstrDisplayContext for CodeObject<C> {
14961496
}
14971497

14981498
impl fmt::Display for ConstantData {
1499-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1499+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15001500
self.borrow_constant().fmt_display(f)
15011501
}
15021502
}
15031503

15041504
impl<C: Constant> fmt::Debug for CodeObject<C> {
1505-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1505+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15061506
write!(
15071507
f,
15081508
"<code object {} at ??? file {:?}, line {}>",

compiler/core/src/marshal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub enum MarshalError {
2121
}
2222

2323
impl std::fmt::Display for MarshalError {
24-
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
24+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2525
match self {
2626
Self::Eof => f.write_str("unexpected end of data"),
2727
Self::InvalidBytecode => f.write_str("invalid bytecode"),

compiler/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl std::error::Error for CompileErrorType {
2525
}
2626
}
2727
impl std::fmt::Display for CompileErrorType {
28-
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
28+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2929
match self {
3030
CompileErrorType::Codegen(e) => e.fmt(f),
3131
CompileErrorType::Parse(e) => e.fmt(f),

derive-impl/src/compile_bytecode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ impl PyCompileArgs {
316316
}
317317
}
318318

319-
fn parse_str(input: ParseStream) -> ParseResult<LitStr> {
319+
fn parse_str(input: ParseStream<'_>) -> ParseResult<LitStr> {
320320
let span = input.span();
321321
if input.peek(LitStr) {
322322
input.parse()

derive-impl/src/pyclass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ enum AttrName {
2525
}
2626

2727
impl std::fmt::Display for AttrName {
28-
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
28+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2929
let s = match self {
3030
Self::Method => "pymethod",
3131
Self::ClassMethod => "pyclassmethod",

derive-impl/src/pymodule.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ enum AttrName {
1919
}
2020

2121
impl std::fmt::Display for AttrName {
22-
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
22+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2323
let s = match self {
2424
Self::Function => "pyfunction",
2525
Self::Attr => "pyattr",

jit/src/instructions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> {
188188

189189
fn prepare_const<C: bytecode::Constant>(
190190
&mut self,
191-
constant: BorrowedConstant<C>,
191+
constant: BorrowedConstant<'_, C>,
192192
) -> Result<JitValue, JitCompileError> {
193193
let value = match constant {
194194
BorrowedConstant::Integer { value } => {

stdlib/src/contextvars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ mod _contextvars {
301301
}
302302

303303
impl std::fmt::Debug for ContextVar {
304-
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
304+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
305305
f.debug_struct("ContextVar").finish()
306306
}
307307
}

stdlib/src/csv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ mod _csv {
910910
}
911911

912912
impl fmt::Debug for Reader {
913-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
913+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
914914
write!(f, "_csv.reader")
915915
}
916916
}
@@ -1064,7 +1064,7 @@ mod _csv {
10641064
}
10651065

10661066
impl fmt::Debug for Writer {
1067-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1067+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
10681068
write!(f, "_csv.writer")
10691069
}
10701070
}

0 commit comments

Comments
 (0)