Commit Graph

262 Commits

Author SHA1 Message Date
bors
5378c1cf07 Auto merge of #119821 - oli-obk:reveal_all_const_evals, r=lcnr
Always use RevealAll for const eval queries

implements what is described in https://github.com/rust-lang/rust/pull/116803#discussion_r1364089471

Using `UserFacing` for const eval does not make sense anymore, unless we significantly change things like avoiding revealing opaque types.

New tests are copied from https://github.com/rust-lang/rust/pull/101478
2024-01-20 04:57:51 +00:00
Oli Scherer
867831a170 Always use RevealAll for const eval queries 2024-01-19 11:32:34 +00:00
George-lewis
d56cdd48cb Bless tests
Update tests
2024-01-13 12:46:58 -05:00
Oli Scherer
af7f8f9811 Silence follow up errors if astconv already errored 2024-01-11 09:03:26 +00:00
bors
94807670a6 Auto merge of #117449 - oli-obk:query_merge_immobile_game, r=matthewjasper
Avoid silencing relevant follow-up errors

r? `@matthewjasper`

This PR only adds new errors to tests that are already failing and fixes one ICE.

Several tests were changed to not emit new errors. I believe all of them were faulty tests, and not explicitly testing for the code that had new errors.
2024-01-09 22:50:49 +00:00
Oli Scherer
0978f6e010 Avoid silencing relevant follow-up errors 2024-01-09 21:08:16 +00:00
Guillaume Gomez
4a24b5bc05
Rollup merge of #117556 - obeis:static-mut-ref-lint, r=davidtwco
Disallow reference to `static mut` and adding `static_mut_ref` lint

Closes #114447

r? `@scottmcm`
2024-01-09 13:23:15 +01:00
Michael Goulet
7e38b70cc0 Split note, fix const/static impl trait error 2024-01-07 18:00:03 +00:00
Obei Sideg
a8aa6878f6 Update test for E0796 and static_mut_ref lint 2024-01-07 17:29:25 +03:00
Matthew Jasper
26f48b4cba Stabilize THIR unsafeck 2024-01-05 10:00:59 +00:00
Matthew Jasper
982b49494e Remove revisions for THIR unsafeck
This is to make the diff when stabilizing it easier to review.
2024-01-05 09:30:27 +00:00
bors
5113ed28ea Auto merge of #118297 - shepmaster:warn-dead-tuple-fields, r=WaffleLapkin
Merge `unused_tuple_struct_fields` into `dead_code`

This implicitly upgrades the lint from `allow` to `warn` and places it into the `unused` lint group.

[Discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Moving.20.60unused_tuple_struct_fields.60.20from.20allow.20to.20warn)
2024-01-05 04:51:55 +00:00
bors
791a53f380 Auto merge of #117213 - oli-obk:check_item_type_cleanup, r=estebank
Reorder check_item_type diagnostics so they occur next to the corresponding `check_well_formed` diagnostics

The first commit is just a cleanup.

The second commit moves most checks from `check_mod_item_types` into `check_well_formed`, invoking the checks in lockstep per-item instead of iterating over all items twice.
2024-01-05 00:04:08 +00:00
Esteban Küber
7f795a5221 Make derive(Trait) suggestion more accurate
Only suggest `derive(PartialEq)` when both LHS and RHS types
are the same, otherwise the suggestion is not useful.
2024-01-03 23:49:56 +00:00
Jake Goulding
53eca9fa87 Adjust compiler tests for unused_tuple_struct_fields -> dead_code 2024-01-02 15:34:37 -05:00
Oli Scherer
cd4c352fb4 Reorder check_item_type diagnostics so they occur next to the corresponding check_well_formed diagnostics 2024-01-02 14:17:56 +00:00
Matthias Krüger
d6382c785f
Rollup merge of #119175 - veera-sivarajan:fix-cast-to-slice, r=WaffleLapkin
fix: diagnostic for casting reference to slice

fixes:  #118790

