Commit graph

469 commits

Author SHA1 Message Date
Santiago Pastorino 35bf466a27
Remove super_traits_of query, just leave a helper function 2020-11-27 11:23:53 -03:00
Santiago Pastorino 67ea9b227f
Make super_traits_of return Lrc for cheaper clone 2020-11-27 11:23:52 -03:00
Santiago Pastorino ac1845a6f0
Fix super_predicates_that_define_assoc_type API doc 2020-11-27 11:23:52 -03:00
Santiago Pastorino b916ac6322
adjust super_predicates_that_define_assoc_type query description 2020-11-27 11:23:51 -03:00
Santiago Pastorino c0007a2d7e
Extract function trait_may_define_assoc_type 2020-11-27 11:23:50 -03:00
Santiago Pastorino b60a214c51
super_traits_of is now a query 2020-11-27 11:23:49 -03:00
Santiago Pastorino 2ca4964db5
Allow to self reference associated types in where clauses 2020-11-27 11:23:47 -03:00
Santiago Pastorino 24dcf6f7a2
Allow to use super trait bounds in where clauses 2020-11-27 11:23:47 -03:00
Jonas Schievink 005a3e5986
Rollup merge of #79402 - bugadani:typos, r=matthewjasper
Fix typos
2020-11-26 13:39:11 +01:00
Jonas Schievink 0ae653a531
Rollup merge of #79365 - richkadel:llvm-cov-map-version-4, r=wesleywiser
Upgrades the coverage map to Version 4

Changes the coverage map injected into binaries compiled with
`-Zinstrument-coverage` to LLVM Coverage Mapping Format, Version 4 (from
Version 3). Note, binaries compiled with this version will require LLVM
tools from at least LLVM Version 11.

r? ``@wesleywiser``
2020-11-26 13:39:09 +01:00
Rich Kadel fdbc121620
fix URLs in doc comment
The angle brackets were confusing my IDE and I thought they were unnecessary. I was wrong.
2020-11-25 13:30:33 -08:00
bors b48cafd9eb Auto merge of #79411 - tmiasko:naked-params, r=Amanieu
Validate use of parameters in naked functions

* Reject use of parameters inside naked function body.
* Reject use of patterns inside function parameters, to emphasize role
  of parameters a signature declaration (mirroring existing behaviour
  for function declarations) and avoid generating code introducing
  specified bindings.

Closes issues below by considering input to be ill-formed.

Closes #75922.
Closes #77848.
Closes #79350.
2020-11-25 21:22:46 +00:00
Dániel Buga 29e8e72675 Fix typos 2020-11-25 20:18:36 +01:00
bors db79d2f637 Auto merge of #79216 - Aaron1011:opt-on-disk-cache, r=pnkfelix
Only create `OnDiskCache` in incremental compilation mode

This lets us skip doing useless work when we're not in incremental
compilation mode.
2020-11-25 16:22:11 +00:00
bors ec039bd075 Auto merge of #79336 - camelid:rename-feature-oibit-to-auto, r=oli-obk
Rename `optin_builtin_traits` to `auto_traits`

They were originally called "opt-in, built-in traits" (OIBITs), but
people realized that the name was too confusing and a mouthful, and so
they were renamed to just "auto traits". The feature flag's name wasn't
updated, though, so that's what this PR does.

There are some other spots in the compiler that still refer to OIBITs,
but I don't think changing those now is worth it since they are internal
and not particularly relevant to this PR.

Also see <https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/opt-in.2C.20built-in.20traits.20(auto.20traits).20feature.20name>.

