Commit Graph

28 Commits

Author SHA1 Message Date
Scott McMurray 0d63e6b608 [ACP 362] genericize `ptr::from_raw_parts` 2024-05-29 09:34:16 -07:00
Caio ab8994d93e Move tests 2024-04-07 17:38:07 -03:00
Michael Goulet 383051092f Ignore tests w/ current/next revisions from compare-mode=next-solver 2024-03-10 21:18:41 -04:00
许杰友 Jieyou Xu (Joe) ec2cc761bc
[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
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
Jake Goulding 53eca9fa87 Adjust compiler tests for unused_tuple_struct_fields -> dead_code 2024-01-02 15:34:37 -05:00
lcnr 11d16c4082 update use of feature flags 2023-12-14 15:22:37 +01: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 6af30ec720 Remove a false statement from Unsize docs, add a test 2023-11-01 20:16:11 +00:00
Oli Scherer 455cf5a4f6 Improve some diagnostics around `?Trait` bounds 2023-10-30 17:47:07 +00:00
Oli Scherer beaf46f7e5 Work around the fact that `check_mod_type_wf` may spuriously return `ErrorGuaranteed`, even if that error is only emitted by `check_modwitem_types` 2023-10-25 12:04:54 +00:00
bohan 7c53e87d55 fix: skip opt if body has tainted error 2023-09-13 23:07:39 +08:00
Michael Goulet 30e6cea0ae Point out if a local trait has no implementations 2023-09-10 21:20:36 +00:00
bohan 967410c640 fix: return ealry when has tainted in mir-lint 2023-09-08 09:30:23 +08:00
Esteban Küber 120c24dab5 Point at appropriate type parameter in more trait bound errors 2023-08-26 01:07:05 +00:00
Michael Goulet 7d8563c602 Separate consider_unsize_to_dyn_candidate from other unsize candidates 2023-08-15 01:02:43 +00:00
bors 6fc0273b5a Auto merge of #112320 - compiler-errors:do-not-impl-via-obj, r=lcnr
Add `implement_via_object` to `rustc_deny_explicit_impl` to control object candidate assembly

Some built-in traits are special, since they are used to prove facts about the program that are important for later phases of compilation such as codegen and CTFE. For example, the `Unsize` trait is used to assert to the compiler that we are able to unsize a type into another type. It doesn't have any methods because it doesn't actually *instruct* the compiler how to do this unsizing, but this is later used (alongside an exhaustive match of combinations of unsizeable types) during codegen to generate unsize coercion code.

Due to this, these built-in traits are incompatible with the type erasure provided by object types. For example, the existence of `dyn Unsize<T>` does not mean that the compiler is able to unsize `Box<dyn Unsize<T>>` into `Box<T>`, since `Unsize` is a *witness* to the fact that a type can be unsized, and it doesn't actually encode that unsizing operation in its vtable as mentioned above.

The old trait solver gets around this fact by having complex control flow that never considers object bounds for certain built-in traits:
2f896da247/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs (L61-L132)

However, candidate assembly in the new solver is much more lovely, and I'd hate to add this list of opt-out cases into the new solver. Instead of maintaining this complex and hard-coded control flow, instead we can make this a property of the trait via a built-in attribute. We already have such a build attribute that's applied to every single trait that we care about: `rustc_deny_explicit_impl`. This PR adds `implement_via_object` as a meta-item to that attribute that allows us to opt a trait out of object-bound candidate assembly as well.

r? `@lcnr`
2023-06-20 08:42:37 +00:00
Michael Goulet 657d3f43a9 Add rustc_do_not_implement_via_object 2023-06-20 04:38:46 +00:00
Lukas Markeffsky b6a3f126c0 change `std::marker::Sized` to just `Sized` 2023-06-15 12:01:38 +02:00
Michael Goulet 3db2bcf4eb Remove return type sized check hack from hir typeck 2023-05-18 01:53:01 +00:00
Michael Goulet 795fdf7d61 Simplify suggestion when returning bare dyn trait 2023-05-18 01:47:55 +00:00
Michael Goulet 14bf909e71 Note base types of coercion 2023-05-12 00:10:52 +00:00
Michael Goulet a58682d7cc Specify what 'this' actually is 2023-02-21 05:21:07 +00:00
Ben Kimock de01ea26c9 Fix unintentional UB in ui tests 2023-02-15 09:05:05 -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
Albert Larsan cf2dff2b1e
Move /src/test to /tests 2023-01-11 09:32:08 +00:00