Skip to content

deprecated_where_clause_location causes syntax error (missing space) #153567

@matthiaskrgr

Description

@matthiaskrgr

Using the following flags

--force-warn deprecated_where_clause_location

this code:

//@ check-pass
//@ run-rustfix

#![allow(dead_code)]

trait Trait {
    // Fine.
    type Assoc where u32: Copy;
    // Fine.
    type Assoc2 where u32: Copy, i32: Copy;
    //
    type Assoc3;
}

impl Trait for u32 {
    // Not fine, suggests moving.
    type Assoc where u32: Copy = ();
    //~^ WARNING where clause not allowed here
    // Not fine, suggests moving `u32: Copy`
    type Assoc2 where u32: Copy = () where i32: Copy;
    // Not fine, suggests moving `u32: Copy`
    type Assoc3 where = ();
    //~^ WARNING where clause not allowed here
}

impl Trait for i32 {
    // Fine.
    type Assoc = () where u32: Copy;
    // Not fine, suggests moving both.
    type Assoc2 where u32: Copy, i32: Copy = ();
    //~^ WARNING where clause not allowed here
    type Assoc3 where i32: Copy = () where;
    //~^ WARNING where clause not allowed here
}

fn main() {}

caused the following diagnostics:

    Checking _edda875ab4436d7618324047168b3a91b01ad984 v0.1.0 (/tmp/icemaker_global_tempdir.gPgWiqot4T9Z/icemaker_clippyfix_tempdir.WigI3vGsnefq/_edda875ab4436d7618324047168b3a91b01ad984)
warning: where clause not allowed here
  --> src/main.rs:17:16
   |
17 |     type Assoc where u32: Copy = ();
   |                ^^^^^^^^^^^^^^^
   |
   = note: see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
   = note: requested on the command line with `--force-warn deprecated-where-clause-location`
help: move it to the end of the type declaration
   |
17 -     type Assoc where u32: Copy = ();
17 +     type Assoc  = () where u32: Copy;
   |

warning: where clause not allowed here
  --> src/main.rs:20:17
   |
20 |     type Assoc2 where u32: Copy = () where i32: Copy;
   |                 ^^^^^^^^^^^^^^^
   |
   = note: see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
help: move it to the end of the type declaration
   |
20 -     type Assoc2 where u32: Copy = () where i32: Copy;
20 +     type Assoc2  = () where i32: Copy, u32: Copy;
   |

warning: where clause not allowed here
  --> src/main.rs:22:17
   |
22 |     type Assoc3 where = ();
   |                 ^^^^^
   |
   = note: see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
help: move it to the end of the type declaration
   |
22 -     type Assoc3 where = ();
22 +     type Assoc3  = () where;
   |

warning: where clause not allowed here
  --> src/main.rs:30:17
   |
30 |     type Assoc2 where u32: Copy, i32: Copy = ();
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
help: move it to the end of the type declaration
   |
30 -     type Assoc2 where u32: Copy, i32: Copy = ();
30 +     type Assoc2  = () where u32: Copy, i32: Copy;
   |

warning: where clause not allowed here
  --> src/main.rs:32:17
   |
32 |     type Assoc3 where i32: Copy = () where;
   |                 ^^^^^^^^^^^^^^^
   |
   = note: see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
help: move it to the end of the type declaration
   |
32 -     type Assoc3 where i32: Copy = () where;
32 +     type Assoc3  = () wherei32: Copy;
   |

warning: `_edda875ab4436d7618324047168b3a91b01ad984` (bin "_edda875ab4436d7618324047168b3a91b01ad984") generated 5 warnings (run `cargo clippy --fix --bin "_edda875ab4436d7618324047168b3a91b01ad984" -p _edda875ab4436d7618324047168b3a91b01ad984 -- -Aclippy::all -Awarnings --force-warn deprecated_where_clause_location --cap-lints warn` to apply 5 suggestions)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.15s

However after applying these diagnostics, the resulting code:

//@ check-pass
//@ run-rustfix

#![allow(dead_code)]

trait Trait {
    // Fine.
    type Assoc where u32: Copy;
    // Fine.
    type Assoc2 where u32: Copy, i32: Copy;
    //
    type Assoc3;
}

impl Trait for u32 {
    // Not fine, suggests moving.
    type Assoc  = () where u32: Copy;
    //~^ WARNING where clause not allowed here
    // Not fine, suggests moving `u32: Copy`
    type Assoc2  = () where i32: Copy, u32: Copy;
    // Not fine, suggests moving `u32: Copy`
    type Assoc3  = () where;
    //~^ WARNING where clause not allowed here
}