r? `@oli-obk` (feel free to re-assign if you're not the right reviewer for this)
2020-11-25 07:25:19 +00:00
Camelid 82dc99ba7a Use the name "auto traits" everywhere in the compiler
Goodbye, OIBIT!
2020-11-24 16:25:43 -08:00
Tomasz Miąsko 22d3431221 Validate use of parameters in naked functions
* Reject use of parameters inside naked function body.
* Reject use of patterns inside function parameters, to emphasize role
  of parameters a signature declaration (mirroring existing behaviour
  for function declarations) and avoid generating code introducing
  specified bindings.
2020-11-25 00:00:00 +00:00
Rich Kadel 5d5dc4c9d8 Updated links to LLVM 11 docs and types 2020-11-23 19:15:10 -08:00
Jonas Schievink 064c3c146a
Rollup merge of #79337 - LingMan:map, r=jyn514
Use Option::map instead of open coding it

r?  `@jonas-schievink` since you're frequently sniping these minor cleanups anyway.
`@rustbot` modify labels +C-cleanup  +T-compiler
2020-11-23 15:25:53 +01:00
Jonas Schievink c7a67209c8
Rollup merge of #79287 - jonas-schievink:const-trait-impl, r=oli-obk
Allow using generic trait methods in `const fn`

Next step for https://github.com/rust-lang/rust/issues/67792, this now also allows code like the following:

```rust
struct S;

impl const PartialEq for S {
    fn eq(&self, _: &S) -> bool {
        true
    }
}

const fn equals_self<T: PartialEq>(t: &T) -> bool {
    *t == *t
}

pub const EQ: bool = equals_self(&S);
```

This works by threading const-ness of trait predicates through trait selection, in particular through `ParamCandidate`, and exposing it in the resulting `ImplSource`.

Since this change makes two bounds `T: Trait` and `T: ?const Trait` that only differ in their const-ness be treated like different bounds, candidate winnowing has been changed to drop the `?const` candidate in favor of the const candidate, to avoid ambiguities when both a const and a non-const bound is present.
2020-11-23 15:25:44 +01:00
Jonas Schievink d4a05696d9
Rollup merge of #79080 - camelid:mir-visit-debuginfo-project, r=jonas-schievink
MIR visitor: Don't treat debuginfo field access as a use of the struct

Fixes #77454.

r? `@jonas-schievink`
2020-11-23 15:25:40 +01:00
LingMan cd8973250d Use Option::map instead of open coding it 2020-11-23 04:58:21 +01:00
Camelid b196bec236 Add comment and remove obsolete special case 2020-11-22 17:39:15 -08:00
Jonas Schievink ee6f42ba94 Thread Constness through selection 2020-11-22 02:13:53 +01:00
bjorn3 43968aa8b8 Replace sext() and zext() with single ext() method 2020-11-21 19:22:31 +01:00
bjorn3 39b8b2b623 Remove StructRet arg attr
It is applied exactly when the return value has an indirect pass mode.
Except for InReg on x86 fastcall, arg attrs are now only used for
optimization purposes and thus are fine to ignore.
2020-11-21 19:22:31 +01:00
bjorn3 42b0b8080d Replace ByVal attribute with on_stack field for Indirect
This makes it clearer that only PassMode::Indirect allows ByVal
2020-11-21 19:22:30 +01:00
bjorn3 967a228208 Replace ZExt and SExt flags with ArgExtension enum
Both flags are mutually exclusive
2020-11-21 19:07:38 +01:00
Aaron Hill d00ed01876
Only create OnDiskCache in incremental compilation mode
This lets us skip doing useless work when we're not in incremental
compilation mode.
2020-11-19 15:50:55 -05:00
Tyson Nottingham 05dde137ca Make PackedFingerprint's Fingerprint private 2020-11-18 15:10:43 -08:00
Tyson Nottingham f09d474836 Use PackedFingerprint in DepNode to reduce memory consumption 2020-11-18 12:49:09 -08:00
Mara Bos 43d13e2d58
Rollup merge of #79158 - lcnr:lazy-norm-coerce, r=oli-obk
type is too big -> values of the type are too big

strictly speaking, `[u8; usize::MAX]` or even `[[[u128; usize::MAX]; usize::MAX]; usize::MAX]` are absolutely fine types as long as you don't try to deal with any values of it.

This error message seems to cause some confusion imo, for example in https://github.com/rust-lang/rust/pull/79135#issuecomment-729361380 so I would prefer us to be more precise here.

See the added test case which uses one of these types without causing an error.

r? ``@oli-obk``
2020-11-18 15:46:40 +01:00
Mara Bos f85c3f72a4
Rollup merge of #79079 - camelid:mir-visit-docs, r=matthewjasper
Turn top-level comments into module docs in MIR visitor
2020-11-18 15:46:29 +01:00
Mara Bos 92dcf6d733
Rollup merge of #78999 - petrochenkov:deprid, r=eddyb
stability: More precise location for deprecation lint on macros

One missing piece of https://github.com/rust-lang/rust/pull/73178.
2020-11-18 15:46:25 +01:00
Bastian Kauschke 88584d5800 change error for LayoutErr::SizeOverflow 2020-11-18 11:38:30 +01:00
Joshua Nelson c9a17b1d3f Fix broken handling of MacroDef in Map::attrs
This also uses an exhaustive match to avoid future similar bugs.
2020-11-17 15:13:25 -05:00
Mara Bos b6f52410bb
Rollup merge of #79072 - oli-obk:byte_str_pat, r=estebank
Fix exhaustiveness in case a byte string literal is used at slice type

fixes #79048
2020-11-17 16:13:53 +01:00
bors e0ef0fc392 Auto merge of #78779 - LeSeulArtichaut:ty-visitor-return, r=oli-obk
Introduce `TypeVisitor::BreakTy`

Implements MCP rust-lang/compiler-team#383.
r? `@ghost`
cc `@lcnr` `@oli-obk`

~~Blocked on FCP in rust-lang/compiler-team#383.~~
2020-11-17 12:24:34 +00:00
oli a1cdf722f4 Fix exhaustiveness in case a byte string literal is used at slice type 2020-11-17 09:07:23 +00:00
Mara Bos 336dc18aa3
Rollup merge of #79027 - tmiasko:inline-always-live-locals, r=oli-obk
Limit storage duration of inlined always live locals

Closes #76375.
2020-11-17 10:06:21 +01:00
bors b5c37e86ff Auto merge of #78801 - sexxi-goose:min_capture, r=nikomatsakis
RFC-2229: Implement Precise Capture Analysis

### This PR introduces
- Feature gate for RFC-2229 (incomplete) `capture_disjoint_field`
- Rustc Attribute to print out the capture analysis `rustc_capture_analysis`
- Precise capture analysis

### Description of the analysis
1. If the feature gate is not set then all variables that are not local to the closure will be added to the list of captures. (This is for backcompat)
2. The rest of the analysis is based entirely on how the captured `Place`s are used within the closure. Precise information (i.e. projections) about the `Place` is maintained throughout.
3. To reduce the amount of information we need to keep track of, we do a minimization step. In this step, we determine a list such that no Place within this list represents an ancestor path to another entry in the list.  Check rust-lang/project-rfc-2229#9 for more detailed examples.
4. To keep the compiler functional as before we implement a Bridge between the results of this new analysis to existing data structures used for closure captures. Note the new capture analysis results are only part of MaybeTypeckTables that is the information is only available during typeck-ing.

### Known issues
- Statements like `let _ = x` will make the compiler ICE when used within a closure with the feature enabled. More generally speaking the issue is caused by `let` statements that create no bindings and are init'ed using a Place expression.

### Testing
We removed the code that would handle the case where the feature gate is not set, to enable the feature as default and did a bors try and perf run. More information here: #78762

### Thanks
This has been slowly in the works for a while now.
I want to call out `@Azhng` `@ChrisPardy` `@null-sleep` `@jenniferwills` `@logmosier` `@roxelo` for working on this and the previous PRs that led up to this, `@nikomatsakis` for guiding us.

Closes rust-lang/project-rfc-2229#7
Closes rust-lang/project-rfc-2229#9
Closes rust-lang/project-rfc-2229#6
Closes rust-lang/project-rfc-2229#19

r? `@nikomatsakis`
2020-11-17 03:56:03 +00:00
lcnr a6cbd64dae words 2020-11-16 22:42:09 +01:00
Bastian Kauschke 2bf93bd852 compiler: fold by value 2020-11-16 22:34:57 +01:00
Aman Arora 40dfe1eddd Ignore doctest for capture analysis examples 2020-11-15 18:53:03 -05:00
Camelid f7bf282d9b MIR visitor: Don't treat debuginfo field access as a use of the struct 2020-11-15 12:58:34 -08:00
Camelid c82a258ad4 Turn top-level comments into module docs in MIR visitor 2020-11-15 12:36:28 -08:00
LeSeulArtichaut f6e6a15f07 Remove dead TypeFoldable::visit_tys_shallow method 2020-11-15 14:45:41 +01:00
Jonas Schievink ce775bc4f6
Rollup merge of #79036 - cjgillot:steal, r=oli-obk
Move Steal to rustc_data_structures.
2020-11-15 13:39:59 +01:00
Dylan DPC 335a2554f9
Rollup merge of #78963 - richkadel:llvm-coverage-counters-2.0.4, r=tmandry
Added some unit tests as requested

As discussed in PR #78267, for example:

* https://github.com/rust-lang/rust/pull/78267#discussion_r515404722
* https://github.com/rust-lang/rust/pull/78267#discussion_r515405958

r? ```````@tmandry```````
FYI: ```````@wesleywiser```````

This is pretty much self contained, but depending on feedback and timing, I may have a chance to add a few more unit tests requested against `counters.rs`. I'm looking at those now.
2020-11-15 03:02:46 +01:00
Tomasz Miąsko f27d56d1ff Limit storage duration of inlined always live locals 2020-11-15 00:00:00 +00:00