Commit Graph

23913 Commits

Author SHA1 Message Date
Matthias Krüger
7bfccb3d7f
Rollup merge of #108687 - compiler-errors:reformulate-point_at_expr_source_of_inferred_type, r=oli-obk
Reformulate `point_at_expr_source_of_inferred_type` to be more accurate

Be more accurate when deducing where along the several usages of a binding it is constrained to be some type that is incompatible with an expectation.

This also renames the method to `note_source_of_type_mismatch_constraint` because I prefer that name, though I guess I can revert that. (Also drive-by rename `note_result_coercion` -> `suggest_coercing_result_via_try_operator`, because it's suggesting, not noting!)

This PR is (probably?) best reviewed per commit, but it does regress a bit only to fix it later on, so it could also be reviewed as a whole if that makes the final results more clear.

r? `@estebank`
2023-04-14 21:11:10 +02:00
Camille GILLOT
df9342aa6f Remove from cranelift too. 2023-04-14 16:26:11 +00:00
Camille GILLOT
194497a1a1 Remove attempt to optimize codegen for discriminants. 2023-04-14 16:26:11 +00:00
Alex Chi
90dc6fe71d fix import Applicability
Signed-off-by: Alex Chi <iskyzh@gmail.com>
2023-04-14 11:42:37 -04:00
Alex Chi
173b8567ee use param instead of ty
Signed-off-by: Alex Chi <iskyzh@gmail.com>
2023-04-14 11:39:35 -04:00
Alex Chi
54c11a688f better suggestion based on hir
Signed-off-by: Alex Chi <iskyzh@gmail.com>
2023-04-14 11:39:35 -04:00
Alex Chi
6e17349b12 suggest lifetime for closure parameter type when mismatch 2023-04-14 11:39:35 -04:00
Yuki Okushi
425913367b
Rollup merge of #110315 - oli-obk:mor_smir, r=WaffleLapkin
Add a stable MIR way to get the main function

This is useful for analysis tools that only analyze the code paths that a specific program actually goes through. Or for code generators built on top of stable MIR.
2023-04-14 23:00:36 +09:00
lcnr
64fbdc3779 explicit adt_dtorck_constraint for ManuallyDrop 2023-04-14 15:44:05 +02:00
Maybe Waffle
5571dd061d fix broken intradoclinks 2023-04-14 13:04:58 +00:00
Maybe Waffle
014c6f208e Use ptr::Alignment for extra coolness points 2023-04-14 12:31:49 +00:00
Maybe Waffle
36f5918bf1 Test CopyTaggedPtr's HashStable impl 2023-04-14 11:59:53 +00:00
Maybe Waffle
251f662e4d Share Tag2 impl between CopyTaggedPtr and TaggedPtr tests 2023-04-14 11:24:22 +00:00
Maybe Waffle
8d49e948a8 Doc fixes from review 2023-04-14 11:24:22 +00:00
Ezra Shaw
b506d966a3
implement review suggestions 2023-04-14 20:18:28 +12:00
Oli Scherer
e404e77c0b Add a stable MIR way to get the main function 2023-04-14 07:28:56 +00:00
Deadbeef
b59ec166ad allow repr(align = x) on inherent methods 2023-04-14 06:39:48 +00:00
Matthias Krüger
610bc68675
Rollup merge of #110299 - kylematsuda:earlybinder-impl-subject, r=compiler-errors
Switch to `EarlyBinder` for `impl_subject` query

Part of the work to finish https://github.com/rust-lang/rust/issues/105779.

Several queries `X` have a `bound_X` variant that wraps the output in `EarlyBinder`. This adds `EarlyBinder` to the return type of the `impl_subject` query and removes `bound_impl_subject`.

r? ```@lcnr```
2023-04-14 07:58:42 +02:00
Matthias Krüger
f3c6955249
Rollup merge of #110276 - nnethercote:rm-BrAnon-Span, r=jackh726
Remove all but one of the spans in `BoundRegionKind::BrAnon`

There are only three places where `BoundRegionKind::BrAnon` uses `Some(span)` instead of `None`. Two of them are easy to remove, which this PR does.

r? ```@jackh726```
2023-04-14 07:58:41 +02:00
Matthias Krüger
69d7172b8e
Rollup merge of #110207 - compiler-errors:new-solver-unpin, r=lcnr
Assemble `Unpin` candidates specially for generators in new solver

Fixes compiler-errors/next-solver-hir-issues#16

r? ``@lcnr``
2023-04-14 07:58:40 +02:00
Matthias Krüger
44db7c3b5a
Rollup merge of #110180 - lcnr:canonicalize, r=compiler-errors
don't uniquify regions when canonicalizing

uniquifying causes a bunch of issues, most notably it causes `AliasEq(<?x as Trait<'a>>::Assoc, <?x as Trait<'a>>::Assoc)` to result in ambiguity because both `normalizes-to` paths result in ambiguity and substs equate should trivially succeed but doesn't because we uniquified `'a` to two different regions.

I originally added uniquification to make it easier to deal with requirement 6 from the dev-guide: https://rustc-dev-guide.rust-lang.org/solve/trait-solving.html#requirements

> ### 6. Trait solving must be (free) lifetime agnostic
>
> Trait solving during codegen should have the same result as during typeck. As we erase
> all free regions during codegen we must not rely on them during typeck. A noteworthy example
> is special behavior for `'static`.

cc https://github.com/rust-lang/rustc-dev-guide/pull/1671

Relying on regions being identical may cause ICE during MIR typeck, but even without this PR we can end up relying on that as type inference vars can resolve to types which contain an identical region. Let's land this and deal with any ICE that crop up as we go. Will look at this issue again before stabilization.

r? ```@compiler-errors```
2023-04-14 07:58:40 +02:00
Matthias Krüger
c6223e198d
Rollup merge of #109800 - bryangarza:safe-transmute-improved-errors, r=compiler-errors
Improve safe transmute error reporting

This patch updates the error reporting when Safe Transmute is not possible between 2 types by including the reason.

Also, fix some small bugs that occur when computing the `Answer` for transmutability.
2023-04-14 07:58:39 +02:00
Michael Goulet
319c790600 Move auto trait built-in candidate disqualification to a separate method 2023-04-14 03:14:02 +00:00
Michael Goulet
b335c2d49f Assemble Unpin candidates specially for generators in new solver 2023-04-14 03:13:56 +00:00
Nicholas Nethercote
f07c335e90 Remove another use of BrAnon(Some(_)). 2023-04-14 11:28:16 +10:00
Nicholas Nethercote
7dbd2e2370 Remove one use of BrAnon(Some(_)). 2023-04-14 11:28:10 +10:00
bors
7a78c4ffd5 Auto merge of #110160 - petrochenkov:notagain2, r=cjgillot
resolve: Pre-compute non-reexport module children

Instead of repeating the same logic by walking HIR during metadata encoding.

The only difference is that we are no longer encoding `macro_rules` items, but we never currently need them as a part of this list. They can be encoded separately if this need ever arises.

`module_reexports` is also un-querified, because I don't see any reasons to make it a query, only overhead.
2023-04-14 01:14:36 +00:00
Kyle Matsuda
8d5ee1a072 make impl_subject more readable 2023-04-13 16:43:34 -06:00
Bryan Garza
36febe1f4d Improve safe transmute error reporting
This patch updates the error reporting when Safe Transmute is not
possible between 2 types by including the reason.

Also, fix some small bugs that occur when computing the `Answer` for
transmutability.
2023-04-13 21:57:08 +00:00
Kyle Matsuda
e2f5a5a71f make tcx.impl_subject return EarlyBinder, remove bound_impl_subject, rename usages of bound_impl_subject to impl_subject 2023-04-13 15:56:00 -06:00
Kyle Matsuda
dcc51f1ef5 change usage of bound_impl_subject to impl_subject 2023-04-13 15:55:54 -06:00
Matthias Krüger
46c6301672
Rollup merge of #110291 - WaffleLapkin:copy_location_detail, r=oli-obk
Implement `Copy` for `LocationDetail`

micro-nano-little-change
2023-04-13 21:58:39 +02:00
Matthias Krüger
c140e25ec8
Rollup merge of #110283 - saethlin:check-panics-before-alignment, r=bjorn3
Only emit alignment checks if we have a panic_impl

Fixes https://github.com/rust-lang/rust/issues/109996

r? `@bjorn3` because you commented that this situation could impact you as well
2023-04-13 21:58:39 +02:00
Matthias Krüger
759d4e8651
Rollup merge of #110277 - Ezrashaw:combine-assoc-fns-dlint, r=lcnr
dead-code-lint: de-dup multiple unused assoc functions

Fixes #109600

Prior art: #97853
2023-04-13 21:58:38 +02:00
Matthias Krüger
e85ecbbcdc
Rollup merge of #110233 - nbdd0121:intrinsic, r=tmiasko
Make rust-intrinsic ABI unwindable

Fix #104451, fix https://github.com/rust-lang/miri/issues/2839

r? `@RalfJung`
2023-04-13 21:58:37 +02:00
Matthias Krüger
232eb698ed
Rollup merge of #110193 - compiler-errors:body-owner-issue, r=WaffleLapkin
Check for body owner fallibly in error reporting

Sometimes the "body id" we use for an obligation cause is not actually a body owner, like when we're doing WF checking on items.

Fixes #110157
2023-04-13 21:58:36 +02:00
Maybe Waffle
09a8791d42 Implement Copy for LocationDetail 2023-04-13 18:04:30 +00:00
Maybe Waffle
c155d5149f Implement Send/Sync for CopyTaggedPtr 2023-04-13 16:51:04 +00:00
Lukas Markeffsky
0d0949d87f emit unused_parens for break if it is not immediately followed by a block 2023-04-13 18:09:47 +02:00
Lukas Markeffsky
8df1f41b9c fix false positives for unused_parens around unary and binary operations 2023-04-13 18:08:52 +02:00
Ben Kimock
4061eb5897 Only emit alignment checks if we have a panic_impl 2023-04-13 10:58:00 -04:00
bors
e14b81f10d Auto merge of #109989 - ids1024:m68k-asm, r=Amanieu
Add inline assembly support for m68k

I believe this should be correct, to the extent I understand the logic around inline assembly. M68k is fairly straightforward here, other than having separate address registers.
2023-04-13 11:41:57 +00:00
Ezra Shaw
39e23ef532
impl reviewer feedback
- remove unused (pun intentional) `continue`
- improve wording with assoc items in general
2023-04-13 23:39:14 +12:00
Ezra Shaw
c41dcac8e8
dead-code-lint: de-dup multiple unused assoc fns 2023-04-13 22:42:47 +12:00
Mara Bos
a77d39b5e2 Enable flatten-format-args by default. 2023-04-13 12:15:36 +02:00
Matthias Krüger
6f1500aec2
Rollup merge of #110220 - lcnr:regionzz, r=compiler-errors
cleanup our region error API

- require `TypeErrCtxt` to always result in an error, closing #108810
- move `resolve_regions_and_report_errors` to the `ObligationCtxt`
- call `process_registered_region_obligations` in `resolve_regions`
- move `resolve_regions` into the `outlives` submodule
- add `#[must_use]` to functions returning lists of errors

r? types
2023-04-13 11:21:05 +02:00
Matthias Krüger
35c4ea59a5
Rollup merge of #110218 - nnethercote:rm-ToRegionVid, r=compiler-errors
Remove `ToRegionVid`

r? ```@compiler-errors```
2023-04-13 11:21:01 +02:00
Matthias Krüger
958413cc08
Rollup merge of #110195 - compiler-errors:issue-110052, r=aliemjay
Erase lifetimes above `ty::INNERMOST` when probing ambiguous types

Turns out that `TyCtxt::replace_escaping_bound_vars_uncached` only erases bound vars exactly at `ty::INNERMOST`, and not everything above. This regresses the suggestions for non-lifetime binders, but oh well, I don't really care about those.

Fixes #110052
2023-04-13 11:21:00 +02:00
Matthias Krüger
6161fb8c65
Rollup merge of #110072 - joshtriplett:stabilize-is-terminal, r=Mark-Simulacrum
Stabilize IsTerminal

FCP completed in https://github.com/rust-lang/rust/issues/98070 .

closes: https://github.com/rust-lang/rust/issues/98070
2023-04-13 11:21:00 +02:00
Ezra Shaw
03cf0e949f
refactor: emit "unused assoc fn" in lexical order
with repect to other dead code lints
2023-04-13 20:53:32 +12:00
Ezra Shaw
ecf2a9b75e
fix: skip implied bounds if unconstrained lifetime exists 2023-04-13 20:29:41 +12:00
Scott McMurray
1bcb0ec28c assume value ranges in transmute
Fixes #109958
2023-04-13 00:12:39 -07:00
bors
d37e2f74af Auto merge of #109786 - estebank:tweak-add-line-sugg, r=compiler-errors
Tweak output for 'add line' suggestion

Closes #108174
2023-04-13 07:02:53 +00:00
Nicholas Nethercote
c18773a286 Make mk_bound_region closure more generic.
This is necessary for the subsequent commits.
2023-04-13 14:47:14 +10:00
Nicholas Nethercote
722e07854a Remove useless match. 2023-04-13 14:47:14 +10:00
Nicholas Nethercote
72605cd267 Remove some unused type folders.
I'm surprised the compiler doesn't warn about these. It appears having
an `impl` on a struct is enough to avoid a warning about it never being
constructed.
2023-04-13 12:20:44 +10:00
Nicholas Nethercote
bbc400993e Remove ToRegionVid.
It is only implemented for `Region`, where it is equivalent to the
inherent `as_var` method.
2023-04-13 12:20:41 +10:00
Nicholas Nethercote
411422f2b9 Remove impl ToRegionVid for RegionVid.
It's weird and unnecessary.
2023-04-13 12:10:16 +10:00
Nicholas Nethercote
c802694bda Make Region::as_var infallible.
It's what all the call sites require.
2023-04-13 12:10:16 +10:00
bors
d8fc819247 Auto merge of #109466 - davidlattimore:inline-arg-via-var-debug-info, r=wesleywiser
Preserve argument indexes when inlining MIR

We store argument indexes on VarDebugInfo. Unlike the previous method of relying on the variable index to know whether a variable is an argument, this survives MIR inlining.

We also no longer check if var.source_info.scope is the outermost scope. When a function gets inlined, the arguments to the inner function will no longer be in the outermost scope. What we care about though is whether they were in the outermost scope prior to inlining, which we know by whether we assigned an argument index.

Fixes #83217

I considered using `Option<NonZeroU16>` instead of `Option<u16>` to store the index. I didn't because `TypeFoldable` isn't implemented for `NonZeroU16` and because it looks like due to padding, it currently wouldn't make any difference. But I indexed from 1 anyway because (a) it'll make it easier if later it becomes worthwhile to use a `NonZeroU16` and because the arguments were previously indexed from 1, so it made for a smaller change.

This is my first PR on rust-lang/rust, so apologies if I've gotten anything not quite right.
2023-04-13 01:51:27 +00:00
AndyJado
bdf0e74777 migrate ftl msg accroding to #103042 2023-04-13 09:43:46 +08:00
AndyJado
d0468a2283 rm var_span_label to var_subdiag & eager subdiag 2023-04-13 09:43:46 +08:00
Ian Douglas Scott
2ac8dee44f Add inline assembly support for m68k 2023-04-12 17:58:15 -07:00
Michael Goulet
5cc4757421 More accurate argument blames, add some comments 2023-04-12 23:20:12 +00:00
Michael Goulet
5a71029dd3 Properly note source of arg mismatch 2023-04-12 23:20:12 +00:00
Michael Goulet
29aee6a125 Restore suggestion based off of backwards inference from bad usage to method call 2023-04-12 23:20:11 +00:00
Michael Goulet
e72c45ad98 Point at which arg causes a binding to be constrained 2023-04-12 23:20:11 +00:00
Michael Goulet
42c4373ad1 Make note_source_of_type_mismatch_constraint simpler 2023-04-12 23:05:55 +00:00
Esteban Küber
9fadcc143a Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
Esteban Küber
5b40aa5eb4 Tweak output for 'add line' suggestion 2023-04-12 22:50:10 +00:00
bors
9693b178fc Auto merge of #110252 - matthiaskrgr:rollup-ovaixra, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #109810 (Replace rustdoc-ui/{c,z}-help tests with a stable run-make test )
 - #110035 (fix: ensure bad `#[test]` invocs retain correct AST)
 - #110089 (sync::mpsc: synchronize receiver disconnect with initialization)
 - #110103 (Report overflows gracefully with new solver)
 - #110122 (Fix x check --stage 1 when download-ci-llvm=false)
 - #110133 (Do not use ImplDerivedObligationCause for inherent impl method error reporting)
 - #110135 (Revert "Don't recover lifetimes/labels containing emojis as character literals")
 - #110235 (Fix `--extend-css` option)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-12 22:19:29 +00:00
lcnr
c0d3d32922 fix comment 2023-04-12 22:07:07 +02:00
Matthias Krüger
57393be6fb
Rollup merge of #110135 - compiler-errors:revert-108031, r=davidtwco
Revert "Don't recover lifetimes/labels containing emojis as character literals"

Reverts PR #108031 per https://github.com/rust-lang/rust/pull/109754#issuecomment-1490452045

Fixes (doesnt close until beta backported) #109746

This reverts commit e3f9db5fc3.
This reverts commit 98b82aedba.
This reverts commit 380fa26413.
2023-04-12 22:04:35 +02:00
Matthias Krüger
5d6aeb9799
Rollup merge of #110133 - compiler-errors:issue-110131, r=petrochenkov
Do not use ImplDerivedObligationCause for inherent impl method error reporting

We were constructing a `TraitRef` out of impl substs, for an *inherent* impl that has no corresponding trait. Instead of doing that, let's construct a meaningful obligation cause code, and instead adjust the error reporting machinery to handle that correctly.

Fixes #110131
cc #106702, which introduced this regression
2023-04-12 22:04:34 +02:00
Matthias Krüger
92eb36461b
Rollup merge of #110103 - compiler-errors:new-solver-overflows, r=lcnr
Report overflows gracefully with new solver

avoid reporting overflows as ambiguity errors, so that the error message is clearer.

r? ```@lcnr```
2023-04-12 22:04:33 +02:00
Matthias Krüger
d40c827e9a
Rollup merge of #110035 - Ezrashaw:improve-test-attr-expansion-code, r=davidtwco
fix: ensure bad `#[test]` invocs retain correct AST

Fixes #109816

Ensures that a `StmtKind::Item` doesn't get converted into a plain `Item` (causing the ICE from the linked issue) Also unifies the error path a bit.
2023-04-12 22:04:32 +02:00
Matthias Krüger
559b2ea531
Rollup merge of #109810 - jyn514:rustdoc-opt-tests, r=TaKO8Ki
Replace rustdoc-ui/{c,z}-help tests with a stable run-make test

This make rustdoc resilient to changes in the debugging options while still testing that it matches rustc.

Fixes https://github.com/rust-lang/rust/issues/109391.
2023-04-12 22:04:32 +02:00
bors
4087deaccd Auto merge of #110249 - matthiaskrgr:rollup-7iig04q, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #110153 (Fix typos in compiler)
 - #110165 (rustdoc: use CSS `overscroll-behavior` instead of JavaScript)
 - #110175 (Symbol cleanups)
 - #110203 (Remove `..` from return type notation)
 - #110205 (rustdoc: make settings radio and checks thicker, less contrast)
 - #110222 (Improve the error message when forwarding a matched fragment to another macro)
 - #110237 (Split out a separate feature gate for impl trait in associated types)
 - #110241 (tidy: Issue an error when UI test limits are too high)

Failed merges:

 - #110218 (Remove `ToRegionVid`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-12 20:01:36 +00:00
Maybe Waffle
dc19dc29c9 doc fixes 2023-04-12 19:00:27 +00:00
Matthias Krüger
214e4ef4ef
Rollup merge of #110237 - oli-obk:impl_trait_in_assoc_tys, r=jackh726
Split out a separate feature gate for impl trait in associated types

in https://github.com/rust-lang/rust/issues/107645 it was decided that we'll take a new route for type alias impl trait. The exact route isn't clear yet, so while I'm working on implementing some of these proposed changes (e.g. in https://github.com/rust-lang/rust/pull/110010) to be able to experiment with them, I will also work on stabilizing another sugar version first: impl trait in associated types. Similarly I'll look into creating feature gates for impl trait in const/static types.

This PR does nothing but split the feature gate, so that you need to enable a different feature gate for

```rust
impl Trait for Type {
    type Assoc = impl SomeTrait;
}
```

than what you need for `type Foo = impl SomeTrait;`
2023-04-12 20:56:24 +02:00
Matthias Krüger
d54a8ac8e2
Rollup merge of #110222 - lovelymono:rustc-expand-mbe-diagnostic, r=davidtwco
Improve the error message when forwarding a matched fragment to another macro

Adds a link to [Forwarding a matched fragment](https://doc.rust-lang.org/nightly/reference/macros-by-example.html#forwarding-a-matched-fragment) section of the Rust Reference, and suggests a possible fix (using `:tt` instead in the macro definition).

Also removes typos from the original message, it should be `:lifetime` instead of `$lifetime`.

## Motivation

When trying to write a macro which uses a literal in the matcher from the outer macro, like the following one, using a fragment specified that isn't one of `:ident`, `:lifetime`, or `:tt` currently results in a hard to understand message.

```rs
macro_rules! make_t_for_all_tokens {
    ($($name:literal as $variant:expr,)*) => {
        macro_rules! t {
            $(
                ($name) => {
                    $variant
                };
            )*
        }
    };
}

make_t_for_all_tokens! {
    "fn" as Token::Fn,
    "return" as Token::Return,
    "let" as Token::Let,
}

// This creates
//
// macro_rules! t {
//     ("fn") => {
//         Token::Fn
//     };
//     ("return") => {
//         Token::Return
//     };
//     ("let") => {
//         Token::Let
//     };
// }

t!["fn"];
```

### Before

```
error: no rules expected the token `"fn"`
   --> src/main.rs:103:10
    |
32  |         macro_rules! t {
    |         -------------- when calling this macro
...
103 |     t!["fn"];
    |        ^^^^ no rules expected this token in macro call
    |
note: while trying to match `"fn"`
   --> src/main.rs:34:6
    |
34  |                   ($name) => {
    |                    ^^^^^
...
58  | / make_t_for_all_tokens! {
59  | |     "fn" as Token::Fn,
60  | |     "return" as Token::Return,
61  | |     "let" as Token::Let,
62  | | }
    | |_- in this macro invocation
    = note: captured metavariables except for `$tt`, `$ident` and `$lifetime` cannot be compared to other tokens
    = note: this error originates in the macro `make_t_for_all_tokens` (in Nightly builds, run with -Z macro-backtrace for more info)
```

### After

```
error: no rules expected the token `"fn"`
   --> src/main.rs:103:10
    |
32  |         macro_rules! t {
    |         -------------- when calling this macro
...
103 |     t!["fn"];
    |        ^^^^ no rules expected this token in macro call
    |
note: while trying to match `"fn"`
   --> src/main.rs:34:6
    |
34  |                   ($name) => {
    |                    ^^^^^
...
58  | / make_t_for_all_tokens! {
59  | |     "fn" as Token::Fn,
60  | |     "return" as Token::Return,
61  | |     "let" as Token::Let,
62  | | }
    | |_- in this macro invocation
    = note: captured metavariables except for `:tt`, `:ident` and `:lifetime` cannot be compared to other tokens
    = note: see https://doc.rust-lang.org/nightly/reference/macros-by-example.html#forwarding-a-matched-fragment for more information
    = help: try using `:tt` instead in the macro definition
    = note: this error originates in the macro `make_t_for_all_tokens` (in Nightly builds, run with -Z macro-backtrace for more info)
```

## Unresolved questions

- Preferrably the suggestion should be attached to the `$name:literal` part of the outer macro, instead of being in the notes section at the end. But I'm not familiar with how the compiler works at all, and I have no idea how to approach this kind of solution.
- `@Nilstrieb` raised a question that the suggestion of adding `:tt` isn't accurate when there's more than `tt` being matched, for example when the input is an `item`.
2023-04-12 20:56:24 +02:00
Matthias Krüger
a34bcd70b2
Rollup merge of #110203 - compiler-errors:rtn-dots, r=eholk
Remove `..` from return type notation

`@nikomatsakis` and I decided that using `..` in the return-type notation syntax is probably overkill.

r? `@eholk` since you reviewed the last one

Since this is piggybacking now totally off of a pre-existing syntax (parenthesized generics), let me know if you need any explanation of the logic here, since it's a bit more complicated now.
2023-04-12 20:56:22 +02:00
Matthias Krüger
b4734f01fe
Rollup merge of #110175 - nnethercote:symbol-cleanups, r=jackh726
Symbol cleanups

r? ```@jackh726```

cc ```@b-naber```
2023-04-12 20:56:22 +02:00
Matthias Krüger
331e7c3659
Rollup merge of #110153 - DaniPopes:compiler-typos, r=Nilstrieb
Fix typos in compiler

I ran [`typos -w compiler`](https://github.com/crate-ci/typos) to fix typos in the `compiler` directory.

Refs #110150
2023-04-12 20:56:21 +02:00
Maybe Waffle
838c5491a4 Document tagged pointers better 2023-04-12 16:22:20 +00:00
Maybe Waffle
6f9b15c40c Add tests for tagged pointers 2023-04-12 16:20:34 +00:00
Oli Scherer
f263f88bea Split out a separate feature gate for impl trait in associated types 2023-04-12 16:17:31 +00:00
Matthias Krüger
7614ea42fc
Rollup merge of #110210 - nnethercote:DescriptionCtx-cleanups, r=davidtwco
`DescriptionCtx` cleanups

Best reviewed one commit at a time.

r? `@davidtwco`
2023-04-12 17:04:33 +02:00
Matthias Krüger
bb037e6fa7
Rollup merge of #110190 - cbeuw:mir-offset, r=oli-obk
Custom MIR: Support `BinOp::Offset`

Since offset doesn't have an infix operator, a new function `Offset` is added which is lowered to `Rvalue::BinaryOp(BinOp::Offset, ..)`

r? ```@oli-obk``` or ```@tmiasko``` or ```@JakobDegen```
2023-04-12 17:04:32 +02:00
Matthias Krüger
f21d8402ac
Rollup merge of #110182 - WaffleLapkin:neither, r=Nilstrieb
Use `itertools::Either` instead of own impl

Yeah.
2023-04-12 17:04:31 +02:00
Matthias Krüger
827b74c709
Rollup merge of #110176 - nnethercote:renumber-cleanups, r=lqd
Renumbering cleanups

r? ``@lqd``
2023-04-12 17:04:31 +02:00
Matthias Krüger
fd40f519c5
Rollup merge of #109959 - JakobDegen:transmute-validate, r=compiler-errors
Fix transmute intrinsic mir validation ICE

I stumbled across this at work, the minimal reproducer is included as a test which ICEs before this change.

I'm not 100% sure this is the right fix, but it matches what we do in `mir_assign_valid_types` so seems reasonable at least.

fixes #110151

r? `@lcnr` since they've been keeping the relevant logic correct, cc `@scottmcm`
2023-04-12 17:04:30 +02:00
Lena Milizé
04f20d4ac8 compiler: print the suggestion only for local macros
And wrap the link in the diagnostic in angle brackets.

Signed-off-by: Lena Milizé <me@lvmn.org>
2023-04-12 15:43:50 +02:00
Gary Guo
229b0a0fdc Make rust-intrinsic ABI unwindable
Stick `#[rustc_nounwind]` to all except `const_eval_select` to undo the
change for all other intrinsics.
2023-04-12 14:05:05 +01:00
Maybe Waffle
5e4577ec65 Add TaggedPtr::set_tag 2023-04-12 12:35:43 +00:00
Vadim Petrochenkov
7c40a6fb34 resolve: Pre-compute non-reexport module children
Instead of repeating the same logic by walking HIR during metadata encoding.

The only difference is that we are no longer encoding `macro_rules` items, but we never currently need them as a part of this list.
They can be encoded separately if this need ever arises.

`module_reexports` is also un-querified, because I don't see any reasons to make it a query, only overhead.
2023-04-12 15:22:03 +03:00
Maybe Waffle
6f64ae3fbc Move code around 2023-04-12 11:50:45 +00:00
Maybe Waffle
3df9a7bde3 Shorten COMPARE_PACKED => CP where it is not important
why can't I _ it :'(
2023-04-12 11:44:52 +00:00
Maybe Waffle
8f408202c3 Remove pointer_{ref,mut} from tagged pointers
Just use `deref{,_mut}`!
2023-04-12 11:41:41 +00:00
Maybe Waffle
c7c0b85f67 Make tagged pointers debug impls print the pointer
Does not really matter, but may be nicer in case
the pointer has some specific debug impl.
2023-04-12 11:30:45 +00:00
Maybe Waffle
c6acd5c92f Remove Pointer::with_ref in favour implementing it on tagged pointers directly 2023-04-12 11:26:34 +00:00
bors
661b33f524 Auto merge of #109935 - michaelwoerister:fix-feed-in-eval-always, r=cjgillot
incr.comp.: Make sure dependencies are recorded when feeding queries during eval-always queries.

This PR makes sure we don't drop dependency edges when feeding queries during an eval-always query.

Background: During eval-always queries, no dependencies are recorded because the system knows to unconditionally re-evaluate them regardless of any actual dependencies. This works fine for these queries themselves but leads to a problem when feeding other queries: When queries are fed, we set up their dependency edges by copying the current set of dependencies of the feeding query. But because this set is empty for eval-always queries, we record no edges at all -- which has the effect that the fed query instances always look "green" to the system, although they should always be "red".

The fix is to explicitly add a dependency on the artificial "always red" dep-node when feeding during eval-always queries.

Fixes https://github.com/rust-lang/rust/issues/108481
Maybe also fixes issue https://github.com/rust-lang/rust/issues/88488.

cc `@jyn514`

r? `@cjgillot` or `@oli-obk`
2023-04-12 11:16:35 +00:00
Maybe Waffle
9051331dd7 Lift Pointer's requirement for the pointer to be thin
fat pointers rule!
2023-04-12 11:00:35 +00:00
Maybe Waffle
26232f1ff5 Remove useless parameter from ghost 2023-04-12 10:34:29 +00:00
Jynn Nelson
bad2af1d38 Make rustdoc and rustc's help match exactly
Before, rustdoc was missing `-C passes=list` and the "Available options"
header.

Making these match allows testing that they match exactly.
2023-04-12 05:27:26 -05:00
Lena Milizé
4b456cb683 compiler: improve captured metavariables diagnostic
Adds a link to the relevant part of The Rust Reference in the eror
message, and suggests a possible fix (replacing the fragment specifier
with :tt in the macro definition).

Fixes typos in the original message.

Signed-off-by: Lena Milizé <me@lvmn.org>
2023-04-12 11:32:25 +02:00
lcnr
cc82ccb145 #[must_use] for fns returning a list of errors 2023-04-12 10:55:14 +02:00
bors
9be9b5e09a Auto merge of #107614 - compiler-errors:allow-elaborator-to-filter-only-super-traits, r=oli-obk
Split implied and super predicate queries, then allow elaborator to filter only supertraits

Split the `super_predicates_of` query into a new `implied_predicates_of` query. The former now only returns the *real* supertraits of a trait alias, and the latter now returns the implied predicates (which include all of the `where` clauses of the trait alias). The behavior of these queries is identical for regular traits.

Now that the two queries are split, we can add a new filter method to the elaborator, `filter_only_self()`, which can be used in instances that we need only the *supertrait* predicates, such as during the elaboration used in closure signature deduction. This toggles the usage of `super_predicates_of` instead of `implied_predicates_of` during elaboration of a trait predicate.

This supersedes #104745, and fixes the four independent bugs identified in that PR.
Fixes #104719
Fixes #106238
Fixes #110023
Fixes #109514

r? types
2023-04-12 08:39:19 +00:00
lcnr
a19adefa0e region error cleanup
- require `TypeErrCtxt` to always result in an error
- move `resolve_regions_and_report_errors` to the `ObligationCtxt`
- merge `process_registered_region_obligations` into `resolve_regions`
2023-04-12 10:24:36 +02:00
Michael Goulet
87c9b3f35e
Rollup merge of #110126 - compiler-errors:new-solver-safe-transmute, r=oli-obk
Support safe transmute in new solver

Basically copies the same implementation as the old solver, but instead of looking for param types, we look for type or const placeholders.
2023-04-11 20:28:48 -07:00
Michael Goulet
4a24aab220
Rollup merge of #96971 - zhaixiaojuan:master, r=wesleywiser
Initial support for loongarch64-unknown-linux-gnu

Hi, We hope to add a new port in rust for LoongArch.

LoongArch intro
LoongArch is a RISC style ISA which is independently designed by Loongson
Technology in China. It is divided into two versions, the 32-bit version (LA32)
and the 64-bit version (LA64). LA64 applications have application-level
backward binary compatibility with LA32 applications. LoongArch is composed of
a basic part (Loongson Base) and an expanded part. The expansion part includes
Loongson Binary Translation (LBT), Loongson VirtualiZation (LVZ), Loongson SIMD
EXtension (LSX) and Loongson Advanced SIMD EXtension(LASX).

Currently the LA464 processor core supports LoongArch ISA and the Loongson
3A5000 processor integrates 4 64-bit LA464 cores. LA464 is a four-issue 64-bit
high-performance processor core. It can be used as a single core for high-end
embedded and desktop applications, or as a basic processor core to form an
on-chip multi-core system for server and high-performance machine applications.

Documentations:
ISA:
https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html
ABI:
https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html
More docs can be found at:
https://loongson.github.io/LoongArch-Documentation/README-EN.html

Since last year, we have locally adapted two versions of rust, rust1.41 and rust1.57, and completed the test locally.
I'm not sure if I'm submitting all the patches at once, so I split up the patches and here's one of the commits
2023-04-11 20:28:45 -07:00
Nicholas Nethercote
76d0c6f518 Inline and remove msg_span_from_early_bound_and_free_regions.
For similar reasons to the previous commit.
2023-04-12 08:02:38 +10:00
Nicholas Nethercote
877777f5bc Inline and remove DescriptionCtx::from_early_bound_and_free_regions.
It has a single call site, and the code is clearer with all region kinds
handled in one function, instead of splitting the handling across two
functions.

The commit also changes `DescriptionCtx::new` to use a more declarative
style, instead of creating a default `DescriptionCtx` and modifying it,
which I find easier to read.
2023-04-12 08:02:38 +10:00
Nicholas Nethercote
c9b0635679 Inline and remove DescriptionCtx::add_to.
It has a single callsite.
2023-04-12 08:02:32 +10:00
Maybe Waffle
ad92677008 Fix doc test 2023-04-11 21:45:19 +00:00
Nicholas Nethercote
74463214a6 Rename NllVisitor as RegionRenumberer.
It's a more descriptive name.
2023-04-12 07:44:37 +10:00
Maybe Waffle
12fd610e01 Refactor tagged ptr packing into a function 2023-04-11 21:40:39 +00:00
Maybe Waffle
3c6f4c1260 Bless tagged pointers (comply to strict provenance) 2023-04-11 21:31:23 +00:00
Maybe Waffle
f028636b1a Sprinkle some whitespace & uses 2023-04-11 19:33:33 +00:00
Maybe Waffle
c738dcc284 Add bits_for helper for tagged pointers & fixup docs 2023-04-11 19:18:59 +00:00
Michael Goulet
7ec72efe10 Allow the elaborator to only filter to real supertraits 2023-04-11 17:45:42 +00:00
Michael Goulet
25c342f30a Split implied and super predicate queries 2023-04-11 17:45:42 +00:00
Michael Goulet
3dab259cb9 Split super_predicates_that_define_assoc_type query from super_predicates_of 2023-04-11 17:40:54 +00:00
Michael Goulet
5eb0528483 Erase lifetimes above ty::INNERMOST when probing ambiguous types 2023-04-11 17:17:32 +00:00
Michael Goulet
1178c49a1b Check for body owner fallibly 2023-04-11 16:52:40 +00:00
bors
45749b21b7 Auto merge of #110092 - clubby789:builtin-macros-translatable, r=compiler-errors
Migrate most of `rustc_builtin_macros` to diagnostic impls

cc #100717

This is a couple of days work, but I decided to stop for now before the PR becomes too big. There's around 50 unresolved failures when `rustc::untranslatable_diagnostic` is denied, which I'll finish addressing once this PR goes thtough

A couple of outputs have changed, but in all instances I think the changes are an improvement/are more consistent with other diagnostics (although I'm happy to revert any which seem worse)
2023-04-11 14:40:54 +00:00
Andy Wang
cecb901e68
Add Offset binary op to custom mir 2023-04-11 16:23:35 +02:00
Maybe Waffle
a32959263c Use SSO_ARRAY_SIZE instead of 8 in SsoHashMap impl 2023-04-11 11:02:01 +00:00
Maybe Waffle
0465201f77 Use itertools::Either instead of own EitherIter impl 2023-04-11 11:02:01 +00:00
bors
dfe024e104 Auto merge of #109765 - petrochenkov:encodeless, r=cjgillot
rustc_metadata: Filter encoded data more aggressively using `DefKind`

I focused on data that contains spans, because spans are expensive to encode/decode/hash, but also touched `should_encode_visibility` too.

One incorrect use of impl visibility in diagnostics is also replaced with trait visibility.
2023-04-11 10:32:41 +00:00
Ezra Shaw
9e70541eac
refactor: extract not_testable_error into function 2023-04-11 21:07:02 +12:00
lcnr
171f541470 don't uniquify regions when canonicalizing 2023-04-11 10:25:49 +02:00
Nicholas Nethercote
955ba37aa5 Remove the unused anon_num_here error. 2023-04-11 17:25:47 +10:00
bors
5072826793 Auto merge of #110170 - JohnTitor:rollup-hdramer, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #109527 (Set up standard library path substitution in rust-gdb and gdbgui)
 - #109752 (Stall auto trait assembly in new solver for int/float vars)
 - #109860 (Add support for RISC-V relax target feature)
 - #109923 (Update `error [E0449]: unnecessary visibility qualifier` to be more clear)
 - #110070 (The `wrapping_neg` example for unsigned types shouldn't use `i8`)
 - #110146 (fix(doc): do not parse inline when output is json for external crate)
 - #110147 (Add regression test for #104916)
 - #110149 (Update books)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-11 05:50:41 +00:00
Nicholas Nethercote
7975779918 Add sym::anon. 2023-04-11 14:56:42 +10:00
Nicholas Nethercote
bd7f301b20 Use the existing static and env symbols instead of interning. 2023-04-11 14:56:11 +10:00
Nicholas Nethercote
1eb53902f3 Fix RegionCtxt::preference_value.
There's a bad pattern matching confusion present in this function.
`_anon` gets assigned to, and then `_anon` is used as an unbound
variable in the pattern, which is unrelated to the first `_anon`.
If the `_anon` didn't start with `_` the compiler would give warnings.

This was introduced in #104239.

I have rewritten the function to remove the confusion and preserve the
existing behaviour. This seems safest, because the original intent is
not clear.
2023-04-11 14:55:33 +10:00
Nicholas Nethercote
5716ae6982 Introduce Region::get_name_or_anon.
For a common pattern.
2023-04-11 14:18:53 +10:00
Nicholas Nethercote
7e8905cd18 Rename a variable. 2023-04-11 13:25:57 +10:00
Nicholas Nethercote
33527755a3 Inline and remove renumber_regions.
It has a single callsite.
2023-04-11 13:25:32 +10:00
Yuki Okushi
788de4701e
Rollup merge of #109923 - ElectrifyPro:visibility, r=wesleywiser
Update `error [E0449]: unnecessary visibility qualifier` to be more clear

This updates the error message `error[E0449]: unnecessary visibility qualifier` by clearly indicating that visibility qualifiers already inherit their visibility from a parent item. The error message previously implied that the qualifiers were permitted, which is not the case anymore.

Resolves #109822.
2023-04-11 12:18:50 +09:00
Yuki Okushi
5af6385f9f
Rollup merge of #109860 - zyedidia:riscv-relax, r=petrochenkov
Add support for RISC-V relax target feature

This adds `relax` as an allowed RISC-V target feature. The relax feature in LLVM enables [linker relaxation](https://www.sifive.com/blog/all-aboard-part-3-linker-relaxation-in-riscv-toolchain), an optimization specific to RISC-V that allows global variable accesses to be resolved by the linker by using the global pointer (`gp`) register (rather than constructing the addresses from scratch for each access). Enabling `relax` will cause LLVM to emit relocations in the object file that support this. The feature can be enabled in rustc with `-C target-feature=+relax`.

Currently this feature is disabled by default, but maybe it should be enabled by default since it is an easy performance improvement (but requires the `gp` register to be set up properly). GCC/Clang enable this feature by default (for both hosted/bare-metal targets), and include the `-mno-relax` flag to disable it (see [here](466d554dca/clang/lib/Driver/ToolChains/Arch/RISCV.cpp (L145)) for the code that enables it in Clang). I think it would make sense to enable by default, at least for all hosted targets since the `gp` register should be automatically set up by the runtime. For bare-metal targets, `gp` must be set up manually, so it is probably best to leave off by default to avoid breaking existing applications that do not set up `gp`. Leaving it disabled by default for all targets is also reasonable though.

Let me know your thoughts. Thanks!

Fixes #109426.
2023-04-11 12:18:50 +09:00
Yuki Okushi
a69cc45d82
Rollup merge of #109752 - compiler-errors:new-solver-stall-auto-trait-for-num-var, r=lcnr
Stall auto trait assembly in new solver for int/float vars

Make sure that we don't match int/float vars against *all* manual auto trait impls due to this check:

2fb0e8d162/compiler/rustc_trait_selection/src/solve/trait_goals.rs (L151-L169)

Since `find_map_relevant_impl` treats all impls as candidates for int/float vars, due to the way that `fast_reject::simplify_type` works.

This fixes compiler-errors/next-solver-hir-issues#11.

r? ``@lcnr``
2023-04-11 12:18:49 +09:00
bors
b80ee3969f Auto merge of #109850 - MU001999:master, r=estebank
Emits non-overlapping suggestions for arguments with wrong types

Fixes #109831
2023-04-11 03:07:58 +00:00
David Lattimore
a6292676eb Preserve argument indexes when inlining MIR
We store argument indexes on VarDebugInfo. Unlike the previous method of
relying on the variable index to know whether a variable is an argument,
this survives MIR inlining.

We also no longer check if var.source_info.scope is the outermost scope.
When a function gets inlined, the arguments to the inner function will
no longer be in the outermost scope. What we care about though is
whether they were in the outermost scope prior to inlining, which we
know by whether we assigned an argument index.
2023-04-11 11:07:48 +10:00
bors
5ca6e98f13 Auto merge of #109778 - petrochenkov:allkind, r=cjgillot
rustc_middle: Document which exactly `DefId`s don't have `DefKind`s

I don't currently have time to investigate when and how to create these missing HIR nodes, but if someone else could do that it would be great.
2023-04-11 00:39:27 +00:00
Michael Goulet
24cbf81b85 Remove .. from return type notation 2023-04-10 22:19:46 +00:00
bors
194a0bb5d6 Auto merge of #109638 - NotStirred:suggest/non-derive, r=davidtwco
Add suggestion to remove `derive()` if invoked macro is non-derive

Adds to the existing `expected derive macro, found {}` error message:
```
help: remove the surrounding "derive()":
  --> $DIR/macro-path-prelude-fail-4.rs:1:3
   |
LL | #[derive(inline)]
   |   ^^^^^^^      ^
```

This suggestion will either fix the issue, in the case that the macro was valid, or provide a better error message if not

Not ready for merge yet, as the highlighted span is only valid for trivial formatting. Is there a nice way to get the parent span of the macro path within `smart_resolve_macro_path`?

Closes #109589
2023-04-10 21:50:46 +00:00
clubby789
64f7597776 Migrate most of rustc_builtin_macros to diagnostic impls
Co-authored-by: Joe ST <joe@fbstj.net>
Co-authored-by: Michael Goulet <michael@errs.io>
2023-04-10 21:16:53 +01:00
DaniPopes
f06640de08
Update ty_utils_never_to_any_not_supported diagnostic message 2023-04-10 22:03:08 +02:00
DaniPopes
677357d32b
Fix typos in compiler 2023-04-10 22:02:52 +02:00
bors
88fb1b922b Auto merge of #108698 - IntQuant:issue-100717-infer-6, r=davidtwco
Migrating rustc_infer to session diagnostics (part 5)

`@rustbot` label +A-translation
cc https://github.com/rust-lang/rust/issues/100717
2023-04-10 19:38:48 +00:00
Michael Goulet
05a6daab84 Report overflows gracefully with new solver 2023-04-10 16:36:30 +00:00
Michael Goulet
d92f74e43b Support safe transmute in new solver 2023-04-10 16:08:14 +00:00
Michael Goulet
8d2dbba63e Stall auto-trait assembly for int/float vars in new solver 2023-04-10 15:54:14 +00:00
IQuant
d07b1cd4a8 Call into_diagnostic_arg on Binder's contained value directly. 2023-04-10 18:08:35 +03:00
Vadim Petrochenkov
f5a9f6fb7e rustc_metadata: Filter encoded data more aggressively using DefKind 2023-04-10 16:24:36 +03:00
Vadim Petrochenkov
9dd27b31ba rustc_metadata: Cleanup fn encode_info_for_item 2023-04-10 15:47:15 +03:00
Dylan DPC
97921abc06
Rollup merge of #110124 - Nilstrieb:📎-told-me-so, r=compiler-errors
Some clippy fixes in the compiler

Best reviewed commit-by-commit 📎.
2023-04-10 14:13:16 +05:30
Dylan DPC
b8725520af
Rollup merge of #110021 - scottmcm:fix-110005, r=compiler-errors
Fix a couple ICEs in the new `CastKind::Transmute` code

Check the sizes of the immediates, rather than the overall types, when deciding whether we can convert types without going through memory.

Fixes #110005
Fixes #109992
Fixes #110032
cc `@matthiaskrgr`
2023-04-10 14:13:14 +05:30
Josh Triplett
afd45c2e10 Stabilize IsTerminal
closes: https://github.com/rust-lang/rust/issues/98070
2023-04-10 17:24:23 +09:00
lcnr
3fab7f7c13 review + some small stuff 2023-04-10 09:21:21 +02:00
lcnr
2186847f28 move structural_traits into assembly 2023-04-10 09:18:47 +02:00
lcnr
2b0f5721c1 prioritize param-env candidates 2023-04-10 09:16:33 +02:00
Michael Goulet
a047064d6b Revert "Don't recover lifetimes/labels containing emojis as character literals"
Reverts PR #108031
Fixes (doesnt close until beta backported) #109746

This reverts commit e3f9db5fc3.
This reverts commit 98b82aedba.
This reverts commit 380fa26413.
2023-04-10 06:52:41 +00:00
Michael Goulet
b369c8ecbd Do not use ImplDerivedObligationCause for inherent impl method error reporting 2023-04-10 06:06:08 +00:00
bors
3c2e2dd5c5 Auto merge of #110127 - matthiaskrgr:rollup-6ui12x5, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #108843 (Instantiate instead of erasing binder when probing param methods)
 - #109985 (Add little `is_test_crate` function)
 - #110028 (Migrate `rustc_hir_analysis` to session diagnostic [Part 3])
 - #110095 (Migrate remainder of rustc_ty_utils to `SessionDiagnostic`)
 - #110108 (Add renaming of ignore-git to changelog)
 - #110114 (compiletest: Give a better error message if `node` isn't installed)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-10 01:57:51 +00:00
Jakob Degen
d8ed2fb0bb Fix transmute intrinsic mir validation ICE 2023-04-09 18:16:05 -07:00
Matthias Krüger
f4827459f8
Rollup merge of #110095 - matthewjasper:ty-utils-diagnostics, r=compiler-errors
Migrate remainder of rustc_ty_utils to `SessionDiagnostic`

This moves the remaining errors in `rust_ty_utils` to `SessionsDiagnostic`.

r? ``@davidtwco``
2023-04-09 23:40:05 +02:00
Matthias Krüger
164d70dc7a
Rollup merge of #110028 - obeis:hir-analysis-migrate-diagnostics-3, r=compiler-errors
Migrate `rustc_hir_analysis` to session diagnostic [Part 3]

Part 3: Finishing `collect.rs` file

r? ``@compiler-errors``
2023-04-09 23:40:04 +02:00
Matthias Krüger
3dfda2c72f
Rollup merge of #109985 - blyxyas:is_test_crate, r=compiler-errors
Add little `is_test_crate` function

Ok, this is quite a story.
I'm mainly a Clippy contributor, so I was fixing [this Clippy issue](https://github.com/rust-lang/rust-clippy/pull/10584) about a lint having to ignore test modules but that wasn't ignoring test files (integration test, `test/` dirs and such).

As test **files** don't tend to have an inner `#[cfg(test)]` module inside them, I tried everything, looking for filenames, looking for item's parents in the HIR Map, doing black magic...

I even asked [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/.E2.9C.94.20Checking.20if.20file.20is.20integration.20test), and jyn answered something about `--cfg test`. Aha! That's something that I might be looking for, so I started looking at `rustc_driver_impl` flag parsing and configuration and all that.

Then, I stumbled on [this function right here](2e486be8d2/compiler/rustc_driver_impl/src/lib.rs (L174-L181)), and noticed the argument `config: Config`. That's a hint.

So [Config](https://doc.rust-lang.org/beta/nightly-rustc/rustc_interface/interface/struct.Config.html) has the field `opts: Options`, and [`Options`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_session/options/struct.Options.html) has the field `test`.

This journey has been ~7 or 8 hours in 3 days, it's a very hard thing to find, so this PR adds a mini-function to check if the current crate is a testing one. So that no one has to travel through the same as me, and can just search for `is_test_crate` in the documentation.
2023-04-09 23:40:04 +02:00
Matthias Krüger
4e165c1c99
Rollup merge of #108843 - compiler-errors:non_lifetime_binders-method-probe, r=jackh726
Instantiate instead of erasing binder when probing param methods

Fixes #108836

There is a really old comment saying that a `WhereClauseCandidate` probe candidate "should not contain any inference variables", but I'm not really confident that that comment applies anymore. In contrast, other candidates that we assemble during method probe contain inference variables in their substitutions (e.g. `InherentImplCandidate`)...

Since this change is made only to support a nightly feature, I'm happy to gate the new behavior behind this feature flag or discuss it further.

r? types
2023-04-09 23:40:03 +02:00
Nilstrieb
9fc1555f74 Remove turbofish 2023-04-09 23:32:04 +02:00
Nilstrieb
73417b1e15
Inline format_args
Co-authored-by: Michael Goulet <michael@errs.io>
2023-04-09 23:29:39 +02:00
Nilstrieb
cab94d29ff fixup! Improve `Allocation::hash 2023-04-09 23:23:33 +02:00
Nilstrieb
5853c28a7f Simply Abi::fmt 2023-04-09 23:22:14 +02:00
Nilstrieb
e5defd0102 Convert manual loop into while let 2023-04-09 23:22:14 +02:00
Nilstrieb
4b4948c2e3 Remove identity casts 2023-04-09 23:22:14 +02:00
Nilstrieb
81c320ea77 Fix some clippy::complexity 2023-04-09 23:22:14 +02:00
Nilstrieb
6fceb0f645 Improve `Allocation::hash
Exhaustively destructure and ignore `()`
2023-04-09 23:22:14 +02:00
Nilstrieb
5a90de8f5e Delete useless loop 2023-04-09 23:22:14 +02:00
Nilstrieb
1c75724752 Properly compare previously shadowed values
The shadowing lead to an incorrect comparison. Rename it and compare it
properly. compiler-errors told me that I should just include the fix
here without a test.
2023-04-09 23:22:14 +02:00
bors
696aaad58c Auto merge of #109760 - MaciejWas:struct-tuple-field-names-suggestion, r=jackh726
Better diagnostic when pattern matching tuple structs

Fixes #108284

When trying to pattern match a tuple struct we might get a flawed error message if there are missing fields. E.g.

```
let x = Foo(100, 200);
if let Foo { 0: bar } = x { ... }
```

Produces this error:

```
error[E0769]: tuple variant `Foo` written as struct variant
 --> hello.rs:5:12
  |
5 |     if let Foo { 0: foo } = x {
  |            ^^^^^^^^^^^^^^
  |
help: use the tuple variant pattern syntax instead
  |
5 |     if let Foo(_, _) = x {
  |               ~~~~~~
```

Which doesn't highlight that we can still use the struct syntax but we need to fill missing fields. This pr changes this error to:

```
error[E0027]: pattern does not mention field `1`
 --> hello.rs:5:12
  |
5 |     if let Foo { 0: foo } = x {
  |            ^^^^^^^^^^^^^^ missing field `1`
  |
help: include the missing field in the pattern
  |
5 |     if let Foo { 0: foo, 1: _ } = x {
  |                        ~~~~~~~~
help: if you don't care about this missing field, you can explicitly ignore it
  |
5 |     if let Foo { 0: foo, .. } = x {
  |                        ~~~~~~
```
2023-04-09 20:57:06 +00:00
Nilstrieb
07cd3826e0 Small clippy::correctness fixes
Nothing was really incorrect before, but it did get nicer.
2023-04-09 22:39:23 +02:00
Nilstrieb
0a0968b207 Allow modulo_one on function using cfg consts 2023-04-09 22:30:24 +02:00
Nilstrieb
968be98756 Allow clippy::from_mut_ref
This pattern is fine for arena allocators.
2023-04-09 22:29:56 +02:00
Nilstrieb
f00366d191 Box large enum variants 2023-04-09 21:59:28 +02:00
Nilstrieb
54e1309c65 Use HashMap entry APIs more 2023-04-09 21:59:28 +02:00
Nilstrieb
f058d05fc2 Some simple clippy::perf fixes 2023-04-09 21:59:28 +02:00
blyxyas
2c976765b8
Migrate sess.opts.tests uses to sess.is_test_crate() 2023-04-09 21:37:31 +02:00
Scott McMurray
d757c4b904 Handle not all immediates having abi::Scalars 2023-04-09 11:16:50 -07:00
bors
7201301df6 Auto merge of #109500 - petrochenkov:modchainld, r=oli-obk
resolve: Preserve reexport chains in `ModChild`ren

This may be potentially useful for
- avoiding uses of `hir::ItemKind::Use` (which usually lead to correctness issues)
- preserving documentation comments on all reexports, including those from other crates
- preserving and checking stability/deprecation info on reexports
- all kinds of diagnostics

The second commit then migrates some hacky logic from rustdoc to `module_reexports` to make it simpler and more correct.
Ideally rustdoc should use `module_reexports` immediately at the top level, so `hir::ItemKind::Use`s are never used.
The second commit also fixes issues with https://github.com/rust-lang/rust/pull/109330 and therefore
Fixes https://github.com/rust-lang/rust/issues/109631
Fixes https://github.com/rust-lang/rust/issues/109614
Fixes https://github.com/rust-lang/rust/issues/109424
2023-04-09 13:05:56 +00:00
blyxyas
28e19f19aa
Add little is_test_crate function 2023-04-09 13:04:59 +02:00
bors
56e0626836 Auto merge of #110041 - fmease:diag-sugg-adding-const-param, r=compiler-errors
Suggest defining const parameter when appropriate

Helps a bit with #91119.
Following #105523's lead, I use placeholder `/* Type */` instead of `_` in the suggestion.
It should be easier for newcomers to parse.

`@rustbot` label A-diagnostics
r? diagnostics
2023-04-09 10:54:04 +00:00
bors
709a97fffe Auto merge of #109173 - flba-eb:add-i586-qnx70-target, r=compiler-errors
Add tier 3 no_std x86 support for QNX Neutrino RTOS, version 7.0

This PR adds the target `i586-pc-nto-qnx700`, which targets QNX Neutrino RTOS version 7.0 on x86 32-bit targets.

cc: `@flba-eb` `@gh-tr`

This target falls under the umbrella of Tier 3 QNX Neutrino RTOS support documented in `nto-qnx.md` and previously started with #102701.
2023-04-09 07:36:53 +00:00
bors
7cd6f55323 Auto merge of #110101 - JohnTitor:rollup-ol20aw7, r=JohnTitor
Rollup of 6 pull requests

Successful merges:

 - #110058 (Remove `box_syntax` usage)
 - #110059 (ignore_git → omit_git_hash)
 - #110060 (Document that `&T` and `&mut T` are `Sync` if `T` is)
 - #110074 (Make the "codegen" profile of `config.toml` download and build llvm from source.)
 - #110086 (Add `max_line_length` to `.editorconfig`, matching rustfmt)
 - #110096 (Tweak tuple indexing suggestion)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-09 05:00:24 +00:00
Yuki Okushi
eed27ac7f4
Rollup merge of #110096 - compiler-errors:tweak-tuple-idx-msg, r=Nilstrieb
Tweak tuple indexing suggestion

Fixes #110091
2023-04-09 12:35:56 +09:00
bors
0030465bcc Auto merge of #109413 - compiler-errors:pointer-like-abi, r=cjgillot
Enforce that `PointerLike` requires a pointer-like ABI

At least temporarily, let's ban coercing things that are pointer-sized and pointer-aligned but *not* `Abi::Scalar(..)` into `dyn*`. See: https://github.com/rust-lang/rust/pull/104694#discussion_r1142522073

This can be lifted in the future if we decie that we *want* to be able to coerce something `repr(C)` into a `dyn*`, but we'll have to figure out what to do with Miri and codegen...

r? compiler
2023-04-09 02:41:58 +00:00
bors
f8ed97ecc1 Auto merge of #110031 - compiler-errors:generic-elaboration, r=b-naber
Make elaboration generic over input

Combines all the `elaborate_*` family of functions into just one, which is an iterator over the same type that you pass in (e.g. elaborating `Predicate` gives `Predicate`s, elaborating `Obligation`s gives `Obligation`s, etc.)
2023-04-09 00:18:10 +00:00
Michael Goulet
fbc3457d35 Tweak tuple indexing suggestion 2023-04-08 21:32:55 +00:00