Removes `if self.cast_ty.is_trait()` to produce the same diagnostic for cast to slice and trait.
2023-12-27 09:11:35 +01:00
Veera
286f2d819e Update existing tests 2023-12-20 22:53:56 -05:00
jyn
b5d8361909 rename to verbose-internals 2023-12-19 13:35:37 -05:00
Michael Goulet
e1c03e9bda Adjust the ignore-compare-mode-next-solver for hangs 2023-12-18 23:55:47 +00:00
lcnr
11d16c4082 update use of feature flags 2023-12-14 15:22:37 +01:00
Esteban Küber
9d846fcc11 Tweak short_ty_string to reduce number of files
When shortening types and writing them to disk, make `short_ty_string`
capable of reusing the same file, instead of writing a file per
shortened type.
2023-12-13 23:07:10 +00:00
Matthias Krüger
dbc6ec6636
Rollup merge of #118759 - compiler-errors:bare-unit-structs, r=petrochenkov
Support bare unit structs in destructuring assignments

We should be allowed to use destructuring assignments on *bare* unit structs, not just unit structs that are located within other pattern constructors.

Fixes #118753

r? petrochenkov since you reviewed #95380, reassign if you're busy or don't want to review this.
2023-12-13 18:03:33 +01:00
Matthias Krüger
ffdb471872
Rollup merge of #117914 - estebank:issue-85843, r=wesleywiser
On borrow return type, suggest borrowing from arg or owned return type

When we encounter a function with a return type that has an anonymous lifetime with no argument to borrow from, besides suggesting the `'static` lifetime we now also suggest changing the arguments to be borrows or changing the return type to be an owned type.

```
error[E0106]: missing lifetime specifier
  --> $DIR/variadic-ffi-6.rs:7:6
   |
LL | ) -> &usize {
   |      ^ expected named lifetime parameter
   |
   = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
   |
LL | ) -> &'static usize {
   |       +++++++
help: instead, you are more likely to want to change one of the arguments to be borrowed...
   |
LL |     x: &usize,
   |        +
help: ...or alternatively, to want to return an owned value
   |
LL - ) -> &usize {
LL + ) -> usize {
   |
```

Fix #85843.
2023-12-12 17:40:53 +01:00
bors
8a3765582c Auto merge of #117758 - Urgau:lint_pointer_trait_comparisons, r=davidtwco
Add lint against ambiguous wide pointer comparisons

This PR is the resolution of https://github.com/rust-lang/rust/issues/106447 decided in https://github.com/rust-lang/rust/issues/117717 by T-lang.

## `ambiguous_wide_pointer_comparisons`

*warn-by-default*

The `ambiguous_wide_pointer_comparisons` lint checks comparison of `*const/*mut ?Sized` as the operands.

### Example

```rust
let ab = (A, B);
let a = &ab.0 as *const dyn T;
let b = &ab.1 as *const dyn T;

let _ = a == b;
```

### Explanation

The comparison includes metadata which may not be expected.

-------

This PR also drops `clippy::vtable_address_comparisons` which is superseded by this one.

~~One thing: is the current naming right? `invalid` seems a bit too much.~~

Fixes https://github.com/rust-lang/rust/issues/117717
2023-12-11 14:33:16 +00:00
surechen
40ae34194c remove redundant imports
detects redundant imports that can be eliminated.

for #117772 :

In order to facilitate review and modification, split the checking code and
removing redundant imports code into two PR.
2023-12-10 10:56:22 +08:00
Michael Goulet
d473bdfdc3 Support bare unit structs in destructuring assignments 2023-12-08 19:55:07 +00:00
jyn
eb53721a34 recurse into refs when comparing tys for diagnostics 2023-12-07 23:00:46 -05:00
Urgau
5e1bfb538f Adjust tests for newly added ambiguous_wide_pointer_comparisons lint 2023-12-06 09:03:48 +01:00
Esteban Küber
4e99db9e54 Tweak unclosed generics errors
Remove unnecessary span label for parse errors that already have a
suggestion.

