Commit Graph

580 Commits

Author SHA1 Message Date
bors
e3c43e64ec Auto merge of #94255 - b-naber:use-mir-constant-in-thir, r=oli-obk
Use mir constant in thir instead of ty::Const

This is blocked on https://github.com/rust-lang/rust/pull/94059 (does include its changes, the first two commits in this PR correspond to those changes) and https://github.com/rust-lang/rust/pull/93800 being reinstated (which had to be reverted). Mainly opening since `@lcnr` offered to give some feedback and maybe also for a perf-run (if necessary).

This currently contains a lot of duplication since some of the logic of `ty::Const` had to be copied to `mir::ConstantKind`, but with the introduction of valtrees a lot of that functionality will disappear from `ty::Const`.

Only the last commit contains changes that need to be reviewed here. Did leave some `FIXME` comments regarding future implementation decisions and some things that might be incorrectly implemented.

r? `@oli-obk`
2022-04-13 07:50:56 +00:00
b-naber
3be987e076 dont make lit_to_mir_constant a query 2022-04-08 11:56:21 +02:00
Ralf Jung
38004b72bc interpret: err instead of ICE on size mismatches in to_bits_or_ptr_internal 2022-04-07 16:24:48 -04:00
b-naber
c3491378e3 get rid of visit_constant in thir visitor 2022-04-06 10:43:58 +02:00
David Wood
c45f29595d span: move MultiSpan
`MultiSpan` contains labels, which are more complicated with the
introduction of diagnostic translation and will use types from
`rustc_errors` - however, `rustc_errors` depends on `rustc_span` so
`rustc_span` cannot use types like `DiagnosticMessage` without
dependency cycles. Introduce a new `rustc_error_messages` crate that can
contain `DiagnosticMessage` and `MultiSpan`.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:00 +01:00
b-naber
14e3d038c0 rebase and remove dead code 2022-04-02 12:47:06 +02:00
b-naber
9b28d3b494 try to evaluate in from_opt_const_arg_anon_const 2022-04-02 12:21:02 +02:00
b-naber
0078e54185 rebase and use ty::Const in patterns again 2022-04-02 12:21:00 +02:00
b-naber
ac60db231c do use ty::Const in patterns and abstract consts 2022-04-02 12:20:59 +02:00
b-naber
b38077ea0b change thir to use mir::ConstantKind instead of ty::Const 2022-04-02 12:20:56 +02:00
lcnr
d7cada1767 obligation cause: RepeatVec -> RepeatValueCopy 2022-03-31 12:51:46 +02:00
Dylan DPC
1b7d6dbd30
Rollup merge of #95497 - nyurik:compiler-spell-comments, r=compiler-errors
Spellchecking compiler comments

This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-31 04:57:28 +02:00
bors
a40c595695 Auto merge of #95436 - cjgillot:static-mut, r=oli-obk
Remember mutability in `DefKind::Static`.

This allows to compute the `BodyOwnerKind` from `DefKind` only, and
removes a direct dependency of some MIR queries onto HIR.

As a side effect, it also simplifies metadata, since we don't need 4
flavours of `EntryKind::*Static` any more.
2022-03-30 22:09:56 +00:00
Yuri Astrakhan
a6dd658254 Addressed comments by @compiler-errors and @bjorn3 2022-03-30 17:04:46 -04:00
Yuri Astrakhan
5160f8f843 Spellchecking compiler comments
This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-30 15:14:15 -04:00
bors
05142a7e44 Auto merge of #95466 - Dylan-DPC:rollup-g7ddr8y, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #95294 (Document Linux kernel handoff in std::io::copy and std::fs::copy)
 - #95443 (Clarify how `src/tools/x` searches for python)
 - #95452 (fix since field version for termination stabilization)
 - #95460 (Spellchecking compiler code)
 - #95461 (Spellchecking some comments)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-03-30 07:45:42 +00:00
Yuri Astrakhan
7e8201ae0a Spellchecking some comments
This PR attempts to clean up some minor spelling mistakes in comments
2022-03-30 01:39:38 -04:00
Camille GILLOT
21a554caf6 Remember mutability in DefKind::Static.
This allows to compute the `BodyOwnerKind` from `DefKind` only, and
removes a direct dependency of some MIR queries onto HIR.

