Commit Graph

27038 Commits

Author SHA1 Message Date
Michael Goulet
a63bb24593 Inline one usage of check_expr_eq_type 2023-08-03 04:23:22 +00:00
Michael Goulet
f3589a723d Inline check_expr_meets_expectation_or_error 2023-08-03 04:23:22 +00:00
Michael Goulet
6868b93cf5 No need for Expectation::IsLast 2023-08-03 04:23:22 +00:00
Taras Tsugrii
6ae2677d72 [rustc_span][perf] Hoist lookup sorted by words out of the loop.
@lqd commented on https://github.com/rust-lang/rust/pull/114351 asking
if `sort_by_words(lookup)` is computed repeatedly. I was assuming that
rustc should have no difficulties to hoist it automatically outside of
the loop to avoid repeated pure computation, but according to
 https://godbolt.org/z/frs8Kj1rq it seems like I was wrong:
original version seems to have 2 calls per loop iteration
```
.LBB16_3:
        mov     rbx, qword ptr [r13]
        mov     r14, qword ptr [r13 + 8]
        lea     rdi, [rsp + 40]
        mov     rsi, rbx
        mov     rdx, r14
        call    example::sort_by_words
        lea     rdi, [rsp + 64]
        mov     rsi, qword ptr [rsp + 8]
        mov     rdx, qword ptr [rsp + 16]
        call    example::sort_by_words
        mov     rdi, qword ptr [rsp + 40]
        mov     rdx, qword ptr [rsp + 56]
        mov     rsi, qword ptr [rsp + 64]
        cmp     rdx, qword ptr [rsp + 80]
        mov     qword ptr [rsp + 32], rdi
        mov     qword ptr [rsp + 24], rsi
        jne     .LBB16_5
        call    qword ptr [rip + bcmp@GOTPCREL]
        test    eax, eax
        sete    al
        mov     dword ptr [rsp + 4], eax
        mov     rsi, qword ptr [rsp + 72]
        test    rsi, rsi
        jne     .LBB16_8
        jmp     .LBB16_9
```
but the manually hoisted version just 1:
```
.LBB16_3:
        mov     r13, qword ptr [r15]
        mov     r14, qword ptr [r15 + 8]
        lea     rdi, [rsp + 64]
        mov     rsi, r13
        mov     rdx, r14
        call    example::sort_by_words
        mov     rdi, qword ptr [rsp + 64]
        mov     rdx, qword ptr [rsp + 16]
        cmp     qword ptr [rsp + 80], rdx
        mov     qword ptr [rsp + 32], rdi
        jne     .LBB16_5
        mov     rsi, qword ptr [rsp + 8]
        call    qword ptr [rip + bcmp@GOTPCREL]
        test    eax, eax
        sete    bpl
        mov     rsi, qword ptr [rsp + 72]
        test    rsi, rsi
        jne     .LBB16_8
        jmp     .LBB16_9
```
This code is probably not very hot, but there is no reason to leave
such a low hanging fruit.
2023-08-02 20:51:16 -07:00
bors
aa70e5fb6e Auto merge of #113292 - MU001999:fix/issue-113222, r=Nilstrieb
Suggest `x build library` for a custom toolchain that fails to load `core`

Fixes #113222

The nicer suggestion for dev-channel won't be emitted if `-Z ui-testing` enabled. IMO, this is acceptable for now.
2023-08-03 00:53:01 +00:00
Catherine Flores
bbd69e4a4c Add test for enum with fields 2023-08-02 23:59:30 +00:00
León Orell Valerian Liehr
263a0dec60
Compute variances for lazy type aliases 2023-08-03 01:38:23 +02:00
León Orell Valerian Liehr
2b8a3b44bf
Make lint missing-copy-implementations honor negative Copy impls 2023-08-03 01:37:42 +02:00
bors
736ef39a84 Auto merge of #107254 - chenyukang:yukang/fix-107113-wrong-sugg-in-macro, r=estebank
Avoid wrong code suggesting for attribute macro

Fixes #107113
r? `@estebank`
2023-08-02 23:04:27 +00:00
Nicholas Nethercote
d75ee2a6bc Remove MacDelimiter.
It's the same as `Delimiter`, minus the `Invisible` variant. I'm
generally in favour of using types to make impossible states
unrepresentable, but this one feels very low-value, and the conversions
between the two types are annoying and confusing.

Look at the change in `src/tools/rustfmt/src/expr.rs` for an example:
the old code converted from `MacDelimiter` to `Delimiter` and back
again, for no good reason. This suggests the author was confused about
the types.
2023-08-03 09:03:30 +10:00
Bryan Garza
673ab17c7f Add separate feature gate for async fn track caller
This patch adds a feature gate `async_fn_track_caller` that is separate from `closure_track_caller`. This is to allow enabling `async_fn_track_caller` separately.

Fixes #110009
2023-08-02 14:18:21 -07:00
Alex Zepeda
2e29d85f7e Avoid exporting symbols more than once.
Exporting `__rust_alloc_error_handler_should_panic` multiple times
causes ld.gold to balk with: `error: version script assignment of  to
symbol __rust_alloc_error_handler_should_panic failed: symbol not
defined`

Specifically this breaks builds on DragonFly and YoctoProject with
ld.gold.  Builds with ld.bfd should be unaffected.
2023-08-02 11:02:23 -07:00
Ralf Jung
7767cbb3b0 const validation: point at where we found a pointer but expected an integer 2023-08-02 18:51:50 +02:00
Mu001999
89b2fe7750 Keep the suggestion for wrong arbitrary self types 2023-08-03 00:00:56 +08:00
Deadbeef
4fec845c3f Remove constness from TraitPredicate 2023-08-02 15:38:00 +00:00
Camille GILLOT
69ea85da02 Adapt error code doc. 2023-08-02 15:30:29 +00:00
Camille GILLOT
2faa2626cc Resolve visibility paths as modules not as types. 2023-08-02 15:30:24 +00:00
Ralf Jung
2984670cea avoid 'miri' when refering to the shared interpreter 2023-08-02 16:52:03 +02:00
bors
7637653b9f Auto merge of #114368 - Nilstrieb:rollup-pgvm9cf, r=Nilstrieb
Rollup of 5 pull requests

Successful merges:

 - #114079 (Use `upvar_tys` in more places, make it return a list)
 - #114166 (Add regression test for resolving `--extern libc=test.rlib`)
 - #114321 (get auto traits for parallel rustc)
 - #114335 (fix and extend ptr_comparison test)
 - #114347 (x.py print more detailed format files and untracked files count)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-02 13:38:36 +00:00
Nilstrieb
0475873813
Rollup merge of #114321 - SparrowLii:parallel_test, r=oli-obk
get auto traits for parallel rustc

test for #106930
#[Edit] Since this doesn't block try build now, we can close https://github.com/rust-lang/rust/issues/106930

fixes #106930
2023-08-02 13:46:55 +02:00
Nilstrieb
46f6b05eb7
Rollup merge of #114079 - compiler-errors:closure-upvars, r=oli-obk
Use `upvar_tys` in more places, make it return a list

Just a cleanup that fell out of a PR that I was gonna write, but that PR kinda got stuck.
2023-08-02 13:46:54 +02:00
bors
d170833431 Auto merge of #112431 - Urgau:cast_ref_to_mut_improvments, r=Nilstrieb
Improve `invalid_reference_casting` lint

This PR is a follow-up to https://github.com/rust-lang/rust/pull/111567 and https://github.com/rust-lang/rust/pull/113422.