Provide structured suggestion to close generics in more cases.
2023-12-01 20:01:39 +00:00
Matthias Krüger
13ded66513
Rollup merge of #118453 - estebank:priv-fields, r=compiler-errors
Tweak message on ADT with private fields building

When trying to create an inaccessible ADT due to private fields, handle the case when no fields were passed.

```
error: cannot construct `Foo` with struct literal syntax due to private fields
  --> $DIR/issue-76077.rs:8:5
   |
LL |     foo::Foo {};
   |     ^^^^^^^^
   |
   = note: private field `you_cant_use_this_field` that was not provided
```
2023-11-30 09:28:25 +01:00
Esteban Küber
44fd3b4d46 Make parse_pat_ident not recover bad name 2023-11-29 18:47:31 +00:00
Esteban Küber
4be07075b3 Tweak message on ADT with private fields building
When trying to create an inaccessible ADT due to private fields, handle
the case when no fields were passed.

```
error: cannot construct `Foo` with struct literal syntax due to private fields
  --> $DIR/issue-76077.rs:8:5
   |
LL |     foo::Foo {};
   |     ^^^^^^^^
   |
   = note: private field `you_cant_use_this_field` that was not provided
```
2023-11-29 18:11:57 +00:00
Nilstrieb
9b80d85722 Manual find replace updates 2023-11-24 21:04:51 +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
Esteban Küber
b7a23bc08b On borrow return type, suggest borrowing from arg or owned return type
When we encounter a function with a return type that has an anonymous
lifetime with no argument to borrow from, besides suggesting the
`'static` lifetime we now also suggest changing the arguments to be
borrows or changing the return type to be an owned type.

```
error[E0106]: missing lifetime specifier
  --> $DIR/variadic-ffi-6.rs:7:6
   |
LL | ) -> &usize {
   |      ^ expected named lifetime parameter
   |
   = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
   |
LL | ) -> &'static usize {
   |       +++++++
help: instead, you are more likely to want to change one of the arguments to be borrowed...
   |
LL |     x: &usize,
   |        +
help: ...or alternatively, to want to return an owned value
   |
LL - ) -> &usize {
LL + ) -> usize {
   |
```

Fix #85843.
2023-11-20 23:44:36 +00:00
Takayuki Maeda
9e84f6d86a
Rollup merge of #117110 - estebank:deref-field-suggestion, r=b-naber
Suggest field typo through derefs

Take into account implicit dereferences when suggesting fields.

```
error[E0609]: no field `longname` on type `Arc<S>`
  --> $DIR/suggest-field-through-deref.rs:10:15
   |
LL |     let _ = x.longname;
   |               ^^^^^^^^ help: a field with a similar name exists: `long_name`
```

CC https://github.com/rust-lang/rust/issues/78374#issuecomment-719564114
2023-11-19 04:14:41 +09:00
bors
e1e60b6976 Auto merge of #117924 - estebank:issue-53841, r=petrochenkov
When a local binding shadows a fn, point at fn def in call failure

When a local binding shadows a function that is then called, this local binding will cause an E0618 error. We now point not only at the binding definition, but also at the locally defined function of the same name.

```
error[E0618]: expected function, found `&str`
  --> $DIR/issue-22468.rs:3:13
   |
LL |     let foo = "bar";
   |         --- `foo` has type `&str`
LL |     let x = foo("baz");
   |             ^^^-------
   |             |
   |             call expression requires function
...
LL | fn foo(file: &str) -> bool {
   | -------------------------- this function of the same name is available here, but it shadowed by the local binding of the same name
```

Fix #53841
2023-11-18 10:47:33 +00:00
Esteban Küber
7141399454 When a local binding shadows a fn, point at fn def in call failure
When a local binding shadows a function that is then called, this local
binding will cause an E0618 error. We now point not only at the binding
definition, but also at the locally defined function of the same name.

```
error[E0618]: expected function, found `&str`
  --> $DIR/issue-22468.rs:3:13
   |
LL |     let foo = "bar";
   |         --- `foo` has type `&str`
LL |     let x = foo("baz");
   |             ^^^-------
   |             |
   |             call expression requires function
...
LL | fn foo(file: &str) -> bool {
   | -------------------------- this function of the same name is avalable here, but it shadowed by the local binding of the same name
```

