Commit graph

1606 commits

Author SHA1 Message Date
Ralf Jung
d4f7dd6702 CTFE/Miri engine Pointer type overhaul: make Scalar-to-Pointer conversion infallible
This resolves all the problems we had around "normalizing" the representation of a Scalar in case it carries a Pointer value: we can just use Pointer if we want to have a value taht we are sure is already normalized.
2021-07-14 18:17:46 +02:00
Eric Huss
636fcacb44 Add -Zfuture-incompat-test to assist with testing future-incompat reports. 2021-07-14 08:37:58 -07:00
Camille GILLOT
3fba5a4844 Shrink the CrateStore dynamic interface. 2021-07-14 16:37:56 +02:00
bors
c7d6bcc788 Auto merge of #87044 - cjgillot:expnhash, r=petrochenkov
Cache expansion hash globally

... instead of computing it multiple times.

Split from #86676
r? `@petrochenkov`
2021-07-13 22:32:58 +00:00
Camille GILLOT
616ce3c5c0 Cache expansion hash. 2021-07-13 23:10:56 +02:00
jackh726
09978bdcd1 Conditionally call normalize_erasing_regions only if polymorhization is enabled 2021-07-13 15:09:01 -04:00
Ellen
8c40360ed4 Put checking if anonct is a default into a method on hir map 2021-07-13 17:23:51 +01:00
bors
394804bb23 Auto merge of #86857 - fee1-dead:add-attr, r=oli-obk
Add #[default_method_body_is_const]

`@rustbot` label F-const_trait_impl
2021-07-13 06:59:34 +00:00
Yuki Okushi
e46b790b9d
Rollup merge of #87089 - RalfJung:ctfe-memory-cleanup, r=oli-obk
CTFE engine: small cleanups

I noticed these while preparing a large PR, and figured I'd better send them ahead to not muddy the diff unnecessarily.

- remove remaining use of Pointer in Allocation API (I missed those in https://github.com/rust-lang/rust/pull/85472)
- remove unnecessary deallocate_local hack (this logic does not seem necessary any more)

r? `@oli-obk`
2021-07-13 08:54:39 +09:00
Yuki Okushi
8d4293c1d4
Rollup merge of #87070 - ehuss:simplify-future-report, r=oli-obk
Simplify future incompatible reporting.

This simplifies the implementation of the future incompatible reporting system. Instead of having a separate field in the future_incompatible definition, this reuses the `FutureIncompatibilityReason` enum. It also drops the "date" field. Cargo does not use the date field, and there isn't much of a need for this to be structured, and I am skeptical that the date can be predicted reliably. The date or release version can be listed in the lint text if desired.
2021-07-13 08:54:36 +09:00
bors
955b9c0d4c Auto merge of #86320 - hi-rustin:rustin-patch-fix-span, r=estebank
shrinking the deprecated span

ref: https://github.com/rust-lang/rust/pull/85617#issuecomment-854947988

part of #85403

r? `@estebank`

The reason is that if we use method_span directly, it will cause the in_derive_expansion judgment to fail.
2021-07-12 20:43:28 +00:00
Ralf Jung
c8baac5776 remove remaining use of Pointer in Allocation API 2021-07-12 18:45:26 +02:00
Eric Huss
4d1daf8683 Simplify future incompatible reporting. 2021-07-11 13:08:58 -07:00
bors
72568552fd Auto merge of #85941 - cjgillot:qresolve, r=Aaron1011
Reduce the amount of untracked state in TyCtxt -- Take 2

Main part of #85153

The offending line (https://github.com/rust-lang/rust/pull/85153#discussion_r642866298) is replaced by a FIXME until the possible bug and the perf concern are both resolved.

r? `@Aaron1011`
2021-07-11 16:09:17 +00:00
Vadim Petrochenkov
28f4dba438 rustc_span: Revert addition of proc_macro field to ExpnKind::Macro
The flag has a vague meaning and is used for a single diagnostic change that is low benefit and appears only under `-Z macro_backtrace`.
2021-07-10 23:03:35 +03:00
bors
a31431fce7 Auto merge of #87029 - JohnTitor:rollup-0yapv7z, r=JohnTitor
Rollup of 5 pull requests

Successful merges:

 - #87006 (Revert the revert of renaming traits::VTable to ImplSource)
 - #87011 (avoid reentrant lock acquire when ThreadIds run out)
 - #87013 (Fix several ICEs related to malformed `#[repr(...)]` attributes)
 - #87020 (remove const_raw_ptr_to_usize_cast feature)
 - #87028 (Fix type: `'satic` -> `'static`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-07-10 16:41:26 +00:00
Ellen
b44be27999 Moves changes to explicit_preds_of/inferred_outlives_of/generics_of 2021-07-10 17:29:11 +01:00
Yuki Okushi
632f84f4cb
Rollup merge of #87006 - ptrojahn:implsource_vtable, r=jonas-schievink
Revert the revert of renaming traits::VTable to ImplSource

As #72114 and #73055 were merged so closely together I think this
accidentally happened while rebasing
2021-07-11 01:15:39 +09:00
Ellen
05dcb7874a Dont provide all parent generics to cgdefaults 2021-07-10 16:43:39 +01:00
bors
3982eb35ca Auto merge of #81360 - Aaron1011:trait-caller-loc, r=nagisa
Support forwarding caller location through trait object method call

Since PR #69251, the `#[track_caller]` attribute has been supported on
traits. However, it only has an effect on direct (monomorphized) method
calls. Calling a `#[track_caller]` method on a trait object will *not*
propagate caller location information - instead, `Location::caller()` will
return the location of the method definition.

This PR forwards caller location information when `#[track_caller]` is
present on the method definition in the trait. This is possible because
`#[track_caller]` in this position is 'inherited' by any impls of that
trait, so all implementations will have the same ABI.

This PR does *not* change the behavior in the case where
`#[track_caller]` is present only on the impl of a trait.
While all implementations of the method might have an explicit
`#[track_caller]`, we cannot know this at codegen time, since other
crates may have impls of the trait. Therefore, we keep the current
behavior of not forwarding the caller location, ensuring that all
implementations of the trait will have the correct ABI.

See the modified test for examples of how this works
2021-07-10 14:11:39 +00:00
Deadbeef
7c9e214bc3
Update DepNode's size 2021-07-10 21:46:31 +08:00
Deadbeef
88b29f5fb2
Test for misusing attribute 2021-07-10 20:54:50 +08:00
Deadbeef
27e863b3df
functions marked with attr are not const 2021-07-10 20:54:49 +08:00
Deadbeef
89d190f090
Add impl_constness query 2021-07-10 20:54:49 +08:00
bors
8d9d4c87d6 Auto merge of #86419 - ricobbe:raw-dylib-stdcall, r=petrochenkov
Add support for raw-dylib with stdcall, fastcall functions

Next stage of work for #58713: allow `extern "stdcall"` and `extern "fastcall"` with `#[link(kind = "raw-dylib")]`.

I've deliberately omitted support for vectorcall, as that doesn't currently work, and I wanted to get this out for review.  (I haven't really investigated the vectorcall failure much yet, but at first (very cursory) glance it appears that the problem is elsewhere.)
2021-07-09 23:24:21 +00:00
Richard Cobbe
a867dd4c7e Add support for raw-dylib with stdcall, fastcall functions on i686-pc-windows-msvc. 2021-07-09 12:04:54 -07:00
Paul Trojahn
5cf954f932 Revert the revert of renaming traits::VTable to ImplSource
As #72114 and #73055 were merged so closely together I think this
accidentally happened while rebasing
2021-07-09 18:26:28 +02:00
lrh2000
cf5eda1b4d Add a query for CapturedPlace::to_symbol 2021-07-10 00:00:25 +08:00
lrh2000
cda90f5541 Store names of captured variables in optimized_mir
- Closures in external crates may get compiled in because of
  monomorphization. We should store names of captured variables
  in `optimized_mir`, so that they are written into the metadata
  file and we can use them to generate debuginfo.

- If there are breakpoints inside closures, the names of captured
  variables stored in `optimized_mir` can be used to print them.
  Now the name is more precise when disjoint fields are captured.
2021-07-09 23:09:48 +08:00
lrh2000
29856acffe Name the captured upvars for closures/generators in debuginfo
Previously, debuggers print closures as something like
```
y::main::closure-0 (0x7fffffffdd34)
```
The pointer actually references to an upvar. It is not
very obvious, especially for beginners.

It's because upvars don't have names before, as they
are packed into a tuple. This commit names the upvars,
so we can expect to see something like
```
y::main::closure-0 {_captured_ref__b: 0x[...]}
```
2021-07-09 23:06:53 +08:00
Mara Bos
e920ef8785
Rollup merge of #86855 - LeSeulArtichaut:patch-1, r=davidtwco
Fix comments about unique borrows
2021-07-09 16:20:32 +02:00
Mara Bos
e3044432c7 Move [debug_]assert_matches to mod {core, std}::assert. 2021-07-08 02:33:36 +02:00
bors
d2b04f075c Auto merge of #86105 - bjorn3:link_info_refactor, r=petrochenkov
Refactor the generation of the metadata for linking
2021-07-07 18:28:53 +00:00
bjorn3
2977dff116 Remove a sorting operation from used_crates 2021-07-07 15:32:51 +02:00
bors
c0bd5a584d Auto merge of #86901 - sexxi-goose:query_remove, r=nikomatsakis
Make type_implements_trait not a query

r? `@nikomatsakis`
2021-07-07 01:03:41 +00:00
Aman Arora
1bcbc18e3d Fix depnode size 2021-07-06 15:55:13 -04:00
Aman Arora
8ef5212eff Make type_implements_trait not a query 2021-07-06 14:38:10 -04:00
Camille GILLOT
9f6d7e7dad Correct comments about untracked accesses. 2021-07-06 19:26:02 +02:00
Camille GILLOT
071a047dc7 Make resolutions a query. 2021-07-06 19:22:27 +02:00
bors
238fd72880 Auto merge of #86572 - rylev:force-warnings-always, r=nikomatsakis
Force warnings even when can_emit_warnings == false

Fixes an issue mentioned in #85512 with --cap-lints overriding --force-warnings.

Fixes https://github.com/rust-lang/rust/issues/86751

r? `@ehuss`
2021-07-06 16:50:33 +00:00
Tomasz Miąsko
9792179648 Add flag to configure large_assignments lint
The `large_assignments` lints detects moves over specified limit.  The
limit is configured through `move_size_limit = "N"` attribute placed at
the root of a crate. When attribute is absent, the lint is disabled.

Make it possible to enable the lint without making any changes to the
source code, through a new flag `-Zmove-size-limit=N`.  For example, to
detect moves exceeding 1023 bytes in a cargo crate, including all
dependencies one could use:

```
$ env RUSTFLAGS=-Zmove-size-limit=1024 cargo build -vv
```
2021-07-06 17:47:15 +02:00
Ryan Levick
5af5a6d49d Add missing docs and remove dead code 2021-07-06 13:47:03 +02:00
bors
d04ec47358 Auto merge of #86143 - bjorn3:revert_revert_merge_crate_disambiguator, r=michaelwoerister
Reland "Merge CrateDisambiguator into StableCrateId"

Reverts https://github.com/rust-lang/rust/pull/85891 as this revert of #85804 made perf even worse.

r? `@Mark-Simulacrum`
2021-07-06 11:31:59 +00:00
bjorn3
56c6a48d2e Truncate hex stable crate id to 8 characters (32 bits) 2021-07-06 11:36:23 +02:00
bjorn3
ca935ddbf1 Make tcx.stable_crate_id() faster 2021-07-06 11:28:06 +02:00
bjorn3
489ad8b8b5 Revert "Revert "Merge CrateDisambiguator into StableCrateId""
This reverts commit 8176ab8bc1.
2021-07-06 11:28:04 +02:00
bors
d7901f37bb Auto merge of #86694 - cjgillot:pmmd, r=petrochenkov
Store macro parent module in ExpnData.

As a consequence, its value is hashed as part of the ExpnId's stable hash.

Closes #85999
2021-07-06 08:50:24 +00:00
Camille GILLOT
3162c37b59 Store macro parent module in ExpnData. 2021-07-06 08:07:06 +02:00
bors
d5a406bb66 Auto merge of #82985 - cjgillot:lint, r=jackh726
Cleanup the computation of lint levels

This now uses an `IndexVec` and a special root `LintStackIndex = 0` to encode command-line levels.
2021-07-06 00:33:21 +00:00
bors
72b0c7dfe9 Auto merge of #86877 - bjorn3:remove_lib_source, r=petrochenkov
Remove LibSource

The information is stored in used_crate_source too anyway.

Split out of #86105

r? `@petrochenkov`
2021-07-05 21:52:34 +00:00
bors
952fdf2a11 Auto merge of #86891 - JohnTitor:rollup-gy2gan9, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #83581 (Add std::os::unix::fs::DirEntryExt2::file_name_ref(&self) -> &OsStr)
 - #85377 (aborts: Clarify documentation and comments)
 - #86685 (double-check mutability inside Allocation)
 - #86794 (Stabilize `Seek::rewind()`)
 - #86852 (Remove some doc aliases)
 - #86878 (⬆️ rust-analyzer)
 - #86886 (Remove `impl Clean for {Ident, Symbol}`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-07-05 19:11:43 +00:00
Yuki Okushi
1ca32050b1
Rollup merge of #86685 - RalfJung:alloc-mut, r=oli-obk
double-check mutability inside Allocation

r? `@oli-obk`
2021-07-06 02:33:14 +09:00
bors
969a6c2481 Auto merge of #86674 - Aaron1011:new-querify-limits, r=michaelwoerister
Query-ify global limit attribute handling

Currently, we read various 'global limits' from inner attributes the crate root (`recursion_limit`, `move_size_limit`, `type_length_limit`, `const_eval_limit`). These limits are then stored in `Sessions`, allowing them to be access from a `TyCtxt` without registering a dependency on the crate root attributes.

This PR moves the calculation of these global limits behind queries, so that we properly track dependencies on crate root attributes. During the setup of macro expansion (before we've created a `TyCtxt`), we need to access the recursion limit, which is now done by directly calling into the code shared by the normal query implementations.
2021-07-05 16:30:53 +00:00
bjorn3
8748e37d35 Remove LibSource
The information is stored in used_crate_source too anyway
2021-07-05 10:49:07 +02:00
bors
44860d13fa Auto merge of #86867 - JohnTitor:convert-to-actual-assert, r=jackh726
Convert `debug_assert!` to `assert!` in `Binder::dummy`

This is needed for #85350 not to be passed.
r? `@jackh726`
2021-07-05 02:05:04 +00:00
Aaron Hill
7e5a88a56c
Combine individual limit queries into single limits query 2021-07-04 13:02:51 -05:00
bors
23c652dfe3 Auto merge of #86866 - nikomatsakis:issue-84841, r=oli-obk
Hack: Ignore inference variables in certain queries

Fixes #84841
Fixes #86753

Some queries are not built to accept types with inference variables, which can lead to ICEs. These queries probably ought to be converted to canonical form, but as a quick workaround, we can return conservative results in the case that inference variables are found.

We should file a follow-up issue (and update the FIXMEs...) to do the proper refactoring.

cc `@arora-aman`

r? `@oli-obk`
2021-07-04 17:39:37 +00:00
Aaron Hill
ff15b5e2c7
Query-ify global limit attribute handling 2021-07-04 12:33:14 -05:00
Niko Matsakis
63fbefd359 tag issues with FIXME 2021-07-04 12:50:28 -04:00
Niko Matsakis
86a5a6520d
Update compiler/rustc_middle/src/ty/normalize_erasing_regions.rs
Co-authored-by: Rémy Rakic <remy.rakic+github@gmail.com>
2021-07-04 12:37:25 -04:00
Yuki Okushi
93882e4396
Convert debug_assert! to assert! in Binder::dummy
This is needed for #85350 not to be passed.
2021-07-05 01:22:33 +09:00
Niko Matsakis
75c172246c be conservative in has_significant_drop 2021-07-04 11:41:40 -04:00
Niko Matsakis
40ee019c17 allow inference vars in type_implements_trait 2021-07-04 11:28:20 -04:00
bors
39e20f1ae5 Auto merge of #86255 - Smittyvb:mir-alloc-oom, r=RalfJung,oli-obk
Support allocation failures when interpreting MIR

This closes #79601 by handling the case where memory allocation fails during MIR interpretation, and translates that failure into an `InterpError`. The error message is "tried to allocate more memory than available to compiler" to make it clear that the memory shortage is happening at compile-time by the compiler itself, and that it is not a runtime issue.

Now that memory allocation can fail, it would be neat if Miri could simulate low-memory devices to make it easy to see how much memory a Rust program needs.

Note that this breaks Miri because it assumes that allocation can never fail.
2021-07-04 09:15:36 +00:00
Niko Matsakis
6f4b539a62 introduce helper function 2021-07-03 22:15:32 -04:00
LeSeulArtichaut
88bcd8a25e Fix comments about unique borrows 2021-07-04 03:34:08 +02:00
Smitty
b201b2f65f Make vtable_allocation always succeed 2021-07-03 11:14:19 -04:00
Smitty
e9d69d9f8e Allocation failure in constprop panics right away 2021-07-02 16:06:12 -04:00
Yuki Okushi
884053a4b4
Remove ty::Binder::bind()
Co-authored-by: Noah Lev <camelidcamel@gmail.com>
2021-07-03 01:12:32 +09:00
Yuki Okushi
13e116f1f7
Use BoundVarsCollector for now 2021-07-03 01:12:31 +09:00
bors
7100b311df Auto merge of #86749 - bjorn3:link_info_refactor_part1, r=petrochenkov
Rename all_crate_nums query to crates and remove useless wrapper

Split out of https://github.com/rust-lang/rust/pull/86105

r? `@petrochenkov`
2021-07-01 19:00:08 +00:00
bjorn3
c7d2099de0 Rename all_crate_nums query to crates and remove useless wrapper 2021-07-01 16:51:11 +02:00
Ryan Levick
33cc7b1fe2 New force_warn diagnostic builder and ensure cap-lints doesn't reduce force_warn level 2021-07-01 12:29:20 +02:00
bors
f8ac8fdacf Auto merge of #86190 - asquared31415:extern-main-86110-fix, r=varkor
Fix ICE when `main` is declared in an `extern` block

Changes in #84401 to implement `imported_main` changed how the crate entry point is found, and a declared `main` in an `extern` block was detected erroneously.  This was causing the ICE described in #86110.

This PR adds a check for this case and emits an error instead.  Previously a `main` declaration in an `extern` block was not detected as an entry point at all, so emitting an error shouldn't break anything that worked previously.  In 1.52.1 stable this is demonstrated, with a `` `main` function not found`` error.

Fixes #86110
2021-07-01 06:39:37 +00:00
bors
1034282bca Auto merge of #86617 - joshtriplett:prune-dependencies, r=Mark-Simulacrum
Remove unused dependencies from compiler crates

Various compiler crates have dependencies that they don't appear to use. I used some scripting to detect such dependencies, filtered them based on some manual review, and removed those that do indeed appear to be entirely unused.
2021-07-01 03:49:47 +00:00
Smitty
3e20129a18 Delay ICE on evaluation fail 2021-06-30 15:38:31 -04:00
Smittyvb
12a8d106f6
Note that even ConstProp follows the rules
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-06-30 12:42:04 -04:00
Smitty
9f227945f1 Simplify memory failure checking 2021-06-30 11:24:52 -04:00
bors
868c702d0c Auto merge of #86695 - sexxi-goose:closure_size, r=nikomatsakis
Introduce -Zprofile-closures to evaluate the impact of 2229

This creates a CSV with name "closure_profile_XXXXX.csv", where the
variable part is the process id of the compiler.

To profile a cargo project you can run one of the following depending on
if you're compiling a library or a binary:

```
cargo +nightly rustc --lib -- -Zprofile-closures
cargo +nightly rustc --bin {binary_name} -- -Zprofile-closures
```

r? `@nikomatsakis`
2021-06-30 13:42:50 +00:00
Smitty
ba542eebc0 Rename is_spurious -> is_volatile 2021-06-30 09:27:30 -04:00
Smittyvb
55379bb7ea
simplify explanation comment
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-06-30 09:07:47 -04:00
Ryan Levick
a3d6905053 Force warnings even when can_emit_warnings == false 2021-06-30 11:18:33 +02:00
Smitty
d04da1125d Properly handle const prop failures 2021-06-29 20:22:32 -04:00
Smitty
ab66c3fbd4 Add comment with reasoning for non-determinism 2021-06-29 19:08:30 -04:00
Smitty
43b55cf893 Simplify allocation creation 2021-06-29 19:08:29 -04:00
Smitty
dc1c6c3a25 Make memory exhaustion a hard error 2021-06-29 19:08:29 -04:00
Smitty
524e575bb4 Support allocation failures when interperting MIR
Note that this breaks Miri.

Closes #79601
2021-06-29 19:08:26 -04:00
Camille GILLOT
5a731ffdae Encode CommandLine in the index only. 2021-06-29 20:05:11 +02:00
Camille GILLOT
66fee063b6 Use a newtype_index instead of a u32. 2021-06-29 19:44:03 +02:00
Camille GILLOT
f51c57fb7a Use the macro to implement HashStable. 2021-06-29 19:23:38 +02:00
bors
e98897e5dc Auto merge of #86475 - crlf0710:miri_vtable_refactor, r=bjorn3
Change vtable memory representation to use tcx allocated allocations.

This fixes https://github.com/rust-lang/rust/issues/86324. However i suspect there's more to change before it can land.

r? `@bjorn3`
cc `@rust-lang/miri`
2021-06-29 15:52:21 +00:00
bors
8971fff984 Auto merge of #86009 - cjgillot:fwarn, r=davidtwco
Make ForceWarn a lint level.

Follow-up to #85788
cc `@rylev`
2021-06-29 13:11:16 +00:00
bors
47b2f15bba Auto merge of #86670 - Aaron1011:copy-variance-diag, r=davidtwco
Derive `Copy` for `VarianceDiagInfo`
2021-06-29 05:15:34 +00:00
Yuki Okushi
14f333597e
Rollup merge of #86671 - m-ou-se:non-fmt-panic-future-incompatible, r=nikomatsakis
Turn non_fmt_panic into a future_incompatible edition lint.

This turns the `non_fmt_panic` lint into a future_incompatible edition lint, so it becomes part of the `rust_2021_compatibility` group. See https://github.com/rust-lang/rust/issues/85894.

This lint produces both warnings about semantical changes (e.g. `panic!("{{")`) and things that will become hard errors (e.g. `panic!("{")`). So I added a `explain_reason: false` that supresses the default "this will become a hard error" or "the semantics will change" message, and instead added a note depending on the situation. (cc `@rylev)`

r? `@nikomatsakis`
2021-06-29 08:46:14 +09:00
Aman Arora
fc273e9bf2 Introduce -Zprofile-closures to evaluate the impact of 2229
This creates a CSV with name "closure_profile_XXXXX.csv", where the
variable part is the process id of the compiler.

To profile a cargo project you can run one of the following depending on
if you're compiling a library or a binary:

```
cargo +stage1 rustc --lib -- -Zprofile-closures
cargo +stage1 rustc --bin -- -Zprofile-closures
```
2021-06-28 14:21:55 -04:00
Charles Lew
d3ff497bec Update other codegens to use tcx managed vtable allocations. 2021-06-28 19:39:48 +08:00
Ralf Jung
719dafc48b double-check mutability inside Allocation 2021-06-28 09:19:36 +02:00
bors
345530412f Auto merge of #85909 - cjgillot:alloc-kind-query, r=Aaron1011
Make allocator_kind a query.

Part of #85153

r? `@Aaron1011`
2021-06-28 01:20:01 +00:00
Mara Bos
7f4e343893 Add explain_reason: false in future_incompatible.
This allows supressing the default warning message for future
incompatible ints, for lints that already provide a more detailed
warning.
2021-06-27 14:47:21 +00:00
Aaron Hill
4be38d2658
Derive Copy for VarianceDiagInfo 2021-06-27 09:30:13 -05:00
Camille GILLOT
e42271db0d Make ForceWarn a lint level. 2021-06-26 12:41:19 +02:00
bors
481971978f Auto merge of #86586 - Smittyvb:https-everywhere, r=petrochenkov
Use HTTPS links where possible

While looking at #86583, I wondered how many other (insecure) HTTP links were in `rustc`. This changes most other `http` links to `https`. While most of the links are in comments or documentation, there are a few other HTTP links that are used by CI that are changed to HTTPS.

Notes:
- I didn't change any to or in licences
- Some links don't support HTTPS :(
- Some `http` links were dead, in those cases I upgraded them to their new places (all of which used HTTPS)
2021-06-26 08:24:31 +00:00
Ryan Levick
7b3940f44b Address PR feedback 2021-06-25 14:51:56 +02:00
Ryan Levick
23176f60e7 Change how edition based future compatibility warnings are handled 2021-06-25 14:51:56 +02:00
bors
117799b73c Auto merge of #86505 - JohnTitor:fix-86483, r=jackh726
Do not panic in `return_type_impl_trait`

Fixes #86483
2021-06-25 09:28:17 +00:00
Josh Triplett
20cedd1925 rustc_middle: Remove unused dependency measureme
Unused since commit 4581d16bcb
("Move the query system to rustc_query_impl.").
2021-06-25 01:12:59 -07:00
Yuki Okushi
9323a2824b
Prefer "allow list" structure to check a type 2021-06-24 15:02:50 +09:00
Yuki Okushi
462c74007e
Rename function name in comments 2021-06-24 14:21:50 +09:00
Yuki Okushi
a141d29612
Do not panic in return_type_impl_trait 2021-06-24 14:06:28 +09:00
Yuki Okushi
469329d4f8
Rollup merge of #86296 - LeSeulArtichaut:thir-doc, r=nikomatsakis
Add documentation for various THIR structs

Helps with rust-lang/project-thir-unsafeck#6.
r? `@nikomatsakis`
2021-06-24 13:47:33 +09:00
Smitty
bdfcb88e8b Use HTTPS links where possible 2021-06-23 16:26:46 -04:00
LeSeulArtichaut
30793c1e81 Add documentation for various THIR structs 2021-06-22 17:58:30 +02:00
bors
80926fc409 Auto merge of #86368 - michaelwoerister:lexing-ice, r=davidtwco
Disambiguate between SourceFiles from different crates even if they have the same path

This PR fixes an ICE that can occur when the compiler encounters a source file that is part of both the local crate and an upstream crate:

1. While importing source files from an upstream crate the compiler creates a `SourceFile` entry for `foo.rs` in the `SourceMap`. Since this is an imported source file its `src` field is `None`.
2. At a later point the parser encounters `foo.rs` again. It tells the `SourceMap` to load the file but because we already have an entry for `foo.rs` the `SourceMap` will return the existing version with `src == None`.
3. The parser proceeds under the assumption that `src.is_some()` and panics when actually trying to use the file's contents.

This PR fixes the issue by adding the source file's associated `CrateNum` to the `SourceMap`'s interning key. As a consequence the two instances of the file will each have a separate entry in the `SourceMap`. They just happen to share the same file path. This approach seemed less problematic to me than trying to mutate the `SourceFile` after it had already been created.

Another, more involved, approach might be to merge the `src` and the `external_src` field.

Fixes #85955
2021-06-22 14:53:58 +00:00
bors
3487be11d5 Auto merge of #86545 - JohnTitor:rollup-7sqdhpa, r=JohnTitor
Rollup of 6 pull requests

Successful merges:

 - #86393 (Add regression test for issue #52025)
 - #86402 (rustdoc: add optional woff2 versions of Source Serif and Source Code)
 - #86451 (Resolve intra-doc links in summary desc)
 - #86501 (Cleanup handling of `crate_name` for doctests)
 - #86517 (Fix `unused_unsafe` around `await`)
 - #86537 (Mark some edition tests as check-pass)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-06-22 12:11:02 +00:00
Yuki Okushi
8ec4e7dfdd
Rollup merge of #86517 - camsteffen:unused-unsafe-async, r=LeSeulArtichaut
Fix `unused_unsafe` around `await`

Enables `unused_unsafe` lint for `unsafe { future.await }`.

The existing test for this is `unsafe { println!() }`, so I assume that `println!` used to contain compiler-generated unsafe but this is no longer true, and so the existing test is broken. I replaced the test with `unsafe { ...await }`. I believe `await` is currently the only instance of compiler-generated unsafe.

Reverts some parts of #85421, but the issue predates that PR.
2021-06-22 20:01:05 +09:00
bors
75ed34223a Auto merge of #84910 - eopb:stabilize_int_error_matching, r=yaahc
stabilize `int_error_matching`

closes #22639

> It has been over half a year since https://github.com/rust-lang/rust/pull/77640#pullrequestreview-511263516, and the indexing question is rejected in https://github.com/rust-lang/rust/pull/79728#pullrequestreview-633030341, so I guess we can submit another stabilization attempt? 😉

_Originally posted by `@kennytm` in https://github.com/rust-lang/rust/issues/22639#issuecomment-831738266_
2021-06-22 09:30:15 +00:00
Cameron Steffen
b07bb6d698 Fix unused_unsafe with compiler-generated unsafe 2021-06-21 17:25:45 -05:00
Michael Woerister
c3c4ab5ed2 Encode SourceFile source crate as StableCrateId in incr. comp. OnDiskCache. 2021-06-21 15:30:16 +02:00
Camille GILLOT
cbdfbdd40b Implement the query in cstore_impl. 2021-06-20 11:58:46 +02:00
Camille GILLOT
ed9ee25108 256th query. 2021-06-20 11:53:59 +02:00
Camille GILLOT
6a371d2c89 Make allocator_kind a query. 2021-06-20 11:52:51 +02:00
bors
29cd70d407 Auto merge of #86437 - nikomatsakis:tait-docs, r=oli-obk
add various coments to explain how the TAIT code works

r? `@oli-obk`
2021-06-19 12:41:10 +00:00
bors
9839f9c7ff Auto merge of #86456 - JohnTitor:rollup-jjzupny, r=JohnTitor
Rollup of 9 pull requests

Successful merges:

 - #86136 (Stabilize span_open() and span_close().)
 - #86359 (Use as_secs_f64 in JunitFormatter)
 - #86370 (Fix rustdoc stabilized versions layout)
 - #86397 (Alter std::cell::Cell::get_mut documentation)
 - #86407 (Use `map_or` instead of open-coding it)
 - #86425 (Update rustversion to 1.0.5)
 - #86440 (Update library tracking issue for libs-api rename.)
 - #86444 (Fix ICE with `#[repr(simd)]` on enum)
 - #86453 (stdlib: Fix typo in internal RefCell docs )

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-06-19 01:57:14 +00:00
bors
ec57c60c50 Auto merge of #86194 - RalfJung:const-ub-hard-error, r=oli-obk
make UB during CTFE a hard error

This is a next step for https://github.com/rust-lang/rust/issues/71800. `const_err` has been a future-incompatibility lint for 4 months now since https://github.com/rust-lang/rust/pull/80394 (and err-by-default for many years before that), so I think we could try making it a proper hard error at least in some situations.

I didn't yet adjust the tests, since I first want to gauge the fall-out via crater.
Cc `@rust-lang/wg-const-eval`
2021-06-18 23:17:40 +00:00
Fabian Wolff
e7a1186c6d Fix ICE with #[repr(simd)] on enum 2021-06-18 21:39:53 +02:00
Niko Matsakis
f6adaedd9b add various coments to explain how the code works 2021-06-18 11:44:56 -04:00
bors
312b894cc1 Auto merge of #85421 - Smittyvb:rm_pushpop_unsafe, r=matthewjasper
Remove some last remants of {push,pop}_unsafe!

These macros have already been removed, but there was still some code handling these macros. That code is now removed.
2021-06-18 14:17:53 +00:00
Ralf Jung
3c08cf8e5e make UB during CTFE a hard error 2021-06-18 16:00:04 +02:00
Yuki Okushi
c062f3dddd
Rollup merge of #86340 - Smittyvb:ctfe-hard-error-message, r=RalfJung
Use better error message for hard errors in CTFE

I noticed this while working on #86255: currently the same message is used for hard errors and soft errors in CTFE. This changes the error messages to make hard errors use a message that indicates the reality of the situation correctly, since usage of the constant is never allowed when there was a hard error evaluating it. This doesn't affect the behaviour of these error messages, only the content.

This changes the error logic to check if the error should be hard or soft where it is generated, instead of where it is emitted, to allow this distinction in error messages.
2021-06-17 21:56:43 +09:00
bors
b17d9c1332 Auto merge of #85834 - cjgillot:save-sbi, r=michaelwoerister
Encode CrateNum using the StableCrateId for incr. comp.
2021-06-17 09:03:58 +00:00
bors
444a85ac38 Auto merge of #86379 - JohnTitor:rollup-mkz9x36, r=JohnTitor
Rollup of 10 pull requests

Successful merges:

 - #85870 (Allow whitespace in dump_mir filter)
 - #86104 (Fix span calculation in format strings)
 - #86140 (Mention the `Borrow` guarantee on the `Hash` implementations for Arrays and `Vec`)
 - #86141 (Link reference in `dyn` keyword documentation)
 - #86260 (Open trait implementations' toggles by default.)
 - #86339 (Mention #79078 on compatibility notes of 1.52)
 - #86341 (Stop returning a value from `report_assert_as_lint`)
 - #86353 (Remove `projection_ty_from_predicates`)
 - #86361 (Add missing backslashes to prevent unwanted newlines in rustdoc HTML)
 - #86372 (Typo correction: s/is/its)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-06-16 22:48:31 +00:00
Smitty
044b3620e7 Move some hard error logic to InterpError 2021-06-16 18:23:34 -04:00
Yuki Okushi
05ba958fe8
Rollup merge of #86353 - JohnTitor:remove-projection_ty_from_predicates, r=oli-obk
Remove `projection_ty_from_predicates`

Fixes #86350
r? ``@oli-obk``
2021-06-17 05:54:59 +09:00
bors
a85f584aeb Auto merge of #86266 - LeSeulArtichaut:box-thir-adt, r=davidtwco
Box `thir::ExprKind::Adt` for performance

`Adt` is the biggest variant in the enum and probably isn't used very often compared to the other expr kinds, so boxing it should be beneficial for performance. We need a perf test to be sure.
2021-06-16 20:00:17 +00:00
Yuki Okushi
280d19395d
Remove projection_ty_from_predicates 2021-06-16 16:33:03 +09:00
bors
2336406b38 Auto merge of #86291 - crlf0710:trait_vtbl_refactor, r=bjorn3
Refactor vtable codegen

This refactor the codegen of vtables of miri interpreter, llvm, cranelift codegen backends.

This is preparation for the implementation of trait upcasting feature. cc #65991

Note that aside from code reorganization, there's an internal behavior change here that now InstanceDef::Virtual's index now include the three metadata slots, and now the first method is with index 3.

cc  `@RalfJung` `@bjorn3`
2021-06-16 07:20:27 +00:00
hi-rustin
92d4164aca better code 2021-06-15 16:26:10 +08:00
hi-rustin
636d872452 shrinking the deprecated method span 2021-06-15 16:21:58 +08:00
Charles Lew
a86d3a7e45 Refactor to make interpreter and codegen backend neutral to vtable internal representation. 2021-06-15 01:59:00 +08:00
Rémy Rakic
19fddc019f Improve documentation on UndefinedBehaviorInfo::ValidationFailure 2021-06-14 18:57:06 +02:00
Ethan Brierley
b59f7d9662 stabilize int_error_matching 2021-06-14 09:58:32 +01:00
Rémy Rakic
87ecf84c36 Improve CTFE validation error message 2021-06-13 22:40:42 +02:00
LeSeulArtichaut
5e802e5e97 Box ExprKind::Adt 2021-06-13 17:03:11 +02:00
bors
fb3ea63d9b Auto merge of #86245 - lqd:const-ub-align, r=RalfJung
Fix ICEs on invalid vtable size/alignment const UB errors

The invalid vtable size/alignment errors from `InterpCx::read_size_and_align_from_vtable` were "freeform const UB errors", causing ICEs when reaching validation. This PR turns them into const UB hard errors to catch them during validation and avoid that.

Fixes #86193

r? `@RalfJung`

(It seemed cleaner to have 2 variants but they can be merged into one variant with a message payload if you prefer that ?)
2021-06-13 12:08:59 +00:00
Rémy Rakic
cae1918b29 Turn incorrect vtable size/alignment errors into hard const-UB errors
They were "freeform const UB" error message, but could reach validation
and trigger ICEs there. We now catch them during validation to avoid
that.
2021-06-13 13:11:07 +02:00
Tomasz Miąsko
06ca736e14 Pretty print generator witness only in -Zverbose mode
In release build of deeply-nested-async benchmark the size of
`no-opt.bc` file is reduced from 46MB to 62kB.
2021-06-12 18:28:17 +02:00
bors
d59b80d588 Auto merge of #86130 - BoxyUwU:abstract_const_as_cast, r=oli-obk
const_eval_checked: Support as casts in abstract consts
2021-06-12 08:50:22 +00:00
bors
0f6ba39fd8 Auto merge of #86180 - cjgillot:defmv, r=petrochenkov
Hash DefId in rustc_span.

This is mostly just moving code around. Changes are simplifications of unneeded callbacks from rustc_span to rustc_middle.

r? `@petrochenkov`
2021-06-12 06:09:20 +00:00
Yuki Okushi
5b78e6de18
Rollup merge of #86189 - JohnTitor:relate-fn-pub, r=Aaron1011
Make `relate_type_and_mut` public

#85343 improved diagnostics around `Relate` impls but made `relate_type_and_mut` private, which was accessible as `relate` previously. This makes it public so that we can use it on rust-semverver.

r? ```@Aaron1011```
2021-06-12 01:16:01 +09:00
Yuki Okushi
3b47d337e0
Rollup merge of #85800 - BoxyUwU:const-param-default-diagnostics, r=oli-obk
Fix some diagnostic issues with const_generics_defaults feature gate

This PR makes a few changes:
- print out const param defaults in "lifetime ordering" errors rather than discarding them
- update `is_simple_text` to account for const params when checking if a type has no generics, this was causing a note to be failed to add to an error message
- fixes some diagnostic wording that incorrectly said there was ordering restrictions between type/const params despite the `const_generics_defaults` feature gate is active
2021-06-12 01:15:56 +09:00
Camille GILLOT
a7a50b0c0a Hash DefId in rustc_span. 2021-06-11 12:25:02 +02:00
asquared31415
9b2ba6d1a1 Fix ICE when main is declared in an extern block 2021-06-09 23:14:02 -04:00
Yuki Okushi
3607857756 Make relate_type_and_mut public 2021-06-10 11:48:51 +09:00
bors
1639a16ebf Auto merge of #85910 - cjgillot:no-meta-version, r=Aaron1011
Drop metadata_encoding_version.

Part of #85153

r? `@Aaron1011`
2021-06-10 00:39:25 +00:00
Camille GILLOT
f387cffadb Access stable_crate_id directly. 2021-06-09 20:25:39 +02:00
Camille GILLOT
a246751ca1 Do not store crate in latest_foreign_def_path_hashes. 2021-06-09 20:23:46 +02:00
Camille GILLOT
5be514992f Encode CrateNum using the StableCrateId for incr. comp. 2021-06-09 20:20:49 +02:00
bors
47d38752c6 Auto merge of #86150 - cjgillot:notable, r=michaelwoerister
Do not require the DefPathTable to construct the on-disk cache.

r? `@michaelwoerister`
2021-06-09 14:06:10 +00:00
bors
c4b5406981 Auto merge of #86118 - spastorino:tait-soundness-bug, r=nikomatsakis
Create different inference variables for different defining uses of TAITs

Fixes #73481

r? `@nikomatsakis`
cc `@oli-obk`
2021-06-09 09:00:16 +00:00
Camille GILLOT
aeb050da9f Do not require the DefPathTable to construct the on-disk cache. 2021-06-08 22:23:03 +02:00
Ellen
47fe696d8f use non_erasable_generics 2021-06-08 09:07:52 +01:00
Ellen
8e7299dfcd Support as casts in abstract consts 2021-06-08 08:02:16 +01:00
Santiago Pastorino
7294f49d52
Remove ResolvedOpaqueTy and just use Ty, SubstsRef is already there 2021-06-07 19:07:07 -03:00
Santiago Pastorino
7f8cad2019
Make OpaqueTypeKey the key of opaque types map 2021-06-07 19:04:52 -03:00
Santiago Pastorino
3405725e00
Change concrete opaque type to be a VecMap 2021-06-07 19:04:19 -03:00
bors
2312ff1a85 Auto merge of #85891 - bjorn3:revert_merge_crate_disambiguator, r=Mark-Simulacrum
Revert "Merge CrateDisambiguator into StableCrateId"

This reverts https://github.com/rust-lang/rust/pull/85804
2021-06-07 10:42:56 +00:00
bjorn3
8176ab8bc1 Revert "Merge CrateDisambiguator into StableCrateId"
This reverts commit d0ec85d3fb.
2021-06-07 10:37:45 +02:00
Yuki Okushi
ac6e239b3b
Rollup merge of #84262 - camelid:sized-ice, r=estebank
Fix ICE during type layout when there's a `[type error]`

Fixes #84108.

Based on estebank's [comment], except I used `delay_span_bug` because it
should work in more cases, and I think it expresses its intent more
clearly.

r? `@estebank`

[comment]: https://github.com/rust-lang/rust/issues/84108#issuecomment-818916848
2021-06-07 15:20:56 +09:00
Smitty
45c55540a8 Remove some last remants of {push,pop}_unsafe!
These macros have already been removed, but there was still some code
handling these macros. That code is now removed.
2021-06-06 17:04:03 -04:00
Aaron Hill
fad2242ff7
Add variance-related information to lifetime error messages 2021-06-06 12:37:42 -05:00
bors
9a576175cc Auto merge of #84171 - ricobbe:raw-dylib-via-llvm, r=petrochenkov
Partial support for raw-dylib linkage

First cut of functionality for issue #58713: add support for `#[link(kind = "raw-dylib")]` on `extern` blocks in lib crates compiled to .rlib files.  Does not yet support `#[link_name]` attributes on functions, or the `#[link_ordinal]` attribute, or `#[link(kind = "raw-dylib")]` on `extern` blocks in bin crates; I intend to publish subsequent PRs to fill those gaps.  It's also not yet clear whether this works for functions in `extern "stdcall"` blocks; I also intend to investigate that shortly and make any necessary changes as a follow-on PR.

This implementation calls out to an LLVM function to construct the actual `.idata` sections as temporary `.lib` files on disk and then links those into the generated .rlib.
2021-06-06 03:59:17 +00:00
bors
6c2dd251bb Auto merge of #86002 - cjgillot:expn_that_defined, r=petrochenkov
Always go through the expn_that_defined query.
2021-06-05 21:10:01 +00:00
Camille Gillot
3f32738628
Update compiler/rustc_middle/src/query/mod.rs 2021-06-05 20:40:58 +02:00
bors
4e20754629 Auto merge of #85919 - workingjubilee:simd-ptrs-are-valid, r=petrochenkov
Allow raw pointers in SIMD types

Closes #85915 by loosening the strictness in typechecking and adding a test to guarantee it passes.

This still might be too strict, as references currently do pass monomorphization, but my understanding is that they are not guaranteed to be "scalar" in the same way.
2021-06-05 06:17:17 +00:00
Richard Cobbe
6aa45b71b1 Add first cut of functionality for #58713: support for #[link(kind = "raw-dylib")].
This does not yet support #[link_name] attributes on functions, the #[link_ordinal]
attribute, #[link(kind = "raw-dylib")] on extern blocks in bin crates, or
stdcall functions on 32-bit x86.
2021-06-04 18:01:35 -07:00
Camille GILLOT
507a1fdf13 Always go through the expn_that_defined query. 2021-06-04 21:37:34 +02:00
Aaron Hill
6fd6624045
Fix rebase fallout 2021-06-04 12:54:28 -05:00
Aaron Hill
d06f774338
Support forwarding caller location through trait object method call
Since PR #69251, the `#[track_caller]` attribute has been supported on
traits. However, it only has an effect on direct (monomorphized) method
calls. Calling a `#[track_caller]` method on a trait object will *not*
propagate caller location information - instead, `Location::caller()` will
return the location of the method definition.

This PR forwards caller location information when `#[track_caller]` is
present on the method definition in the trait. This is possible because
`#[track_caller]` in this position is 'inherited' by any impls of that
trait, so all implementations will have the same ABI.

This PR does *not* change the behavior in the case where
`#[track_caller]` is present only on the impl of a trait.
While all implementations of the method might have an explicit
`#[track_caller]`, we cannot know this at codegen time, since other
crates may have impls of the trait. Therefore, we keep the current
behavior of not forwarding the caller location, ensuring that all
implementations of the trait will have the correct ABI.

See the modified test for examples of how this works
2021-06-04 12:24:12 -05:00
bors
595088d602 Auto merge of #85788 - rylev:force-warns, r=nikomatsakis
Support for force-warns

Implements https://github.com/rust-lang/rust/issues/85512.

This PR adds a new command line option `force-warns` which will force the provided lints to warn even if they are allowed by some other mechanism such as `#![allow(warnings)]`.

Some remaining issues:
* https://github.com/rust-lang/rust/issues/85512 mentions that `force-warns` should also be capable of taking lint groups instead of individual lints. This is not implemented.
* If a lint has a higher warning level than `warn`, this will cause that lint to warn instead. We probably want to allow the lint to error if it is set to a higher lint and is not allowed somewhere else.
* One test is currently ignored because it's not working - when a deny-by-default lint is allowed, it does not currently warn under `force-warns`. I'm not sure why, but I wanted to get this in before the weekend.

r? `@nikomatsakis`
2021-06-04 13:31:51 +00:00
Yuki Okushi
36f1ed6de2
Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514
Remove unused feature gates

The first commit removes a usage of a feature gate, but I don't expect it to be controversial as the feature gate was only used to workaround a limitation of rust in the past. (closures never being `Clone`)

The second commit uses `#[allow_internal_unstable]` to avoid leaking the `trusted_step` feature gate usage from inside the index newtype macro. It didn't work for the `min_specialization` feature gate though.

The third commit removes (almost) all feature gates from the compiler that weren't used anyway.
2021-06-04 13:42:54 +09:00
Yuki Okushi
2fddcfda7a
Rollup merge of #85934 - tmiasko:is-union, r=jackh726
Add `Ty::is_union` predicate
2021-06-03 14:35:41 +09:00
Yuki Okushi
a5466fc5ad
Rollup merge of #85911 - cjgillot:one-output, r=Aaron1011
Avoid a clone of output_filenames.

Part of #85153
2021-06-03 14:35:39 +09:00
Jubilee Young
3d738b0594 Inline is_machine into check_simd 2021-06-02 15:20:15 -07:00
Camille GILLOT
0e71283495 Restrict access to crate_name.
Also remove original_crate_name, which had the exact same implementation
2021-06-02 18:35:32 +02:00
Ryan Levick
ab419314e9 Add a page on force-warns in unstable book 2021-06-02 18:07:39 +02:00
Tomasz Miąsko
c898681a86 Add Ty::is_union predicate and use it 2021-06-02 17:09:17 +02:00
Tomasz Miąsko
012c323467 Implement Ty::is_enum using matches! 2021-06-02 17:09:13 +02:00
Ryan Levick
3b206b7a70 Force warn on lint groups as well 2021-06-02 17:09:07 +02:00
bors
1e13a9bb33 Auto merge of #85892 - tmiasko:i, r=oli-obk
Miscellaneous inlining improvements
2021-06-02 10:47:58 +00:00
bors
7350f655ef Auto merge of #85908 - cjgillot:private-dep-query, r=Aaron1011
Make is_private_dep a query.

Part of #85153

r? `@Aaron1011`
2021-06-02 08:06:45 +00:00
Tomasz Miąsko
c1f6495b8e Miscellaneous inlining improvements 2021-06-02 08:49:58 +02:00
bors
d20b9add05 Auto merge of #85905 - cjgillot:one-trait-map, r=Aaron1011
Only compute the trait map once

Part of #85153

r? `@Aaron1011`
2021-06-02 05:25:41 +00:00
Jubilee Young
d03683caf6 Allow raw pointers in SIMD types 2021-06-01 17:00:44 -07:00
bors
625d5a693e Auto merge of #85829 - bjorn3:simplify_crate_num, r=jackh726
Remove CrateNum::ReservedForIncrCompCache

It's only use is easily replaceable with `Option<CrateNum>`.
2021-06-01 20:09:03 +00:00
Camille GILLOT
ba0ac88cd5 Avoid a clone of output_filenames. 2021-06-01 21:22:55 +02:00
Camille GILLOT
202d39a96b Drop metadata_encoding_version. 2021-06-01 21:12:27 +02:00
Camille GILLOT
28afaeec17 Make is_private_dep a query. 2021-06-01 21:03:55 +02:00
Camille GILLOT
273778086c Remove StableVec. 2021-06-01 20:53:04 +02:00
Camille GILLOT
e291be3649 Only compute the trait_map once. 2021-06-01 20:43:50 +02:00
Ryan Levick
4675690ac4 Fix issues and add test 2021-06-01 18:45:29 +02:00
Camille Gillot
0f0f3138cb
Revert "Reduce the amount of untracked state in TyCtxt" 2021-06-01 09:05:22 +02:00
bors
41278062c8 Auto merge of #85153 - cjgillot:qresolve, r=Aaron1011
Reduce the amount of untracked state in TyCtxt

Access to untracked global state may generate instances of #84970.

The GlobalCtxt contains the lowered HIR, the resolver outputs and interners.
By wrapping the resolver inside a query, we make sure those accesses are properly tracked.
As a no_hash query, all dependent queries essentially become `eval_always`,
what they should have been from the beginning.
2021-06-01 00:51:00 +00:00
bors
d9feaaa548 Auto merge of #85704 - Aaron1011:const-panic-hard-err, r=RalfJung
Emit a hard error when a panic occurs during const-eval

Previous, a panic during const evaluation would go through the
`const_err` lint. This PR ensures that such a panic always causes
compilation to fail.
2021-05-31 12:41:55 +00:00
bjorn3
312f964478 Remove unused feature gates 2021-05-31 13:55:43 +02:00
bors
91ddf3e76a Auto merge of #85266 - cjgillot:hir-dep-clean, r=michaelwoerister
Remove obsolete workaround.

The regression test for #62649 appears to pass even without the workaround.
2021-05-31 10:13:46 +00:00
Camille GILLOT
2543028161 Drop metadata_encoding_version. 2021-05-30 20:05:46 +02:00
Camille GILLOT
1119b48e02 Correct comments about untracked accesses. 2021-05-30 20:04:37 +02:00
Camille GILLOT
f0e5e22806 Make is_private_dep a query. 2021-05-30 20:04:22 +02:00
Camille GILLOT
ee94fbb607 Make allocator_kind a query. 2021-05-30 19:58:01 +02:00
Camille GILLOT
e1e6949558 Avoid a clone of output_filenames. 2021-05-30 19:57:13 +02:00
Camille GILLOT
ee567fe1b1 Remove StableVec. 2021-05-30 19:54:21 +02:00
Camille GILLOT
10fb4b2fe5 Restrict access to crate_name.
Also remove original_crate_name, which had the exact same implementation
2021-05-30 19:54:04 +02:00
Camille GILLOT
5d9f96ab27 Make resolutions a query. 2021-05-30 19:47:00 +02:00
Camille GILLOT
139f7ad637 Only compute the trait_map once. 2021-05-30 19:37:53 +02:00
Aaron Hill
2779fc1c47
Emit a hard error when a panic occurs during const-eval
Previous, a panic during const evaluation would go through the
`const_err` lint. This PR ensures that such a panic always causes
compilation to fail.
2021-05-30 11:59:54 -05:00
bjorn3
1ef98856c7 Remove CrateNum::ReservedForIncrCompCache 2021-05-30 14:33:16 +02:00
bjorn3
d0ec85d3fb Merge CrateDisambiguator into StableCrateId 2021-05-30 12:51:34 +02:00
bors
9a72afa7dd Auto merge of #83772 - jhpratt:revamp-step-trait, r=Mark-Simulacrum
Make `Step` trait safe to implement

This PR makes a few modifications to the `Step` trait that I believe better position it for stabilization in the short term. In particular,

1. `unsafe trait TrustedStep` is introduced, indicating that the implementation of `Step` for a given type upholds all stated invariants (which have remained unchanged). This is gated behind a new `trusted_step` feature, as stabilization is realistically blocked on min_specialization.
2. The `Step` trait is internally specialized on the `TrustedStep` trait, which avoids a serious performance regression.
3. `TrustedLen` is implemented for `T: TrustedStep` as the latter's invariants subsume the former's.
4. The `Step` trait is no longer `unsafe`, as the invariants must not be relied upon by unsafe code (unless the type implements `TrustedStep`).
5. `TrustedStep` is implemented for all types that implement `Step` in the standard library and compiler.
6. The `step_trait_ext` feature is merged into the `step_trait` feature. I was unable to find any reasoning for the features being split; the `_unchecked` methods need not necessarily be stabilized at the same time, but I think it is useful to have them under the same feature flag.

All existing implementations of `Step` will be broken, as it is not possible to `unsafe impl` a safe trait. Given this trait only exists on nightly, I feel this breakage is acceptable. The blanket `impl<T: Step> TrustedLen for T` will likely cause some minor breakage, but this should be covered by the equivalent impl for `TrustedStep`.

Hopefully these changes are sufficient to place `Step` in decent position for stabilization, which would allow user-defined types to be used with `a..b` syntax.
2021-05-30 01:21:39 +00:00
Ellen
d75742b1eb Fix missing note on type mismatch error diagnostics 2021-05-29 05:37:45 +01:00
Camille GILLOT
4f8e34cbf8 Merge fields and comment. 2021-05-28 21:14:11 +02:00
bors
0e44ca6dba Auto merge of #85789 - ptrojahn:generator_typo, r=nagisa
Fix typo
2021-05-28 17:44:47 +00:00
Ryan Levick
69a19bfd43 Initial support for force-warns 2021-05-28 18:19:59 +02:00
bors
ce0d64e03e Auto merge of #85546 - hyd-dev:unwind, r=RalfJung
const-eval: disallow unwinding across functions that `!fn_can_unwind()`

Following https://github.com/rust-lang/miri/pull/1776#discussion_r633074343, so r? `@RalfJung`

This PR turns `unwind` in `StackPopCleanup::Goto` into a new enum `StackPopUnwind`, with a `NotAllowed` variant to indicate that unwinding is not allowed. This variant is chosen based on `rustc_middle::ty::layout::fn_can_unwind()` in `eval_fn_call()` when pushing the frame. A check is added in `unwind_to_block()` to report UB if unwinding happens across a `StackPopUnwind::NotAllowed` frame.

Tested with Miri `HEAD` with [minor changes](https://github.com/rust-lang/miri/compare/HEAD..9cf3c7f0d86325a586fbcbf2acdc9232b861f1d8) and the rust-lang/miri#1776 branch with [these changes](d866c1c52f..626638fbfe).
2021-05-28 08:49:48 +00:00
bors
d854c3c0e9 Auto merge of #85729 - LeSeulArtichaut:thir-no-hash, r=nikomatsakis
Don't hash `thir_body`

Experiment to see if/how much this helps negate the perf impact of #85273.
r? `@ghost`
2021-05-27 15:46:48 +00:00
Niko Matsakis
9385be7a0c
Update compiler/rustc_middle/src/query/mod.rs
Co-authored-by: Léo Lanteri Thauvin <leseulartichaut@gmail.com>
2021-05-27 10:31:47 -04:00
Dylan DPC
e7c9469786
Rollup merge of #85583 - cjgillot:no-previous-dg, r=petrochenkov
Get rid of PreviousDepGraph.

Its only role is to access the `SerializedDepGraph`.
2021-05-27 03:02:09 +02:00
Jacob Pratt
bc2f0fb5a9
Specialize implementations
Implementations in stdlib are now optimized as they were before.
2021-05-26 18:07:09 -04:00
LeSeulArtichaut
fdc15ef823 Don't hash thir_body 2021-05-26 22:34:42 +02:00
Paul Trojahn
119bff1247 Fix typo 2021-05-26 19:19:47 +02:00
Dylan DPC
4b0014e3bb
Rollup merge of #85633 - lqd:stackless_span_stacks, r=oli-obk
Post-monomorphization errors traces MVP

This PR works towards better diagnostics for the errors encountered in #85155 and similar.

We can encounter post-monomorphization errors (PMEs) when collecting mono items. The current diagnostics are confusing for these cases when they happen in a dependency (but are acceptable when they happen in the local crate).

These kinds of errors will be more likely now that `stdarch` uses const generics for its intrinsics' immediate arguments, and validates these const arguments with a mechanism that triggers such PMEs.

(Not to mention that the errors happen during codegen, so only when building code that actually uses these code paths. Check builds don't trigger them, neither does unused code)

So in this PR, we detect these kinds of errors during the mono item graph walk: if any error happens while collecting a node or its neighbors, we print a diagnostic about the current collection step, so that the user has at least some context of which erroneous code and dependency triggered the error.

The diagnostics for issue #85155 now have this note showing the source of the erroneous const argument:
```
note: the above error was encountered while instantiating `fn std::arch::x86_64::_mm_blend_ps::<51_i32>`
  --> issue-85155.rs:11:24
   |
11 |         let _blended = _mm_blend_ps(a, b, 0x33);
   |                        ^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error
```

Note that #85155 is a reduced version of a case happening in the wild, to indirect users of the `rustfft` crate, as seen in https://github.com/ejmahler/RustFFT/issues/74. The crate had a few of these out-of-range immediates. Here's how the diagnostics in this PR would have looked on one of its examples before it was fixed:

<details>

```
error[E0080]: evaluation of constant value failed
 --> ./stdarch/crates/core_arch/src/macros.rs:8:9
  |
8 |         assert!(IMM >= MIN && IMM <= MAX, "IMM value not in expected range");
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'IMM value not in expected range', ./stdarch/crates/core_arch/src/macros.rs:8:9
  |
  = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)

note: the above error was encountered while instantiating `fn _mm_blend_ps::<51_i32>`
    --> /tmp/RustFFT/src/avx/avx_vector.rs:1314:23
     |
1314 |         let blended = _mm_blend_ps(rows[0], rows[2], 0x33);
     |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

note: the above error was encountered while instantiating `fn _mm_permute_pd::<5_i32>`
    --> /tmp/RustFFT/src/avx/avx_vector.rs:1859:9
     |
1859 |         _mm_permute_pd(self, 0x05)
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^

note: the above error was encountered while instantiating `fn _mm_permute_pd::<15_i32>`
    --> /tmp/RustFFT/src/avx/avx_vector.rs:1863:32
     |
1863 |         (_mm_movedup_pd(self), _mm_permute_pd(self, 0x0F))
     |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0080`.
error: could not compile `rustfft`

To learn more, run the command again with --verbose.
```

</details>

I've developed and discussed this with them, so maybe r? `@oli-obk` -- but feel free to redirect to someone else of course.

(I'm not sure we can say that this PR definitely closes issue 85155, as it's still unclear exactly which diagnostics and information would be interesting to report in such cases -- and we've discussed printing backtraces before. I have prototypes of some complete and therefore noisy backtraces I showed Oli, but we decided to not include them in this PR for now)
2021-05-26 13:32:08 +02:00
Rémy Rakic
d14dd9f763 emit diagnostic after post-monomorphization errors
Emit a diagnostic when the monomorphized item collector
encounters errors during a step of the recursive item collection.

These post-monomorphization errors otherwise only show the
erroneous expression without a trace, making them very obscure
and hard to pinpoint whenever they happen in dependencies.
2021-05-25 18:39:50 +02:00
Guillaume Gomez
aa8c37d2c9
Rollup merge of #85650 - scottmcm:adjust-adjustment-docs, r=jyn514
Add some backticks to the `rustc_middle::ty::adjustment::Adjustment` docs

A few `[i32]`s are getting picked up as intra-doc links, rather than showing as slices, making the sentence quite confusing.

See https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/adjustment/struct.Adjustment.html
2021-05-25 13:05:16 +02:00
Guillaume Gomez
ad72247833
Rollup merge of #85605 - ptrojahn:closure_struct, r=matthewjasper
Replace Local::new(1) with CAPTURE_STRUCT_LOCAL
2021-05-25 13:05:14 +02:00
bors
a7890c7952 Auto merge of #84985 - pietroalbini:bootstrap-1.54, r=Mark-Simulacrum
Bump bootstrap compiler to beta 1.53.0

This PR bumps the bootstrap compiler to version 1.53.0 beta, as part of our usual release process (this was supposed to be Wednesday's step, but creating the beta release took longer than expected).

The PR also includes the "Bootstrap: skip rustdoc fingerprint for building docs" commit, see the reasoning [on Zulip](https://zulip-archive.rust-lang.org/241545trelease/88450153betabootstrap.html).

r? `@Mark-Simulacrum`
2021-05-25 05:48:00 +00:00
bors
d568d63b1f Auto merge of #85273 - LeSeulArtichaut:thir-query, r=nikomatsakis
Make building THIR a stealable query

This PR creates a stealable `thir_body` query so that we can build the THIR only once for THIR unsafeck and MIR build.

Blocked on #83842.
r? `@nikomatsakis`
2021-05-25 03:07:03 +00:00
Scott McMurray
bc2c3dca55 Add some backticks to the rustc_middle::ty::adjustment::Adjustment docs
A few `[i32]`s are getting picked up as intra-doc links, rather than showing as slices, making the sentence quite confusing.
2021-05-24 15:47:28 -07:00
Pietro Albini
9e22b844dd remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
Paul Trojahn
0a80cc4d83 Replace Local::new(1) with CAPTURE_STRUCT_LOCAL 2021-05-23 18:36:23 +02:00
Ralf Jung
f9b36b4f65
fix comment
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2021-05-23 13:26:51 +02:00
Ralf Jung
585141b219 support creating mutable allocations from byte slices 2021-05-23 12:37:16 +02:00
hyd-dev
7b3e10c751
const-eval: disallow unwinding across functions that !fn_can_unwind() 2021-05-23 04:20:53 +08:00
LeSeulArtichaut
3f31044d90 Handle typeck errors properly 2021-05-22 16:21:36 +02:00
LeSeulArtichaut
6f64eb1fe6 Make THIR building a stealable query 2021-05-22 14:36:22 +02:00
LeSeulArtichaut
bd80018159 Move THIR structure definitions to rustc_middle 2021-05-22 14:36:22 +02:00
Camille GILLOT
a50f1e949b Get rid of PreviousDepGraph. 2021-05-22 14:14:23 +02:00
bors
3e827cc21e Auto merge of #85376 - RalfJung:ptrless-allocs, r=oli-obk
CTFE core engine allocation & memory API improvemenets

This is a first step towards https://github.com/rust-lang/miri/issues/841.
- make `Allocation` API offset-based (no more making up `Pointer`s just to access an `Allocation`)
- make `Memory` API higher-level (combine checking for access and getting access into one operation)

The Miri-side PR is at https://github.com/rust-lang/miri/pull/1804.
r? `@oli-obk`
2021-05-19 10:11:28 +00:00
Ralf Jung
563ab4a106 add Align::ONE; add methods to access alloc.extra 2021-05-18 19:33:55 +02:00
Ralf Jung
46c2286395 CTFE core engine allocation & memory API improvemenets
- make Allocation API offset-based (no more Pointer)
- make Memory API higher-level (combine checking for access and getting access into one operation)
2021-05-18 19:33:55 +02:00
bors
a5560a6a90 Auto merge of #85437 - GuillaumeGomez:rollup-3jcirty, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #84587 (rustdoc: Make "rust code block is empty" and "could not parse code block" warnings a lint (`INVALID_RUST_CODEBLOCKS`))
 - #85280 (Toggle-wrap items differently than top-doc.)
 - #85338 (Implement more Iterator methods on core::iter::Repeat)
 - #85339 (Report an error if a lang item has the wrong number of generic arguments)
 - #85369 (Suggest borrowing if a trait implementation is found for &/&mut <type>)
 - #85393 (Suppress spurious errors inside `async fn`)
 - #85415 (Clean up remnants of BorrowOfPackedField)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-18 14:48:53 +00:00
Guillaume Gomez
f4a0d97def
Rollup merge of #85415 - LeSeulArtichaut:no-packed-borrow-unsafeck, r=RalfJung
Clean up remnants of BorrowOfPackedField

cc #82525 which removed `BorrowOfPackedField` from unsafety-checking
r? `@RalfJung`
2021-05-18 14:08:57 +02:00