Commit graph

436 commits

Author SHA1 Message Date
bors
d8d1d1059a Auto merge of #89158 - the8472:rollup-3e4ijth, r=the8472
Rollup of 12 pull requests

Successful merges:

 - #88795 (Print a note if a character literal contains a variation selector)
 - #89015 (core::ascii::escape_default: reduce struct size)
 - #89078 (Cleanup: Remove needless reference in ParentHirIterator)
 - #89086 (Stabilize `Iterator::map_while`)
 - #89096 ([bootstrap] Improve the error message when `ninja` is not found to link to installation instructions)
 - #89113 (dont `.ensure()` the `thir_abstract_const` query call in `mir_build`)
 - #89114 (Fixes a technicality regarding the size of C's `char` type)
 - #89115 (⬆️ rust-analyzer)
 - #89126 (Fix ICE when `indirect_structural_match` is allowed)
 - #89141 (Impl `Error` for `FromSecsError` without foreign type)
 - #89142 (Fix match for placeholder region)
 - #89147 (add case for checking const refs in check_const_value_eq)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-09-21 22:07:32 +00:00
the8472
8d95bb2146
Rollup merge of #89126 - FabianWolff:issue-89088, r=petrochenkov
Fix ICE when `indirect_structural_match` is allowed

Fixes #89088. The ICE is caused by `delay_good_path_bug()`, which is called (indirectly) from a `format!()` macro invocation. I have moved the macro invocation into the `decorate` closure of `struct_span_lint_hir()`, so that the macro is only invoked if the lint is not allowed (i.e., causes at least a warning, and thus prevents `delay_good_path_bug()` from firing).
2021-09-21 22:54:06 +02:00
the8472
ecfdadcef9
Rollup merge of #89113 - BoxyUwU:incr-comp-thir-act, r=lcnr
dont `.ensure()` the `thir_abstract_const` query call in `mir_build`

might fix an ICE seen in #89022 (note: this PR does not close that issue) about attempting to read stolen thir. I couldn't repro the ICE but this `.ensure` seems sus anyway.

r? `@lcnr`
2021-09-21 22:54:03 +02:00
Mark Rousskov
f338900826 Remove Drop-caused migration-added captures
All of these were added due to insignificant Drop types being present.
2021-09-20 22:21:43 -04:00
Mark Rousskov
c746be2219 Migrate to 2021 2021-09-20 22:21:42 -04:00
Fabian Wolff
402ebc72b3 Fix ICE when indirect_structural_match is allowed 2021-09-20 21:25:44 +02:00
Mark Rousskov
45b989a033 Enable 2021 compatibility lints for all in-tree code
This just applies the suggested fixes from the compatibility warnings,
leaving any that are in practice spurious in. This is primarily intended to
provide a starting point to identify possible fixes to the migrations (e.g., by
avoiding spurious warnings).

A secondary commit cleans these up where they are false positives (as is true in
many of the cases).
2021-09-20 08:45:39 -04:00
Ellen
5fdb9e4cf4 no ensure 2021-09-20 09:30:28 +01:00
Aaron Hill
a41a13f775
Add ConstraintCategory::Usage for handling aggregate construction
In some cases, we emit borrowcheck diagnostics pointing
at a particular field expression in a struct expression
(e.g. `MyStruct { field: my_expr }`). However, this
behavior currently relies on us choosing the
`ConstraintCategory::Boring` with the 'correct' span.
When adding additional variants to `ConstraintCategory`,
(or changing existing usages away from `ConstraintCategory::Boring`),
the current behavior can easily get broken, since a non-boring
constraint will get chosen over a boring one.

To make the diagnostic output less fragile, this commit
adds a `ConstraintCategory::Usage` variant. We use this variant
for the temporary assignments created for each field of
an aggregate we are constructing.

Using this new variant, we can emit a message mentioning
"this usage", emphasizing the fact that the error message
is related to the specific use site (in the struct expression).

