summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty
AgeCommit message (Collapse)AuthorLines
2021-03-19Rollup merge of #83297 - oli-obk:why_bug_today_if_you_can_delay_to_tomorrow, ↵Dylan DPC-5/+9
r=petrochenkov Do not ICE on ty::Error as an error must already have been reported fixes #83253
2021-03-19Do not ICE on ty::Error as an error must already have been reportedOli Scherer-5/+9
2021-03-19Hash hir_owner in typeck resultsAman Arora-1/+3
2021-03-18Replace closures_captures and upvar_capture with closure_min_capturesJennifer Wills-35/+52
make changes to liveness to use closure_min_captures use different span borrow check uses new structures rename to CapturedPlace stop using upvar_capture in regionck remove the bridge cleanup from rebase + remove the upvar_capture reference from mutability_errors.rs remove line from livenes test make our unused var checking more consistent update tests adding more warnings to the tests move is_ancestor_or_same_capture to rustc_middle/ty update names to reflect the closures add FIXME check that all captures are immutable borrows before returning add surrounding if statement like the original move var out of the loop and rename Co-authored-by: Logan Mosier <logmosier@gmail.com> Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
2021-03-18hir: Preserve used syntax in `TyKind::TraitObject`Vadim Petrochenkov-0/+1
2021-03-17Auto merge of #83090 - jackh726:bound_var_replacer_option, r=varkorbors-55/+53
Make functions passed to BoundVarReplacer be optional This means we can reuse the bound vars when we don't care to change them
2021-03-16Auto merge of #82936 - oli-obk:valtree, r=RalfJung,lcnr,matthewjasperbors-141/+248
Implement (but don't use) valtree and refactor in preparation of use This PR does not cause any functional change. It refactors various things that are needed to make valtrees possible. This refactoring got big enough that I decided I'd want it reviewed as a PR instead of trying to make one huge PR with all the changes. cc `@rust-lang/wg-const-eval` on the following commits: * 2027184 implement valtree * eeecea9 fallible Scalar -> ScalarInt * 042f663 ScalarInt convenience methods cc `@eddyb` on ef04a6d cc `@rust-lang/wg-mir-opt` for cf1700c (`mir::Constant` can now represent either a `ConstValue` or a `ty::Const`, and it is totally possible to have two different representations for the same value)
2021-03-16Auto merge of #82536 - sexxi-goose:handle-patterns-take-2, r=nikomatsakisbors-0/+28
2229: Handle patterns within closures correctly when `capture_disjoint_fields` is enabled This PR fixes several issues related to handling patterns within closures when `capture_disjoint_fields` is enabled. 1. Matching is always considered a use of the place, even with `_` patterns 2. Compiler ICE when capturing fields in closures through `let` assignments To do so, we - Introduced new Fake Reads - Delayed use of `Place` in favor of `PlaceBuilder` - Ensured that `PlaceBuilder` can be resolved before attempting to extract `Place` in any of the pattern matching code Closes rust-lang/project-rfc-2229/issues/27 Closes rust-lang/project-rfc-2229/issues/24 r? `@nikomatsakis`
2021-03-16Update compiler/rustc_middle/src/ty/consts/valtree.rsOli Scherer-1/+1
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-03-16Update compiler/rustc_middle/src/ty/consts/valtree.rsOli Scherer-1/+2
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-03-16Use delay_span_bug instead of panic in layout_scalar_valid_rangeTomasz Miąsko-6/+9
83054 introduced validation of scalar range attributes, but panicking code that uses the attribute remained reachable. Use `delay_span_bug` instead to avoid the ICE.
2021-03-15Make functions passed to BoundVarReplacer be optionalJack Huey-55/+53
2021-03-15Add comments with examples and testsRoxane-1/+23
2021-03-15Pacify tidyOli Scherer-1/+1
2021-03-15Do not expose fallible `to_int` operation on `Scalar`.Oli Scherer-1/+1
Any use of it has been shown to be a bug in the past.
2021-03-15Document valtreeOli Scherer-0/+18
2021-03-14Don't encode file information for span with a dummy locationAaron Hill-3/+3
Fixes #83112 The location information for a dummy span isn't real, so don't encode it. This brings the incr comp cache code into line with the Span `StableHash` impl, which doesn't hash the location information for dummy spans. Previously, we would attempt to load the 'original' file from a dummy span - if the file id changed (e.g. due to being moved on disk), we would get an ICE, since the Span was still valid due to its hash being unchanged.
2021-03-14Use the correct FakeReadCauseRoxane-2/+2
2021-03-14Introduce new fake readsRoxane-0/+6
2021-03-12Directly intern allocations so that we can write a `Lift` impl for themOli Scherer-6/+29
2021-03-12Split pretty printer logic for scalar int and scalar ptrOli Scherer-46/+67
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-12Pull out ConstValue relating into its own functionOli Scherer-46/+51
2021-03-12Reduce the duplication in the relation logic for constantsOli Scherer-67/+45
2021-03-12Reduce destructuring and re-interning where possibleOli Scherer-15/+18
2021-03-12Resolve a FIXME around type equality checks in Relate for constantsOli Scherer-6/+9
2021-03-12Add convenience conversion methods for ScalarIntOli Scherer-2/+30
2021-03-12Intern valtree field vectorOli Scherer-5/+15
2021-03-12Implement valtreeOli Scherer-2/+19
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-11Auto merge of #82964 - Nicholas-Baron:shorten_middle_ty, r=jackh726bors-1240/+1279
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-10Moved more of the capture related types into closure.rsNicholas-Baron-172/+173
2021-03-10Moved more types into upvar.rs (now named closure.rs)Nicholas-Baron-169/+170
2021-03-10Moved all Adt* types to adt.rsNicholas-Baron-467/+488
2021-03-10Moved all Assoc* types to assoc.rs.Nicholas-Baron-162/+173
2021-03-10Moved types starting with 'Generic' into generics.rs.Nicholas-Baron-248/+259
2021-03-10Moved UpVar* types to a separate file.Nicholas-Baron-64/+74
2021-03-10Grouped some ungrouped use and mod lines.Nicholas-Baron-35/+19
2021-03-10Auto merge of #82982 - Dylan-DPC:rollup-mt497z7, r=Dylan-DPCbors-3/+5
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 #81309 - lcnr:lazy-norm-err-msgh, r=nikomatsakisDylan DPC-3/+5
always eagerly eval consts in Relate r? ```@nikomatsakis``` cc ```@varkor```
2021-03-09address pr review commentskatelyn a. martin-1/+19
### Add debug assertion to check `AbiDatas` ordering This makes a small alteration to `Abi::index`, so that we include a debug assertion to check that the index we are returning corresponds with the same abi in our data array. This will help prevent ordering bugs in the future, which can manifest in rather strange errors. ### Using exhaustive ABI matches This slightly modifies the changes from our previous commits, favoring exhaustive matches in place of `_ => ...` fall-through arms. This should help with maintenance in the future, when additional ABI's are added, or when existing ABI's are modified. ### List all `-unwind` ABI's in unstable book This updates the `c-unwind` page in the unstable book to list _all_ of the other ABI strings that are introduced by this feature gate. Now, all of the ABI's specified by RFC 2945 are shown. Co-authored-by: Amanieu d'Antras <amanieu@gmail.com> Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2021-03-09implement unwinding abi's (RFC 2945)katelyn a. martin-12/+17
### Changes This commit implements unwind ABI's, specified in RFC 2945. 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. ### Tests Unit tests, checking that the behavior is correct for `C-unwind`, `stdcall-unwind`, `system-unwind`, and `thiscall-unwind`, are included. These alternative `unwind` ABI strings are specified in RFC 2945, in the "_Other `unwind` ABI strings_" section. Additionally, a test case is included to assert that the LLVM IR generated for an external function defined with the `C-unwind` ABI will be appropriately labeled with the `nounwind` LLVM attribute when the `panic=abort` compilation flag is used. ### Ignore Directives This commit uses `ignore-*` directives 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`.
2021-03-09rustc_target: add "unwind" payloads to `Abi`katelyn a. martin-4/+4
### 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-06Change x64 size checks to not apply to x32.Harald van Dijk-5/+5
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-05Auto merge of #82795 - m-ou-se:rollup-uzx0b92, r=m-ou-sebors-2/+0
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 #80723 - rylev:noop-lint-pass, r=estebankMara-2/+0
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-04TypoOli Scherer-1/+1
2021-03-04Remove a dead code pathOli Scherer-1/+4
2021-03-04Auto merge of #81114 - bugadani:generator, r=estebankbors-1/+1
Box generator-related Body fields Might save some memory on functions that aren't generators.
2021-03-03Fix testsRyan Levick-2/+0
2021-03-02Revert non-power-of-two vector restrictionErin Power-5/+0
2021-03-01Box generator-related Body fieldsDániel Buga-1/+1