As a side effect, it also simplifies metadata, since we don't need 4
flavours of `EntryKind::*Static` any more.
2022-03-29 18:50:52 +02:00
Oli Scherer
264cd05b16 Revert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk"
This reverts commit 6499c5e7fc, reversing
changes made to 78450d2d60.
2022-03-28 16:27:14 +00:00
b-naber
19041d995d dont use a query for lit_to_constant 2022-03-23 20:18:34 +01:00
b-naber
5fcccd1739 use NonHirLiteral instead of ScalarLiteral, move pattern related code to pat_is_poly in IsThirPolymorphic 2022-03-23 11:34:33 +01:00
b-naber
9cd8bb0456 use ParamConst in ExprKind::ConstParam 2022-03-23 11:34:33 +01:00
b-naber
e2496b3cf4 remove thir::Visitor::visit_const 2022-03-23 11:34:32 +01:00
b-naber
f713b5017c change thir to lazily create constants 2022-03-23 11:34:32 +01:00
Dylan DPC
270a41c33e
Rollup merge of #94960 - codehorseman:master, r=oli-obk
Fix many spelling mistakes

Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-17 22:55:05 +01:00
mark
bb8d4307eb rustc_error: make ErrorReported impossible to construct
There are a few places were we have to construct it, though, and a few
places that are more invasive to change. To do this, we create a
constructor with a long obvious name.
2022-03-16 10:35:24 -05:00
codehorseman
01dbfb3eb2 resolve the conflict in compiler/rustc_session/src/parse.rs
Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-16 20:12:30 +08:00
est31
0f4c81a1a9 Extend the irrefutable_let_patterns lint to let chains
Only look for complete suffixes or prefixes of irrefutable let patterns, so
that an irrefutable let pattern in a chain surrounded by refutable ones is
not linted, as it is an useful pattern.
2022-03-16 00:28:07 +01:00
Dylan DPC
13e889986d fix typos 2022-03-15 02:00:08 +01:00
Devin Ragotzy
492d8d7293 Fix rebase conflicts with stderr files 2022-03-12 15:38:44 -05:00
Devin Ragotzy
7ffb29d03c Only filter doc(hidden) fields/variants when not crate local 2022-03-12 15:16:11 -05:00
Nicholas Nethercote
ca5525d564 Improve AdtDef interning.
This commit makes `AdtDef` use `Interned`. Much the commit is tedious
changes to introduce getter functions. The interesting changes are in
`compiler/rustc_middle/src/ty/adt.rs`.
2022-03-11 13:31:24 +11:00
bors
d7b282b886 Auto merge of #94059 - b-naber:constantkind-val-transformation, r=lcnr
Treat constant values as mir::ConstantKind::Val

Another step that is necessary for the introduction of Valtrees: we don't want to treat `ty::Const` instances of kind `ty::ConstKind::Value` as `mir::ConstantKind::Ty` anymore.

r? `@oli-obk`
2022-03-10 05:53:59 +00:00
Matthias Krüger
ec09e70ee1
Rollup merge of #94739 - estebank:suggest-let-else, r=oli-obk
Suggest `if let`/`let_else` for refutable pat in `let`

r? `````@oli-obk`````
2022-03-09 23:14:11 +01:00
b-naber
40e4bd2d02 treat all mir::Constant values as ConstantKind::Val 2022-03-09 10:52:04 +01:00
bors
1eb72580d0 Auto merge of #94702 - b-naber:static-refs-mir, r=lcnr
Reinstate #93800

https://github.com/rust-lang/rust/pull/93800 caused a regression in an alt builder with parallel enabled. https://github.com/rust-lang/rust/pull/94205 reverted that PR because of the regression. For an unknown reason the regression has disappeared, so we reinstate the changes in https://github.com/rust-lang/rust/pull/93800 here.

r? `@Mark-Simulacrum`
2022-03-08 19:25:19 +00:00
Esteban Kuber
c3a998e82a Do not suggest let_else if no bindings would be introduced 2022-03-08 17:20:05 +00:00
Esteban Kuber
0d92752b8a Suggest if let/let_else for refutable pat in let 2022-03-08 16:32:08 +00:00
b-naber
d92df974fe treat literals in ExprKind::StaticRef as mir::ConstantKind::Val 2022-03-08 10:04:28 +01:00
Esteban Kuber
6f45f73adc Change wording of suggestion to add missing match arm 2022-03-08 00:20:41 +00:00
Esteban Kuber
ab4feea50d Point at uncovered variants in enum definition in note instead of a span_label
This makes the order of the output always consistent:

1. Place of the `match` missing arms
2. The `enum` definition span
3. The structured suggestion to add a fallthrough arm
2022-03-08 00:19:08 +00:00
Esteban Kuber
084ca79e7c When finding a match expr with multiple arms that requires more, suggest it
Given

```rust
match Some(42) {
    Some(0) => {}
    Some(1) => {}
}
```

suggest

```rust
match Some(42) {
    Some(0) => {}
    Some(1) => {}
    None | Some(_) => todo!(),
}
```
2022-03-08 00:18:24 +00:00
Esteban Kuber
2383858f34 When finding a match expr with a single arm that requires more, suggest it
Given

```rust
match Some(42) {
    Some(0) => {}
}
```

suggest

```rust
match Some(42) {
    Some(0) => {}
    None | Some(_) => todo!(),
}
```
2022-03-08 00:18:24 +00:00
Esteban Kuber
02a3830f24 When encountering a match expr with no arms, suggest it
Given

```rust
match Some(42) {}
```

suggest

```rust
match Some(42) { None | Some(_) => todo!(), }
```
2022-03-08 00:18:23 +00:00
mark
e489a94dee rename ErrorReported -> ErrorGuaranteed 2022-03-02 09:45:25 -06:00
Caio
fe94f78b9b 6 - Make more use of let_chains
Continuation of #94376.

cc #53667
2022-02-28 21:12:52 -03:00
Mark Rousskov
76b13c9eea Enable rustc_pass_by_value for Span 2022-02-25 08:00:53 -05:00
Mark Rousskov
22c3a71de1 Switch bootstrap cfgs 2022-02-25 08:00:52 -05:00
Eduard-Mihai Burtescu
b7e95dee65 rustc_errors: let DiagnosticBuilder::emit return a "guarantee of emission". 2022-02-23 06:38:52 +00:00
Eduard-Mihai Burtescu
02ff9e0aef Replace &mut DiagnosticBuilder, in signatures, with &mut Diagnostic. 2022-02-23 05:38:19 +00:00