Skip to content

fn_delegation: renamed-function-param is missing snippet #16132

@matthiaskrgr

Description

@matthiaskrgr

Using the following flags

--force-warn clippy::renamed-function-params

this code:

//@ run-pass

#![feature(fn_delegation)]
#![allow(incomplete_features)]

mod to_reuse {
    pub fn foo(x: i32) -> i32 { x }
    pub mod inner {}
}

reuse to_reuse::foo {{
    use self::to_reuse::foo;
    let x = foo(12);
    x + self
}}

trait Trait { //~ WARN trait `Trait` is never used
    fn bar(&self, x: i32) -> i32 { x }
}

struct F; //~ WARN struct `F` is never constructed
impl Trait for F {}

struct S(F); //~ WARN struct `S` is never constructed
impl Trait for S {
    reuse <F as Trait>::bar {
        #[allow(unused_imports)]
        use self::to_reuse::{foo, inner::self};
        let x = foo(12);
        assert_eq!(x, 12);
        &self.0
    }
}

fn main() {
    assert_eq!(foo(12), 24);
}

caused the following diagnostics:

    Checking _target-expr-pass v0.1.0 (/tmp/icemaker_global_tempdir.gOhJUmIOFvoe/icemaker_clippyfix_tempdir.JbOb8YYLGCCz/_target-expr-pass)
warning: renamed function parameter of trait impl
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#renamed_function_params
  = note: requested on the command line with `--force-warn clippy::renamed-function-params`

warning: `_target-expr-pass` (bin "_target-expr-pass") generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.24s

However after applying these diagnostics, the resulting code:

x//@ run-pass

#![feature(fn_delegation)]
#![allow(incomplete_features)]

mod to_reuse {
    pub fn foo(x: i32) -> i32 { x }
    pub mod inner {}
}

reuse to_reuse::foo {{
    use self::to_reuse::foo;
    let x = foo(12);
    x + self
}}

trait Trait { //~ WARN trait `Trait` is never used
    fn bar(&self, x: i32) -> i32 { x }
}

struct F; //~ WARN struct `F` is never constructed
impl Trait for F {}

struct S(F); //~ WARN struct `S` is never constructed
impl Trait for S {
    reuse <F as Trait>::bar {
        #[allow(unused_imports)]
        use self::to_reuse::{foo, inner::self};
        let x = foo(12);
        assert_eq!(x, 12);
        &self.0
    }
}

fn main() {
    assert_eq!(foo(12), 24);
}

no longer compiled:

    Checking _target-expr-pass v0.1.0 (/tmp/icemaker_global_tempdir.gOhJUmIOFvoe/icemaker_clippyfix_tempdir.JbOb8YYLGCCz/_target-expr-pass)
error: expected one of `!` or `::`, found `#`
 --> src/main.rs:3:1
  |
1 | x//@ run-pass
  |  - expected one of `!` or `::`
2 |
3 | #![feature(fn_delegation)]
  | ^ unexpected token

error: could not compile `_target-expr-pass` (bin "_target-expr-pass") due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `_target-expr-pass` (bin "_target-expr-pass" test) due to 1 previous error

Version:

rustc 1.93.0-nightly (4b1b6dde0 2025-11-22)
binary: rustc
commit-hash: 4b1b6dde0c15243857165672a1c616a4523ef32a
commit-date: 2025-11-22
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions