Commit Graph

224213 Commits

Author SHA1 Message Date
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
Jubilee Young
e4cecc1ab7 Correct swizzle_dyn cfg for armv7 neon 2023-05-11 17:22:00 -07:00
Michael Goulet
14bf909e71 Note base types of coercion 2023-05-12 00:10:52 +00:00
bors
5b24e12785 Auto merge of #111395 - scottmcm:slice-iter-zst-experiment, r=the8472
Simplify the implementation of iterators over slices of ZSTs

Currently, slice iterators over ZSTs store `end = start.wrapping_byte_add(len)`.

That's slightly convenient for `is_empty`, but kinda annoying for pretty much everything else -- see bugs like #42789, for example.

This PR instead changes it to just `end = ptr::invalid(len)` instead.

That's easier to think about (IMHO, at least) as well as easier to represent.

`next` is still to big to get inlined into the mir-opt/pre-codegen/ tests, but if I bump the inline threshold to force it to show the whole thing, this implementation is also less MIR:
```
> git diff --numstat
241     370     tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.mir
255     329     tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.mir
184     216     tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.mir
182     254     tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.mir
```
(That's ≈70 lines less for `Iter::next`, for example.)

r? `@ghost`

~~Built atop #111282, so draft until that lands.~~
2023-05-11 23:26:55 +00:00
Evgeniy A. Dushistov
6b58ff5cdf Usage of atomic counters for llvm code coverage 2023-05-12 01:40:04 +03:00
clubby789
2555f3bbcf Better diagnostics for env! where variable contains escape 2023-05-11 21:41:07 +01:00
Jubilee Young
de858e7ea7 miri: Move patterns for simd tests
It isn't clear to me why these error patterns do not trigger,
but I am not going to waste time analyzing bugs in compiletest.
2023-05-11 12:15:02 -07:00
Jubilee Young
4499daac77 Bless tests for portable-simd sync
API changes resulted in subtle MIR and impl differences
2023-05-11 12:14:57 -07:00
Jubilee Young
b05d7e5bfa Sync portable-simd to 2023 May 10
Sync up to rust-lang/portable-simd@852762563a
2023-05-11 12:13:00 -07:00
Oli Scherer
9642e40076 Remove a misleading part of a function name 2023-05-11 16:41:46 +00:00
Oli Scherer
49e4c8dc0d Stop ignoring the --manifest-path 2023-05-11 16:40:42 +00:00
AngelicosPhosphoros
7c263adb2a Add support for cfg(overflow_checks)
This PR adds support for detecting if overflow checks are enabled in similar fashion as debug_assertions are detected.
Possible use-case of this, for example, if we want to use checked integer casts in builds with overflow checks, e.g.

```rust
pub fn cast(val: usize)->u16 {
    if cfg!(overflow_checks) {
        val.try_into().unwrap()
    }
    else{
        vas as _
    }
}
```

Resolves #91130.
Tracking issue: #111466.
2023-05-11 18:06:31 +04: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
Bryanskiy
670f5b134e Populate effective visibilities in rustc_privacy 2023-05-11 14:51:01 +03:00
Oli Scherer
641927f748 Add ./miri run-dep for running a file with test dependencies available 2023-05-11 10:53:16 +00: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
Urgau
f5aede9c82 Improve code around SGX waitqueue
Followed up of d36e390d81
See https://github.com/rust-lang/rust/pull/109732#issuecomment-1543574908
for more details.

Co-authored-by: Jethro Beekman <jethro@fortanix.com>
2023-05-11 11:03:07 +02:00
bors
44de0ee5c8 Auto merge of #2889 - oli-obk:ui_test, r=oli-obk
Emit the compiler flags in CI again

fixes #2886
2023-05-11 08:54:43 +00: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
Oli Scherer
3f7d620440 Emit the compiler flags again 2023-05-11 08:33:01 +00:00
Ralf Jung
b0b76a5db3 fix deny_lint test 2023-05-11 10:09:20 +02:00
WANG Rui
eadf3bb311 Update cargo 2023-05-11 14:26:42 +08: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
clubby789
a348f8aea5 Generate shell completions for bootstrap with Clap 2023-05-10 21:41:38 +01:00
Scott McMurray
15aa7fad7e Simplify the implementation of iterators over slices of ZSTs
Currently, slice iterators over ZSTs store `end = start.wrapping_byte_add(len)`.

That's slightly convenient for `is_empty`, but kinda annoying for pretty much everything else -- see bugs like 42789, for example.

This PR instead changes it to just `end = ptr::invalid(len)` instead.

That's easier to think about (IMHO, at least) as well as easier to represent.
2023-05-10 13:01:43 -07:00
Camille GILLOT
a2fe9935ea Only warn single-use lifetime when the binders match. 2023-05-10 19:49:02 +00:00
Camille GILLOT
9fb1c73a73 Avoid shadowing. 2023-05-10 19:23:01 +00:00
Camille GILLOT
aeac555578 Do not see through copies of mutable pointers. 2023-05-10 19:22:57 +00:00
Camille GILLOT
d0d4e0237f Iteratively replace pointers. 2023-05-10 19:22:54 +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
Urgau
e280df556d Add note to suggest using let _ = x to ignore the value 2023-05-10 19:36:02 +02:00
Urgau
d23f8957ae Improve warning message by saying that it "does nothing" 2023-05-10 19:36:02 +02:00
Urgau
457fa953a2 Use label instead of note to be more consistent with other lints 2023-05-10 19:36:02 +02:00
Urgau
77773ad002 Allow the drop_copy lint in some library examples 2023-05-10 19:36:02 +02:00
Urgau
61ff2718f7 Adjust tests for new drop and forget lints 2023-05-10 19:36:02 +02:00
Urgau
3f81b6b8a2 Drop uplifted clippy::forget_copy 2023-05-10 19:36:02 +02:00