Commit Graph

231 Commits

Author SHA1 Message Date
León Orell Valerian Liehr
b00e408e61
Generalize E0401 2023-09-10 23:06:14 +02:00
bors
1accf068d8 Auto merge of #113126 - Bryanskiy:delete_old, r=petrochenkov
Replace old private-in-public diagnostic with type privacy lints

Next part of RFC https://github.com/rust-lang/rust/issues/48054.

r? `@petrochenkov`
2023-09-01 12:40:01 +00:00
Michael Goulet
bf66723c0e Test and note unsafe ctor to fn ptr coercion
Also remove a note that I don't consider to be very useful in context.
2023-08-30 15:09:40 -07:00
bors
bb90f81070 Auto merge of #112775 - c410-f3r:t3st3ss, r=petrochenkov
Move tests

r? `@petrochenkov`
2023-08-29 13:53:34 +00:00
Caio
5a69151d7d Move tests 2023-08-28 17:47:37 -03:00
David Tolnay
823bacb6e3
Revert "Suggest using Arc on !Send/!Sync types"
This reverts commit 9de1a472b6.
2023-08-28 03:16:48 -07:00
Esteban Küber
ef11db803c Remove unnecessary select_obligations_where_possible and redundant errors 2023-08-26 19:35:54 +00:00
Esteban Küber
b6494a7bb4 More accurately point at arguments 2023-08-26 19:25:46 +00:00
Esteban Küber
bac0e556f0 On let binding type point to type parameter that introduced unmet bound
On the following example, point at `String` instead of the whole type:

```
error[E0277]: the trait bound `String: Copy` is not satisfied
  --> $DIR/own-bound-span.rs:14:24
   |
LL |     let _: <S as D>::P<String>;
   |                        ^^^^^^ the trait `Copy` is not implemented for `String`
   |
note: required by a bound in `D::P`
  --> $DIR/own-bound-span.rs:4:15
   |
LL |     type P<T: Copy>;
   |               ^^^^ required by this bound in `D::P`
```
2023-08-26 02:23:25 +00: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
13e8b13e15 Handle Self in paths too 2023-08-25 19:05:38 +00:00
bors
c9228aeaba Auto merge of #115193 - weihanglo:rollup-6s3mz06, r=weihanglo
Rollup of 9 pull requests

Successful merges:

 - #114987 (elaborate a bit on the (lack of) safety in 'Mmap::map')
 - #115084 (Add smir `predicates_of`)
 - #115117 (Detect and report nix shell)
 - #115124 (kmc-solid: Import `std::sync::PoisonError` in `std::sys::solid::os`)
 - #115152 (refactor(lint): translate `RenamedOrRemovedLint`)
 - #115154 (Move some ui tests to subdirectories)
 - #115167 (Fix ub-int-array test for big-endian platforms)
 - #115172 (Add more tests for if_let_guard)
 - #115177 (Add symbols for Clippy usage)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-25 03:30:23 +00:00
bors
4354192429 Auto merge of #114201 - Centri3:explicit-repr-rust, r=WaffleLapkin
Allow explicit `#[repr(Rust)]`

This is identical to no `repr()` at all. For `Rust, packed` and `Rust, align(x)`, it should be the same as no `Rust` at all (as, afaik, `#[repr(align(16))]` uses the Rust ABI.)

The main use case for this is being able to explicitly say "I want to use the Rust ABI" in very very rare circumstances where the first obvious choice would be the C ABI yet is undesirable, which is already possible with functions as `extern "Rust"`. This would be useful for silencing https://github.com/rust-lang/rust-clippy/pull/11253. It's also more consistent with `extern`.

The lack of this also tripped me up a bit when I was new to Rust, as I expected this to be possible.
2023-08-25 00:02:54 +00:00
Olanti
8216f17d7d Move issue 29181, 2804, 17431, 66768 2023-08-24 20:44:08 +03:00
Catherine Flores
1f7bad0d12 Clarify that Rust is default repr 2023-08-20 13:22:39 +00:00
bors
c94cb834d0 Auto merge of #112500 - lukas-code:span-ctxt, r=petrochenkov
Fix argument removal suggestion around macros

Fixes #112437.
Fixes #113866.
Helps with #114255.

The issue was that `span.find_ancestor_inside(outer)` could previously return a span with a different expansion context from `outer`.

This happens for example for the built-in macro `panic!`, which expands to another macro call of `panic_2021!` or `panic_2015!`. Because the call site of `panic_20xx!` has not associated source code, its span currently points to the call site of `panic!` instead.

Something similar also happens items that get desugared in AST->HIR lowering. For example, `for` loops get two spans: One "inner" span that has the `.desugaring_kind()` kind set to `DesugaringKind::ForLoop` and one "outer" span that does not. Similar to the macro situation, both of these spans point to the same source code, but have different expansion contexts.

This causes problems, because joining two spans with different expansion contexts will usually[^1] not actually join them together to avoid creating "spaghetti" spans that go from the macro definition to the macro call. For example, in the following snippet `full_span` might not actually contain the `adjusted_start` and `adjusted_end`. This caused the broken suggestion / debug ICE in the linked issues.
```rust
let adjusted_start = start.find_ancestor_inside(shared_ancestor);
let adjusted_end = end.find_ancestor_inside(shared_ancestor);
let full_span = adjusted_start.to(adjusted_end)
```

To fix the issue, this PR introduces a new method, `find_ancestor_inside_same_ctxt`, which combines the functionality of `find_ancestor_inside` and `find_ancestor_in_same_ctxt`: It finds an ancestor span that is contained within the parent *and* has the same syntax context, and is therefore safe to extend. This new method should probably be used everywhere, where the returned span is extended, but for now it is just used for the argument removal suggestion.

Additionally, this PR fixes a second issue where the function call itself is inside a macro but the arguments come from outside the macro. The test is added in the first commit to include stderr diff, so this is best reviewed commit by commit.

[^1]: If one expansion context is the root context and the other is not.
2023-08-16 14:47:01 +00:00
Esteban Küber
55f8c66a60 Point at return type when it influences non-first match arm
When encountering code like

```rust
fn foo() -> i32 {
    match 0 {
        1 => return 0,
        2 => "",
        _ => 1,
    }
}
```

Point at the return type and not at the prior arm, as that arm has type
`!` which isn't influencing the arm corresponding to arm `2`.

Fix #78124.
2023-08-14 21:43:56 +00:00
Esteban Kuber
9de1a472b6 Suggest using Arc on !Send/!Sync types 2023-08-09 14:04:10 +00:00
Martin Nordholts
6ba393c28f Rename tests/ui/issues/issue-100605.rs to ../type/option-ref-advice.rs
The test is a regression test for a bug where the compiler gave bad
advice for an `Option<&String>`. Rename the file appropriately.
2023-08-05 15:36:19 +02:00
Nilstrieb
5706be1854 Improve spans for indexing expressions
Indexing is similar to method calls in having an arbitrary
left-hand-side and then something on the right, which is the main part
of the expression. Method calls already have a span for that right part,
but indexing does not. This means that long method chains that use
indexing have really bad spans, especially when the indexing panics and
that span in coverted into a panic location.

This does the same thing as method calls for the AST and HIR, storing an
extra span which is then put into the `fn_span` field in THIR.
2023-08-04 13:17:39 +02:00
Bryanskiy
e26614e6a7 Replace old private-in-public diagnostic with type privacy lints 2023-08-02 13:40:28 +03:00
Lukas Markeffsky
3694fd08e6 introduce Span::find_ancestor_inside_same_ctxt
and use it for function argument diagnostics
2023-08-01 16:51:20 +00:00
Mara Bos
0e729404da Change default panic handler message format. 2023-07-29 11:42:50 +02:00
Catherine Flores
f42d361a22 Allow explicit #[repr(Rust)] 2023-07-29 06:58:29 +00:00
bors
4734ac0943 Auto merge of #111916 - fee1-dead-contrib:noop-method-call-warn, r=compiler-errors
make `noop_method_call` warn by default

r? `@compiler-errors`
2023-07-29 01:40:50 +00:00
bors
bd1ae282f1 Auto merge of #113893 - mdibaiee:type-name-spill-flag, r=compiler-errors
new unstable option: -Zwrite-long-types-to-disk