impl Trait for i32 {
    // Fine.
    type Assoc = () where u32: Copy;
    // Not fine, suggests moving both.
    type Assoc2  = () where u32: Copy, i32: Copy;
    //~^ WARNING where clause not allowed here
    type Assoc3  = () wherei32: Copy;
    //~^ WARNING where clause not allowed here
type Assoc3 = /* Type */;
}

fn main() {}

no longer compiled:

    Checking _edda875ab4436d7618324047168b3a91b01ad984 v0.1.0 (/tmp/icemaker_global_tempdir.gPgWiqot4T9Z/icemaker_clippyfix_tempdir.WigI3vGsnefq/_edda875ab4436d7618324047168b3a91b01ad984)
warning: failed to automatically apply fixes suggested by rustc to crate `_edda875ab4436d7618324047168b3a91b01ad984`

after fixes were automatically applied the compiler reported errors within these files:

  * src/main.rs

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag

The following errors were reported:
error: expected one of `;` or `where`, found `wherei32`
  --> src/main.rs:32:23
   |
26 | impl Trait for i32 {
   |                    - while parsing this item list starting here
...
32 |     type Assoc3  = () wherei32: Copy;
   |                       ^^^^^^^^ expected one of `;` or `where`
...
36 | }
   | - the item list ends here

error[E0046]: not all trait items implemented, missing: `Assoc3`
  --> src/main.rs:26:1
   |
12 |     type Assoc3;
   |     ----------- `Assoc3` from trait
...
26 | impl Trait for i32 {
   | ^^^^^^^^^^^^^^^^^^ missing `Assoc3` in implementation

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0046`.
Original diagnostics will follow.

error: expected one of `;` or `where`, found `wherei32`
  --> src/main.rs:32:23
   |
26 | impl Trait for i32 {
   |                    - while parsing this item list starting here
...
32 |     type Assoc3  = () wherei32: Copy;
   |                       ^^^^^^^^ expected one of `;` or `where`
...
35 | }
   | - the item list ends here

error[E0046]: not all trait items implemented, missing: `Assoc3`
  --> src/main.rs:26:1
   |
12 |     type Assoc3;
   |     ----------- `Assoc3` from trait
...
26 | impl Trait for i32 {
   | ^^^^^^^^^^^^^^^^^^ missing `Assoc3` in implementation

For more information about this error, try `rustc --explain E0046`.
error: could not compile `_edda875ab4436d7618324047168b3a91b01ad984` (bin "_edda875ab4436d7618324047168b3a91b01ad984") due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
warning: failed to automatically apply fixes suggested by rustc to crate `_edda875ab4436d7618324047168b3a91b01ad984`

after fixes were automatically applied the compiler reported errors within these files:

  * src/main.rs

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag

The following errors were reported:
error: expected one of `;` or `where`, found `wherei32`
  --> src/main.rs:32:23
   |
26 | impl Trait for i32 {
   |                    - while parsing this item list starting here
...
32 |     type Assoc3  = () wherei32: Copy;
   |                       ^^^^^^^^ expected one of `;` or `where`
...
37 | }
   | - the item list ends here

error[E0046]: not all trait items implemented, missing: `Assoc3`
  --> src/main.rs:26:1
   |
12 |     type Assoc3;
   |     ----------- `Assoc3` from trait
...
26 | impl Trait for i32 {
   | ^^^^^^^^^^^^^^^^^^ missing `Assoc3` in implementation

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0046`.
Original diagnostics will follow.

error: expected one of `;` or `where`, found `wherei32`
  --> src/main.rs:32:23
   |
26 | impl Trait for i32 {
   |                    - while parsing this item list starting here
...
32 |     type Assoc3  = () wherei32: Copy;
   |                       ^^^^^^^^ expected one of `;` or `where`
...
36 | }
   | - the item list ends here

error: could not compile `_edda875ab4436d7618324047168b3a91b01ad984` (bin "_edda875ab4436d7618324047168b3a91b01ad984" test) due to 2 previous errors

Version:

rustc 1.96.0-nightly (e3d66fe39 2026-03-07)
binary: rustc
commit-hash: e3d66fe39ae70380fa2365c008e2927479114844
commit-date: 2026-03-07
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.D-papercutDiagnostics: An error or lint that needs small tweaks.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions