about summary refs log tree commit diff
path: root/compiler/rustc_mir/src
AgeCommit message (Collapse)AuthorLines
2021-03-15s/ConstantSource/ConstantKind/Oli Scherer-12/+12
2021-03-14remove unnecessary conditionErik Desjardins-3/+1
`_local` isn't visited in `_local = <rhs>` statements in the situation we care about
2021-03-13Move ZST check inside UsedLocalsSimon Vandel Sillesen-50/+53
2021-03-13Extend SimplifyLocals to remove ZST writesSimon Vandel Sillesen-3/+27
2021-03-12We won't support trait object constants in type level constants for the ↵Oli Scherer-3/+5
forseeable future
2021-03-12Prepare mir::Constant for ty::Const only supporting valtreesOli Scherer-107/+157
2021-03-12Intern valtree field vectorOli Scherer-3/+7
2021-03-12Implement valtreeOli Scherer-3/+95
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-12Auto merge of #82935 - henryboisdequin:diagnostic-cleanups, r=estebankbors-6/+7
Diagnostic cleanups Follow up to #81503 Helps with #82916 (don't show note if `span` is `DUMMY_SP`)
2021-03-12Don't show note if `span` is `DUMMY_SP`Henry Boisdequin-6/+7
2021-03-10Auto merge of #82982 - Dylan-DPC:rollup-mt497z7, r=Dylan-DPCbors-3/+7
Rollup of 9 pull requests Successful merges: - #81309 (always eagerly eval consts in Relate) - #82217 (Edition-specific preludes) - #82807 (rustdoc: Remove redundant enableSearchInput function) - #82924 (WASI: Switch to crt1-command.o to enable support for new-style commands) - #82949 (Do not attempt to unlock envlock in child process after a fork.) - #82955 (fix: wrong word) - #82962 (Treat header as first paragraph for shortened markdown descriptions) - #82976 (fix error message for copy(_nonoverlapping) overflow) - #82977 (Rename `Option::get_or_default` to `get_or_insert_default`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-03-10Rollup merge of #82977 - camsteffen:opt-get-insert-def, r=m-ou-seDylan DPC-2/+3
Rename `Option::get_or_default` to `get_or_insert_default` ...as [suggested](https://github.com/rust-lang/rust/issues/82901#issuecomment-793548515) by `@m-ou-se.` In hindsight this seems rather obvious, at least to me. r? `@joshtriplett`
2021-03-10Auto merge of #76570 - cratelyn:implement-rfc-2945-c-unwind-abi, r=Amanieubors-3/+3
Implement RFC 2945: "C-unwind" ABI ## Implement RFC 2945: "C-unwind" ABI This branch implements [RFC 2945]. The tracking issue for this RFC is #74990. The feature gate for the issue is `#![feature(c_unwind)]`. This RFC was created as part of the ffi-unwind project group tracked at rust-lang/lang-team#19. ### Changes Further details will be provided in commit messages, but a high-level overview of the changes follows: * A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`, and `Thiscall` variants, marking whether unwinding across FFI boundaries is acceptable. The cases where each of these variants' `unwind` member is true correspond with the `C-unwind`, `system-unwind`, `stdcall-unwind`, and `thiscall-unwind` ABI strings introduced in RFC 2945 [3]. * This commit adds a `c_unwind` feature gate for the new ABI strings. Tests for this feature gate are included in `src/test/ui/c-unwind/`, which ensure that this feature gate works correctly for each of the new ABIs. A new language features entry in the unstable book is added as well. * We adjust the `rustc_middle::ty::layout::fn_can_unwind` function, used to compute whether or not a `FnAbi` object represents a function that should be able to unwind when `panic=unwind` is in use. * Changes are also made to `rustc_mir_build::build::should_abort_on_panic` so that the function ABI is used to determind whether it should abort, assuming that the `panic=unwind` strategy is being used, and no explicit unwind attribute was provided. [RFC 2945]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md
2021-03-10Rename Option::get_or_insert_defaultCameron Steffen-2/+3
2021-03-10fix error message for copy(_nonoverlapping) overflowRalf Jung-1/+4
2021-03-10fix copy_nonoverlappingRalf Jung-7/+8
2021-03-10Rollup merge of #82849 - camsteffen:option-get-or-default, r=joshtriplettYuki Okushi-4/+2
Add Option::get_or_default Tracking issue: #82901 The original issue is #55042, which was closed, but for an invalid reason (see discussion there). Opening this to reconsider (I hope that's okay). It seems like the only gap for `Option` being "entry-like". I ran into a need for this method where I had a `Vec<Option<MyData>>` and wanted to do `vec[n].get_or_default().my_data_method()`. Using an `Option` as an inner component of a data structure is probably where the need for this will normally arise.
2021-03-10Rollup merge of #79208 - LeSeulArtichaut:stable-unsafe_op_in_unsafe_fn, ↵Yuki Okushi-3/+2
r=nikomatsakis Stabilize `unsafe_op_in_unsafe_fn` lint This makes it possible to override the level of the `unsafe_op_in_unsafe_fn`, as proposed in https://github.com/rust-lang/rust/issues/71668#issuecomment-729770896. Tracking issue: #71668 r? ```@nikomatsakis``` cc ```@SimonSapin``` ```@RalfJung``` # Stabilization report This is a stabilization report for `#![feature(unsafe_block_in_unsafe_fn)]`. ## Summary Currently, the body of unsafe functions is an unsafe block, i.e. you can perform unsafe operations inside. The `unsafe_op_in_unsafe_fn` lint, stabilized here, can be used to change this behavior, so performing unsafe operations in unsafe functions requires an unsafe block. For now, the lint is allow-by-default, which means that this PR does not change anything without overriding the lint level. For more information, see [RFC 2585](https://github.com/rust-lang/rfcs/blob/master/text/2585-unsafe-block-in-unsafe-fn.md) ### Example ```rust // An `unsafe fn` for demonstration purposes. // Calling this is an unsafe operation. unsafe fn unsf() {} // #[allow(unsafe_op_in_unsafe_fn)] by default, // the behavior of `unsafe fn` is unchanged unsafe fn allowed() { // Here, no `unsafe` block is needed to // perform unsafe operations... unsf(); // ...and any `unsafe` block is considered // unused and is warned on by the compiler. unsafe { unsf(); } } #[warn(unsafe_op_in_unsafe_fn)] unsafe fn warned() { // Removing this `unsafe` block will // cause the compiler to emit a warning. // (Also, no "unused unsafe" warning will be emitted here.) unsafe { unsf(); } } #[deny(unsafe_op_in_unsafe_fn)] unsafe fn denied() { // Removing this `unsafe` block will // cause a compilation error. // (Also, no "unused unsafe" warning will be emitted here.) unsafe { unsf(); } } ```
2021-03-09rustc_target: add "unwind" payloads to `Abi`katelyn a. martin-3/+3
### Overview This commit begins the implementation work for RFC 2945. For more information, see the rendered RFC [1] and tracking issue [2]. A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`, and `Thiscall` variants, marking whether unwinding across FFI boundaries is acceptable. The cases where each of these variants' `unwind` member is true correspond with the `C-unwind`, `system-unwind`, `stdcall-unwind`, and `thiscall-unwind` ABI strings introduced in RFC 2945 [3]. ### Feature Gate and Unstable Book This commit adds a `c_unwind` feature gate for the new ABI strings. Tests for this feature gate are included in `src/test/ui/c-unwind/`, which ensure that this feature gate works correctly for each of the new ABIs. A new language features entry in the unstable book is added as well. ### Further Work To Be Done This commit does not proceed to implement the new unwinding ABIs, and is intentionally scoped specifically to *defining* the ABIs and their feature flag. ### One Note on Test Churn This will lead to some test churn, in re-blessing hash tests, as the deleted comment in `src/librustc_target/spec/abi.rs` mentioned, because we can no longer guarantee the ordering of the `Abi` variants. While this is a downside, this decision was made bearing in mind that RFC 2945 states the following, in the "Other `unwind` Strings" section [3]: > More unwind variants of existing ABI strings may be introduced, > with the same semantics, without an additional RFC. Adding a new variant for each of these cases, rather than specifying a payload for a given ABI, would quickly become untenable, and make working with the `Abi` enum prone to mistakes. This approach encodes the unwinding information *into* a given ABI, to account for the future possibility of other `-unwind` ABI strings. ### Ignore Directives `ignore-*` directives are used in two of our `*-unwind` ABI test cases. Specifically, the `stdcall-unwind` and `thiscall-unwind` test cases ignore architectures that do not support `stdcall` and `thiscall`, respectively. These directives are cribbed from `src/test/ui/c-variadic/variadic-ffi-1.rs` for `stdcall`, and `src/test/ui/extern/extern-thiscall.rs` for `thiscall`. This would otherwise fail on some targets, see: https://github.com/rust-lang-ci/rust/commit/fcf697f90206e9c87b39d494f94ab35d976bfc60 ### Footnotes [1]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md [2]: https://github.com/rust-lang/rust/issues/74990 [3]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md#other-unwind-abi-strings
2021-03-09Clean up todoskadmin-77/+63
Also add some span_bugs where it is unreachable
2021-03-09Switch to changing cp_non_overlap in tformkadmin-36/+63
It was suggested to lower this in MIR instead of ssa, so do that instead.
2021-03-09Replace todos with implskadmin-8/+44
Changed to various implementations, copying the style of prior function calls in places I was unsure of. Also one minor style nit.
2021-03-09Update craneliftkadmin-1288/+24
2021-03-09Update interpret stepkadmin-3/+13
2021-03-09Update match brancheskadmin-0/+1319
This updates all places where match branches check on StatementKind or UseContext. This doesn't properly implement them, but adds TODOs where they are, and also adds some best guesses to what they should be in some cases.
2021-03-09Rollup merge of #82841 - hvdijk:x32, r=joshtriplettMara Bos-8/+8
Change x64 size checks to not apply to x32. Rust contains various size checks conditional on target_arch = "x86_64", but these checks were never intended to apply to x86_64-unknown-linux-gnux32. Add target_pointer_width = "64" to the conditions.
2021-03-08Use Option::get_or_defaultCameron Steffen-4/+2
2021-03-08Rollup merge of #82684 - tmiasko:dest-prop, r=jonas-schievinkDylan DPC-0/+5
Disable destination propagation on all mir-opt-levels The new `// compile-flags: -Zunsound-mir-opts` are inserted without an extra newline to avoid introducing a large mir-opt diff.
2021-03-08Auto merge of #82727 - oli-obk:shrinkmem, r=pnkfelixbors-36/+44
Test the effect of shrinking the size of Rvalue by 16 bytes r? `@ghost`
2021-03-06Change x64 size checks to not apply to x32.Harald van Dijk-8/+8
Rust contains various size checks conditional on target_arch = "x86_64", but these checks were never intended to apply to x86_64-unknown-linux-gnux32. Add target_pointer_width = "64" to the conditions.
2021-03-06Disable destination propagation on all mir-opt-levelsTomasz Miąsko-0/+5
2021-03-05Rollup merge of #82736 - spastorino:mir-opt-level-perf-changes, r=oli-obkGuillaume Gomez-18/+18
Bump optimization from mir_opt_level 2 to 3 and 3 to 4 and make "release" be level 2 by default r? `@oli-obk`
2021-03-05Bump one missing mir_opt_levelSantiago Pastorino-1/+1
2021-03-05Bump all mir_opt_level 2 to 3Santiago Pastorino-7/+7
2021-03-05Bump all mir_opt_level 3 to 4Santiago Pastorino-7/+7
2021-03-05For better consistency change mir_opt_level <= 1 to < 2Santiago Pastorino-2/+2
2021-03-05Extract mir_opt_level to a method and use Option to be able to know if the ↵Santiago Pastorino-13/+13
value is provided or not
2021-03-05Auto merge of #82795 - m-ou-se:rollup-uzx0b92, r=m-ou-sebors-8/+33
Rollup of 10 pull requests Successful merges: - #80723 (Implement NOOP_METHOD_CALL lint) - #80763 (resolve: Reduce scope of `pub_use_of_private_extern_crate` deprecation lint) - #81136 (Improved IO Bytes Size Hint) - #81939 (Add suggestion `.collect()` for iterators in iterators) - #82289 (Fix underflow in specialized ZipImpl::size_hint) - #82728 (Avoid unnecessary Vec construction in BufReader) - #82764 (Add {BTreeMap,HashMap}::try_insert) - #82770 (Add assert_matches macro.) - #82773 (Add diagnostic item to `Default` trait) - #82787 (Remove unused code from main.js) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-03-05Rollup merge of #81939 - kper:fixing-81584-allocate-in-iter, r=davidtwcoMara-4/+29
Add suggestion `.collect()` for iterators in iterators Closes #81584 ``` error[E0515]: cannot return value referencing function parameter `y` --> main3.rs:4:38 | 4 | ... .map(|y| y.iter().map(|x| x + 1)) | -^^^^^^^^^^^^^^^^^^^^^^ | | | returns a value referencing data owned by the current function | `y` is borrowed here | help: Maybe use `.collect()` to allocate the iterator ``` Added the suggestion: `help: Maybe use `.collect()` to allocate the iterator`
2021-03-05Rollup merge of #80723 - rylev:noop-lint-pass, r=estebankMara-4/+4
Implement NOOP_METHOD_CALL lint Implements the beginnings of https://github.com/rust-lang/lang-team/issues/67 - a lint for detecting noop method calls (e.g, calling `<&T as Clone>::clone()` when `T: !Clone`). This PR does not fully realize the vision and has a few limitations that need to be addressed either before merging or in subsequent PRs: * [ ] No UFCS support * [ ] The warning message is pretty plain * [ ] Doesn't work for `ToOwned` The implementation uses [`Instance::resolve`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/instance/struct.Instance.html#method.resolve) which is normally later in the compiler. It seems that there are some invariants that this function relies on that we try our best to respect. For instance, it expects substitutions to have happened, which haven't yet performed, but we check first for `needs_subst` to ensure we're dealing with a monomorphic type. Thank you to ```@davidtwco,``` ```@Aaron1011,``` and ```@wesleywiser``` for helping me at various points through out this PR ❤️.
2021-03-05Shrink the size of Rvalue by 16 bytesOli Scherer-36/+44
2021-03-04Fixes -Zpolymorphize for src/test/ui/const-generics/auxiliary/crayte.rsOli Scherer-9/+39
2021-03-04Spread tracing instrumentation into the polymorphization logicOli Scherer-33/+27
2021-03-04Auto merge of #81114 - bugadani:generator, r=estebankbors-19/+17
Box generator-related Body fields Might save some memory on functions that aren't generators.
2021-03-03Fix testsRyan Levick-4/+4
2021-03-02Rollup merge of #82376 - tmiasko:inline-options, r=oli-obkYuki Okushi-17/+22
Add option to enable MIR inlining independently of mir-opt-level Add `-Zinline-mir` option that enables MIR inlining independently of the current MIR opt level. The primary use-case is enabling MIR inlining on the default MIR opt level. Turn inlining thresholds into optional values to make it possible to configure different defaults depending on the current mir-opt-level (although thresholds are yet to be used in such a manner).
2021-03-02Rollup merge of #80734 - abonander:ab/issue-66693, r=oli-obkGuillaume Gomez-2/+22
check that first arg to `panic!()` in const is `&str` closes #66693 ~~TODO: regression test~~ cc `@RalfJung` for error message wording
2021-03-01check that first arg to `panic!()` in const is `&str`Austin Bonander-2/+22
2021-03-01Box generator-related Body fieldsDániel Buga-19/+17
2021-02-28Remove storage markers if they won't be used during code generationTomasz Miąsko-0/+27
The storage markers constitute a substantial portion of all MIR statements. At the same time, for builds without any optimizations, the storage markers have no further use during and after MIR optimization phase. If storage markers are not necessary for code generation, remove them.