This is preparation for additional work on improving NLL error messages
(see #57374)
2021-09-16 12:36:19 -05:00
Devin Ragotzy
33a06b73d9 Add reachable_patterns lint to rfc-2008-non_exhaustive
Add linting on non_exhaustive structs and enum variants

Add ui tests for non_exhaustive reachable lint

Rename to non_exhaustive_omitted_patterns and avoid triggering on if let
2021-09-14 15:45:13 -04:00
Manish Goregaokar
f5ac5cadd3
Rollup merge of #88709 - BoxyUwU:thir-abstract-const, r=lcnr
generic_const_exprs: use thir for abstract consts instead of mir

Changes `AbstractConst` building to use `thir` instead of `mir` so that there's less chance of consts unifying when they shouldn't because lowering to mir dropped information (see `abstract-consts-as-cast-5.rs` test)

r? `@lcnr`
2021-09-12 03:44:56 -07:00
Jubilee
c2e1097f44
Rollup merge of #88849 - matthiaskrgr:clony_on_copy, r=petrochenkov
don't clone types that are Copy (clippy::clone_on_copy)
2021-09-11 08:23:45 -07:00
bors
641e02f388 Auto merge of #88327 - bonega:scalar_refactor, r=eddyb
`WrappingRange` (#88242) follow-up (`is_full_for`, `Scalar: Copy`, etc.)

Some changes related to feedback during #88242
r? `@RalfJung`
2021-09-11 10:18:05 +00:00
Matthias Krüger
c1e96085d3 don't clone types that are Copy (clippy::clone_on_copy) 2021-09-11 10:18:56 +02:00
Fabian Wolff
79adda930f Ignore automatically derived impls of Clone and Debug in dead code analysis 2021-09-09 19:49:07 +02:00
Andreas Liljeqvist
dd34e0c966 Rename (un)signed to (un)signed_int 2021-09-09 10:41:19 +02:00
Andreas Liljeqvist
9129f4306f Move unsigned_max etc into Size again 2021-09-09 10:41:19 +02:00
Ellen
406d2ab95d rename mir -> thir around abstract consts 2021-09-09 01:32:03 +01:00
Ellen
15101c8e95 remove debug stmts 2021-09-09 01:32:03 +01:00
Ellen
08e8644016 move thir visitor to rustc_middle 2021-09-09 01:32:03 +01:00
Ellen
2987f4ba42 WIP state 2021-09-09 01:32:03 +01:00
Matthew Jasper
ad7f109bfa Change scope of temporaries in match guards
Each pattern in a match arm has its own copy of the match guard in MIR,
with its own temporary, so it has to be dropped before the the guards
are joined to the single copy of the arm.
2021-09-05 18:50:55 +01:00
Matthew Jasper
9366dfdff5 Bless 32bit MIR opt tests 2021-09-02 10:18:08 +01:00
Matthew Jasper
fd5b40fd3e Remove TODO 2021-09-02 09:21:16 +01:00
Matthew Jasper
ff8c0ef0e4 Fix drop handling for if let expressions
MIR lowering for `if let` expressions is now more complicated now that
`if let` exists in HIR. This PR adds a scope for the variables bound in
an `if let` expression and then uses an approach similar to how we
handle loops to ensure that we reliably drop the correct variables.
2021-09-01 23:47:41 +01:00
Cameron Steffen
df9a2e0687 Handle irrufutable or unreachable let-else 2021-08-30 20:18:43 -05:00
Cameron Steffen
dc028f6568 Calculate LetSource later 2021-08-30 20:18:42 -05:00
bors
3a21a5b324 Auto merge of #88088 - nbdd0121:const2, r=nagisa
Forbid inline const block referencing params from being used in patterns

Fix #82518
2021-08-29 02:21:07 +00:00
bors
d5cd3205fd Auto merge of #88371 - Manishearth:rollup-pkkjsme, r=Manishearth
Rollup of 11 pull requests

Successful merges:

 - #87832 (Fix debugger stepping behavior with `match` expressions)
 - #88123 (Make spans for tuple patterns in E0023 more precise)
 - #88215 (Reland #83738: "rustdoc: Don't load all extern crates unconditionally")
 - #88216 (Don't stabilize creation of TryReserveError instances)
 - #88270 (Handle type ascription type ops in NLL HRTB diagnostics)
 - #88289 (Fixes for LLVM change 0f45c16f2caa7c035e5c3edd40af9e0d51ad6ba7)
 - #88320 (type_implements_trait consider obligation failure on overflow)
 - #88332 (Add argument types tait tests)
 - #88340 (Add `c_size_t` and `c_ssize_t` to `std::os::raw`.)
 - #88346 (Revert "Add type of a let tait test impl trait straight in let")
 - #88348 (Add field types tait tests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-08-27 01:07:17 +00:00
lcnr
ab9108b70f update TypeFlags to deal with missing ct substs 2021-08-26 11:00:30 +02:00
lcnr
cc47998e28 add tcx to fn walk 2021-08-26 11:00:30 +02:00
lcnr
bfaf13af4e make unevaluated const substs optional 2021-08-26 11:00:30 +02:00
Wesley Wiser
0a42dfc2fa Fix debugger stepping behavior around match expressions
Previously, we would set up the source lines for `match` expressions so
that the code generated to perform the test of the scrutinee was matched
to the line of the arm that required the test and then jump from the arm
block to the "next" block was matched to all of the lines in the `match`
expression.

While that makes sense, it has the side effect of causing strange
stepping behavior in debuggers.

I've changed the source information so that all of the generated tests
are sourced to `match {scrutinee}` and the jumps are sourced to the last
line of the block they are inside. This resolves the weird stepping
behavior in all debuggers and resolves some instances of "ambiguous
symbol" errors in WinDbg preventing the user from setting breakpoints at
`match` expressions.
2021-08-25 15:17:22 -04:00
Frank Steffahn
2f9ddf3bc7 Fix typos “an”→“a” and a few different ones that appeared in the same search 2021-08-22 18:15:49 +02:00
Frank Steffahn
2396fad095 Fix more “a”/“an” typos 2021-08-22 17:27:18 +02:00
Frank Steffahn
bf88b113ea Fix typos “a”→“an” 2021-08-22 15:35:11 +02:00
bors
7611fe438d Auto merge of #88039 - sexxi-goose:fix-87987, r=nikomatsakis
RFC2229 Only compute place if upvars can be resolved

Closes https://github.com/rust-lang/rust/issues/87987

This PR fixes an ICE when trying to unwrap an Err. This error appears when trying to convert a PlaceBuilder into Place when upvars can't yet be resolved. We should only try to convert a PlaceBuilder into Place if upvars can be resolved.

r? `@nikomatsakis`
2021-08-20 02:19:58 +00:00
est31
8b0b7ef812 Remove box syntax from rustc_mir_build 2021-08-18 09:25:26 +02:00
Gary Guo
53a7cdd9a3 Forbid inline const block referencing params from being used in patterns 2021-08-16 19:33:47 +01:00
Caio
6aa9937a76 Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
Matthew Jasper
2d9f2eae84 Use correct drop scopes for if expressions 2021-08-15 16:05:25 -03:00
Roxane
9c32b5b3ba Only compute place if upvars can be resolved 2021-08-14 21:00:58 -04:00
bors
99efc51dae Auto merge of #85020 - lrh2000:named-upvars, r=tmandry
Name the captured upvars for closures/generators in debuginfo

Previously, debuggers print closures as something like
```
y::main::closure-0 (0x7fffffffdd34)
```
The pointer actually references to an upvar. It is not very obvious, especially for beginners.

It's because upvars don't have names before, as they are packed into a tuple. This PR names the upvars, so we can expect to see something like
```
y::main::closure-0 {_captured_ref__b: 0x[...]}
```

r? `@tmandry`
Discussed at https://github.com/rust-lang/rust/pull/84752#issuecomment-831639489 .
2021-08-14 07:01:36 +00:00
bors
61a941b8ba Auto merge of #87737 - LeSeulArtichaut:unsafeck-less-freeze, r=oli-obk
Only compute `is_freeze` for layout-constrained ADTs

Places are usually shallow and quick to visit. By contrast, computing `is_freeze` can be much costlier, involving inference and trait solving. Making sure to call `is_freeze` only when necessary should be beneficial for performance in most cases.

See [this comparison](https://perf.rust-lang.org/compare.html?start=81f08a4763e7537b92506fa5a597e6bf774d20cc&end=56a58d347b1c7dd0c2984b8fc3930c408e26fbc2&stat=instructions%3Au) from #87710.

r? `@oli-obk`
2021-08-05 14:45:09 +00:00
Léo Lanteri Thauvin
2b169ccc96 Only compute is_freeze for layout-constrained ADTs
Places are usually shallow and quick to visit. By contrast, computing
`is_freeze` can be much costlier, involving inference and trait
solving. Making sure to call `is_freeze` only when necessary should be
beneficial for performance in most cases.
2021-08-03 22:04:37 +02:00
Alex Crichton
1c07096a45 rustc: Fill out remaining parts of C-unwind ABI
This commit intends to fill out some of the remaining pieces of the
C-unwind ABI. This has a number of other changes with it though to move
this design space forward a bit. Notably contained within here is:

* On `panic=unwind`, the `extern "C"` ABI is now considered as "may
  unwind". This fixes a longstanding soundness issue where if you
  `panic!()` in an `extern "C"` function defined in Rust that's actually
  UB because the LLVM representation for the function has the `nounwind`
  attribute, but then you unwind.

* Whether or not a function unwinds now mainly considers the ABI of the
  function instead of first checking the panic strategy. This fixes a
  miscompile of `extern "C-unwind"` with `panic=abort` because that ABI
  can still unwind.

* The aborting stub for non-unwinding ABIs with `panic=unwind` has been
  reimplemented. Previously this was done as a small tweak during MIR
  generation, but this has been moved to a separate and dedicated MIR
  pass. This new pass will, for appropriate functions and function
  calls, insert a `cleanup` landing pad for any function call that may
  unwind within a function that is itself not allowed to unwind. Note
  that this subtly changes some behavior from before where previously on
  an unwind which was caught-to-abort it would run active destructors in
  the function, and now it simply immediately aborts the process.

* The `#[unwind]` attribute has been removed and all users in tests and
  such are now using `C-unwind` and `#![feature(c_unwind)]`.

I think this is largely the last piece of the RFC to implement.
Unfortunately I believe this is still not stabilizable as-is because
activating the feature gate changes the behavior of the existing `extern
"C"` ABI in a way that has no replacement. My thinking for how to enable
this is that we add support for the `C-unwind` ABI on stable Rust first,
and then after it hits stable we change the behavior of the `C` ABI.
That way anyone straddling stable/beta/nightly can switch to `C-unwind`
safely.
2021-08-03 07:06:19 -07:00
Yuki Okushi
345862d224
Rollup merge of #87645 - LeSeulArtichaut:issue-87414, r=oli-obk
Properly find owner of closure in THIR unsafeck

Previously, when encountering a closure in a constant, the THIR unsafeck gets invoked on the owner of the constant instead of the constant itself, producing cycles.
Supersedes #87492. ```@FabianWolff``` thanks for your work on that PR, I copied your test file and added you as a co-author.

Fixes #87414.
r? ```@oli-obk```
2021-08-03 19:07:43 +09:00
LeSeulArtichaut
12804230a2 Properly find owner of closure in THIR unsafeck
Co-authored-by: FabianWolff <fabian.wolff@alumni.ethz.ch>
2021-07-30 19:05:34 +02:00
Jade
3cf820e17d rfc3052: Remove authors field from Cargo manifests
Since RFC 3052 soft deprecated the authors field anyway, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information, we should remove it from
crates in this repo.
2021-07-29 14:56:05 -07:00
bors
eba3228b2a Auto merge of #86251 - Smittyvb:thir-tree-again, r=oli-obk
Support -Z unpretty=thir-tree again

Currently `-Z unpretty=thir-tree` is broken after some THIR refactorings. This re-implements it, making it easier to debug THIR-related issues.

We have to do analyzes before getting the THIR, since trying to create THIR from invalid HIR can ICE. But doing those analyzes requires the THIR to be built and stolen. We work around this by creating a separate query to construct the THIR tree string representation.

Closes https://github.com/rust-lang/project-thir-unsafeck/issues/8, fixes #85552.
2021-07-28 09:01:11 +00:00