rust/tests/ui/range
许杰友 Jieyou Xu (Joe) 7b821d1752
Rollup merge of #151278 - estebank:issue-108894, r=davidtwco
Provide more context on trait bounds being unmet due to imperfect derive

When encountering a value that has a borrow checker error where the type was previously moved, when suggesting cloning verify that it is not already being derived. If it is, explain why the `derive(Clone)` doesn't apply:

```
note: if `TypedAddress<T>` implemented `Clone`, you could clone the value
  --> $DIR/derive-clone-implicit-bound.rs:6:1
   |
LL | #[derive(Clone, Copy)]
   |          ----- derived `Clone` adds implicit bounds on type parameters
LL | pub struct TypedAddress<T>{
   | ^^^^^^^^^^^^^^^^^^^^^^^^-^
   | |                       |
   | |                       introduces an implicit `T: Clone` bound
   | consider manually implementing `Clone` for this type
...
LL |         let old = self.return_value(offset);
   |                                     ------ you could clone this value
```

When encountering a bound coming from a derive macro, suggest manual impl of the trait.

Use the span for the specific param when adding bounds in builtin derive macros, so the diagnostic will point at them as well as the derive macro itself.

```
note: required for `Id<SomeNode>` to implement `PartialEq`
  --> $DIR/derive-implicit-bound.rs:5:10
   |
LL | #[derive(PartialEq, Eq)]
   |          ^^^^^^^^^
LL | pub struct Id<T>(PhantomData<T>);
   |               - unsatisfied trait bound introduced in this `derive` macro
   = help: consider manually implementing `PartialEq` to avoid undesired bounds
```

Mention that the trait could be manually implemented in E0599.

Fix rust-lang/rust#108894. Address rust-lang/rust#143714. Address #rust-lang/rust#146515 (but ideally would also suggest constraining the fn bound correctly as well).
2026-02-06 10:25:43 +08:00
..
exclusive-range-patterns-2021.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
exclusive-range-patterns-2021.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
impossible_range.fixed Move 100 entries from tests/ui into subdirs 2024-05-20 19:55:59 -07:00
impossible_range.rs Move 100 entries from tests/ui into subdirs 2024-05-20 19:55:59 -07:00
impossible_range.stderr Make parse error suggestions verbose and fix spans 2024-07-12 03:02:57 +00:00
issue-54505-no-literals.fixed [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-54505-no-literals.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-54505-no-literals.stderr change end to last 2025-09-08 22:07:43 -04:00
issue-54505-no-std.rs Provide diagnostic for Struct(a, .., z) expression 2024-12-09 21:55:12 +00:00
issue-54505-no-std.stderr change end to last 2025-09-08 22:07:43 -04:00
issue-54505.fixed Provide diagnostic for Struct(a, .., z) expression 2024-12-09 21:55:12 +00:00
issue-54505.rs Provide diagnostic for Struct(a, .., z) expression 2024-12-09 21:55:12 +00:00
issue-54505.stderr change end to last 2025-09-08 22:07:43 -04:00
issue-73553-misinterp-range-literal.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-73553-misinterp-range-literal.stderr recurse into refs when comparing tys for diagnostics 2023-12-07 23:00:46 -05:00
misleading-field-access-hint.rs Fix #131471, range misleading field access 2024-10-18 17:27:28 +02:00
misleading-field-access-hint.stderr Fix #131471, range misleading field access 2024-10-18 17:27:28 +02:00
range-1.rs Update rustc_on_unimplemented message for Step 2026-01-13 01:28:28 +00:00
range-1.stderr Mention the type in the label, to avoid confusion at the cost of redundancy 2026-01-13 19:47:06 +00:00
range-inclusive-pattern-precedence.fixed Gate 2015 UI tests 2025-11-27 11:19:00 -05:00
range-inclusive-pattern-precedence.rs Gate 2015 UI tests 2025-11-27 11:19:00 -05:00
range-inclusive-pattern-precedence.stderr Gate 2015 UI tests 2025-11-27 11:19:00 -05:00
range-inclusive-pattern-precedence2.rs Gate 2015 UI tests 2025-11-27 11:19:00 -05:00
range-inclusive-pattern-precedence2.stderr Gate 2015 UI tests 2025-11-27 11:19:00 -05:00
range-negative-literal-unsigned-type.rs Add regression test for issue-136514: Negative literal in unsigned range 2026-02-01 22:49:57 +01:00
range-negative-literal-unsigned-type.stderr Add regression test for issue-136514: Negative literal in unsigned range 2026-02-01 22:49:57 +01:00
range-pattern-out-of-bounds-issue-68972.rs Stabilize exclusive_range 2024-05-02 19:42:31 -04:00
range-pattern-out-of-bounds-issue-68972.stderr Stabilize exclusive_range 2024-05-02 19:42:31 -04:00
range-to-iterator-suggestion-issue-147749.rs Suggest add bounding value for RangeTo 2025-11-11 20:13:10 +08:00
range-to-iterator-suggestion-issue-147749.stderr Suggest add bounding value for RangeTo 2025-11-11 20:13:10 +08:00
range_inclusive.rs Move 100 entries from tests/ui into subdirs 2024-05-20 19:55:59 -07:00
range_traits-1.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
range_traits-1.stderr Do not suggest using -Zmacro-backtrace for builtin macros 2025-03-14 19:50:03 +00:00
range_traits-2.rs Keep span of type in builtin derive macros expansions 2026-02-01 18:20:30 +00:00
range_traits-2.stderr Keep span of type in builtin derive macros expansions 2026-02-01 18:20:30 +00:00
range_traits-3.rs Keep span of type in builtin derive macros expansions 2026-02-01 18:20:30 +00:00
range_traits-3.stderr Keep span of type in builtin derive macros expansions 2026-02-01 18:20:30 +00:00
range_traits-4.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
range_traits-5.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
range_traits-6.rs Keep span of type in builtin derive macros expansions 2026-02-01 18:20:30 +00:00
range_traits-6.stderr Keep span of type in builtin derive macros expansions 2026-02-01 18:20:30 +00:00
range_traits-7.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00