This option guards the logic of writing long type names in files and instead using short forms in error messages in rustc_middle/ty/error behind a flag. The main motivation for this change is to disable this behaviour when running ui tests.

This logic can be triggered by running tests in a directory that has a long enough path, e.g. /my/very-long-path/where/rust-codebase/exists/

This means ui tests can fail depending on how long the path to their file is.

Some ui tests actually rely on this behaviour for their assertions, so for those we enable the flag manually.
2023-07-26 00:46:06 +00:00
Mahdi Dibaiee
b2d052b22d write-long-types-to-disk: update tests 2023-07-25 12:08:44 +01:00
Mahdi Dibaiee
8df39667dc new unstable option: -Zwrite-long-types-to-disk
This option guards the logic of writing long type names in files and
instead using short forms in error messages in rustc_middle/ty/error
behind a flag. The main motivation for this change is to disable this
behaviour when running ui tests.

This logic can be triggered by running tests in a directory that has a
long enough path, e.g. /my/very-long-path/where/rust-codebase/exists/

This means ui tests can fail depending on how long the path to their
file is.

Some ui tests actually rely on this behaviour for their assertions,
so for those we enable the flag manually.
2023-07-24 12:25:05 +01:00
Deadbeef
33ec4e4bb0 make noop_method_call warn by default 2023-07-23 07:09:14 +00:00
Oli Scherer
44e21503a8 Double check that hidden types match the expected hidden type 2023-07-21 13:19:36 +00:00
nxya
a54a66830d moved note as unspanned note, moved note to the bottom of the msg 2023-07-18 21:53:34 -04:00
nxya
e6e8892051 added links as a note 2023-07-18 09:27:35 -04:00
nxya
f92a9f6808 add links to query documentation for E0391 2023-07-18 09:27:26 -04:00
nxya
bef91ee687 added links as a note 2023-07-18 09:20:25 -04:00
nxya
c429a72db9 add links to query documentation for E0391 2023-07-18 09:20:25 -04:00
Matthias Krüger
893a5d2b32
Rollup merge of #113353 - compiler-errors:select-better, r=lcnr
Implement selection for `Unsize` for better coercion behavior

In order for much of coercion to succeed, we need to be able to deal with partial ambiguity of `Unsize` traits during selection. However, I pessimistically implemented selection in the new trait solver to just bail out with ambiguity if it was a built-in impl:
9227ff28af/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs (L126)

This implements a proper "rematch" procedure for dealing with built-in `Unsize` goals, so that even if the goal is ambiguous, we are able to get nested obligations which are used in the coercion selection-like loop:
9227ff28af/compiler/rustc_hir_typeck/src/coercion.rs (L702)

Second commit just moves a `resolve_vars_if_possible` call to fix a bug where we weren't detecting a trait upcasting to occur.

r? ``@lcnr``
2023-07-13 12:19:22 +02:00
Michael Goulet
fe870424a7 Do not set up wrong span for adjustments 2023-07-10 20:09:26 +00:00
bors
83964c156d Auto merge of #113491 - matthiaskrgr:rollup-mueqz7h, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #113005 (Don't call `query_normalize` when reporting similar impls)
 - #113064 (std: edit [T]::swap docs)
 - #113138 (Add release notes for 1.71.0)
 - #113217 (resolve typerelative ctors to adt)
 - #113254 (Use consistent formatting in Readme)
 - #113482 (Migrate GUI colors test to original CSS color format)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-08 20:56:57 +00:00
Matthias Krüger
48a0d038fa
Rollup merge of #113005 - compiler-errors:dont-query-normalize, r=cjgillot
Don't call `query_normalize` when reporting similar impls

Firstly, It's sketchy to be using `query_normalize` at all during HIR typeck -- it's asking for an ICE 😅. Secondly, we're normalizing an impl trait ref that potentially has parameter types in `ty::ParamEnv::empty()`, which is kinda sketchy as well.

The only UI test change from removing this normalization is that we don't evaluate anonymous constants in impls, which end up giving us really ugly suggestions:

```
error[E0277]: the trait bound `[X; 35]: Default` is not satisfied
 --> /home/gh-compiler-errors/test.rs:4:5
  |
4 |     <[X; 35] as Default>::default();
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[X; 35]`
  |
  = help: the following other types implement trait `Default`:
            &[T]
            &mut [T]
            [T; 32]
            [T; core::::array::{impl#30}::{constant#0}]
            [T; core::::array::{impl#31}::{constant#0}]
            [T; core::::array::{impl#32}::{constant#0}]
            [T; core::::array::{impl#33}::{constant#0}]
            [T; core::::array::{impl#34}::{constant#0}]
          and 27 others
```

So just fold the impls with a `BottomUpFolder` that calls `ty::Const::eval`. This doesn't work totally correctly with generic-const-exprs, but it's fine for stable code, and this is error reporting after all.
2023-07-08 20:53:27 +02:00
Michael Goulet
a071044562 Eagerly resolve vars in predicate during coercion loop 2023-07-08 03:41:22 +00:00
Michael Goulet
713f9bb5d1 Mark more hanging new-solver tests 2023-07-07 16:02:24 +00:00
lcnr
30ed152330 update tests 2023-07-03 09:12:15 +02:00
Bryanskiy
35c6a1d0f3 Fix type privacy lints error message 2023-06-29 16:24:07 +03:00
Matthias Krüger
42a495da7e
Rollup merge of #112670 - petrochenkov:typriv, r=eholk
privacy: Type privacy lints fixes and cleanups

See individual commits.
Follow up to https://github.com/rust-lang/rust/pull/111801.
2023-06-29 05:48:39 +02:00
Michael Goulet
2c33dfea76 Don't sort strings right after we just sorted by types 2023-06-27 23:31:06 +00:00
Matthias Krüger
353dd71d73
Rollup merge of #112454 - ferrocene:pa-compiletest-dynamic-linking, r=davidtwco
Make compiletest aware of targets without dynamic linking

Some parts of the compiletest internals and some tests require dynamic linking to work, which is not supported by all targets. Before this PR, this was handled by if branches matching on the target name.

This PR loads whether a target supports dynamic linking or not from the target spec, and adds a `// needs-dynamic-linking` attribute for tests that require it. Note that I was not able to replace all the old conditions based on the target name, as some targets have `dynamic_linking: true` in their spec but pretend they don't have it in compiletest.

Also, to get this to work I had to *partially* revert #111472 (cc `@djkoloski` `@tmandry` `@bjorn3).` On one hand, only the target spec contains whether a target supports dynamic linking, but on the other hand a subset of the fields can be overridden through `-C` flags (as far as I'm aware only `-C panic=$strategy`). The solution I came up with is to take the target spec as the base, and then override the panic strategy based on `--print=cfg`. Hopefully that should not break y'all again.
2023-06-27 22:10:13 +02:00
bors
6f8c27ae89 Auto merge of #112887 - WaffleLapkin:become_unuwuable_in_hir, r=compiler-errors,Nilstrieb
`hir`: Add `Become` expression kind (explicit tail calls experiment)

This adds `hir::ExprKind::Become` alongside ast lowering. During hir-thir lowering we currently lower `become` as `return`, so that we can partially test `become` without ICEing.

cc `@scottmcm`
r? `@Nilstrieb`
2023-06-26 13:51:04 +00:00
Maybe Waffle
ccb71ff424 hir: Add Become expression kind 2023-06-26 08:56:32 +00:00
Matthias Krüger
27ae068de3
Rollup merge of #112643 - compiler-errors:sized-obl-for-arg, r=wesleywiser
Always register sized obligation for argument

Removes a "hack" that skips registering sized obligations for parameters that are simple identifiers. This doesn't seem to affect diagnostics because we're probably already being smart enough about deduplicating identical error messages anyways.

Fixes #112608
2023-06-23 19:39:57 +02:00
Esteban Küber
7dffd24da5 Tweak privacy errors to account for reachable items
Suggest publicly accessible paths for items in private mod:

  When encountering a path in non-import situations that are not reachable
  due to privacy constraints, search for any public re-exports that the
  user could use instead.

Track whether an import suggestion is offering a re-export.

When encountering a path with private segments, mention if the item at
the final path segment is not publicly accessible at all.

Add item visibility metadata to privacy errors from imports:

  On unreachable imports, record the item that was being imported in order
  to suggest publicly available re-exports or to be explicit that the item
  is not available publicly from any path.

  In order to allow this, we add a mode to `resolve_path` that will not
  add new privacy errors, nor return early if it encounters one. This way
  we can get the `Res` corresponding to the final item in the import,
  which is used in the privacy error machinery.
2023-06-22 16:50:31 +00:00
Pietro Albini
767c4b9ef1
add support for needs-dynamic-linking 2023-06-20 17:20:57 +02:00
Vadim Petrochenkov
d326aed46f privacy: Feature gate new type privacy lints 2023-06-15 21:25:47 +03:00
许杰友 Jieyou Xu (Joe)
72b3b58efc
Extend unused_must_use to cover block exprs 2023-06-15 17:59:13 +08:00
Michael Goulet
0d6da78b06 Always register sized obligation for argument 2023-06-15 03:18:21 +00:00
Michael Goulet
7ff79cf4aa Move test 2023-06-13 21:54:11 +00:00
Michael Goulet
c92342d58d Erase regions even if normalization fails in writeback 2023-06-13 21:53:01 +00:00
bors
2ca8d358e5 Auto merge of #112549 - jieyouxu:fix-tests-for-unit-bindings, r=Nilstrieb
Adjust UI tests for `unit_bindings` lint

- Explicitly annotate `let x: () = expr;` where `x` has unit type, or remove the unit binding to leave only `expr;` instead.
- Use `let () = init;` or `let pat = ();` where appropriate.
- Fix disjoint-capture-in-same-closure test which wasn't actually testing a closure: `tests/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs`.

Note that unfortunately there's *a lot* of UI tests, there are a couple of places where I may have left something like `let (): ()` (this is not needed but is left over from an ealier version of the lint) which is bad style.

This PR is to help with the `unit_bindings` lint at #112380.
2023-06-13 13:07:43 +00:00
许杰友 Jieyou Xu (Joe)
edafbaffb2
Adjust UI tests for unit_bindings
- Either explicitly annotate `let x: () = expr;` where `x` has unit
  type, or remove the unit binding to leave only `expr;` instead.
- Fix disjoint-capture-in-same-closure test
2023-06-12 20:24:48 +08:00
bors
77dba225c1 Auto merge of #111801 - Bryanskiy:lints1, r=petrochenkov
Private-in-public lints implementation

Next part of RFC https://github.com/rust-lang/rust/issues/48054.

r? `@petrochenkov`
2023-06-11 22:18:23 +00:00
Bryanskiy
6d46382f6f Private-in-public lints implementation 2023-06-12 01:02:19 +03:00
bors
788c98df59 Auto merge of #111818 - Urgau:uplift_cmp_nan, r=cjgillot
Uplift `clippy::cmp_nan` lint

This PR aims at uplifting the `clippy::cmp_nan` lint into rustc.

## `invalid_nan_comparisons`

~~(deny-by-default)~~ (warn-by-default)

The `invalid_nan_comparisons` lint checks comparison with `f32::NAN` or `f64::NAN` as one of the operand.

### Example

```rust,compile_fail
let a = 2.3f32;
if a == f32::NAN {}
```

### Explanation

NaN does not compare meaningfully to anything – not even itself – so those comparisons are always false.

-----

Mostly followed the instructions for uplifting a clippy lint described here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751

`@rustbot` label: +I-lang-nominated
r? compiler
2023-06-10 12:47:51 +00:00
Urgau
3e91349c42 Uplift improved version of clippy::cmp_nan to rustc 2023-06-10 11:12:55 +02:00
Michael Goulet
3152ac34bd Ignore tests that hang in new solver 2023-06-09 21:57:37 +00:00
bors
dcc9028c0c Auto merge of #112450 - matthiaskrgr:rollup-fdbazkr, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #112323 (Don't mention already-set fields in struct constructor missing field error)
 - #112395 (Add Terminator::InlineAsm conversion from MIR to SMIR)
 - #112411 (add programmerjake to portable-simd cc list)
 - #112428 (Structurally resolve pointee in `check_pat_lit`)
 - #112444 (Don't debug-print `Interned` or `PrivateZst`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-09 06:38:22 +00:00
Matthias Krüger
17cc282880
Rollup merge of #112323 - compiler-errors:dont-mention-set-fields, r=WaffleLapkin
Don't mention already-set fields in struct constructor missing field error

Fixes #111149
2023-06-09 08:15:55 +02:00
Michael Goulet
a9188226a8 Peel borrows before suggesting as_ref/as_deref 2023-06-08 16:30:05 +00:00
Michael Goulet
af54d584b2 More robust as_ref/as_deref suggestions 2023-06-08 16:30:05 +00:00
Michael Goulet
140c011ca6 Don't mention already set fields 2023-06-05 21:00:08 +00:00
Michael Goulet
979379aff7 Resolve vars in result from scrape_region_constraints 2023-06-05 19:40:30 +00:00
bors
8177591aec Auto merge of #111516 - compiler-errors:issue-111500, r=jackh726
Don't use `can_eq` in `derive(..)` suggestion for missing method

Unsatisfied predicates returned from method probe may reference inference vars from that probe, so drop this extra check I added in #110877 for more accurate derive suggestions...

Fixes #111500
2023-06-03 07:25:40 +00:00
Matthias Krüger
9e47e90071
Rollup merge of #111558 - c410-f3r:t3st3ss, r=WaffleLapkin
Move tests

r? `@petrochenkov`
2023-05-29 21:34:16 +02:00
bors
089677eb32 Auto merge of #111813 - scottmcm:pretty-mir, r=cjgillot
MIR: opt-in normalization of `BasicBlock` and `Local` numbering

This doesn't matter at all for actual codegen, but after spending some time reading pre-codegen MIR, I was wishing I didn't have to jump around so much in reading post-inlining code.

So this add two passes that are off by default for every mir level, but can be enabled (`-Zmir-enable-passes=+ReorderBasicBlocks,+ReorderLocals`) for humans.
2023-05-28 21:53:56 +00:00
Caio
25e395653d Move tests 2023-05-24 19:35:59 -03:00
Scott McMurray
57c5ac7894 Tweak the post-order for multi-successor blocks 2023-05-21 17:48:36 -07:00
Michael Goulet
795fdf7d61 Simplify suggestion when returning bare dyn trait 2023-05-18 01:47:55 +00:00
bors
eb03a3e3f9 Auto merge of #111363 - asquared31415:tidy_no_random_ui_tests, r=fee1-dead
Add a tidy check to find unexpected files in UI tests, and clean up the results

While looking at UI tests, I noticed several weird files that were not being tested, some from even pre-1.0. I added a tidy check that fails if any files not known to compiletest or not used in tests (via manual list) are present in the ui tests.

Unfortunately the root entry limit had to be raised by 1 to accommodate the stderr file for one of the tests.

r? `@fee1-dead`
2023-05-13 21:34:05 +00:00
Michael Goulet
c5604cd0b5 Don't use can_eq in derive suggestion for missing method 2023-05-12 20:34:51 +00:00
Michael Goulet
14bf909e71 Note base types of coercion 2023-05-12 00:10:52 +00:00
asquared31415
517ea5652a tidy check to find misc files in ui tests, and clean up the results 2023-05-09 20:35:39 -04:00
Matthias Krüger
985ea22489
Rollup merge of #111021 - c410-f3r:dqewdas, r=petrochenkov
Move some tests

r? ``@petrochenkov``
2023-05-09 20:49:31 +02:00
Dylan DPC
ff30b8cb7b
Rollup merge of #110583 - Ezrashaw:tweak-make-mut-spans, r=estebank
tweak "make mut" spans when assigning to locals

Work towards fixing #106857

This PR just cleans up a lot of spans which is helpful before properly fixing the issues. Best reviewed commit-by-commit.

r? `@estebank`
2023-05-09 12:33:45 +05:30
Dylan DPC
2ecc72217b
Rollup merge of #110504 - compiler-errors:tweak-borrow-sugg, r=cjgillot
Tweak borrow suggestion span

Avoids a `span_to_snippet` call when we don't need to surround the expression in parentheses. The fact that the suggestion was using the whole span of the expression rather than just appending a `&` was prevented me from using `// run-rustfix` in another PR (https://github.com/rust-lang/rust/pull/110432#discussion_r1170500484).

Also some drive-by renames of functions that have been annoying me for a bit.
2023-05-09 12:33:44 +05:30
Caio
0285611096 Move tests 2023-05-08 17:58:01 -03:00
Dylan DPC
aceb5d951b
Rollup merge of #111056 - JohnBobbo96:fix_box_suggestions, r=compiler-errors
Fix some suggestions where a `Box<T>` is expected.

This fixes #111011, and also adds a suggestion for boxing a unit type when a `Box<T>` was expected and an empty block was found.
2023-05-08 11:39:21 +05:30
Michael Goulet
4731a25d2d Make suggest_deref_or_ref return a multipart suggestion 2023-05-08 03:42:21 +00:00
Michael Goulet
a9051d861c Tweak borrow suggestion 2023-05-08 03:36:30 +00:00
John Bobbo
35985091cc
Fix suggestion for boxing an async closure body, and
also add a suggestion for boxing empty blocks.
2023-05-07 20:30:56 -07:00
Ezra Shaw
9624d2b08e
tweak "make mut" spans (No. 2) 2023-05-05 22:40:05 +12:00
Ezra Shaw
fd8aa5ec7d
tweak "make mut" spans when assigning to locals 2023-05-05 22:40:04 +12:00
Manish Goregaokar
48c78248a3
Rollup merge of #111146 - petrochenkov:decident, r=compiler-errors
rustc_middle: Fix `opt_item_ident` for non-local def ids

Noticed while working on https://github.com/rust-lang/rust/pull/110855.
2023-05-03 16:42:51 -07:00
Manish Goregaokar
84d8159ebf
Rollup merge of #97594 - WaffleLapkin:array_tuple_conv, r=ChrisDenton
Implement tuple<->array convertions via `From`

This PR adds the following impls that convert between homogeneous tuples and arrays of the corresponding lengths:
```rust
impl<T> From<[T; 1]> for (T,) { ... }
impl<T> From<[T; 2]> for (T, T) { ... }
/* ... */
impl<T> From<[T; 12]> for (T, T, T, T, T, T, T, T, T, T, T, T) { ... }

impl<T> From<(T,)> for [T; 1] { ... }
impl<T> From<(T, T)> for [T; 2] { ... }
/* ... */
impl<T> From<(T, T, T, T, T, T, T, T, T, T, T, T)> for [T; 12] { ... }
```

IMO these are quite uncontroversial but note that they are, just like any other trait impls, insta-stable.
2023-05-03 16:42:47 -07:00
Vadim Petrochenkov
6f6c379ee0 rustc_middle: Fix opt_item_ident for non-local def ids 2023-05-03 20:09:10 +03:00
Michael Goulet
6e01e910cb Implement negative bounds 2023-05-02 22:36:24 +00:00
Maybe Waffle
36f86936b2 --bless tests 2023-05-02 14:48:39 +00:00
Nilstrieb
c63b6a437e Rip it out
My type ascription
Oh rip it out
Ah
If you think we live too much then
You can sacrifice diagnostics
Don't mix your garbage
Into my syntax
So many weird hacks keep diagnostics alive
Yet I don't even step outside
So many bad diagnostics keep tyasc alive
Yet tyasc doesn't even bother to survive!
2023-05-01 16:15:13 +08:00
Michael Goulet
3125979b78 Fix a bad binop error when we need a call 2023-04-27 01:34:03 +00:00
Michael Goulet
015acc2611 Provide RHS type hint when reporting operator error 2023-04-27 01:34:03 +00:00
Camille GILLOT
ed7e50e08b Ensure mir_drops_elaborated_and_const_checked when requiring codegen. 2023-04-21 16:14:43 +00:00
Matthias Krüger
7d046551a7
Rollup merge of #110555 - compiler-errors:subst-missing-trait-items, r=cjgillot
Substitute missing trait items suggestion correctly

Properly substitute missing item suggestions, so that when they reference generics from their parent trait they actually have the right time for the impl.

Also, some other minor tweaks like using `/* Type */` to signify a GAT's type is actually missing, and fixing generic arg suggestions for GATs in general.
2023-04-21 06:44:29 +02:00
Caio
4adc5f9281 Move test files 2023-04-20 15:06:17 -03:00