Commit Graph

223968 Commits

Author SHA1 Message Date
Michael Goulet
6641b49cdd
Rollup merge of #111460 - clubby789:lowercase-box-self, r=compiler-errors
Improve suggestion for `self: Box<self>`

Fixes #110642
2023-05-11 17:43:09 -07:00
Michael Goulet
eead6f4703
Rollup merge of #111459 - GuillaumeGomez:update-browser-ui-test, r=notriddle
Update browser-ui-test version to 0.16.0

This new version brings one major improvement: it allows to use the original color format in checks (I plan to slowly continue converting colors back to their "original" format, ie the one used in CSS).

It also provides some improvements in some commands API.

r? `````@notriddle`````
2023-05-11 17:43:09 -07:00
Michael Goulet
7c31df9d6c
Rollup merge of #111444 - cjgillot:issue-111400, r=oli-obk
Only warn single-use lifetime when the binders match.

Fixes https://github.com/rust-lang/rust/issues/111400
2023-05-11 17:43:08 -07:00
Michael Goulet
d4d15e8a74
Rollup merge of #111439 - uweigand:backtrace-normalize, r=compiler-errors
Fix backtrace normalization in ice-bug-report-url.rs

This test case currently fails on s390x, and probably other platforms where the last line of a backtrace does not contain and " at <source location>" specification.

The problem with the existing normalization lines
// normalize-stderr-test "\s*\d{1,}: .*\n" -> ""
// normalize-stderr-test "\s at .*\n" -> ""
is that \s matches all whitespace, including newlines, so the first (but not second) of these regexes may merge multiple lines.  Thus the output differs depending on which of these matches on the last line of a backtrace.

As the whitespace used in backtraces is just normal space characters, change both regexes to just match at least one space character instead:
// normalize-stderr-test " +\d{1,}: .*\n" -> ""
// normalize-stderr-test " + at .*\n" -> ""
2023-05-11 17:43:08 -07:00
Michael Goulet
691a5f3883
Rollup merge of #111375 - rcvalle:rust-cfi-fix-106547, r=bjorn3
CFI: Fix SIGILL reached via trait objects

Fix #106547 by transforming the concrete self into a reference to a trait object before emitting type metadata identifiers for trait methods.
2023-05-11 17:43:07 -07:00
Michael Goulet
41ab8e6b87
Rollup merge of #111366 - obeis:ascribe-user-type-variance, r=lcnr
Make `NonUseContext::AscribeUserTy` carry `ty::Variance`

Close #108267
2023-05-11 17:43:07 -07:00
Michael Goulet
341d6dfba5
Rollup merge of #106038 - aliemjay:opaque-implied, r=lcnr
use implied bounds when checking opaque types

During opaque type inference, we check for the well-formedness of the hidden type in the opaque type's own environment, not the one of the defining site, which are different in the case of TAIT.

