Commit Graph

4741 Commits

Author SHA1 Message Date
Yuki Okushi 0466b6ac6d Improve the wording for the can't reassign error 2021-03-13 06:06:54 +09:00
Oli Scherer 11ddd22510 Run rustfmt 2021-03-12 13:46:39 +00:00
Oli Scherer c51749af6e We won't support trait object constants in type level constants for the forseeable future 2021-03-12 13:00:16 +00:00
Oli Scherer 6ca1d87194 Visit mir::Constant::user_ty for completeness.
It's not necessary yet, but it may become necessary with things like lazy normalization.
2021-03-12 12:59:37 +00:00
Oli Scherer 20f737966e Replace a custom lift method with a Lift impl 2021-03-12 12:44:12 +00:00
Oli Scherer 3127a9c60f Prepare mir::Constant for ty::Const only supporting valtrees 2021-03-12 12:43:54 +00:00
Oli Scherer 3ecde6f5db Directly intern allocations so that we can write a Lift impl for them 2021-03-12 12:34:29 +00:00
Oli Scherer 914df2a493 Add ty helper function for mir constants
This is in preparation of the `literal` field becoming an enum that distinguishes between type level constants and runtime constants
2021-03-12 12:33:46 +00:00
Oli Scherer d5eec653c0 Use the explicit error constant instead of fake dummies 2021-03-12 12:25:08 +00:00
Oli Scherer 0bb367e070 Split pretty printer logic for scalar int and scalar ptr
Value trees won't have scalar ptr at all, so we need a scalar int printing method anyway. This way we'll be able to share that method between all const representations.
2021-03-12 12:24:29 +00:00
Oli Scherer b729cc9d61 Pull out ConstValue relating into its own function 2021-03-12 12:23:50 +00:00
Oli Scherer 5e8a89b2e5 Reduce the duplication in the relation logic for constants 2021-03-12 12:23:11 +00:00
Oli Scherer 4d917faa99 Reduce destructuring and re-interning where possible 2021-03-12 12:22:33 +00:00
Oli Scherer 019dba0ceb Resolve a FIXME around type equality checks in Relate for constants 2021-03-12 12:21:55 +00:00
Oli Scherer 09f7f91532 Add convenience conversion methods for ScalarInt 2021-03-12 12:20:54 +00:00
Oli Scherer 858216cabf Add fallible Scalar to ScalarInt conversion method 2021-03-12 12:20:14 +00:00
Oli Scherer 0fe4f38769 Intern valtree field vector 2021-03-12 12:19:17 +00:00
Oli Scherer a4fbac163e Implement valtree
valtree is a version of constants that is inherently safe to be used within types.
This is in contrast to ty::Const which can have different representations of the same value. These representation differences can show up in hashing or equality comparisons, breaking type equality of otherwise equal types.
valtrees do not have this problem.
2021-03-12 12:16:14 +00:00
bors 338647db73 Auto merge of #82422 - petrochenkov:allunst, r=oli-obk
expand: Do not allocate `Lrc` for `allow_internal_unstable` list unless necessary

This allocation is done for any macro defined in the current crate, or used from a different crate.
EDIT: This also removes an `Lrc` increment from each *use* of such macro, which may be more significant.
Noticed when reviewing https://github.com/rust-lang/rust/pull/82367.
This probably doesn't matter, but let's do a perf run.
2021-03-12 11:46:50 +00:00
bors 0cc64a34e9 Auto merge of #82935 - henryboisdequin:diagnostic-cleanups, r=estebank
Diagnostic cleanups

Follow up to #81503
Helps with #82916 (don't show note if `span` is `DUMMY_SP`)
2021-03-12 09:05:38 +00:00
Ömer Sinan Ağacan b24902ea18 Run analyses before thir-tree dumps
Fixes #83048
2021-03-12 10:08:44 +03:00
hi-rustin d180f91824 Emit the enum range assumption if the range only contains one element
test: add test case

make tidy happy
2021-03-12 12:06:10 +08:00
Hiroki Noda 8357e57346 Add support for storing code model to LLVM module IR
This patch avoids undefined behavior by linking different object files.
Also this would it could be propagated properly to LTO.

See https://reviews.llvm.org/D52322 and https://reviews.llvm.org/D52323.

This patch is based on https://github.com/rust-lang/rust/pull/74002
2021-03-12 11:02:25 +09:00
Henry Boisdequin 26478c81fd Don't show note if span is DUMMY_SP 2021-03-12 06:18:33 +05:30
Yuki Okushi 14846d945d Rollup merge of #83018 - oli-obk:float_check, r=davidtwco
Reintroduce accidentally deleted assertions.

These were removed in https://github.com/rust-lang/rust/pull/50198
2021-03-12 08:55:22 +09:00
Yuki Okushi 5ab8f53a71 Rollup merge of #83013 - hyd-dev:cfg-unix-windows, r=bjorn3
Adjust some `#[cfg]`s to take non-Unix non-Windows operating systems into account

This makes compilation to such targets (e.g. `wasm32-wasi`) easier.

cc rust-lang/miri#722 https://github.com/rust-lang/rust/commit/bb6d1d0a0966c04a75389348642e11ae44c86514#r48100619
2021-03-12 08:55:21 +09:00
Hiroki Noda 65ed23c282 Support merge_functions option in NewPM since LLVM >= 12
now we can pass this flag since https://reviews.llvm.org/D93002 has been
merged.
2021-03-12 08:16:10 +09:00
Guillaume Gomez 1d26e6b632 Improve code by removing similar function calls and using loops instead for collecting iterators 2021-03-11 22:33:40 +01:00
LeSeulArtichaut 6bf4147646 Add -Z unpretty flag for the THIR 2021-03-11 19:42:40 +01:00
LeSeulArtichaut 2a34428253 Make THIR data structures public 2021-03-11 19:42:39 +01:00
csmoe 77fb6a0f32 fix: check before index into generated patterns 2021-03-12 01:54:08 +08:00
csmoe 2fd2796aae add ui testcase for issue 82772 2021-03-12 01:53:55 +08:00
bors 61365c0625 Auto merge of #82495 - LeSeulArtichaut:eager-thir, r=oli-obk
Eagerly construct bodies of THIR

With this PR:
 - the THIR is no longer constructed lazily, but is entirely built before being passed to the MIR Builder
 - the THIR is now allocated in arenas instead of `Box`es

However, this PR doesn't make any changes to the way patterns are constructed: they are still boxed, and exhaustiveness checking is unchanged.

Implements MCP rust-lang/compiler-team#409.
Closes rust-lang/project-thir-unsafeck#1.
r? `@ghost` cc `@nikomatsakis` `@oli-obk`
2021-03-11 15:34:01 +00:00
Oli Scherer c69b108d2a Reintroduce accidentally deleted assertions.
These were removed in https://github.com/rust-lang/rust/pull/50198
2021-03-11 14:56:03 +00:00
Camille GILLOT 34e92bbf65 Hash SyntaxContext first. 2021-03-11 12:31:31 +01:00
Camille GILLOT fe2d728e62 Remove useless method. 2021-03-11 12:24:58 +01:00
Camille GILLOT 84bf599bac Add inlining. 2021-03-11 12:24:43 +01:00
hyd-dev 00c08727c8 Adjust some #[cfg]s to take non-Unix non-Windows operating systems into account 2021-03-11 18:03:32 +08:00
bors 04fce73196 Auto merge of #82641 - camelid:lang-item-docs, r=jyn514
Improve lang item generated docs

cc https://rust-lang.zulipchat.com/#narrow/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F/near/226738260

r? `@jyn514`
2021-03-11 06:38:22 +00:00
bors b3ac52646f Auto merge of #82964 - Nicholas-Baron:shorten_middle_ty, r=jackh726
Shorten `rustc_middle::ty::mod`

Related to #60302.

This PR moves all `Adt*`, `Assoc*`, `Generic*`, and `UpVar*` types to separate files.
This, alongside some `use` reordering, puts `mod.rs` at ~2,200 lines, thus removing the `// ignore-tidy-filelength`.

The particular groups were chosen as they had 4 or more "substantive" members.
2021-03-11 04:09:44 +00:00
Josh Stone f7e75a2124 Update to rustc-rayon 0.3.1
This pulls in rust-lang/rustc-rayon#8 to fix #81425. (h/t @ammaraskar)

That revealed weak constraints on `rustc_arena::DropArena`, because its
`DropType` was holding type-erased raw pointers to generic `T`. We can
implement `Send` for `DropType` (under `cfg(parallel_compiler)`) by
requiring all `T: Send` before they're type-erased.
2021-03-10 17:53:35 -08:00
Tomasz Miąsko 1aee8083be Import small cold functions
The Rust code is often written under an assumption that for generic
methods inline attribute is mostly unnecessary, since for optimized
builds using ThinLTO, a method will be generated in at least one CGU and
available for import.

For example, deref implementations for Box, Vec, MutexGuard, and
MutexGuard are not currently marked as inline, neither is identity
implementation of From trait.

In PGO builds, when functions are determined to be cold, the default
multiplier of zero will stop the import, even for completely trivial
functions.

Increase slightly the default multiplier from 0 to 0.1 to import them
regardless.
2021-03-11 00:00:00 +00:00
Tomasz Miąsko 49431909a6 Validate rustc_layout_scalar_valid_range_{start,end} attributes 2021-03-11 00:00:00 +00:00
Tomasz Miąsko 1ba71abddd Inline Attribute::has_name 2021-03-11 16:04:14 +01:00
Nicholas-Baron d022142ade Moved more of the capture related types into closure.rs 2021-03-10 14:32:14 -08:00
Nicholas-Baron 90cbb39d74 Moved more types into upvar.rs (now named closure.rs) 2021-03-10 14:32:14 -08:00
Nicholas-Baron 0ba5a6b6e5 Moved all Adt* types to adt.rs 2021-03-10 14:32:14 -08:00
Nicholas-Baron ffcf7e8b6d Moved all Assoc* types to assoc.rs. 2021-03-10 14:32:13 -08:00
Nicholas-Baron 11e41b052f Moved types starting with 'Generic' into generics.rs. 2021-03-10 14:32:13 -08:00
Nicholas-Baron 5375575717 Moved UpVar* types to a separate file. 2021-03-10 14:32:13 -08:00