Commit Graph

19 Commits

Author SHA1 Message Date
Esteban Küber
8b0ab54ffe review comment: change wording 2024-02-01 03:31:03 +00:00
Esteban Küber
c4c22b0d52 On E0277 be clearer about implicit Sized bounds on type params and assoc types
```
error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
   --> f100.rs:2:33
    |
2   |     let _ = std::mem::size_of::<[i32]>();
    |                                 ^^^^^ doesn't have a size known at compile-time
    |
    = help: the trait `Sized` is not implemented for `[i32]`
note: required by an implicit `Sized` bound in `std::mem::size_of`
   --> /home/gh-estebank/rust/library/core/src/mem/mod.rs:312:22
    |
312 | pub const fn size_of<T>() -> usize {
    |                      ^ required by the implicit `Sized` requirement on this bound in `size_of`
```

Fix #120178.
2024-02-01 03:30:26 +00:00
Esteban Küber
6efddac288 Provide more context on derived obligation error primary label
Expand the primary span of E0277 when the immediate unmet bound is not what the user wrote:

```
error[E0277]: the trait bound `i32: Bar` is not satisfied
 --> f100.rs:6:6
  |
6 |     <i32 as Foo>::foo();
  |      ^^^ the trait `Bar` is not implemented for `i32`, which is required by `i32: Foo`
  |
help: this trait has no implementations, consider adding one
 --> f100.rs:2:1
  |
2 | trait Bar {}
  | ^^^^^^^^^
note: required for `i32` to implement `Foo`
 --> f100.rs:3:14
  |
3 | impl<T: Bar> Foo for T {}
  |         ---  ^^^     ^
  |         |
  |         unsatisfied trait bound introduced here
```

Fix #40120.
2024-01-30 21:28:18 +00:00
Guillaume Gomez
0a4fd52c91
Rollup merge of #120293 - estebank:issue-102629, r=nnethercote
Deduplicate more sized errors on call exprs

Change the implicit `Sized` `Obligation` `Span` for call expressions to include the whole expression. This aids the existing deduplication machinery to reduce the number of errors caused by a single unsized expression.
2024-01-30 16:57:47 +01:00
Esteban Küber
d992d9cd56 On E0308 involving dyn Trait, mention trait objects
When encountering a type mismatch error involving `dyn Trait`, mention
the existence of boxed trait objects if the other type involved
implements `Trait`.

Partially addresses #102629.
2024-01-24 16:32:24 +00:00
Esteban Küber
a9841936fe Deduplicate more sized errors on call exprs
Change the implicit `Sized` `Obligation` `Span` for call expressions to
include the whole expression. This aids the existing deduplication
machinery to reduce the number of errors caused by a single unsized
expression.
2024-01-24 02:53:15 +00:00
sjwang05
2618e0f805
Provide better suggestions for T == &T and &T == T 2023-12-16 19:56:50 -08:00
Nilstrieb
41e8d152dc Show number in error message even for one error
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:52 +01:00
Michael Goulet
30e6cea0ae Point out if a local trait has no implementations 2023-09-10 21:20:36 +00:00
yukang
3635b48973 Fix wrong span for trait selection failure error reporting 2023-08-03 23:47:57 +08:00
Urgau
87e8feaf50 Fix invalid slice coercion suggestion reported in turbofish 2023-08-01 12:34:31 +02:00
Lukas Markeffsky
b6a3f126c0 change std::marker::Sized to just Sized 2023-06-15 12:01:38 +02:00
Michael Goulet
14bf909e71 Note base types of coercion 2023-05-12 00:10:52 +00:00
Ben Reeves
8ac7d0eef5 Add suggestion to diagnostic when user has array but trait wants slice.
For #90528.
2023-03-07 00:39:34 -05:00
Esteban Küber
62ba3e70a1 Modify primary span label for E0308
The previous output was unintuitive to users.
2023-01-30 20:12:19 +00:00
Esteban Küber
656db98bd9 Tweak E0597
CC #99430
2023-01-15 19:46:20 +00:00
Michael Goulet
5924c2511e Only point at impl self ty in WF if trait predicate shares self ty 2023-01-12 22:25:30 +00:00
Michael Goulet
2aabb0fd5d Point at impl self type for impl wf obligations 2023-01-12 20:44:47 +00:00
Albert Larsan
cf2dff2b1e
Move /src/test to /tests 2023-01-11 09:32:08 +00:00