Ralf Jung
fa2aa1cedb
interpret: move type_name implementation to an interpreter-independent helper file
2022-10-31 11:04:03 +01:00
Dylan DPC
c1c2922aa1
Rollup merge of #103603 - camsteffen:refactor-lang, r=oli-obk
...
Lang item cleanups
Various cleanups related to lang items.
2022-10-31 14:52:56 +05:30
Sarthak Singh
8609364480
All verbosity checks in PrettyPrinter
now go through PrettyPrinter::should_print_verbose
2022-10-30 20:37:43 +05:30
Cameron Steffen
a6180ede5c
Simplify lang item groups
2022-10-29 16:04:10 -05:00
Ralf Jung
d366471e58
interpret: fix align_of_val on packed types
2022-10-29 15:58:32 +02:00
Guillaume Gomez
2414a4c31a
Rollup merge of #103625 - WaffleLapkin:no_tyctxt_dogs_allowed, r=compiler-errors
...
Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functions
Functions in answer:
- `Ty::is_freeze`
- `Ty::is_sized`
- `Ty::is_unpin`
- `Ty::is_copy_modulo_regions`
This allows to remove a lot of useless `.at(DUMMY_SP)`, making the code a bit nicer :3
r? `@compiler-errors`
2022-10-29 14:18:03 +02:00
bors
5237c4d83d
Auto merge of #102674 - CastilloDel:master, r=oli-obk
...
Remove allow(rustc::potential_query_instability) in rustc_const_eval
The use of FxHashMap has been replaced with FxIndexMap.
Related to #84447
2022-10-28 12:52:17 +00:00
Maybe Waffle
a17ccfa621
Accept TyCtxt
instead of TyCtxtAt
in Ty::is_*
functions
...
Functions in answer:
- `Ty::is_freeze`
- `Ty::is_sized`
- `Ty::is_unpin`
- `Ty::is_copy_modulo_regions`
2022-10-27 15:06:08 +04:00
bors
0a6b941df3
Auto merge of #103572 - Dylan-DPC:rollup-a8bnxrw, r=Dylan-DPC
...
Rollup of 6 pull requests
Successful merges:
- #95710 (Stabilize arbitrary_enum_discriminant, take 2)
- #102706 (Support excluding the generation of the standalone docs)
- #103428 (Removed verbose printing from the `PrettyPrinter` when printing constants)
- #103543 (Update books)
- #103546 (interpret: a bit of cast cleanup)
- #103554 (rustdoc: add visible focus outline to rustdoc-toggle)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-26 14:12:16 +00:00
Dylan DPC
709462bfe1
Rollup merge of #103546 - RalfJung:cast, r=oli-obk
...
interpret: a bit of cast cleanup
r? `@oli-obk`
2022-10-26 17:32:55 +05:30
Dylan DPC
ffde0f722e
Rollup merge of #103428 - SarthakSingh31:issue-94187, r=compiler-errors
...
Removed verbose printing from the `PrettyPrinter` when printing constants
Partially solves #94187 by completing the first step described in [this comment](https://github.com/rust-lang/rust/issues/94187#issuecomment-1282339909 ).
2022-10-26 17:32:54 +05:30
bors
43dd3d514b
Auto merge of #103284 - compiler-errors:const-sad, r=oli-obk
...
Revert "Unify tcx.constness and param env constness checks"
Too much of a perf regression https://github.com/rust-lang/rust/pull/102975#issuecomment-1282702513 , and an attempt in #103263 didn't fix it except for just a tiny bit.
This change isn't really needed (see https://github.com/rust-lang/rust/pull/102830#issuecomment-1272514096 ), so this should be an easy revert.
2022-10-26 11:29:15 +00:00
bors
629a414d7b
Auto merge of #103562 - Dylan-DPC:rollup-sheepp5, r=Dylan-DPC
...
Rollup of 10 pull requests
Successful merges:
- #102951 (suggest type annotation for local statement initialed by ref expression)
- #103209 (Diagnostic derives: allow specifying multiple alternative suggestions)
- #103287 (Use a faster allocation size check in slice::from_raw_parts)
- #103416 (Name the `impl Trait` in region bound suggestions)
- #103430 (Workaround unstable stmt_expr_attributes for method receiver expressions)
- #103444 (Remove extra type error after missing semicolon error)
- #103520 (rustc_middle: Rearrange resolver outputs structures slightly)
- #103533 (Use &self instead of &mut self for cast methods)
- #103536 (Remove `rustc_driver::set_sigpipe_handler()`)
- #103542 (Pinning tests for some `macro_rules!` errors discussed in the lang meeting)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-26 07:58:28 +00:00
Dylan DPC
39e0e2cc24
Rollup merge of #103533 - jachris:cast-without-mut, r=oli-obk
...
Use &self instead of &mut self for cast methods
r? ``@oli-obk``
2022-10-26 11:29:56 +05:30
bors
d49e7e7fa1
Auto merge of #103279 - compiler-errors:normalize-hack-back, r=lcnr
...
Add eval hack in `super_relate_consts` back
Partially reverts 01adb7e98d
.
This extra eval call *still* needs to happen, for example, in `normalize_param_env_or_error` when a param-env predicate has an unnormalized constant, since the param-env candidates never get normalized during candidate assembly (everywhere else we can assume that they are normalized fully).
r? `@lcnr,` though I feel like I've assigned quite a few PRs to you in the last few days, so feel free to reassign to someone else familiar with this code if you're busy!
cc #103243 (fixes the issue, but don't want to auto-close that until a backport is performed).
2022-10-26 05:17:46 +00:00
Ralf Jung
52fda858dd
interpret: a bit of cast cleanup
2022-10-25 22:09:35 +02:00
Jannis Christopher Köhl
5378c82d80
Use &self instead of &mut self for cast methods
2022-10-25 18:31:11 +02:00
bors
bed4ad65bf
Auto merge of #102340 - JakobDegen:pass-manager-simplification, r=oli-obk
...
Split phase change from `MirPass`
The main goal here is to simplify the pass manager logic. `MirPass` no longer contains the `phase_change` method, and `run_passes` instead accepts an `Option<PhaseChange>`. The hope is that this addresses the comments (and maybe perf regression) from #99102 .
r? `@oli-obk` cc `@RalfJung`
2022-10-25 15:55:39 +00:00
Dylan DPC
8ba2a651fb
Rollup merge of #103122 - ouz-a:mir-technical-debt, r=oli-obk
...
Remove misc_cast and validate types when casting
Continuing our work in #102675
r? ````@oli-obk````
2022-10-25 14:43:14 +05:30
Sarthak Singh
5e46d8675c
Added helper to prevent verbose printing from the PrettyPrinter
when printing constants
2022-10-25 13:05:34 +05:30
Jakob Degen
be2401b8bf
Split phase change from MirPass
2022-10-23 14:18:09 -07:00
Michael Goulet
6e6fe30d0f
Comment why normalization is needed for debug assertions
2022-10-23 17:23:35 +00:00
ouz-a
4bd98443ed
remove misc_cast and validate types
2022-10-23 18:47:16 +03:00
Nilstrieb
c65ebae221
Migrate all diagnostics
2022-10-23 10:09:44 +02:00
Matthias Krüger
801e32647e
Rollup merge of #103315 - RalfJung:interpret-switchint-ice, r=bjorn3
...
interpret: remove an incorrect assertion
This fixes an ICE in Miri, [reported](https://rust-lang.zulipchat.com/#narrow/stream/269128-miri/topic/SwitchInt.20with.20no.20targets.3F ) by `@saethlin.` The faulty assertion was introduced by 432535da2b
, when a previously correct assertion checking that the `otherwise` target exists got replaced by this assertion checking that at least one more target beyond `otherwise` exists.
Sadly we don't have a small reproducer so I don't think we can easily add a testcase.
2022-10-20 22:42:41 +02:00
Ralf Jung
bf14e3196b
interpret: remove an incorrect assertion
2022-10-20 19:06:34 +02:00
Michael Goulet
ab36a2fe16
Revert "Unify tcx.constness and param env constness checks"
...
This reverts commit bef8681a18
.
This reverts commit c646c4d403
.
2022-10-20 03:44:12 +00:00
CastilloDel
c3a1ca6be7
Remove allow(rustc::potential_query_instability) in rustc_const_eval
...
The use of FxHashMap has been replaced with FxIndexMap. For
more information see https://github.com/rust-lang/rust/issues/84447
2022-10-18 17:44:01 +02:00
Gimgim
49f34bd814
Surround type with backticks
2022-10-15 15:28:29 +05:30
Dylan DPC
77064b7f0a
Rollup merge of #103018 - Rageking8:more-dupe-word-typos, r=TaKO8Ki
...
More dupe word typos
I only picked those changes (from the regex search) that I am pretty certain doesn't change meaning and is just a typo fix. Do correct me if any fix is undesirable and I can revert those. Thanks.
2022-10-14 16:19:15 +05:30
Rageking8
7122abaddf
more dupe word typos
2022-10-14 12:57:56 +08:00
Michael Goulet
af3c6f9a03
Delay intrinsic call until after we've determined the callee is a function
2022-10-13 03:10:00 +00:00
Dylan DPC
c763ebc72f
Rollup merge of #102830 - compiler-errors:constness-parity, r=fee1-dead
...
Unify `tcx.constness` query and param env constness checks
The checks that we do in the `constness` query seem inconsistent with the checks that we do to determine if an item's param-env is const, so I merged them into the `constness` query and call that from the `param_env` query.
I'm not sure if this totally makes sense -- is there a case where `tcx.param_env()` would return a const param-env for an item whose `tcx.constness()` is `Constness::NotConst`? Because if not, it seems a bit dangerous that these two differ.
Luckily, not many places actually use `tcx.constness()`, and the checks in `tcx.param_env()` seem stricter than the checks in `tcx.constness()` (at least for the types of items we type-check).
Also, due to the way that `tcx.param_env()` is implemented, it _never_ used to return a const param-env for a item coming from a different crate, which also seems dangerous (though also probably not weaponizable currently, because we seldom actually compute the param-env for a non-local item).
2022-10-12 22:13:25 +05:30
Nilstrieb
7bfef19844
Use tidy-alphabetical
in the compiler
2022-10-12 17:49:10 +05:30
Michael Goulet
c646c4d403
Unify tcx.constness and param env constness checks
2022-10-12 04:04:09 +00:00
Matthias Krüger
c731646d6a
Rollup merge of #102675 - ouz-a:mir-technical-debt, r=oli-obk
...
Remove `mir::CastKind::Misc`
As discussed in #97649 `mir::CastKind::Misc` is not clear, this PR addresses that by creating a new enum variant for every valid cast.
r? ````@oli-obk````
2022-10-08 14:38:18 +02:00
bors
8b0c05d9ad
Auto merge of #102091 - RalfJung:const_err, r=oli-obk
...
make const_err a hard error
This lint has been deny-by-default with future incompat wording since [Rust 1.51](https://github.com/rust-lang/rust/pull/80394 ) and the stable release of this week starts showing it in cargo's future compat reports. I can't wait to finally get rid of at least some of the mess in our const-err-reporting-code. ;)
r? `@oli-obk`
Fixes https://github.com/rust-lang/rust/issues/71800
Fixes https://github.com/rust-lang/rust/issues/100114
2022-10-07 20:50:51 +00:00
Ralf Jung
fd59d44f58
make const_err a hard error
2022-10-07 18:08:49 +02:00
Cameron Steffen
283abbf0e7
Change InferCtxtBuilder from enter to build
2022-10-07 07:10:40 -05:00
Cameron Steffen
4a68373217
Introduce TypeErrCtxt
...
TypeErrCtxt optionally has a TypeckResults so that InferCtxt doesn't
need to.
2022-10-07 07:06:16 -05:00
ouz-a
d59c7ff000
Remove mir::CastKind::Misc
2022-10-06 15:32:41 +03:00
bors
0152393048
Auto merge of #99324 - reez12g:issue-99144, r=jyn514
...
Enable doctests in compiler/ crates
Helps with https://github.com/rust-lang/rust/issues/99144
2022-10-06 03:01:57 +00:00
Ralf Jung
a0131f0a36
change might_permit_raw_init to fully detect LLVM UB, but not more than that
2022-10-05 09:22:50 +02:00
Dylan DPC
32dde232d8
Rollup merge of #102559 - compiler-errors:issue-102553, r=oli-obk
...
Don't ICE when trying to copy unsized value in const prop
When we have a trivially false where-clause predicate like `Self: Sized` where `Self = dyn Trait`, we sometimes don't throw an error during typeck for an illegal operation such as copying an unsized type.
This, unfortunately, cannot be made into an error (at least not without some migration -- see #95611 for example), but we should at least not ICE, since this function will never actually be reachable from main, for example.
r? `@RalfJung` since I think you added these assertions? but feel free to reassign.
Fixes #102553
2022-10-04 16:11:02 +05:30
Michael Goulet
c7d1ec009c
Don't ICE when trying to copy unsized value in const prop
2022-10-02 19:21:06 +00:00
Cameron Steffen
4f12de0660
Change feature name to is_some_and
2022-10-01 11:45:52 -05:00
Maybe Waffle
a8f7e244b7
Refactor rustc lint API
2022-10-01 10:03:06 +00:00
reez12g
00612e23cb
Mark ignore(illustrative) on docs in compiler/rustc_const_eval/src/interpret/validity.rs
2022-09-29 16:49:23 +09:00
reez12g
9a4c5abe45
Remove from compiler/ crates
2022-09-29 16:49:04 +09:00
Pietro Albini
3975d55d98
remove cfg(bootstrap)
2022-09-26 10:14:45 +02:00
fee1-dead
b7d9de72ac
Rollup merge of #102194 - fee1-dead-contrib:improve-const-drop, r=oli-obk
...
Note the type when unable to drop values in compile time
2022-09-25 22:06:39 +08:00
Deadbeef
2ce1cd511f
Note the type when unable to drop values in compile time
2022-09-24 20:32:51 +00:00
bors
9a963e3bad
Auto merge of #102056 - b-naber:unevaluated, r=lcnr
...
Introduce mir::Unevaluated
Previously the distinction between unevaluated constants in the type-system and in mir was not explicit and a little confusing. Probably better to introduce its own type for that.
r? `@lcnr`
2022-09-23 13:39:11 +00:00
b-naber
a705e65605
rename Unevaluated to UnevaluatedConst
2022-09-23 14:27:34 +02:00
Matthias Krüger
41ad726110
Rollup merge of #102113 - RalfJung:opty-assert-mem, r=oli-obk
...
OpTy: fix a method taking self rather than &self
r? `@oli-obk`
2022-09-22 21:34:49 +02:00
b-naber
9f3784df89
introduce mir::Unevaluated
2022-09-22 12:35:28 +02:00
bors
7a8636c843
Auto merge of #100982 - fee1-dead-contrib:const-impl-requires-const-trait, r=oli-obk
...
Require `#[const_trait]` on `Trait` for `impl const Trait`
r? `@oli-obk`
2022-09-22 04:22:24 +00:00
Ralf Jung
0f4d7b6de8
OpTy: fix a method taking self rather than &self
2022-09-21 22:20:40 +02:00
Jhonny Bill Mena
a3396b2070
UPDATE - rename DiagnosticHandler macro to Diagnostic
2022-09-21 11:39:53 -04:00
Jhonny Bill Mena
19b348fed4
UPDATE - rename DiagnosticHandler trait to IntoDiagnostic
2022-09-21 11:39:52 -04:00
Michael Howell
b149c48186
Rollup merge of #102021 - lcnr:tyConst-fun, r=b-naber,BoxyUwU
...
some post-valtree cleanup
r? project-const-generics cc ```@b-naber```
2022-09-20 10:13:01 -07:00
bors
4136b59b7d
Auto merge of #99806 - oli-obk:unconstrained_opaque_type, r=estebank
...
Allow patterns to constrain the hidden type of opaque types
fixes #96572
reverts a revert as original PR was a perf regression that was fixed by reverting it: https://github.com/rust-lang/rust/pull/99368#issuecomment-1186587864 )
TODO:
* check if https://github.com/rust-lang/rust/issues/99685 is avoided
2022-09-20 12:09:52 +00:00
Matthias Krüger
8c0f8a285f
Rollup merge of #101985 - RalfJung:generate_stacktrace, r=oli-obk
...
interpret: expose generate_stacktrace without full InterpCx
In Miri we sometimes want to emit diagnostics without having a full `&InterpCx` available. To avoid duplicating code, this adds a way to get a stacktrace from an arbitrary slice of interpreter frames, that Miri can use with access to just a thread manager.
2022-09-19 17:55:21 +02:00
lcnr
c54c5a3c77
DestructuredConst
split mir and ty
2022-09-19 17:00:38 +02:00
lcnr
526856768d
ctfe, const_to_op
only for mir constants
2022-09-19 16:17:33 +02:00
lcnr
647052fc04
remove the Subst
trait, always use EarlyBinder
2022-09-19 11:37:27 +02:00
Ralf Jung
9fa3171015
interpret: expose generate_stacktrace without full InterpCx
2022-09-18 20:51:04 +02:00
Dylan DPC
3ad81e0dd8
Rollup merge of #93628 - est31:stabilize_let_else, r=joshtriplett
...
Stabilize `let else`
🎉 **Stabilizes the `let else` feature, added by [RFC 3137](https://github.com/rust-lang/rfcs/pull/3137 ).** 🎉
Reference PR: https://github.com/rust-lang/reference/pull/1156
closes #87335 (`let else` tracking issue)
FCP: https://github.com/rust-lang/rust/pull/93628#issuecomment-1029383585
----------
## Stabilization report
### Summary
The feature allows refutable patterns in `let` statements if the expression is
followed by a diverging `else`:
```Rust
fn get_count_item(s: &str) -> (u64, &str) {
let mut it = s.split(' ');
let (Some(count_str), Some(item)) = (it.next(), it.next()) else {
panic!("Can't segment count item pair: '{s}'");
};
let Ok(count) = u64::from_str(count_str) else {
panic!("Can't parse integer: '{count_str}'");
};
(count, item)
}
assert_eq!(get_count_item("3 chairs"), (3, "chairs"));
```
### Differences from the RFC / Desugaring
Outside of desugaring I'm not aware of any differences between the implementation and the RFC. The chosen desugaring has been changed from the RFC's [original](https://rust-lang.github.io/rfcs/3137-let-else.html#reference-level-explanations ). You can read a detailed discussion of the implementation history of it in `@cormacrelf` 's [summary](https://github.com/rust-lang/rust/pull/93628#issuecomment-1041143670 ) in this thread, as well as the [followup](https://github.com/rust-lang/rust/pull/93628#issuecomment-1046598419 ). Since that followup, further changes have happened to the desugaring, in #98574 , #99518 , #99954 . The later changes were mostly about the drop order: On match, temporaries drop in the same order as they would for a `let` declaration. On mismatch, temporaries drop before the `else` block.
### Test cases
In chronological order as they were merged.
Added by df9a2e0687
(#87688 ):
* [`ui/pattern/usefulness/top-level-alternation.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/pattern/usefulness/top-level-alternation.rs ) to ensure the unreachable pattern lint visits patterns inside `let else`.
Added by 5b95df4bdc
(#87688 ):
* [`ui/let-else/let-else-bool-binop-init.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-bool-binop-init.rs ) to ensure that no lazy boolean expressions (using `&&` or `||`) are allowed in the expression, as the RFC mandates.
* [`ui/let-else/let-else-brace-before-else.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-brace-before-else.rs ) to ensure that no `}` directly preceding the `else` is allowed in the expression, as the RFC mandates.
* [`ui/let-else/let-else-check.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-check.rs ) to ensure that `#[allow(...)]` attributes added to the entire `let` statement apply for the `else` block.
* [`ui/let-else/let-else-irrefutable.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-irrefutable.rs ) to ensure that the `irrefutable_let_patterns` lint fires.
* [`ui/let-else/let-else-missing-semicolon.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-missing-semicolon.rs ) to ensure the presence of semicolons at the end of the `let` statement.
* [`ui/let-else/let-else-non-diverging.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-non-diverging.rs ) to ensure the `else` block diverges.
* [`ui/let-else/let-else-run-pass.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-run-pass.rs ) to ensure the feature works in some simple test case settings.
* [`ui/let-else/let-else-scope.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-scope.rs ) to ensure the bindings created by the outer `let` expression are not available in the `else` block of it.
Added by bf7c32a447
(#89965 ):
* [`ui/let-else/issue-89960.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/issue-89960.rs ) as a regression test for the ICE-on-error bug #89960 . Later in 102b9125e1
this got removed in favour of more comprehensive tests.
Added by 856541963c
(#89974 ):
* [`ui/let-else/let-else-if.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-if.rs ) to test for the improved error message that points out that `let else if` is not possible.
Added by 9b45713b6c
:
* [`ui/let-else/let-else-allow-unused.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-allow-unused.rs ) as a regression test for #89807 , to ensure that `#[allow(...)]` attributes added to the entire `let` statement apply for bindings created by the `let else` pattern.
Added by 61bcd8d307
(#89841 ):
* [`ui/let-else/let-else-non-copy.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-non-copy.rs ) to ensure that a copy is performed out of non-copy wrapper types. This mirrors `if let` behaviour. The test case bases on rustc internal changes originally meant for #89933 but then removed from the PR due to the error prior to the improvements of #89841 .
* [`ui/let-else/let-else-source-expr-nomove-pass.rs `](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-source-expr-nomove-pass.rs ) to ensure that while there is a move of the binding in the successful case, the `else` case can still access the non-matching value. This mirrors `if let` behaviour.
Added by 102b9125e1
(#89841 ):
* [`ui/let-else/let-else-ref-bindings.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-ref-bindings.rs ) and [`ui/let-else/let-else-ref-bindings-pass.rs `](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-ref-bindings-pass.rs ) to check `ref` and `ref mut` keywords in the pattern work correctly and error when needed.
Added by 2715c5f984
(#89841 ):
* Match ergonomic tests adapted from the `rfc2005` test suite.
Added by fec8a507a2
(#89841 ):
* [`ui/let-else/let-else-deref-coercion-annotated.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-deref-coercion-annotated.rs ) and [`ui/let-else/let-else-deref-coercion.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-deref-coercion.rs ) to check deref coercions.
#### Added since this stabilization report was originally written (2022-02-09)
Added by 76ea566677
(#94211 ):
* [`ui/let-else/let-else-destructuring.rs`](https://github.com/rust-lang/rust/blob/1.63.0/src/test/ui/let-else/let-else-destructuring.rs ) to give a nice error message if an user tries to do an assignment with a (possibly refutable) pattern and an `else` block, like asked for in #93995 .
Added by e7730dcb7e
(#94208 ):
* [`ui/let-else/let-else-allow-in-expr.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-allow-in-expr.rs ) to test whether `#[allow(unused_variables)]` works in the expr, as well as its non presence, as well as putting it on the entire `let else` *affects* the expr, too. This was adding a missing test as pointed out by the stabilization report.
* Expansion of `ui/let-else/let-else-allow-unused.rs` and `ui/let-else/let-else-check.rs` to ensure that non-presence of `#[allow(unused)]` does issue the unused lint. This was adding a missing test case as pointed out by the stabilization report.
Added by 5bd71063b3
(#94208 ):
* [`ui/let-else/let-else-slicing-error.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-slicing-error.rs ), a regression test for #92069 , which got fixed without addition of a regression test. This resolves a missing test as pointed out by the stabilization report.
Added by 5374688e1d
(#98574 ):
* [`src/test/ui/async-await/async-await-let-else.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/async-await/async-await-let-else.rs ) to test the interaction of async/await with `let else`
Added by 6c529ded86
(#98574 ):
* [`src/test/ui/let-else/let-else-temporary-lifetime.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/let-else-temporary-lifetime.rs ) as a (partial) regression test for #98672
Added by 9b56640106
(#99518 ):
* [`src/test/ui/let-else/let-else-temp-borrowck.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/let-else-temporary-lifetime.rs ) as a regression test for #93951
* Extension of `src/test/ui/let-else/let-else-temporary-lifetime.rs` to include a partial regression test for #98672 (especially regarding `else` drop order)
Added by baf9a7cb57
(#99518 ):
* Extension of `src/test/ui/let-else/let-else-temporary-lifetime.rs` to include a partial regression test for #93951 , similar to `let-else-temp-borrowck.rs`
Added by 60be2de8b7
(#99518 ):
* Extension of `src/test/ui/let-else/let-else-temporary-lifetime.rs` to include a program that can now be compiled thanks to borrow checker implications of #99518
Added by 47a7a91c96
(#100132 ):
* [`src/test/ui/let-else/issue-100103.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/issue-100103.rs ), as a regression test for #100103 , to ensure that there is no ICE when doing `Err(...)?` inside else blocks.
Added by e3c5bd617d
(#100443 ):
* [`src/test/ui/let-else/let-else-then-diverge.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/let-else-then-diverge.rs ), to verify that there is no unreachable code error with the current desugaring.
Added by 981852677c
(#100443 ):
* [`src/test/ui/let-else/issue-94176.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/issue-94176.rs ), to make sure that a correct span is emitted for a missing trailing expression error. Regression test for #94176 .
Added by e182d12a84
(#100434 ):
* [src/test/ui/unpretty/pretty-let-else.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/unpretty/pretty-let-else.rs ), as a regression test to ensure pretty printing works for `let else` (this bug surfaced in many different ways)
Added by e26285603c
(#99954 ):
* [`src/test/ui/let-else/let-else-temporary-lifetime.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/let-else-temporary-lifetime.rs ) extended to contain & borrows as well, as this was identified as an earlier issue with the desugaring: https://github.com/rust-lang/rust/issues/98672#issuecomment-1200196921
Added by 2d8460ef43
(#99291 ):
* [`src/test/ui/let-else/let-else-drop-order.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/let-else-drop-order.rs ) a matrix based test for various drop order behaviour of `let else`. Especially, it verifies equality of `let` and `let else` drop orders, [resolving](https://github.com/rust-lang/rust/pull/93628#issuecomment-1238498468 ) a [stabilization blocker](https://github.com/rust-lang/rust/pull/93628#issuecomment-1055738523 ).
Added by 1b87ce0d40
(#101410 ):
* Edit to `src/test/ui/let-else/let-else-temporary-lifetime.rs` to add the `-Zvalidate-mir` flag, as a regression test for #99228
Added by af591ebe4d
(#101410 ):
* [`src/test/ui/let-else/issue-99975.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/issue-99975.rs ) as a regression test for the ICE #99975 .
Added by this PR:
* `ui/let-else/let-else.rs`, a simple run-pass check, similar to `ui/let-else/let-else-run-pass.rs`.
### Things not currently tested
* ~~The `#[allow(...)]` tests check whether allow works, but they don't check whether the non-presence of allow causes a lint to fire.~~ → *test added by e7730dcb7eb29a10ee73f269f4dc6e9d606db0da*
* ~~There is no `#[allow(...)]` test for the expression, as there are tests for the pattern and the else block.~~ → *test added by e7730dcb7eb29a10ee73f269f4dc6e9d606db0da*
* ~~`let-else-brace-before-else.rs` forbids the `let ... = {} else {}` pattern and there is a rustfix to obtain `let ... = ({}) else {}`. I'm not sure whether the `.fixed` files are checked by the tooling that they compile. But if there is no such check, it would be neat to make sure that `let ... = ({}) else {}` compiles.~~ → *test added by e7730dcb7eb29a10ee73f269f4dc6e9d606db0da*
* ~~#92069 got closed as fixed, but no regression test was added. Not sure it's worth to add one.~~ → *test added by 5bd71063b3810d977aa376d1e6dd7cec359330cc*
* ~~consistency between `let else` and `if let` regarding lifetimes and drop order: https://github.com/rust-lang/rust/pull/93628#issuecomment-1055738523~~ → *test added by 2d8460ef43d902f34ba2133fe38f66ee8d2fdafc*
Edit: they are all tested now.
### Possible future work / Refutable destructuring assignments
[RFC 2909](https://rust-lang.github.io/rfcs/2909-destructuring-assignment.html ) specifies destructuring assignment, allowing statements like `FooBar { a, b, c } = foo();`.
As it was stabilized, destructuring assignment only allows *irrefutable* patterns, which before the advent of `let else` were the only patterns that `let` supported.
So the combination of `let else` and destructuring assignments gives reason to think about extensions of the destructuring assignments feature that allow refutable patterns, discussed in #93995 .
A naive mapping of `let else` to destructuring assignments in the form of `Some(v) = foo() else { ... };` might not be the ideal way. `let else` needs a diverging `else` clause as it introduces new bindings, while assignments have a default behaviour to fall back to if the pattern does not match, in the form of not performing the assignment. Thus, there is no good case to require divergence, or even an `else` clause at all, beyond the need for having *some* introducer syntax so that it is clear to readers that the assignment is not a given (enums and structs look similar). There are better candidates for introducer syntax however than an empty `else {}` clause, like `maybe` which could be added as a keyword on an edition boundary:
```Rust
let mut v = 0;
maybe Some(v) = foo(&v);
maybe Some(v) = foo(&v) else { bar() };
```
Further design discussion is left to an RFC, or the linked issue.
2022-09-17 15:31:06 +05:30
bors
c524c7dd25
Auto merge of #98588 - b-naber:valtrees-cleanup, r=lcnr
...
Use only ty::Unevaluated<'tcx, ()> in type system
r? `@lcnr`
2022-09-17 03:04:22 +00:00
Oli Scherer
40e2de8c41
Revert "Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank""
...
This reverts commit 4a742a691e
.
2022-09-16 11:36:39 +00:00
Deadbeef
f8813cf10e
do const trait method bounds check later in rustc_const_eval
2022-09-16 11:48:43 +08:00
est31
173eb6f407
Only enable the let_else feature on bootstrap
...
On later stages, the feature is already stable.
Result of running:
rg -l "feature.let_else" compiler/ src/librustdoc/ library/ | xargs sed -s -i "s#\\[feature.let_else#\\[cfg_attr\\(bootstrap, feature\\(let_else\\)#"
2022-09-15 21:06:45 +02:00
b-naber
6af8fb7936
address review again
2022-09-14 17:30:25 +02:00
Eric Holk
cf04547b0b
Address code review comments
2022-09-13 14:50:12 -07:00
b-naber
29c0364c37
rebase
2022-09-13 17:48:05 +02:00
b-naber
a7735cd329
fixes/working version
2022-09-13 17:41:02 +02:00
b-naber
a4bbb8db5c
use ty::Unevaluated<'tcx, ()> in type system
2022-09-13 17:40:59 +02:00
Michael Goulet
b2ed2dcaae
Rename some variants
2022-09-12 16:55:59 -07:00
Michael Goulet
12ec2f0e34
Construct dyn* during const interp
2022-09-12 16:55:59 -07:00
Eric Holk
549c105bb3
dyn* through more typechecking and MIR
2022-09-12 16:55:56 -07:00
Eric Holk
6c01273a15
Plumb dyn trait representation through ty::Dynamic
2022-09-12 16:55:55 -07:00
bors
5197c96c49
Auto merge of #101483 - oli-obk:guaranteed_opt, r=fee1-dead
...
The `<*const T>::guaranteed_*` methods now return an option for the unknown case
cc https://github.com/rust-lang/rust/issues/53020#issuecomment-1236932443
I chose `0` for "not equal" and `1` for "equal" and left `2` for the unknown case so backends can just forward to raw pointer equality and it works ✨
r? `@fee1-dead` or `@lcnr`
cc `@rust-lang/wg-const-eval`
2022-09-10 09:50:21 +00:00
Oli Scherer
f632dbe46f
The <*const T>::guaranteed_*
methods now return an option for the unknown case
2022-09-09 15:16:04 +00:00
bors
1120c5e01d
Auto merge of #101437 - compiler-errors:erase-normalize-ordering, r=tmandry
...
Normalize before erasing late-bound regions in `equal_up_to_regions`
Normalize erasing regions **first**, before passing the type through a `BottomUpFolder` which erases late-bound regions too.
The root cause of this issue is due to 96d4137dee
, which removes a `normalize_erasing_regions` that happens before this call to `equal_up_to_regions`. While reverting that commit might be a fix, I think it was suspicious to be erasing late-bound regions first _then_ normalizing types in the first place in `equal_up_to_regions`.
-----
I am tempted to ask the reviewer to review and `r+` this without a UI test, since the existing issues that I think this fixes are all incredibly difficult to minimize (anything hyper/warp related, given the nature of those libraries 😓 ) or impossible to reproduce locally (the miri test), namely:
* This recently reported issue with tokio + warp: #101430
* This issue from `@RalfJung` about Miri being broken: #101344
* This additional issue reported in a comment by `@tmandry` (issue with fuchsia + hyper): https://github.com/rust-lang/rust/issues/101344#issuecomment-1235974564
I have locally verified that the repro in #101430 is fixed with this PR, but after a couple of hours of attempting to minimize this error and either failing to actually repro the ICE, or being overwhelmed with the number of traits and functions I need to inline into a UI test, I have basically given up. Thoughts are appreciated on how best to handle this.
r? `@oli-obk` who is at the intersection of MIR and types-related stuff who may be able to give advice 😅
2022-09-08 19:01:39 +00:00
lcnr
e6660326a3
bound variables during ctfe are a bug
2022-09-08 11:41:00 +02:00
Michael Benfield
d7a750b504
Use niche-filling optimization even when multiple variants have data.
...
Fixes #46213
2022-09-07 20:12:45 +00:00
Michael Benfield
1a08b96a0b
Change name of "dataful" variant to "untagged"
...
This is in anticipation of a new enum layout, in which the niche
optimization may be applied even when multiple variants have data.
2022-09-07 20:12:45 +00:00
Oli Scherer
104f97e5aa
Move CTFE handling of nondiverging intrinsics to intrinsics.rs
2022-09-06 14:18:32 +00:00
Oli Scherer
b7413511dc
Generalize the Assume intrinsic statement to a general Intrinsic statement
2022-09-06 14:18:32 +00:00
Oli Scherer
3f07645120
Lower the assume intrinsic to a MIR statement
2022-09-06 14:18:32 +00:00
Yuki Okushi
957b44a13c
Rollup merge of #101402 - saethlin:inline-asm-hook, r=oli-obk
...
Add a Machine hook for inline assembly
I'm sketching out some support in Miri to "execute" inline assembly. I want this because there are codebases which have very simple inline assembly like hand-written syscall wrappers, and it would be nice to test such code without modification.
r? ``@oli-obk``
2022-09-06 08:36:04 +09:00
Michael Goulet
76b494a9dd
Normalize before erasing late-bound regions in equal_up_to_regions
2022-09-05 06:44:33 +00:00
Deadbeef
075084f772
Make const_eval_select
a real intrinsic
2022-09-04 20:35:23 +08:00
Ben Kimock
563a75b6e3
Add a Machine hook for inline assembly
2022-09-03 18:05:02 -04:00
bors
06b72b06a2
Auto merge of #101154 - RalfJung:validation-perf, r=oli-obk
...
interpret: fix unnecessary allocation in validation visitor
Should fix the perf regression introduced by https://github.com/rust-lang/rust/pull/100043 .
r? `@oli-obk`
2022-09-03 09:20:54 +00:00
Matthias Krüger
938897e2e4
Rollup merge of #100121 - Nilstrieb:mir-validator-param-env, r=oli-obk
...
Try normalizing types without RevealAll in ParamEnv in MIR validation
Before, the MIR validator used RevealAll in its ParamEnv for type
checking. This could cause false negatives in some cases due to
RevealAll ParamEnvs not always use all predicates as expected here.
Since some MIR passes like inlining use RevealAll as well, keep using
it in the MIR validator too, but when it fails usign RevealAll, also
try the check without it, to stop false negatives.
Fixes #99866
cc ````````@compiler-errors```````` who nicely helped me on zulip
2022-09-02 18:21:58 +02:00
Oli Scherer
1fc9ef1edd
tracing::instrument cleanup
2022-09-01 14:54:27 +00:00
Oli Scherer
d3b22c7267
Directly use the instrument
macro instead of its full path
2022-09-01 14:53:46 +00:00
bors
b32223fec1
Auto merge of #100707 - dzvon:fix-typo, r=davidtwco
...
Fix a bunch of typo
This PR will fix some typos detected by [typos].
I only picked the ones I was sure were spelling errors to fix, mostly in
the comments.
[typos]: https://github.com/crate-ci/typos
2022-09-01 05:39:58 +00:00
Ralf Jung
d814d10069
interpret: use new OpTy::len for Len rvalue
...
This avoids a `force_allocation`
2022-08-31 15:22:44 +02:00