Fix #53841
2023-11-18 00:05:19 +00:00
bors
82b804c744 Auto merge of #118023 - matthiaskrgr:rollup-i9skwic, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #117338 (Remove asmjs)
 - #117549 (Use `copied` instead of manual `map`)
 - #117745 (Emit smir)
 - #117964 (When using existing fn as module, don't claim it doesn't exist)
 - #118006 (clarify `fn discriminant` guarantees: only free lifetimes may get erased)
 - #118016 (Add stable mir members to triagebot config)
 - #118022 (Miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-17 22:58:19 +00:00
Matthias Krüger
ca3a02836e
Rollup merge of #117338 - workingjubilee:asmjs-meets-thanatos, r=b-naber
Remove asmjs

Fulfills [MCP 668](https://github.com/rust-lang/compiler-team/issues/668).

`asmjs-unknown-emscripten` does not work as-specified, and lacks essential upstream support for generating asm.js, so it should not exist at all.
2023-11-17 23:04:21 +01:00
Esteban Küber
4f7dddd4a1 recover primary span label 2023-11-16 17:00:23 +00:00
Esteban Küber
8bd8f3b090 Suggest unwrap() on field not found for Result/Option
When encountering a `Result<T, _>` or `Option<T>` where `T` has a field
that's being accessed, suggest calling `.unwrap()` to get to the field.
2023-11-16 17:00:23 +00:00
Esteban Küber
dfa75391f8 Suggest field typo through derefs
Take into account implicit dereferences when suggesting fields.

```
error[E0609]: no field `longname` on type `Arc<S>`
  --> $DIR/suggest-field-through-deref.rs:10:15
   |
LL |     let _ = x.longname;
   |               ^^^^^^^^ help: a field with a similar name exists: `long_name`
```

CC https://github.com/rust-lang/rust/issues/78374#issuecomment-719564114
2023-11-16 17:00:23 +00:00
Esteban Küber
4e418805da More detail when expecting expression but encountering bad macro argument
Partially address #71039.
2023-11-16 16:19:04 +00:00
Esteban Küber
aae391cf68 Apply structured suggestion that allows test to work since 1.64
Close #73497.
2023-11-07 01:54:00 +00:00
Michael Goulet
c83f642f12 Pretty print Fn traits in rustc_on_unimplemented 2023-11-02 20:57:05 +00:00
bors
a395214a3a Auto merge of #116405 - estebank:issue-103155, r=davidtwco
Detect object safety errors when assoc type is missing

When an associated type with GATs isn't specified in a `dyn Trait`, emit an object safety error instead of only complaining about the missing associated type, as it will lead the user down a path of three different errors before letting them know that what they were trying to do is impossible to begin with.

Fix #103155.
2023-10-30 22:47:48 +00:00
Esteban Küber
17a6ae2df3 Detect object safety errors when assoc type is missing
When an associated type with GATs isn't specified in a `dyn Trait`, emit
an object safety error instead of only complaining about the missing
associated type, as it will lead the user down a path of three different
errors before letting them know that what they were trying to do is
impossible to begin with.

Fix #103155.
2023-10-30 22:12:07 +00:00
bors
31bc7e2c47 Auto merge of #117415 - matthiaskrgr:rollup-jr2p1t2, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #116862 (Detect when trait is implemented for type and suggest importing it)
 - #117389 (Some diagnostics improvements of `gen` blocks)
 - #117396 (Don't treat closures/coroutine types as part of the public API)
 - #117398 (Correctly handle nested or-patterns in exhaustiveness)
 - #117403 (Poison check_well_formed if method receivers are invalid to prevent typeck from running on it)
 - #117411 (Improve some diagnostics around `?Trait` bounds)
 - #117414 (Don't normalize to an un-revealed opaque when we hit the recursion limit)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-30 20:50:14 +00:00