However in the case of associated-type-impl-trait, we don't use implied bounds from the impl header. This caused us to reject the following:
```rust
trait Service<Req> {
    type Output;
    fn call(req: Req) -> Self::Output;
}

impl<'a, Req> Service<&'a Req> for u8 {
    type Output= impl Sized; // we can't prove WF of hidden type  `WF(&'a Req)` although it's implied by the impl
    //~^ ERROR type parameter Req doesn't live long enough
    fn call(req: &'a Req) -> Self::Output {
        req
    }
}
```

although adding an explicit bound would make it pass:
```diff
- impl<'a, Req> Service<&'a Req> for u8 {
+ impl<'a, Req> Service<&'a Req> for u8  where Req: 'a, {
```

I believe it should pass as we already allow the concrete type to be used:
```diff
impl<'a, Req> Service<&'a Req> for u8 {
-    type Output= impl Sized;
+    type Output= &'a Req;
```

Fixes #95922

Builds on #105982

cc ``@lcnr`` (because implied bounds)

r? ``@oli-obk``
2023-05-11 17:43:06 -07:00
clubby789
3851a4bb91 Improve error for self: Box<self> 2023-05-11 13:21:10 +01:00
bors
2a8221dbdf Auto merge of #111454 - RalfJung:miri, r=RalfJung
update Miri

r? `@ghost`
2023-05-11 12:13:04 +00:00
Ulrich Weigand
cac7e42b52 Fix backtrace normalization in ice-bug-report-url.rs
This test case currently fails on s390x, and probably other
platforms where the last line of a backtrace does not contain
and " at <source location>" specification.

The problem with the existing normalization lines
// normalize-stderr-test "\s*\d{1,}: .*\n" -> ""
// normalize-stderr-test "\s at .*\n" -> ""
is that \s matches all whitespace, including newlines, so the
first (but not second) of these regexes may merge multiple
lines.  Thus the output differs depending on which of these
matches on the last line of a backtrace.

As the whitespace used in backtraces is just normal space
characters, change both regexes to just match at least one
space character instead:
// normalize-stderr-test " +\d{1,}: .*\n" -> ""
// normalize-stderr-test " + at .*\n" -> ""
2023-05-11 13:59:38 +02:00
Guillaume Gomez
8e55400ec9 Convert some GUI tests color checks to use original format 2023-05-11 11:49:16 +02:00
Guillaume Gomez
0630283e9d Migrate to 0.16.0 browser-ui-test version 2023-05-11 11:34:22 +02:00
Guillaume Gomez
616fb42098 Update browser-ui-test version to 0.16.0 2023-05-11 11:34:22 +02:00
bors
f8d8ffa2eb Auto merge of #111029 - Nilstrieb:when-the-errs-are-too-big, r=petrochenkov
Shrink `SelectionError` a lot

`SelectionError` used to be 80 bytes (on 64 bit). That's quite big. Especially because the selection cache contained `Result<_, SelectionError>. The Ok type is only 32 bytes, so the 80 bytes significantly inflate the size of the cache.

Most variants of the `SelectionError` seem to be hard errors, only `Unimplemented` shows up in practice (for cranelift-codegen, it occupies 23.4% of all cache entries). We can just box away the biggest variant, `OutputTypeParameterMismatch`, to get the size down to 16 bytes, well within the size of the Ok type inside the cache.
2023-05-11 08:43:38 +00:00
Ralf Jung
b0b76a5db3 fix deny_lint test 2023-05-11 10:09:20 +02:00
Ralf Jung
2c88ee8e45 update lockfile 2023-05-11 08:05:07 +02:00
bors
4d941cd981 Auto merge of #111452 - matthiaskrgr:rollup-uic8dgy, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #108705 (Prevent ICE with broken borrow in closure)
 - #111292 (Fix mishandled `--check-cfg` arguments order)
 - #111382 (Isolate coverage FFI type layouts from their underlying LLVM C++ types)
 - #111385 (vec-shrink-panik: update expectations to work on LLVM 17)
 - #111389 (Add esp-idf platform-support page)
 - #111432 (Use visit_assign to detect SSA locals.)
 - #111448 (Use proper impl self type for alias impl in rustdoc)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-11 05:06:09 +00:00
Matthias Krüger
07af55edd4
Rollup merge of #111448 - compiler-errors:rustdoc-alias-impl, r=notriddle
Use proper impl self type for alias impl in rustdoc

We don't want to use `type_of(type_alias)`, we want to use `type_of(impl)` -- this will give us the self type of the impl *properly substituted* in the case that it's an alias.

Fixes #111420
2023-05-11 07:05:29 +02:00
Matthias Krüger
968911dbc0
Rollup merge of #111432 - cjgillot:issue-111426, r=oli-obk
Use visit_assign to detect SSA locals.

I screwed up the logic in 3c43b61b87.

Fixes https://github.com/rust-lang/rust/issues/111426
2023-05-11 07:05:29 +02:00
Matthias Krüger
3b7c02b769
Rollup merge of #111389 - esp-rs:esp-idf-platform-support, r=jyn514
Add esp-idf platform-support page

As mentioned in https://github.com/rust-lang/rust/pull/111369#issuecomment-1539881848, the initial PR for esp-idf didn't include a platform support document which is required for the merge of  https://github.com/rust-lang/rust/pull/111369.
2023-05-11 07:05:28 +02:00
Matthias Krüger
acae72e493
Rollup merge of #111385 - durin42:vec-panik-17, r=Amanieu
vec-shrink-panik: update expectations to work on LLVM 17

For some reason, the called function is `cleanup` on LLVM 17 instead of `filter`.

r? `@Amanieu`
2023-05-11 07:05:28 +02:00
Matthias Krüger
39761b0cf9
Rollup merge of #111382 - Zalathar:ffi, r=cuviper
Isolate coverage FFI type layouts from their underlying LLVM C++ types

I noticed that several of the types used to send coverage information through FFI are not properly isolated from the layout of their corresponding C++ types in the LLVM API.

This PR adds more explicitly-defined FFI struct/enum types in `CoverageMappingWrapper.cpp`, so that Rust source files in `rustc_codegen_ssa` and `rustc_codegen_llvm` aren't directly exposed to LLVM C++ types.
2023-05-11 07:05:27 +02:00
Matthias Krüger
aa9adf457b
Rollup merge of #111292 - Urgau:check-cfg-issue-111291, r=petrochenkov
Fix mishandled `--check-cfg` arguments order

This PR fixes a bug in `--check-cfg` where the order of `--check-cfg=names(a)` and `--check-cfg=values(a,…)` would trip the compiler.

Fixes https://github.com/rust-lang/rust/issues/111291
cc `@taiki-e` `@petrochenkov`
2023-05-11 07:05:27 +02:00
Matthias Krüger
40d933a19a
Rollup merge of #108705 - clubby789:refutable-let-closure-borrow, r=cjgillot
Prevent ICE with broken borrow in closure

r? `@Nilstrieb`
Fixes #108683

This solution isn't ideal, I'm hoping to find a way to continue compilation without ICEing.
2023-05-11 07:05:26 +02:00
Michael Goulet
6509c42d16 Use proper impl self type for alias impl in rustdoc 2023-05-10 22:49:05 +00:00
bors
9a767b6b9e Auto merge of #110820 - cjgillot:faster-dcp, r=oli-obk
Optimize dataflow-const-prop place-tracking infra

Optimization opportunities found while investigating https://github.com/rust-lang/rust/pull/110719

Computing places breadth-first ensures that we create short projections before deep projections, since the former are more likely to be propagated.

The most relevant is the pre-computation of flooded places. Callgrind showed `flood_*` methods and especially `preorder_preinvoke` were especially hot. This PR attempts to pre-compute the set of `ValueIndex` that `preorder_invoke` would visit.

Using this information, we make some `PlaceIndex` inaccessible when they contain no `ValueIndex`, allowing to skip computations for those places.

cc `@jachris` as original author
2023-05-10 20:54:31 +00:00
Camille GILLOT
a2fe9935ea Only warn single-use lifetime when the binders match. 2023-05-10 19:49:02 +00:00
bors
d2ea42fad3 Auto merge of #2879 - saethlin:measureme, r=RalfJung
Include the current Crate name in the measureme output name

See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/measureme.20flamegraph.20panics/near/356367013
cc `@andjo403`

Currently, attempting to use `MIRIFLAGS=-Zmiri-measureme=miri cargo miri test` on a crate with multiple test targets (which is very common) will produce a corrupted measureme output file, because the various interpreter processes will stomp each other's output.

This change does not entirely prevent this, but the various test targets seem to always have different crate names, so if nothing else this will make the broken measureme files much harder to encounter by accident, while also making it clear what they are all for.
2023-05-10 19:03:17 +00:00
Ben Kimock
f9a4213968 Explain the padding 2023-05-10 13:27:31 -04:00
Camille GILLOT
6ad0497cc0 Use visit_assign to detect SSA locals. 2023-05-10 15:26:51 +00:00
Augie Fackler
fbe479558c vec-shrink-panik: update expectations to work on LLVM 17
For some reason, the called function is `cleanup` on LLVM 17 instead of
`filter`.

r? @Amanieu
2023-05-10 09:31:33 -04:00
bors
cba14074bb Auto merge of #111401 - ChrisDenton:no-windows-allowed, r=workingjubilee
Don't force include Windows goop when documenting

Why do we need to include all the windows bits on non-windows platforms? Let's try not doing that.

Possible alternative to #111394, if it works.
2023-05-10 10:28:38 +00:00
bors
7a41eacf17 Auto merge of #2885 - RalfJung:rustup, r=RalfJung
Rustup
2023-05-10 07:39:31 +00:00
Ralf Jung
68c7d2083f disable opt-level 4 tests for now 2023-05-10 09:39:13 +02:00
Obei Sideg
2198faeee2 Make NonUseContext::AscribeUserTy carry ty::Variance 2023-05-10 09:54:56 +03:00
bors
25444e5a2e Auto merge of #111414 - matthiaskrgr:rollup-q0qoc47, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #110673 (Make alias bounds sound in the new solver (take 2))
 - #110747 (Encode types in SMIR)
 - #111095 (Correctly handle associated items of a trait inside a `#[doc(hidden)]` item)
 - #111381 (Keep encoding attributes for closures)
 - #111408 (Fix incorrect implication of transmuting slices)
 - #111410 (Switch to `EarlyBinder` for `thir_abstract_const` query)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-10 06:53:47 +00:00
Ralf Jung
96491a9c57 fmt 2023-05-10 08:53:06 +02:00
Ralf Jung
efa68d02d2 Merge from rustc 2023-05-10 08:31:30 +02:00
Ralf Jung
53801d3f08 Preparing for merge from rustc 2023-05-10 08:31:22 +02:00
bors
7fb4332ce4 Auto merge of #2865 - Vanille-N:tb-perf, r=RalfJung
Thorough merge after GC: fix of #2863

Context: #2863.

`perf report`s of `MIRIFLAGS=-Zmiri-tree-borrows cargo +miri miri test test_invalid_name_lengths` in crate `http`:

### Pre
```
  91.06%  rustc    miri                                 [.] miri::borrow_tracker::tree_borrows::tree::Tree::keep_only_needed
   2.99%  rustc    miri                                 [.] miri::borrow_tracker::tree_borrows::tree::TreeVisitor::traverse_parents_this
   0.91%  rustc    miri                                 [.] miri::borrow_tracker::tree_borrows::tree::Tree::perform_access
   0.62%  rustc    miri                                 [.] miri::range_map::RangeMap<T>::iter_mut
   0.17%  rustc    libc.so.6                            [.] realloc
   0.14%  rustc    miri                                 [.] miri::concurrency:🧵:EvalContextExt::run_threads
   0.13%  rustc    miri                                 [.] rustc_const_eval::interpret::operand::<impl rustc_const_eval::interpret::eva
   0.13%  rustc    miri                                 [.] hashbrown::raw::RawTable<T,A>::remove_entry
   0.10%  rustc    miri                                 [.] miri::intptrcast::GlobalStateInner::alloc_base_addr
   0.08%  rustc    librustc_driver-c82c1dc22c817a10.so  [.] <rustc_middle::mir::Body>::source_info
```
Interrupted after 3min 30s.

### Post
```
  20.75%  rustc    miri                                 [.] miri::borrow_tracker::tree_borrows::tree::TreeVisitor::traverse_parents_this
  18.50%  rustc    miri                                 [.] miri::borrow_tracker::tree_borrows::tree::Tree::keep_only_needed
   6.49%  rustc    miri                                 [.] miri::borrow_tracker::tree_borrows::tree::Tree::perform_access
   4.25%  rustc    miri                                 [.] miri::range_map::RangeMap<T>::iter_mut
   1.91%  rustc    libc.so.6                            [.] realloc
   1.79%  rustc    miri                                 [.] miri::concurrency:🧵:EvalContextExt::run_threads
   1.40%  rustc    miri                                 [.] rustc_const_eval::interpret::operand::<impl rustc_const_eval::interpret::eva
   1.40%  rustc    miri                                 [.] miri::range_map::RangeMap<T>::merge_adjacent_thorough
   1.34%  rustc    miri                                 [.] miri::intptrcast::GlobalStateInner::alloc_base_addr
   0.90%  rustc    librustc_driver-c82c1dc22c817a10.so  [.] <rustc_middle::ty::context::CtxtInterners>::intern_ty
```
Terminates after 1min 13s.

No significant changes to `./miri bench` in either direction: on small benches not enough garbage accumulates for this to be relevant.
2023-05-10 06:30:26 +00:00
Matthias Krüger
70d5bf7fae
Rollup merge of #111410 - kylematsuda:earlybinder-abstract-const, r=BoxyUwU
Switch to `EarlyBinder` for `thir_abstract_const` query

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

This PR adds `EarlyBinder` to the return type of the `thir_abstract_const` query and removes `bound_abstract_const`.

r? `@compiler-errors`
2023-05-10 06:12:15 +02:00
Matthias Krüger
f60a174c2d
Rollup merge of #111408 - TomMD:patch-1, r=workingjubilee
Fix incorrect implication of transmuting slices

transmute<&[u8]> would be useful and as a beginner it is confusing to see documents casually confuse the types of &[u8] and [u8; SZ]
2023-05-10 06:12:15 +02:00
Matthias Krüger
3d4d6703a9
Rollup merge of #111381 - oli-obk:closure_attr, r=petrochenkov
Keep encoding attributes for closures

see https://github.com/model-checking/kani/pull/2406#issuecomment-1539630332 for some context.

We stopped encoding attributes for closures, but some tools need them
2023-05-10 06:12:14 +02:00
Matthias Krüger
d117b41409
Rollup merge of #111095 - GuillaumeGomez:fix-assoc-item-trait-inside-hidden, r=notriddle
Correctly handle associated items of a trait inside a `#[doc(hidden)]` item

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

cc `@compiler-errors`
r? `@notriddle`
2023-05-10 06:12:14 +02:00
Matthias Krüger
f1922275b7
Rollup merge of #110747 - oli-obk:smirty, r=spastorino
Encode types in SMIR

The first commit makes sure we can actually store a Ty<'tcx> (with the lifetime) in the thread local and get it back out. The second commit then introduces types.

r? `@spastorino`
2023-05-10 06:12:13 +02:00
Matthias Krüger
c14d912cd2
Rollup merge of #110673 - compiler-errors:alias-bounds-2, r=lcnr
Make alias bounds sound in the new solver (take 2)

Make alias bounds sound in the new solver (in a way that does not require coinduction) by only considering them for projection types whose corresponding trait refs come from a param-env candidate.

That is, given `<T as Trait>::Assoc: Bound`, we only *really* need to consider the alias bound if `T: Trait` is satisfied via a param-env candidate. If it's instead satisfied, e.g., via an user provided impl candidate or a , then that impl should have a concrete type to which we could otherwise normalize `<T as Trait>::Assoc`, and that concrete type is then responsible to prove the `Bound` on it.

Similar consideration is given to opaque types, since we only need to consider alias bounds if we're *not* in reveal-all mode, since similarly we'd be able to reveal the opaque types and prove any bounds that way.

This does not remove that hacky "eager projection replacement" logic from object bounds, which are somewhat like alias bounds. But removing this eager normalization behavior (added in #108333) would require full coinduction to be enabled. Compare to #110628, which does remove this object-bound custom logic but requires coinduction to be sound.

r? `@lcnr`
2023-05-10 06:12:13 +02:00
bors
63fc57b98e Auto merge of #106560 - bjorn3:support_staticlib_dylib_linking, r=pnkfelix
Support linking to rust dylib with --crate-type staticlib

This allows for example dynamically linking libstd, while statically linking the user crate into an executable or C dynamic library. For this two unstable flags (`-Z staticlib-allow-rdylib-deps` and `-Z staticlib-prefer-dynamic`) are introduced. Without the former you get an error. The latter is the equivalent to `-C prefer-dynamic` for the staticlib crate type to indicate that dynamically linking is preferred when both options are available, like for libstd. Care must be taken to ensure that no crate ends up being merged into two distinct staticlibs that are linked together. Doing so will cause a linker error at best and undefined behavior at worst. In addition two distinct staticlibs compiled by different rustc may not be combined under any circumstances due to some rustc private symbols not being mangled.

To successfully link a staticlib, `--print native-static-libs` can be used while compiling to ask rustc for the linker flags necessary when linking the staticlib. This is an existing flag which previously only listed native libraries. It has been extended to list rust dylibs too. Trying to locate libstd yourself to link against it is not supported and may break if for example the libstd of multiple rustc versions are put in the same directory.

For an example on how to use this see the `src/test/run-make-fulldeps/staticlib-dylib-linkage/` test.
2023-05-10 03:40:40 +00:00
bors
65dfca8488 Auto merge of #111409 - weihanglo:update-cargo, r=weihanglo
Update cargo

10 commits in 569b648b5831ae8a515e90c80843a5287c3304ef..26b73d15a68fb94579f6d3590585ec0e9d81d3d5
2023-05-05 15:49:44 +0000 to 2023-05-09 20:28:03 +0000
- Update the semver-check script to be able to run in any directory. (rust-lang/cargo#12117)
- Semver: Note that it is not a breaking change to make an unsafe function safe (rust-lang/cargo#12116)
- Add more documentation for artifact-dependencies. (rust-lang/cargo#12110)
- changelog: move registry query fixes to the right place (rust-lang/cargo#12086)
- Disallow RUSTUP_TOOLCHAIN in the [env] table. (rust-lang/cargo#12107)
- Disallow RUSTUP_HOME in the [env] table. (rust-lang/cargo#12101)
- Fix redacting tokens in http debug. (rust-lang/cargo#12095)
- Fix self_signed_should_fail for macOS. (rust-lang/cargo#12097)
- Update git2 (rust-lang/cargo#12096)
- do not try an exponential number of package names (rust-lang/cargo#12083)

r? `@ghost`
2023-05-10 00:41:09 +00:00
Ben Kimock
9f1624a22d Amend the docs for -Zmiri-measureme 2023-05-09 20:34:16 -04:00
Ben Kimock
c3e7ff4609 Adopt the measureme output naming strategy from rustc 2023-05-09 20:34:16 -04:00