This PR does multiple things:
 - First it adds support for deferred de-reference, the goal is to support code like this, where the casting and de-reference are not done on the same expression
    ```rust
    let myself = self as *const Self as *mut Self;
    *myself = Self::Ready(value);
    ```
 - Second it does not lint anymore on SB/TB UB code by only checking assignments (`=`, `+=`, ...) and creation of mutable references `&mut *`
 - Thirdly it greatly improves the diagnostics in particular for cast from `&mut` to `&mut` or assignments
 - ~~And lastly it renames the lint from `cast_ref_to_mut` to `invalid_reference_casting` which is more consistent with the ["rules"](https://github.com/rust-lang/rust-clippy/issues/2845) and also more consistent with what the lint checks~~ *https://github.com/rust-lang/rust/pull/113422*

This PR is best reviewed commit by commit.

r? compiler
2023-08-02 11:25:13 +00:00
bors
64ad036307 Auto merge of #114333 - RalfJung:dangling-ptr-offset, r=oli-obk
Miri: fix error on dangling pointer inbounds offset

We used to claim that the pointer was "dereferenced", but that is just not true.

Can be reviewed commit-by-commit. The first commit is an unrelated rename that didn't seem worth splitting into its own PR.

r? `@oli-obk`
2023-08-02 09:12:32 +00:00
yukang
ac25636a8f fix RedundantLocals clippy caused by async and await 2023-08-02 16:32:49 +08:00
SparrowLii
90db1132c7 get auto traits for parallel rustc
Signed-off-by: SparrowLii <liyuan179@huawei.com>
2023-08-02 16:21:45 +08:00
bors
5cbfee5455 Auto merge of #114360 - Zalathar:ffi-types, r=oli-obk
coverage: Consolidate FFI types into one module

Coverage FFI types were historically split across two modules, because some of them were needed by code in `rustc_codegen_ssa`.

Now that all of the coverage codegen code has been moved into `rustc_codegen_llvm` (#113355), it's possible to move all of the FFI types into a single module, making it easier to see all of them at once.

---

This PR only moves code and adjusts imports; there should be no functional changes.
2023-08-02 07:23:57 +00:00
yukang
75b9f53e47 Fix #107113, avoid suggest for macro attributes 2023-08-02 14:54:37 +08:00
Zalathar
d6ed6e3904 coverage: Consolidate FFI types into one module
Coverage FFI types were historically split across two modules, because some of
them were needed by code in `rustc_codegen_ssa`.

Now that all of the coverage codegen code has been moved into
`rustc_codegen_llvm` (#113355), it's possible to move all of the FFI types into
a single module, making it easier to see all of them at once.
2023-08-02 15:26:47 +10:00
bors
7a5d2d0138 Auto merge of #114358 - matthiaskrgr:rollup-d810m9e, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #114178 (Account for macros when suggesting a new let binding)
 - #114199 (Don't unsize coerce infer vars in select in new solver)
 - #114301 (Don't check unnecessarily that impl trait is RPIT)
 - #114314 (Tweaks to `adt_sized_constraint`)
 - #114322 (Fix invalid slice coercion suggestion reported in turbofish)
 - #114340 ([rustc_attr][nit] Replace `filter` + `is_some` with `map_or`.)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-02 04:30:51 +00:00
Matthias Krüger
4876afba38
Rollup merge of #114340 - ttsugriy:rustc-attr, r=lqd
[rustc_attr][nit] Replace `filter` + `is_some` with `map_or`.

It's slightly shorter and better communicates the intent.
2023-08-02 06:22:50 +02:00
Matthias Krüger
1778c58905
Rollup merge of #114322 - Urgau:fix-issue-110063, r=compiler-errors
Fix invalid slice coercion suggestion reported in turbofish

This PR fixes the invalid slice coercion suggestion reported in turbofish and inferred generics by not emitting them.

Fixes https://github.com/rust-lang/rust/issues/110063
2023-08-02 06:22:49 +02:00
Matthias Krüger
3d29ce7484
Rollup merge of #114314 - compiler-errors:sized-crit, r=lcnr
Tweaks to `adt_sized_constraint`

fixes a comment, but also some other nits.

r? lcnr
2023-08-02 06:22:49 +02:00
Matthias Krüger
f338a1f7ee
Rollup merge of #114301 - compiler-errors:dont-error-on-missing-region-outlives, r=spastorino
Don't check unnecessarily that impl trait is RPIT

We have this random `return_type_impl_trait` function to detect if a function returns an RPIT which is used in outlives suggestions, but removing it doesn't actually change any diagnostics. Let's just remove it.

Also, suppress a spurious outlives error from a ReError.

Fixes #114274
2023-08-02 06:22:48 +02:00
Matthias Krüger
bb3dee1a8a
Rollup merge of #114199 - compiler-errors:dont-select-unsize-infer, r=lcnr
Don't unsize coerce infer vars in select in new solver

Otherwise we're too eagerly preferring the `T -> dyn Trait` branch during coercion.

r? `@lcnr`
2023-08-02 06:22:48 +02:00
Matthias Krüger
9cdca18840
Rollup merge of #114178 - estebank:let-binding-macro, r=petrochenkov
Account for macros when suggesting a new let binding

Provide a structured suggestion when the expression comes from a macro expansion:

```
error[E0716]: temporary value dropped while borrowed
  --> $DIR/borrowck-let-suggestion.rs:2:17
   |
LL |     let mut x = vec![1].iter();
   |                 ^^^^^^^       - temporary value is freed at the end of this statement
   |                 |
   |                 creates a temporary value which is freed while still in use
LL |
LL |     x.use_mut();
   |     - borrow later used here
   |
   = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider using a `let` binding to create a longer lived value
   |
LL ~     let binding = vec![1];
LL ~     let mut x = binding.iter();
   |
```
2023-08-02 06:22:47 +02:00
bors
90bb4184f8 Auto merge of #114170 - lcnr:add-commmentz, r=compiler-errors
add `dropck_outlives` comments
2023-08-02 02:45:47 +00:00
yukang
026c4b6a65 trivial style fix 2023-08-02 09:56:02 +08:00
bors
aa8462b6df Auto merge of #112922 - g0djan:godjan/wasi-threads, r=wesleywiser
WASI threads, implementation of wasm32-wasi-preview1-threads target

This PR adds a target proposed in https://github.com/rust-lang/compiler-team/issues/574 by `@abrown` and implementation of `std:🧵:spawn` for the target `wasm32-wasi-preview1-threads`

### Tier 3 Target Policy
As tier 3 targets, the new targets are required to adhere to [the tier 3 target policy](https://doc.rust-lang.org/nightly/rustc/target-tier-policy.html#tier-3-target-policy) requirements. This section quotes each requirement in entirety and describes how they are met.
> - A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)

See [src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md](https://github.com/rust-lang/rust/pull/112922/files#diff-a48ee9d94f13e12be24eadd08eb47b479c153c340eeea4ef22276d876dfd4f3e).
> - Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.
> - Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it.
If possible, use only letters, numbers, dashes and underscores for the name. Periods (.) are known to cause issues in Cargo.

The target is using the same name for $ARCH=wasm32 and $OS=wasi as existing Rust targets. The suffix `preview1` introduced to accurately set expectations because eventually this target will be deprecated and follows [MCP 607](https://github.com/rust-lang/compiler-team/issues/607). The suffix `threads` indicates that it’s an extension that enables threads to the existing target and it follows [MCP 574](https://github.com/rust-lang/compiler-team/issues/574) which describes the rationale behind introducing a separate target.

> - Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.
> - The target must not introduce license incompatibilities.
> - Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0).
> - The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the tidy tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements.
> - Compiling, linking, and emitting functional binaries, libraries, or other code for the target (whether hosted on the target itself or cross-compiling from another target) must not depend on proprietary (non-FOSS) libraries. Host tools built for the target itself may depend on the ordinary runtime libraries supplied by the platform and commonly used by other applications built for the target, but those libraries must not be required for code generation for the target; cross-compilation to the target must not require such libraries at all. For instance, rustc built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3.
> - "onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are not limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users.

This PR does not introduce any new dependency.
The new target doesn’t support building host tools.
> Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.

The full standard library is available for this target as it’s an extension to an existing target that has already supported it.
> The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary.

Only manual test running is supported at the moment with some tweaks in the test runner codebase. For build and running tests see [src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md](https://github.com/rust-lang/rust/pull/112922/files#diff-a48ee9d94f13e12be24eadd08eb47b479c153c340eeea4ef22276d876dfd4f3e).
> - Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.
> - This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements.
> - Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via `@)` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.
> - Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications.
> - Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.
> - In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target.

I acknowledge these requirements and intend to ensure they are met.
2023-08-02 01:01:48 +00:00
Nicholas Nethercote
ba294a816b Fix an erroneous comment.
The `None` variant has already been renamed `Invisible`.
2023-08-02 10:32:35 +10:00
Nicholas Nethercote
ac64a53e17 Avoid an unnecessary local variable. 2023-08-02 10:29:13 +10:00
Nicholas Nethercote
6fc2c481e5 Move TokenCursor::break_last_token into Parser.
Similar to the last commit, it's more of a `Parser`-level concern than a
`TokenCursor`-level concern. And the struct size reductions are nice.

After this change, `TokenCursor` is as minimal as possible (two fields
and two methods) which is nice.
2023-08-02 10:11:41 +10:00
Nicholas Nethercote
54eb6bc34c Move TokenCursor::num_next_calls into Parser and rename it.
It's more of a `Parser`-level concern than a `TokenCursor`-level
concern. Also, `num_bump_calls` is a more accurate name, because it's
incremented in `Parser::bump`.
2023-08-02 10:07:18 +10:00
Nicholas Nethercote
db7b07aa02 Inline and remove parse_all_token_trees.
It has a single call site.
2023-08-02 10:03:16 +10:00
Nicholas Nethercote
d9f2fdfaed parse_all_token_trees cannot fail. 2023-08-02 10:01:49 +10:00
Taras Tsugrii
f74eee2fa6 [rustc_span][perf] Remove unnecessary string joins and allocs.
Comparing vectors of string parts yields the same result but avoids
unnecessary `join` and potential allocation for resulting `String`.
This code is cold so it's unlikely to have any measurable impact, but
considering but since it's also simpler, why not? :)
2023-08-01 16:57:43 -07:00
Michael Goulet
99969d282b Use upvar_tys in more places, make it a list 2023-08-01 23:19:31 +00:00
bors
f77c624c03 Auto merge of #113339 - lqd:respect-filters, r=tmiasko
Filter out short-lived LLVM diagnostics before they reach the rustc handler

During profiling I saw remark passes being unconditionally enabled: for example `Machine Optimization Remark Emitter`.

The diagnostic remarks enabled by default are [from missed optimizations and opt analyses](https://github.com/rust-lang/rust/pull/113339#discussion_r1259480303). They are created by LLVM, passed to the diagnostic handler on the C++ side, emitted to rust, where they are unpacked, C++ strings are converted to rust, etc.

Then they are discarded in the vast majority of the time (i.e. unless some kind of `-Cremark` has enabled some of these passes' output to be printed).

These unneeded allocations are very short-lived, basically only lasting between the LLVM pass emitting them and the rust handler where they are discarded. So it doesn't hugely impact max-rss, and is only a slight reduction in instruction count (cachegrind reports a reduction between 0.3% and 0.5%) _on linux_. It's possible that targets without `jemalloc` or with a worse allocator, may optimize these less.

It is however significant in the aggregate, looking at the total number of allocated bytes:
- it's the biggest source of allocations according to dhat, on the benchmarks I've tried e.g. `syn` or `cargo`
- allocations on `syn` are reduced by 440MB, 17% (from 2440722647 bytes total, to 2030461328 bytes)
- allocations on `cargo` are reduced by 6.6GB, 19% (from 35371886402 bytes total, to 28723987743 bytes)

Some of these diagnostics objects [are allocated in LLVM](https://github.com/rust-lang/rust/pull/113339#discussion_r1252387484) *before* they're emitted to our diagnostic handler, where they'll be filtered out. So we could remove those in the future, but that will require changing a few LLVM call-sites upstream, so I left a FIXME.
2023-08-01 23:15:20 +00:00
Michael Goulet
d21a335e8f Don't select infer -> dyn Trait 2023-08-01 23:12:03 +00:00
Michael Goulet
ac6f2f0d2e Fix a comment 2023-08-01 23:10:38 +00:00
Michael Goulet
44be25d8a2 don't create a predicate for just a comparison 2023-08-01 23:10:38 +00:00
Michael Goulet
8696fa71b3 Convert adt_sized_constraint to early-binder, use list 2023-08-01 23:10:38 +00:00
bors
d12c6e947c Auto merge of #114273 - nnethercote:move-doc-comment-desugaring, r=petrochenkov
Move doc comment desugaring out of `TokenCursor`.

It's awkward that `TokenCursor` sometimes desugars doc comments on the fly, but usually doesn't.

r? `@petrochenkov`
2023-08-01 21:27:48 +00:00
Rémy Rakic
ca5a383fb6 remove remark filtering on the rust side
now that remarks are filtered before cg_llvm's diagnostic handler callback
is called, we don't need to do the filtering post c++-to-rust conversion
of the diagnostic.
2023-08-01 21:01:20 +00:00
Rémy Rakic
77d01103a3 filter LLVM diagnostics before crossing the rust bridge
this will eliminate many short-lived allocations (e.g. 20% of the memory used
building cargo) when unpacking the diagnostic and converting its various
C++ strings into rust strings, just to be filtered out most of the time.
2023-08-01 21:01:20 +00:00
bors
abd3637e42 Auto merge of #105545 - erikdesjardins:ptrclean, r=bjorn3
cleanup: remove pointee types

This can't be merged until the oldest LLVM version we support uses opaque pointers, which will be the case after #114148. (Also note `-Cllvm-args="-opaque-pointers=0"` can technically be used in LLVM 15, though I don't think we should support that configuration.)

I initially hoped this would provide some minor perf win, but in https://github.com/rust-lang/rust/pull/105412#issuecomment-1341224450 it had very little impact, so this is only valuable as a cleanup.

As a followup, this will enable #96242 to be resolved.

r? `@ghost`

`@rustbot` label S-blocked
2023-08-01 19:44:17 +00:00
Taras Tsugrii
9563eec9a8 [rustc_attr][nit] Replace filter + is_some with map_or.
It's slightly shorter and better communicates the intent.
2023-08-01 12:39:32 -07:00
Taras Tsugrii
64dfd1090d [rustc_data_structures][base_n][perf] Remove unnecessary utf8 check.
Since all output characters taken from `BASE_64` are valid UTF8 chars
there is no need to waste cycles on validation.

Even though it's obviously a perf win, I've also used a [benchmark](https://gist.github.com/ttsugriy/e1e63c07927d8f31e71695a9c617bbf3)
on M1 MacBook Air with following results:
```
Running benches/base_n_benchmark.rs (target/release/deps/base_n_benchmark-825fe5895b5c2693)
push_str/old            time:   [14.670 µs 14.852 µs 15.074 µs]
                        Performance has regressed.
Found 11 outliers among 100 measurements (11.00%)
  4 (4.00%) high mild
  7 (7.00%) high severe
push_str/new            time:   [12.573 µs 12.674 µs 12.801 µs]
                        Performance has regressed.
Found 11 outliers among 100 measurements (11.00%)
  7 (7.00%) high mild
  4 (4.00%) high severe
```
2023-08-01 11:10:17 -07:00
Urgau
0b9529cca3 Add diagnostic items for <*const _>::cast and ptr::from_mut 2023-08-01 20:04:01 +02:00
Urgau
d2b7c8028f Rename incorrect_fn_null_checks to useless_ptr_null_checks 2023-08-01 19:35:31 +02:00
Urgau
743ae5a2eb Expand incorrect_fn_null_check lint with reference null checking 2023-08-01 19:35:31 +02:00
Michael Goulet
1c35634efe Suppress unnecessary outlives 2023-08-01 17:16:47 +00:00
Ralf Jung
8496292dda properly track why we checked whether a pointer is in-bounds
also simplify the in-bounds checking in Miri's borrow trackers
2023-08-01 17:57:13 +02:00
Matthias Krüger
41364c7c1d
Rollup merge of #114320 - ouz-a:smir_statements, r=oli-obk
Cover statements for stable_mir

Added missing statements to stable_mir, used opaque types for few types that are only used for diagnostic.

cc https://github.com/rust-lang/project-stable-mir/issues/16

r? `@oli-obk`
2023-08-01 17:39:13 +02:00
Matthias Krüger
00ad3ccae6
Rollup merge of #114306 - ttsugriy:push_str, r=wesleywiser
[rustc_data_structures][perf] Simplify base_n::push_str.

This minor change removes the need to reverse resulting digits. Since reverse is O(|digit_num|) but bounded by 128, it's unlikely to be a noticeable in practice. At the same time, this code is also a 1 line shorter, so combined with tiny perf win, why not?

I ran https://gist.github.com/ttsugriy/ed14860ef597ab315d4129d5f8adb191 on M1 macbook air and got a small improvement
```
Running benches/base_n_benchmark.rs (target/release/deps/base_n_benchmark-825fe5895b5c2693)
push_str/old            time:   [14.180 µs 14.313 µs 14.462 µs]
                        Performance has improved.
Found 5 outliers among 100 measurements (5.00%)
  4 (4.00%) high mild
  1 (1.00%) high severe
push_str/new            time:   [13.741 µs 13.839 µs 13.973 µs]
                        Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
  3 (3.00%) high mild
  5 (5.00%) high severe
```
2023-08-01 17:39:12 +02:00
Matthias Krüger
fa33d6e185
Rollup merge of #114296 - RalfJung:interpret-repeat-align, r=oli-obk
interpret: fix alignment handling for Repeat expressions
2023-08-01 17:39:12 +02:00
Matthias Krüger
c726dcb962
Rollup merge of #114288 - Urgau:fix-issue-109352, r=b-naber
Improve diagnostic for wrong borrow on binary operations

This PR improves the diagnostic for wrong borrow on binary operations by suggesting to reborrow on appropriate expressions.

```diff
+    = note: an implementation for `&Foo * &Foo` exist
+ help: consider reborrowing both sides
+    |
+ LL |     let _ = &*ref_mut_foo * &*ref_mut_foo;
+    |             ++              ++
```

Fixes https://github.com/rust-lang/rust/issues/109352
2023-08-01 17:39:11 +02:00
Matthias Krüger
b38718090e
Rollup merge of #114283 - oli-obk:parkin_lot_rwlock, r=SparrowLii
Use parking lot's rwlock even without parallel-rustc

Considering that this doesn't affect perf, I think we should use the simplest solution.
2023-08-01 17:39:10 +02:00
Matthias Krüger
52bfceb8f9
Rollup merge of #113428 - Zalathar:operand, r=davidtwco
coverage: Replace `ExpressionOperandId` with enum `Operand`

*This is one step in my larger coverage refactoring ambitions described at <https://github.com/rust-lang/compiler-team/issues/645>.*

LLVM coverage has a concept of “mapping expressions” that allow a span's execution count to be computed as a simple arithmetic expression over other counters/expressions, instead of requiring a dedicated physical counter for every control-flow branch.

These expressions have an operator (`+` or `-`) and two operands. Operands are currently represented as `ExpressionOperandId`, which wraps a `u32` with the following semantics:

- 0 represents a special counter that always has a value of zero
- Values ascending from 1 represent counter IDs
- Values descending from `u32::MAX` represent the IDs of other expressions

---

This change replaces that whole `ExpressionOperandId` scheme with a simple enum that explicitly distinguishes between the three cases.

This lets us remove a lot of fiddly code for dealing with the different operand kinds:
- Previously it was only possible to distinguish between counter-ID operands and expression-ID operands by comparing the operand ID with the total number of counters in a function. This is unnecessary now that the enum distinguishes them explicitly.
- There's no need for expression IDs to descend from `u32::MAX` and then get translated into zero-based indices in certain places. Now that they ascend from zero, they can be used as indices directly.
- There's no need to reserve ID number 0 for the special zero operand, since it can just have its own variant in the enum, so counter IDs can count up from 0.

(Making counter IDs ascend from 0 also lets us fix an off-by-one error in the query for counting the total number of counters, which would cause LLVM to emit an extra unused counter for every instrumented function.)

---

This PR may be easiest to review as individual patches, since that breaks it up into clearly distinct parts:
- Replace a `u32` wrapper with an explicit enum, without changing the semantics of the underlying IDs being stored.
- Change the numbering scheme used by `Operand::Expression` to make expression IDs ascend from 0 (instead of descending from `u32::MAX`).
- Change the numbering scheme used by `Operand::Counter` to make counter IDs ascend from 0 (instead of ascending from 1).
2023-08-01 17:39:10 +02:00
Mu001999
049c728c60 Suggests turbofish in patterns 2023-08-01 23:30:40 +08:00
ouz-a
2ff62fdfcc clean up, use opaque types 2023-08-01 17:48:20 +03:00
Ralf Jung
7d5886504c rename deref_operand → deref_pointer and some Miri helper functions 2023-08-01 13:40:29 +02:00
Urgau
a40829498e Rename maybe_suggest_convert_to_slice fn name to consistent naming 2023-08-01 12:34:31 +02:00
Urgau
87e8feaf50 Fix invalid slice coercion suggestion reported in turbofish 2023-08-01 12:34:31 +02:00
ouz-a
206bfc47ea Cover statements for stable_mir 2023-08-01 12:57:13 +03:00
bors
c435af0d5c Auto merge of #114318 - matthiaskrgr:rollup-c7gcw18, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #111081 (impl SliceIndex<str> for (Bound<usize>, Bound<usize>))
 - #113394 (style-guide: Document style editions, start 2024 style edition)
 - #113588 (bootstrap: use git merge-base for LLVM CI download logic)
 - #113743 (Directly link more target docs)
 - #114262 (Improve the rust style guide doc)
 - #114309 (Update books)
 - #114313 ([rustc_data_structures] Simplify SortedMap::insert.)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-01 09:40:59 +00:00
Urgau
ad0729e9d2 Improve diagnostic for wrong borrow on binary operations 2023-08-01 10:08:17 +02:00
Oli Scherer
3eb5733ed4 Always use parking_lot's RwLock, even without parallel compiler 2023-08-01 06:55:12 +00:00
Matthias Krüger
a902550233
Rollup merge of #114313 - ttsugriy:sm-insert, r=petrochenkov
[rustc_data_structures] Simplify SortedMap::insert.

It looks like current usage of `swap` is aimed at achieving what `std::mem::replace` does but more concisely and idiomatically.
2023-08-01 06:55:55 +02:00
bors
866710c552 Auto merge of #111753 - cjgillot:simp-place-conflict, r=compiler-errors
Only consider places with the same local in each_borrow_involving_path.

This avoids having a busy loop that repeatedly checks for equality of locals.
2023-08-01 03:53:19 +00:00
Zalathar
3920e07f0b Make coverage counter IDs count up from 0, not 1
Operand types are now tracked explicitly, so there is no need to reserve ID 0
for the special always-zero counter.

As part of the renumbering, this change fixes an off-by-one error in the way
counters were counted by the `coverageinfo` query. As a result, functions
should now have exactly the number of counters they actually need, instead of
always having an extra counter that is never used.
2023-08-01 11:29:55 +10:00
Zalathar
f103db894f Make coverage expression IDs count up from 0, not down from u32::MAX
Operand types are now tracked explicitly, so there is no need for expression
IDs to avoid counter IDs by descending from `u32::MAX`. Instead they can just
count up from 0, and can be used directly as indices when necessary.
2023-08-01 11:29:55 +10:00
Zalathar
1a014d42f4 Replace ExpressionOperandId with enum Operand
Because the three kinds of operand are now distinguished explicitly, we no
longer need fiddly code to disambiguate counter IDs and expression IDs based on
the total number of counters/expressions in a function.

This does increase the size of operands from 4 bytes to 8 bytes, but that
shouldn't be a big deal since they are mostly stored inside boxed structures,
and the current coverage code is not particularly size-optimized anyway.
2023-08-01 11:29:55 +10:00
Zalathar
5a808d40f4 Add some line comments to enum CoverageKind
The actual motivation here is to prevent `rustfmt` from suddenly reformatting
these enum variants onto a single line, when they become slightly shorter in
the future.

But there's no harm in adding some helpful documentation at the same time.
2023-08-01 11:29:55 +10:00
Taras Tsugrii
9eae73a5de [rustc_data_structures] Simplify SortedMap::insert.
It looks like current usage of `swap` is aimed at achieving what
`std::mem::replace` does but more concisely and idiomatically.
2023-07-31 16:58:04 -07:00
bors
706a4d9a4e Auto merge of #114308 - matthiaskrgr:rollup-m64bkm7, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #109318 (Make `Debug` representations of `[Lazy, Once]*[Cell, Lock]` consistent with `Mutex` and `RwLock`)
 - #113701 (Re-export core::ffi::FromBytesUntilNulError in std::ffi)
 - #113804 (Resolve correct archive version name in `opt-dist`)
 - #114165 (Add missing rvalues to smir)
 - #114182 (clean up after 113312)
 - #114193 (Update lexer emoji diagnostics to Unicode 15.0)
 - #114200 (Detect trait upcasting through struct tail unsizing in new solver select)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-31 23:30:28 +00:00
Matthias Krüger
c73e232d20
Rollup merge of #114200 - compiler-errors:detect-tail-unsize-then-upcast, r=lcnr
Detect trait upcasting through struct tail unsizing in new solver select

Oops, we were able to hide trait upcasting behind a parent unsize goal that evaluated to `Certainty::Yes`. Let's do rematching for `Certainty::Yes` unsize goals with `BuiltinImplSource::Misc` sources (corresponding to all of the other unsize rules) to make sure we end up selecting any nested goals which may be satisfied via `BuiltinImplSource::TraitUpcasting` or `::TupleUnsizing`.

r? ``@lcnr``
2023-07-31 22:51:16 +02:00
Matthias Krüger
57c57a555b
Rollup merge of #114193 - crlf0710:lexer_unicode15, r=Manishearth
Update lexer emoji diagnostics to Unicode 15.0

This replaces the `unic-emoji-char` dep tree (which hasn't been updated for a while) with `unicode-properties` crate which contains Unicode 15.0 data.

Improves diagnostics for added emoji characters in recent years. (See tests).

cc #101840

cc ``@Manishearth``
2023-07-31 22:51:15 +02:00
Matthias Krüger
35ba616850
Rollup merge of #114165 - ouz-a:smir1, r=spastorino
Add missing rvalues to smir

Added few missing rvalues to smir, not entirely confident about changes to `Aggregate`

cc https://github.com/rust-lang/project-stable-mir/issues/13

r? `@oli-obk`
2023-07-31 22:51:14 +02:00
Matthias Krüger
2de51cce90
Rollup merge of #113920 - bvanjoi:fix-81413, r=petrochenkov
fix(resolve): report unresolved imports firstly

Fixes #81413

An easy fix, r? ```@petrochenkov```
2023-07-31 22:49:50 +02:00
Matthias Krüger
58f963fb65
Rollup merge of #113717 - cuishuang:master, r=Nilstrieb
remove repetitive words
2023-07-31 22:49:47 +02:00
Matthias Krüger
d0ae0b31a8
Rollup merge of #112858 - chriswailes:riscv64-android, r=Mark-Simulacrum
Update Android system definitions and add riscv-linux-android as tier 3 target

This PR includes the following:
* Corrected Android system definitions for some types
* Support for the riscv64-linux-android target

The authoritative types for the system definitions can be found here: https://cs.android.com/android/platform/superproject/+/master:bionic/libc/include/sys/stat.h

Fixes rust-lang/compiler-team#640
2023-07-31 22:49:46 +02:00
ouz-a
2a3da87c0e add missing rvalues to smir 2023-07-31 22:48:55 +03:00
Taras Tsugrii
b84942a0fe [rustc_data_structures][perf] Simplify base_n::push_str.
This minor change removes the need to reverse resulting digits.
Since reverse is O(|digit_num|) but bounded by 128, it's unlikely
to be a noticeable in practice. At the same time, this code is
also a 1 line shorter, so combined with tiny perf win, why not?

I ran https://gist.github.com/ttsugriy/ed14860ef597ab315d4129d5f8adb191
on M1 macbook air and got a small improvement
```
Running benches/base_n_benchmark.rs (target/release/deps/base_n_benchmark-825fe5895b5c2693)
push_str/old            time:   [14.180 µs 14.313 µs 14.462 µs]
                        Performance has improved.
Found 5 outliers among 100 measurements (5.00%)
  4 (4.00%) high mild
  1 (1.00%) high severe
push_str/new            time:   [13.741 µs 13.839 µs 13.973 µs]
                        Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
  3 (3.00%) high mild
  5 (5.00%) high severe
```
2023-07-31 12:40:11 -07:00
Michael Goulet
9295817bad Don't check unnecessarily that impl trait is RPIT 2023-07-31 18:13:48 +00:00
Ralf Jung
b169ee7c1a fix alignment handling for Repeat expressions 2023-07-31 19:22:14 +02:00
Matthias Krüger
f59a5604f9
Rollup merge of #114286 - nbdd0121:upcast, r=compiler-errors
Add missing feature gate in multiple_supertrait_upcastable doc

Fix #112424
2023-07-31 16:57:56 +02:00
Matthias Krüger
692d764e53
Rollup merge of #114267 - compiler-errors:rpitit-opaque-bounds, r=spastorino
Map RPITIT's opaque type bounds back from projections to opaques

An RPITIT in a program's AST is eventually translated into both a projection GAT and an opaque. The opaque is used for default trait methods, like:

```
trait Foo {
  fn bar() -> impl Sized { 0i32 }
}
```

The item bounds for both the projection and opaque are identical, and both have a *projection* self ty. This is mostly okay, since we can normalize this projection within the default trait method body to the opaque, but it does two things:
1. it leads to bugs in places where we don't normalize item bounds, like `deduce_future_output_from_obligations`
2. it leads to extra match arms that are both suspicious looking and also easy to miss

This PR maps the opaque type bounds of the RPITIT's *opaque* back to the opaque's self type to avoid this quirk. Then we can fix the UI test for #108304 (1.) and also remove a bunch of match arms (2.).

Fixes #108304

r? `@spastorino`
2023-07-31 16:57:55 +02:00
Matthias Krüger
95b7116d70
Rollup merge of #114228 - fmease:wf-lazy-ty-aliases, r=oli-obk
Check lazy type aliases for well-formedness

Previously we didn't check if `T: Mul` holds given lazy `type Alias<T> = <T as Mul>::Output;`.
Now we do. It only makes sense.

`@rustbot` label F-lazy_type_alias

r? `@oli-obk`
2023-07-31 16:57:54 +02:00
Matthias Krüger
b8f78fb47c
Rollup merge of #114169 - lcnr:unsize, r=compiler-errors
refactor builtin unsize handling, extend comments

r? `@compiler-errors`
2023-07-31 16:57:53 +02:00
Gary Guo
e617faabe7 Add missing feature gate in multiple_supertrait_upcastable doc 2023-07-31 12:28:53 +01:00
lcnr
fc98c5a098 update comment 2023-07-31 12:47:24 +02:00
Oli Scherer
375d8f1b25 Sanity check that we actually flush all buffers 2023-07-31 09:34:36 +00:00
Oli Scherer
d9deaf4b8a Get rid of the thin wrapper type that is Destination and just write to the Writer trait object directly 2023-07-31 09:34:36 +00:00
Oli Scherer
2131eee179 Turn a single-variant enum into a struct 2023-07-31 09:34:36 +00:00
Oli Scherer
10da30f540 Merge all Destination variants 2023-07-31 09:34:36 +00:00
Oli Scherer
826a8ef52e Remove a now-redundant single-variant enum 2023-07-31 09:34:36 +00:00
Oli Scherer
1e2167f5b5 Move WritableDst method onto Style directly 2023-07-31 09:34:36 +00:00
Oli Scherer
00074698a7 Merge buffered destination into raw destination 2023-07-31 09:34:36 +00:00
Oli Scherer
339890e186 Remove an enum variant that can be covered by another 2023-07-31 09:34:36 +00:00
Oli Scherer
51c22154f5 Remove a bool for color in favor of the WriteColor trait wrapping colored and uncolored printing 2023-07-31 09:34:36 +00:00
Oli Scherer
0e7ec9683d Use builder pattern instead of lots of arguments for EmitterWriter::new 2023-07-31 09:34:30 +00:00
bors
5082281609 Auto merge of #113879 - nnethercote:codegen_ssa-cleanups, r=bjorn3
`codegen_ssa` cleanups

Some clarifications I made when reading this code closely.

r? `@tmiasko`
2023-07-31 08:18:19 +00:00
cui fliter
88c7b16e03 remove repetitive words
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-07-31 16:13:02 +08:00
Oli Scherer
29de70da1b Replace the many arguments of EmitterWriter::stderr with builder methods 2023-07-31 07:19:23 +00:00
Nicholas Nethercote
c17c8dc78e Remove unnecessary semicolon. 2023-07-31 16:34:13 +10:00
Nicholas Nethercote
5673f47042 Clean up generate_lto_work.
This function has some shared code for the thin LTO and fat LTO cases,
but those cases have so little in common that it's actually clearer to
treat them fully separately.
2023-07-31 16:21:03 +10:00
Nicholas Nethercote
d404699fb1 Fix LLVM thread names on Windows.
PR #112946 tweaked the naming of LLVM threads, but messed things up
slightly, resulting in threads on Windows having names like `optimize
module {} regex.f10ba03eb5ec7975-cgu.0`.

This commit removes the extraneous `{} `.
2023-07-31 16:21:03 +10:00
Nicholas Nethercote
90ce358afa Introduce running_with_any_token closure.
It makes things a little clearer.
2023-07-31 16:21:02 +10:00
Nicholas Nethercote
3b44f5b0eb Use standard Rust capitalization rules for names containing "LTO". 2023-07-31 16:21:02 +10:00
Nicholas Nethercote
a08220bcab Tweak structure of the message loop.
The main loop has a *very* complex condition, which includes two
mentions of `codegen_state`. The body of the loop then immediately
switches on the `codegen_state`.

I find it easier to understand if it's a `loop` and we check for exit
conditions after switching on `codegen_state`. We end up with a tiny bit
of code duplication, but it's clear that (a) we never exit in the
`Ongoing` case, (b) we exit in the `Completed` state only if several
things are true (and there's interaction with LTO there), and (c) we
exit in the `Aborted` state if a couple of things are true. Also, the
exit conditions are all simple conjunctions.
2023-07-31 16:21:02 +10:00
Nicholas Nethercote
179bf19813 Tweak a loop condition.
This loop condition involves `codegen_state`, `work_items`, and
`running_with_own_token`. But the body of the loop cannot modify
`codegen_state`, so repeatedly checking it is unnecessary.
2023-07-31 16:21:02 +10:00
Nicholas Nethercote
d21d31cce7 Move maybe_start_llvm_timer's body into spawn_work.
The two functions are alway called together. This commit factors out the
repeated code.
2023-07-31 16:21:02 +10:00
Nicholas Nethercote
3517fe899e Remove CodegenContext::worker.
`CodegenContext` is immutable except for the `worker` field - we clone
`CodegenContext` in multiple places, changing the `worker` field each
time. It's simpler to move the `worker` field out of `CodegenContext`.
2023-07-31 16:21:02 +10:00
Nicholas Nethercote
67e4bec200 Fix a comment.
Make it match the corresponding comment at the start of the unstable
options.
2023-07-31 16:21:02 +10:00
Nicholas Nethercote
4a120f33f7 Remove ExtraBackendMethods::spawn_thread.
It's no longer used, and `spawn_named_thread` is preferable, because
naming threads is helpful when profiling.
2023-07-31 16:21:02 +10:00
Nicholas Nethercote
e78fb95dfa Give the coordinator thread a name.
This is useful when profiling with a profiler like Samply.
2023-07-31 16:21:02 +10:00
Nicholas Nethercote
176610c2cd Remove some unused values in codegen_crate. 2023-07-31 16:21:02 +10:00
Nicholas Nethercote
8b9e3f0dd6 Remove an unnecessary pub. 2023-07-31 16:21:00 +10:00
Nicholas Nethercote
f81fe9d702 Rename MainThreadWorkerState.
The `Worker` is unnecessary, and just makes it longer than necessary.
2023-07-31 16:20:18 +10:00
Nicholas Nethercote
5bef04ed38 Rename things related to the main thread's operations.
It took me some time to understand how the main thread can lend a
jobserver token to an LLVM thread. This commit renames a couple of
things to make it clearer.

- Rename the `LLVMing` variant as `Lending`, because that is a clearer
  description of what is happening.
- Rename `running` as `running_with_own_token`, which makes it clearer
  that there might be one additional LLVM thread running (with a loaned
  token). Also add a comment to its definition.
2023-07-31 16:20:18 +10:00
Nicholas Nethercote
fd017d3c17 Add some assertions.
- Thin and fat LTO can't happen together.
- `NeedsLink` and (non-allocator) `Compiled` work item results can't
  happen together.
2023-07-31 16:20:18 +10:00
Nicholas Nethercote
4f598b852c Add comments to WorkItemResult.
And rename the `Compiled` variant as `Finished`, because that name makes
it clearer there is nothing left to do, contrasting nicely with the
`Needs*` variants.
2023-07-31 16:20:18 +10:00
Nicholas Nethercote
a8c71f0a15 Inline and remove submit_pre_codegened_module_to_llvm.
It has a single callsite, and provides little value.
2023-07-31 16:20:18 +10:00
Nicholas Nethercote
2e6ce68fba Remove desugar_doc_comments arg from Parser::new().
It's only true at one call site; do the desugaring there instead.
2023-07-31 14:47:08 +10:00
Nicholas Nethercote
d72fc5ce44 Remove TokenTreeCursor::replace_prev_and_rewind.
It's no longer used.
2023-07-31 14:47:06 +10:00
Nicholas Nethercote
ff7d5ba65e Move doc comment desugaring out of TokenCursor.
`TokenCursor` currently does doc comment desugaring on the fly, if the
`desugar_doc_comment` field is set. This requires also modifying the
token stream on the fly with `replace_prev_and_rewind`.

This commit moves the doc comment desugaring out of `TokenCursor`, by
introducing a new `TokenStream::desugar_doc_comment` method. This
separation of desugaring and iterating makes the code nicer.
2023-07-31 14:47:03 +10:00
bors
3be07c1161 Auto merge of #114266 - calebzulawski:simd-bswap, r=compiler-errors
Fix simd_bswap for i8/u8

#114156 missed this test case ☹️
cc `@workingjubilee`
2023-07-31 04:43:48 +00:00
bohan
8e32dade71 parser: more friendly hints for handling async move in the 2015 edition 2023-07-31 11:04:28 +08:00
Nicholas Nethercote
c70c8b7196 No need to desugar doc comments when parsing decl macro definitions. 2023-07-31 11:21:30 +10:00
Nicholas Nethercote
a8909b059f Reflow an overlong comment. 2023-07-31 11:21:24 +10:00
Nicholas Nethercote
cfc1aa3c5d Fix a typo in a comment. 2023-07-31 11:14:39 +10:00
Nicholas Nethercote
d16b1f4a8c Remove more unnecessary return keywords. 2023-07-31 11:14:39 +10:00
Nicholas Nethercote
f8650114bd Remove an unnecessary return keyword. 2023-07-31 11:14:39 +10:00
Jubilee
126d809287
Rollup merge of #113741 - compiler-errors:rpitit-projects-to-missing-opaque, r=spastorino
Don't install default projection bound for return-position `impl Trait` in trait methods with no body

This ensures that we never try to project to an opaque type in a trait method that has no body to infer its hidden type, which means we never later call `type_of` on that opaque. This is because opaque types try to reveal their hidden type when proving auto traits.

I thought about this a lot, and I think this is a fix that's less likely to introduce other strange downstream ICEs than #113461.

Fixes #113434

r? `@spastorino`
2023-07-30 17:50:48 -07:00
Michael Goulet
6f5c51f3f4 We don't need impl_trait_in_trait_parent_fn anymore 2023-07-31 00:42:38 +00:00
Michael Goulet
0f0ab89feb Don't install default projection bound for RPITITs 2023-07-30 21:46:29 +00:00
Michael Goulet
44c8ab9f8b No need to expect RPITIT projections in opaque item bounds 2023-07-30 20:47:45 +00:00
Michael Goulet
23776619a8 Remap explicit item bounds of RPITIT's opaque back to ty::Opaque 2023-07-30 20:31:27 +00:00
Caleb Zulawski
77ed437de8 Fix simd_bswap for i8/u8 2023-07-30 15:40:32 -04:00
Matthias Krüger
4916ab5330
Rollup merge of #114258 - WaffleLapkin:reuse_in_derive_expansion, r=petrochenkov
Simplify `Span::can_be_used_for_suggestions` a little tiny bit

Just something I saw randomly.
2023-07-30 20:36:35 +02:00
Matthias Krüger
97bacad9c2
Rollup merge of #114256 - Urgau:fix-issue-114180, r=WaffleLapkin
Fix invalid suggestion for mismatched types in closure arguments

This PR fixes the invalid suggestion for mismatched types in closure arguments.

The invalid suggestion came from a wrongly created span in the parser for closure arguments that don't have a type specified. Specifically, the span in this case was the last token span, but in the case of tuples, the span represented the last parenthesis instead of the whole tuple, which is fixed by taking the more accurate span of the pattern.

There is one unfortunate downside of this fix, it worsens even more the diagnostic for mismatched types in closure args without an explicit type. This happens because there is no correct span for implied inferred type. I tried also fixing this but it's a rabbit hole.

Fixes https://github.com/rust-lang/rust/issues/114180
2023-07-30 20:36:35 +02:00
Matthias Krüger
d113b5b848
Rollup merge of #114246 - Bryanskiy:type-privacy-lints-fixes, r=petrochenkov
Weaken unnameable_types lint

`unnameable_types` lint is no longer emitted for
- associated types
- internal types

r? ``@petrochenkov``
2023-07-30 20:36:34 +02:00
Matthias Krüger
b192576036
Rollup merge of #114074 - matthiaskrgr:fmt_args_rustc_2, r=WaffleLapkin
inline format!() args from rustc_middle up to and including rustc_codegen_llvm (3)

r? `@WaffleLapkin`
2023-07-30 20:36:34 +02:00
Maybe Waffle
a3838780f2 Simplify Span::can_be_used_for_suggestions a little tiny bit 2023-07-30 15:37:39 +00:00
Urgau
8ea7e45e44 Fix invalid suggestion for mismatched types in closure arguments
The invalid suggestion came from a wrongly created span in `rustc_parse'
for closure arguments that didn't have a type specified. Specifically,
the span in this case was the last token span, but in the case of
tuples, the span represented the last parenthesis instead of the whole
tuple, which is fixed by taking the more accurate span of the pattern.
2023-07-30 17:15:55 +02:00
Matthias Krüger
a964f948d5
Rollup merge of #114068 - matthiaskrgr:fmt_args_rustc_1, r=WaffleLapkin
inline format!() args up to and including rustc_middle (2)

r? `@WaffleLapkin`
2023-07-30 14:25:09 +02:00
Matthias Krüger
427f3d3266
Rollup merge of #114018 - Enselic:multi-annotation, r=b-naber
Make `--error-format human-annotate-rs` handle multiple files

Closes #64205 which is E-help-wanted
2023-07-30 14:25:09 +02:00
Matthias Krüger
e3bf088fb5
Rollup merge of #112655 - WaffleLapkin:must_use_map_or, r=workingjubilee
Mark `map_or` as `#[must_use]`

I don't know what else to say.

r? libs
2023-07-30 14:25:08 +02:00
Matthias Krüger
3ce90b1649 inline format!() args up to and including rustc_codegen_llvm 2023-07-30 14:22:50 +02:00
Matthias Krüger
23815467a2 inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00
Bryanskiy
8203d1ddf6 Weaken unnameable_types lint 2023-07-30 14:02:21 +03:00
Maybe Waffle
90f9640528 Mark map_or as #[must_use] 2023-07-30 10:22:23 +00:00
León Orell Valerian Liehr
0ca432844c
Check lazy type aliases for well-formedness 2023-07-30 11:24:15 +02:00
fee1-dead
7b4bfd640d
Rollup merge of #114203 - fee1-dead-contrib:effects/pp-no-host, r=oli-obk
Effects: don't print `host` param in diagnostics

r? ``@oli-obk``
2023-07-30 07:13:03 +00:00
bors
fb53384c94 Auto merge of #114226 - matthiaskrgr:rollup-wxdudsm, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #114129 (Rustdoc small cleanups)
 - #114152 ([rustc][data_structures] Simplify binary_search_slice.)
 - #114222 (Mark `lazy_type_alias` as incomplete)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-30 00:41:35 +00:00
Matthias Krüger
d4926b13aa
Rollup merge of #114222 - compiler-errors:lazy-type-alias-is-incomplete, r=oli-obk
Mark `lazy_type_alias` as incomplete

This feature is very not complete: https://github.com/rust-lang/rust/issues?q=is%3Aissue+is%3Aopen+label%3AF-lazy_type_alias

r? types
2023-07-30 01:22:43 +02:00
Matthias Krüger
b8895980bc
Rollup merge of #114152 - ttsugriy:master, r=WaffleLapkin
[rustc][data_structures] Simplify binary_search_slice.

Instead of using `binary_search_by_key`, it's possible to use `partition_point` to find the lower bound. This avoids the need to locate the leftmost matching entry separately.

It's also possible to use `partition_point` to find the upper bound, so I plan to send a separate PR for your consideration.
2023-07-30 01:22:42 +02:00
Michael Goulet
744e770939 some nits, bless test 2023-07-29 21:29:03 +00:00
Michael Goulet
50d21091ee Implement assumed_wf_types for RPITITs' implementations 2023-07-29 21:19:33 +00:00
Michael Goulet
349a2372ed Take RPITITs inherit the assumed_wf_types of their parent fn 2023-07-29 21:19:33 +00:00
Erik Desjardins
55800123b7 cg_llvm: simplify llvm.masked.gather/scatter naming with opaque pointers
With opaque pointers, there's no longer a need to generate a chain
of pointer types in the intrinsic name when arguments are pointers to
pointers.
2023-07-29 16:56:27 -04:00
Erik Desjardins
cf7788d54b cg_llvm: clean up match 2023-07-29 16:32:03 -04:00
Erik Desjardins
def44c5669 cg_llvm: inline check_store 2023-07-29 16:31:53 -04:00
Erik Desjardins
1d7f728901 cg_llvm: stop identifying ADTs in LLVM IR
Now that we use opaque pointers, ADTs can no longer be recursive, so we
do not need to name them. Previously, this would be necessary if you had
a struct like

```rs
struct Foo(Box<Foo>, u64, u64);
```

which would be represented with something like

```ll
%Foo = type { %Foo*, i64, i64 }
```

which is now just

```ll
{ ptr, i64, i64 }
```
2023-07-29 16:12:27 -04:00
Michael Goulet
4b58ae0bb8 Mark lazy_type_alias as incomplete 2023-07-29 19:47:15 +00:00
bors
03a57254b5 Auto merge of #114156 - calebzulawski:simd-bswap, r=compiler-errors
Add simd_bswap, simd_bitreverse, simd_ctlz, and simd_cttz intrinsics

cc `@workingjubilee`
2023-07-29 18:51:45 +00:00
Erik Desjardins
04303cfb3a cg_ssa: remove pointee types and pointercast/bitcast-of-ptr 2023-07-29 13:18:20 -04:00
Erik Desjardins
b6540777fe cg_llvm: remove pointee types and pointercast/bitcast-of-ptr 2023-07-29 13:18:17 -04:00
bors
a04e649c09 Auto merge of #114028 - Centri3:ternary-operator, r=compiler-errors
Gracefully handle ternary operator

Fixes #112578

~~May not be the best way to do this as it doesn't check for a single `:`, so it could perhaps appear even when the actual issue is just a missing semicolon. May not be the biggest deal, though?~~

Nevermind, got it working properly now ^^
2023-07-29 16:45:29 +00:00
Georgii Rylov
5697f1620d Add wasm32-wasi-threads target + WASI threads 2023-07-29 16:37:50 +01:00
bors
4c96822796 Auto merge of #114148 - cuviper:drop-llvm-14, r=nikic
Update the minimum external LLVM to 15

With this change, we'll have stable support for LLVM 15 through 17 (pending release).
For reference, the previous increase to LLVM 14 was #107573.
2023-07-29 14:57:47 +00:00
Deadbeef
df3f9fdf5a Effects: don't print host param in diagnostics 2023-07-29 14:55:35 +00:00
Taras Tsugrii
31fadf621b [rustc][data_structures] Simplify binary_search_slice. 2023-07-29 07:22:56 -07:00
bors
f9f674f2bc Auto merge of #114150 - clubby789:improve-option-ref-suggestion, r=WaffleLapkin
Refactor + improve diagnostics for `&mut T`/`T` mismatch inside Option/Result

Follow up to #114052. This also makes the diagnostics structured + translatable.

r? `@WaffleLapkin`
2023-07-29 13:15:56 +00:00
Urgau
20a6b57106 Improve diagnostics of the invalid_reference_casting lint 2023-07-29 12:20:59 +02:00
Urgau
50a46710a9 Avoid linting on expression that are only UB with SB/TB 2023-07-29 12:20:59 +02:00
Urgau
f3dafe91ff Add support for deferred casting for the invalid_reference_casting lint 2023-07-29 12:20:59 +02:00
Urgau
345d6b816b Revert "Temporarily switch invalid_reference_casting lint to allow-by-default"
This reverts commit f25ad54a4d.
2023-07-29 12:20:59 +02:00
bors
04411507be Auto merge of #113422 - Urgau:cast_ref_to_mut-pre-beta, r=Nilstrieb
Rename and allow `cast_ref_to_mut` lint

This PR is a small subset of https://github.com/rust-lang/rust/pull/112431, that is the renaming of the lint (`cast_ref_to_mut` -> `invalid_reference_casting`).

BUT also temporarily change the default level of the lint from deny-by-default to allow-by-default until https://github.com/rust-lang/rust/pull/112431 is merged.

r? `@Nilstrieb`
2023-07-29 07:48:44 +00:00
Michael Goulet
752e6e13ad Detect trait upcasting through struct tail unsizing 2023-07-29 06:40:36 +00:00
bors
2dc661037d Auto merge of #113099 - bvanjoi:fix-112713-2, r=petrochenkov
fix(resolve): update the ambiguity glob binding as warning recursively

Fixes #47525
Fixes #56593, but `issue-56593-2.rs` is not fixed to ensure backward compatibility.
Fixes #98467
Fixes #105235
Fixes #112713

This PR had added a field called `warn_ambiguous` in `NameBinding` which is only for back compatibly reason and used for lint.

More details: https://github.com/rust-lang/rust/pull/112743

r? `@petrochenkov`
2023-07-29 06:04:41 +00:00
Michael Goulet
57407a3555 Bubble up nested goals from equation in predicates_for_object_candidate 2023-07-29 05:55:03 +00:00
bors
5ed61a4378 Auto merge of #114197 - matthiaskrgr:rollup-iluf7u4, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #113773 (Don't attempt to compute layout of type referencing error)
 - #114107 (Prevent people from assigning me as a PR reviewer)
 - #114124 (tests/ui/proc-macro/*: Migrate FIXMEs to check-pass)
 - #114171 (Fix switch-stdout test for none unix/windows platforms)
 - #114172 (Fix issue_15149 test for the SGX target)
 - #114173 (btree/map.rs: remove "Basic usage" text)
 - #114174 (doc: replace wrong punctuation mark)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-29 04:18:46 +00:00
Matthias Krüger
5dee519386
Rollup merge of #113773 - compiler-errors:err-layout-bail, r=cjgillot
Don't attempt to compute layout of type referencing error

Leads to more ICEs and strange diagnostics than are worth it.

Fixes #113760
2023-07-29 06:13:05 +02: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
Charles Lew
bca79a26d8 Update lexer emoji diagnostics to Unicode 15.0 2023-07-29 08:47:21 +08:00
bors
ca1f813cc3 Auto merge of #114181 - matthiaskrgr:rollup-14m8s7f, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #114099 (privacy: no nominal visibility for assoc fns )
 - #114128 (When flushing delayed span bugs, write to the ICE dump file even if it doesn't exist)
 - #114138 (Adjust spans correctly for fn -> method suggestion)
 - #114146 (Skip reporting item name when checking RPITIT GAT's associated type bounds hold)
 - #114147 (Insert RPITITs that were shadowed by missing ADTs that resolve to [type error])
 - #114155 (Replace a lazy `RefCell<Option<T>>` with `OnceCell<T>`)
 - #114164 (Add regression test for `--cap-lints allow` and trait bounds warning)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-28 23:53:12 +00:00
León Orell Valerian Liehr
8c390286e4
Type-check generic const items 2023-07-28 22:21:41 +02:00
León Orell Valerian Liehr
da17134be0
Resolve generic const items 2023-07-28 22:21:41 +02:00
León Orell Valerian Liehr
9213aec762
Lower generic const items to HIR 2023-07-28 22:21:40 +02:00
León Orell Valerian Liehr
afd009a8d8
Parse generic const items 2023-07-28 22:21:33 +02:00
Matthias Krüger
048794d624
Rollup merge of #114155 - Zalathar:once-cell, r=lcnr
Replace a lazy `RefCell<Option<T>>` with `OnceCell<T>`

This code was using `RefCell<Option<T>>` to manually implement lazy initialization. Now that we have `OnceCell` in the standard library, we can just use that instead.

In particular, this avoids a confusing doubly-nested option, because the value being lazily computed is itself an `Option<Symbol>`.
2023-07-28 19:51:16 +02:00
Matthias Krüger
76f0a8c30c
Rollup merge of #114147 - compiler-errors:missing-rpitits, r=spastorino
Insert RPITITs that were shadowed by missing ADTs that resolve to [type error]

Comment inline explains how this can happen.

Fixes #113903
2023-07-28 19:51:16 +02:00
Matthias Krüger
06eebbe6e7
Rollup merge of #114146 - compiler-errors:dont-report-rpitit-name, r=spastorino
Skip reporting item name when checking RPITIT GAT's associated type bounds hold

Doesn't really make sense to label an item that has a name that users can't really mention. Fixes #114145. Also fixes #113794.

r? `@spastorino`
2023-07-28 19:51:15 +02:00
Matthias Krüger
3aa8da1474
Rollup merge of #114138 - compiler-errors:bad-rcvr-span-on-method-sugg, r=estebank
Adjust spans correctly for fn -> method suggestion

Fixes #114131
2023-07-28 19:51:15 +02:00
Matthias Krüger
02f1e2ada7
Rollup merge of #114128 - estebank:delayed-span-bug-dump, r=davidtwco
When flushing delayed span bugs, write to the ICE dump file even if it doesn't exist

Fix #113881.
2023-07-28 19:51:15 +02:00
Matthias Krüger
a1fb86144d
Rollup merge of #114099 - davidtwco:issue-113860-staged-api-effective-vis-gt-nominal-vis-when-trait-method-vis, r=petrochenkov
privacy: no nominal visibility for assoc fns

Fixes #113860.

When `staged_api` is enabled, effective visibilities are computed earlier and this can trigger an ICE in some cases.

In particular, if a impl of a trait method has a visibility then an error will be reported for that, but when privacy invariants are being checked, the effective visibility will still be greater than the nominal visbility and that will trigger a `span_bug!`.

However, this invariant - that effective visibilites are limited to nominal visibility - doesn't make sense for associated functions.
2023-07-28 19:51:14 +02:00
bohan
cac0bd0bef fix(resolve): update the ambiguity glob binding as warning recursively 2023-07-29 00:19:50 +08:00
bohan
1b18e2a176 fix(resolve): report unresolved imports firstly 2023-07-29 00:14:38 +08:00
Esteban Küber
66d23793f0 Account for macros when suggesting a new let binding 2023-07-28 14:44:03 +00:00
bors
317ec04d18 Auto merge of #111780 - weiznich:diagnostic_namespace, r=petrochenkov
Diagnostic namespace

This PR implements the basic infrastructure for accepting the `#[diagnostic]` attribute tool namespace as specified in https://github.com/rust-lang/rfcs/pull/3368. Note: This RFC is not merged yet, but it seems like it will be accepted soon. I open this PR early on to get feedback on the actual implementation as soon as possible. This hopefully enables getting at least the diagnostic namespace to stable rust "soon", so that crates do not need to bump their MSRV if we stabilize actual attributes in this namespace.

 This PR only adds infrastructure accept attributes from this namespace, it does not add any specific attribute. Therefore the compiler will emit a lint warning for each attribute that's actually used. This namespace is added behind a feature flag, so it will be only available on a nightly compiler for now.

cc `@estebank` as they've supported me in planing, specifying and implementing this feature.
2023-07-28 14:18:29 +00:00
Caleb Zulawski
ce4a48f41f Use i1 instead of bool 2023-07-28 09:46:16 -04:00
David Wood
e051a32311
privacy: no nominal visibility for assoc fns
When `staged_api` is enabled, effective visibilities are computed earlier
and this can trigger an ICE in some cases.

In particular, if a impl of a trait method has a visibility then an error
will be reported for that, but when privacy invariants are being checked,
the effective visibility will still be greater than the nominal visbility
and that will trigger a `span_bug!`.

However, this invariant - that effective visibilites are limited to
nominal visibility - doesn't make sense for associated functions.

Signed-off-by: David Wood <david@davidtw.co>
2023-07-28 14:28:02 +01:00
bors
b95fd857fe Auto merge of #114119 - nnethercote:opt-TokenKind-clone, r=petrochenkov
Optimize `TokenKind::clone`.

`TokenKind` would impl `Copy` if it weren't for
`TokenKind::Interpolated`. This commit makes `clone` reflect that.

r? `@ghost`
2023-07-28 12:30:27 +00:00
Georg Semmler
5b576665e5
Introduce the #[diagnostic] attribute namespace
Co-authored-by: est31 <est31@users.noreply.github.com>

Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>

Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2023-07-28 13:28:02 +02:00
lcnr
84043589a6 dropck_outlives comments 2023-07-28 13:16:36 +02:00
lcnr
17f87c5aff fix comment 2023-07-28 13:00:54 +02:00
lcnr
f1753ff8f8 refactor builtin unsize handling, extend comments 2023-07-28 13:00:54 +02:00
bors
e4c98caffe Auto merge of #113312 - Ddystopia:auto-trait-fun, r=lcnr
discard default auto trait impls if explicit ones exist (rebase of #85048)

Rebase of #85048
2023-07-28 10:41:00 +00:00
Oleksandr Babak
37159345a7
Change the description of SUSPICIOUS_AUTO_TRAIT_IMPLS 2023-07-28 11:50:10 +02:00
bors
aafd75a9c5 Auto merge of #114134 - fee1-dead-contrib:rm-constness-from-param-env, r=oli-obk
Remove `constness` from `ParamEnv`

This should be replaced by keyword generics/effects. cc #110395

r? `@oli-obk`
2023-07-28 08:53:12 +00:00
Caleb Zulawski
4c02b4cf4c Add SIMD bitreverse, ctlz, cttz intrinsics 2023-07-27 23:53:45 -04:00
Caleb Zulawski
3ea0e6e3fb Add simd_bswap intrinsic 2023-07-27 23:04:14 -04:00
Zalathar
8745fdc448 Replace a lazy RefCell<Option<T>> with OnceCell<T> 2023-07-28 12:55:13 +10:00
bors
0699d99516 Auto merge of #114115 - nnethercote:less-token-tree-cloning, r=petrochenkov
Less `TokenTree` cloning

`TokenTreeCursor` has this comment on it:
```
// FIXME: Many uses of this can be replaced with by-reference iterator to avoid clones.
```
This PR completes that FIXME. It doesn't have much perf effect, but at least we now know that.

r? `@petrochenkov`
2023-07-28 01:21:27 +00:00
clubby789
fafc3d2d0e Handle exclusive refs in suggestion to copy/clone 2023-07-27 23:13:26 +00:00
clubby789
683b2656bf Refactor suggest_copied_cloned_or_as_ref 2023-07-27 23:13:25 +00:00
Michael Goulet
a4ac773f62 Insert RPITITs that were shadowed by missing ADTs that resolve to type error 2023-07-27 22:32:58 +00:00
Michael Goulet
bf38111ac1 tighten span slightly for synthetic item 2023-07-27 22:20:32 +00:00
Michael Goulet
0ae0643a53 Skip reporting item name when checking RPITIT GAT's associated type bounds hold 2023-07-27 22:09:44 +00:00
Josh Stone
190ded8443 Update the minimum external LLVM to 15 2023-07-27 14:07:08 -07:00
Jubilee
b457992130
Rollup merge of #114139 - Urgau:make-print-with-path-unstable, r=jackh726
Make `--print` with path unstable

https://github.com/rust-lang/rust/pull/113780 should have gone through an MCP+FCP but wasn't, but instead of reverting the original PR, this PR just make that new option unstable.

[Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202023-07-27/near/379199738)
cc `@dtolnay`
2023-07-27 13:22:07 -07:00
Michael Goulet
d45eb41c50 Dont report CTFE errors that are due to references-error layouts 2023-07-27 18:51:44 +00:00
Michael Goulet
37076c9b4e Don't attempt to compute layout of type referencing error 2023-07-27 18:24:08 +00:00
Deadbeef
b0fa2201d3 bless clippy 2023-07-27 17:56:25 +00:00
bors
0eb5efc7ae Auto merge of #113298 - tgross35:update-bless-envs, r=oli-obk
Unite bless environment variables under `RUST_BLESS`

Currently, Clippy and Miri both use an environment variable to indicate that output should be blessed, but they use different variable names. In order to improve consistency, this patch applies the following changes:

- Rename the variable `MIRI_BLESS` (as used in the Miri subtree) to `RUST_BLESS`
- Rename the variable `BLESS` (as used in the Clippy subtree) to `RUST_BLESS`
- Move emitting `RUST_BLESS` into `prepare_cargo_test` so it is always available (I need this for a WIP PR)

---

I prefer something like `RUST_BLESS` to `BLESS` just for a lower chance of conflict (not super common but other tools [do use `BLESS`](https://grep.app/search?q=%22BLESS%22&case=true&words=true&filter[lang][0]=Text&filter[lang][1]=Rust&filter[lang][2]=Python&filter[lang][3]=C%2B%2B&filter[lang][4]=Markdown&filter[lang][5]=C&filter[lang][6]=JSON)), but I can change it to whatever is preferred.

Original discussion: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/BLESS.20env.20var.3A.20rename.20to.20CLIPPY_BLESS

r? `@oli-obk`
cc `@flip1995`
2023-07-27 17:45:11 +00:00
Urgau
9268a8b060 Make --print KIND=PATH unstable
https://github.com/rust-lang/rust/pull/113780 should have gone through
an MCP+FCP but wasn't, but instead of reverting the original PR, this PR
just make that new option unstable.
2023-07-27 19:05:17 +02:00
Michael Goulet
b09091c69b Adjust spans correctly for fn -> method suggestion 2023-07-27 16:50:28 +00:00
Deadbeef
e6b423aebb Remove constness from ParamEnv 2023-07-27 15:50:42 +00:00
Esteban Küber
656213cc83 When flushing delayed span bugs, write to the ICE dump file even if it doesn't exist
Fix #113881.
2023-07-27 14:06:27 +00:00
Guillaume Gomez
218e88e5d8
Rollup merge of #114123 - oli-obk:tait_wtf, r=WaffleLapkin
Turns out opaque types can have hidden types registered during mir validation

See the newly added test's documentation for an explanation.

fixes #114121
2023-07-27 16:05:15 +02:00
Guillaume Gomez
0bebfa39cc
Rollup merge of #114117 - compiler-errors:return-to-uniq, r=lcnr
Restore region uniquification in the new solver 🎉

All of the bugs that were "due" to uniquification have been settled via other means (e.g. bidirectional alias-relate, param-env incompleteness, etc).

Firstly, revert the functional changes in #110180. 😸

Secondly, we need to ignore regions when considering if a goal has changed (the "has_changed" boolean returned from `evaluate_goal`) -- otherwise, because we're doing region uniquification, we may perpetually consider a goal to be changed. See the UI test I committed for an explanation.
2023-07-27 16:05:15 +02:00
Guillaume Gomez
f7123db888
Rollup merge of #114088 - oli-obk:syn, r=davidtwco
Bump syn dependency

r? `@davidtwco` because this affects diagnostics derive diagnostics (yes this sentence is grammatically correct)
2023-07-27 16:05:13 +02:00
bors
f239bb6bea Auto merge of #113281 - dayo05:master, r=davidtwco
Implement diagnostic translation for rustc-errors

This is my first PR to rustc yeah~

I'm going to implement diagnostic translation on rustc-errors crate.

This PR is WIP, the reason of opening this as draft, I want to show my code to prevent the issue caused by misunderstanding and also I have few questions.

Some error messages are processed by `pluralize!` macro which determines to use plural word or not. From now, I make two kinds of keys and combine with enum but I'm not sure is this best method to do it.

Is there any prefered method to do this? => This resolved on conversation on PR.

I'll remain to perform force-push until my first implementation looks good to me
2023-07-27 09:20:40 +00:00
Oli Scherer
99a9a63ca6 Turns out opaque types can have hidden types registered during mir validation 2023-07-27 08:23:06 +00:00
bors
2efa46dc15 Auto merge of #114080 - compiler-errors:negative, r=spastorino
Don't treat negative trait predicates as always knowable

We don't need this. It was added in #90104 but I don't really know why. It's not sound afaict -- negative trait predicates need the same coherence-ambiguity/orphan check rules as positive ones.

r? `@lcnr`

cc `@spastorino,` do you remember why?
2023-07-27 07:29:00 +00:00
Nicholas Nethercote
ac747a8481 Optimize TokenKind::clone.
`TokenKind` would impl `Copy` if it weren't for
`TokenKind::Interpolated`. This commit makes `clone` reflect that.
2023-07-27 15:05:23 +10:00
bors
3e11b223d7 Auto merge of #114116 - matthiaskrgr:rollup-dtdfk76, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #113872 (Tweak CGU sorting in a couple of places.)
 - #114053 (CI: fix CMake installation for 32/64 bit `dist` Linux)
 - #114075 (inline format!() args from rustc_codegen_llvm to the end (4))
 - #114081 (`desugar_doc_comments` cleanups)
 - #114082 (add stable NullaryOp)
 - #114098 (replace atty crate with std's IsTerminal)
 - #114102 (Dont pass `-Zwrite-long-types-to-disk=no` for `ui-fulldeps --stage=1`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-27 04:37:48 +00:00
Matthias Krüger
dea5b4fff3
Rollup merge of #114098 - klensy:drop-atty, r=fee1-dead
replace atty crate with std's IsTerminal
2023-07-27 06:04:15 +02:00
Matthias Krüger
17e4f80257
Rollup merge of #114082 - ericmarkmartin:smir-nullary-op, r=spastorino
add stable NullaryOp

r? `@spastorino`
2023-07-27 06:04:14 +02:00