Commit graph

903 commits

Author SHA1 Message Date
varkor
96eb68b121 Add FIXME for const generic defaults 2020-10-03 14:28:55 +01:00
varkor
488b759d5c Replace "non trivial" with "non-trivial" 2020-10-03 14:28:54 +01:00
Jonas Schievink
eff6398014
Rollup merge of #77452 - Mark-Simulacrum:fix-symbol-v0, r=eddyb
Permit ty::Bool in const generics for v0 mangling

This should unbreak using new-symbol-mangling = true in config.toml (once it lands in beta anyway).

Fixes #76365 (well, it will, but seems fine to close as soon as we have support)

r? @eddyb (for mangling) but I'm okay with some other reviewer too :)
2020-10-03 00:31:17 +02:00
Jonas Schievink
23408de992
Rollup merge of #77421 - petrochenkov:globtravel, r=nagisa
Revert "resolve: Avoid "self-confirming" import resolutions in one more case"

And remove the assert that https://github.com/rust-lang/rust/pull/70236 tried to avoid instead.

Closes https://github.com/rust-lang/rust/issues/74556.
2020-10-03 00:31:16 +02:00
Jonas Schievink
6522868664
Rollup merge of #77251 - dtolnay:drop, r=Aaron1011
Bypass const_item_mutation if const's type has Drop impl

Follow-up to #75573. This PR disables the const_item_mutation lint in cases that the const has a Drop impl which observes the mutation.

```rust
struct Log { msg: &'static str }
const LOG: Log = Log { msg: "" };
impl Drop for Log {
    fn drop(&mut self) { println!("{}", self.msg); }
}

LOG.msg = "wow";  // prints "wow"
```

r? @Aaron1011
2020-10-03 00:31:12 +02:00
Jake Vossen
3ea96b86ab made multiline macro calls into single line 2020-10-02 15:08:01 -06:00
bors
8876ffc923 Auto merge of #77462 - jonas-schievink:rollup-m0rqdh5, r=jonas-schievink
Rollup of 12 pull requests

Successful merges:

 - #76101 (Update RELEASES.md for 1.47.0)
 - #76739 (resolve: prohibit anon const non-static lifetimes)
 - #76811 (Doc alias name restriction)
 - #77405 (Add tracking issue of iter_advance_by feature)
 - #77409 (Add example for iter chain struct)
 - #77415 (Better error message for `async` blocks in a const-context)
 - #77423 (Add `-Zprecise-enum-drop-elaboration`)
 - #77432 (Use posix_spawn on musl targets)
 - #77441 (Fix AVR stack corruption bug)
 - #77442 (Clean up on example doc fixes for ptr::copy)
 - #77444 (Fix span for incorrect pattern field and add label)
 - #77453 (Stop running macOS builds on Azure Pipelines)

Failed merges:

r? `@ghost`
2020-10-02 19:42:07 +00:00
Jonas Schievink
de8d7aa400
Rollup merge of #77444 - estebank:pat-field-label, r=davidtwco
Fix span for incorrect pattern field and add label

Address #73750.
2020-10-02 20:27:16 +02:00
Jonas Schievink
1e3c7e214a
Rollup merge of #77423 - ecstatic-morse:discriminant-switch-effect-config, r=pnkfelix
Add `-Zprecise-enum-drop-elaboration`

Its purpose is to assist in debugging #77382 and #74551. Passing `-Zprecise-enum-drop-elaboration=no` will turn off the added precision that seems to be causing issues on some platforms. This assumes that we can reproduce #77382 on the latest master. I should have done this earlier. Oh well.

cc @cuviper
r? @pnkfelix
2020-10-02 20:27:09 +02:00
Jonas Schievink
cac5352e33
Rollup merge of #77415 - ecstatic-morse:const-checking-async-block, r=oli-obk
Better error message for `async` blocks in a const-context

Improves the error message for the case in #77361.

r? @oli-obk
2020-10-02 20:27:08 +02:00
Jonas Schievink
c7c2418227
Rollup merge of #76811 - GuillaumeGomez:doc-alias-name-restriction, r=oli-obk,ollie27
Doc alias name restriction

Fixes #76705.
2020-10-02 20:27:03 +02:00
Jonas Schievink
c8eb2059da
Rollup merge of #76739 - davidtwco:issue-75323-non-static-lifetime-in-anonconst, r=varkor
resolve: prohibit anon const non-static lifetimes

Fixes #75323, fixes #74447 and fixes #73375.

This PR prohibits non-static lifetimes in anonymous constants when only the `min_const_generics` feature is enabled. ~~To do so, `to_region_vid`'s `bug!` had to be changed into a delayed bug, which unfortunately required providing it a `TyCtxt`.~~

---
~~While I am happy with how the implementation of the error turned out in `rustc_passes::check_const`,  emitting an error wasn't sufficient to avoid hitting the ICE later. I also tried implementing the error in `rustc_mir::transform::check_consts::validation` and that worked, but it didn't silence the ICE either. To silence the ICE, I changed it to a delayed bug which worked but was more invasive that I would have liked, and required I return an incorrect lifetime. It's possible that this check should be implemented earlier in the compiler to make the invasive changes unnecessary, but I wasn't sure where that would be and wanted to get some feedback first.~~
The approach taken by this PR has been changed to implement the error in name resolution, which ended up being much simpler.

cc @rust-lang/wg-const-eval
r? @lcnr
2020-10-02 20:26:55 +02:00
Guillaume Gomez
84cb71c6fa Forbid some characters to be used as doc alias 2020-10-02 19:26:59 +02:00
Jonas Schievink
acc150b2e9 validate: skip debuginfo 2020-10-02 16:50:29 +02:00
Guillaume Gomez
d1d94ba026 Improve E0777 help message 2020-10-02 16:33:44 +02:00
Jonas Schievink
c1a431edc3 validate: storage must be allocated on local use 2020-10-02 16:11:47 +02:00
Mark Rousskov
89fdfe6828 Permit ty::Bool in const generics for v0 mangling 2020-10-02 09:45:48 -04:00
David Wood
eacfb2b265
resolve: prohibit anon const non-static lifetimes
This commit modifies name resolution to emit an error when non-static
lifetimes are used in anonymous constants when the `min_const_generics`
feature is enabled.

Signed-off-by: David Wood <david@davidtw.co>
2020-10-02 13:54:25 +01:00
bors
4dedf5edd5 Auto merge of #77396 - wesleywiser:disable-simplifyarmidentity, r=oli-obk
Disable the SimplifyArmIdentity mir-opt

The optimization still has some bugs that need to be worked out
such as #77359.

We can try re-enabling this again after the known issues are resolved.

r? `@oli-obk`
2020-10-02 10:04:46 +00:00
Esteban Küber
7d5a6203ec Fix span for incorrect pattern field and add label 2020-10-02 00:44:16 -07:00
Harald Hoyer
cadd12b5f0 Implement Make handle_alloc_error default to panic (for no_std + liballoc)
Related: https://github.com/rust-lang/rust/issues/66741

Guarded with `#![feature(default_alloc_error_handler)]` a default
`alloc_error_handler` is called, if a custom allocator is used and no
other custom `#[alloc_error_handler]` is defined.

The panic message does not contain the size anymore, because it would
pull in the fmt machinery, which would blow up the code size
significantly.
2020-10-02 09:00:29 +02:00
varkor
0801263279 Fix missing diagnostic span for impl Trait with const generics 2020-10-02 01:39:04 +01:00
Wesley Wiser
f9d7720be7 Disable the SimplifyArmIdentity mir-opt
The optimization still has some bugs that need to be worked out
such as #77359.

We can try re-enabling this again after the known issues are resolved.
2020-10-01 20:29:53 -04:00
Yuki Okushi
b97334f65e
Rollup merge of #77375 - petrochenkov:inherext, r=oli-obk
rustc_metadata: Do not forget to encode inherent impls for foreign types

So I tried to move FFI interface for LLVM from `rustc_codegen_llvm` to `rustc_llvm` and immediately encountered this fascinating issue.

Fixes https://github.com/rust-lang/rust/issues/46665.
2020-10-02 08:25:20 +09:00
Yuki Okushi
1fa5f8f05b
Rollup merge of #76851 - fusion-engineering-forks:fixme-nonzero, r=petrochenkov
Fix 'FIXME' about using NonZeroU32 instead of u32.

It was blocked by #58732 (const fn NonZeroU32::new), which is fixed now.
2020-10-02 08:25:10 +09:00
Jonas Schievink
b01694e0a2 Returns values up to 2*usize by value 2020-10-02 00:23:25 +02:00
Vadim Petrochenkov
b20bce8ce5 Revert "resolve: Avoid "self-confirming" import resolutions in one more case" 2020-10-02 00:58:37 +03:00
David Tolnay
804d159c62
Fixme with link for re-enabling const mutation lint for Drop consts 2020-10-01 13:41:43 -07:00
Michael Howell
cd159fd7f9 Uplift drop-bounds lint from clippy 2020-10-01 12:06:33 -07:00
Guillaume Gomez
8b7aeefede Import struct_span_err macro instead of prepending it 2020-10-01 20:41:57 +02:00
Guillaume Gomez
de21c3df0e Create E0777 error code for "invalid literal in derive" 2020-10-01 20:41:57 +02:00
Dylan MacKenzie
6691d11234 Add -Zprecise-enum-drop-elaboration
Its purpose is to assist in debugging #77382 and #74551.
2020-10-01 11:31:43 -07:00
Dylan MacKenzie
50e0c0d97b Give better const-checking error for async blocks 2020-10-01 10:11:58 -07:00
Mara Bos
2140d80a9d
Add note about possible future improvement
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2020-10-01 17:32:23 +02:00
bors
9cba260df0 Auto merge of #74839 - alarsyo:multiple_return_terminators, r=oli-obk
Implement multiple return terminator optimization

Closes #72022
2020-10-01 09:52:58 +00:00
Antoine Martin
f54bfac074 Implement multiple return terminators optimization 2020-10-01 10:06:37 +02:00
bors
fc42fb8e70 Auto merge of #77354 - ecstatic-morse:const-checking-moar-errors, r=oli-obk
Overhaul const-checking diagnostics

The primary purpose of this PR was to remove `NonConstOp::STOPS_CONST_CHECKING`, which causes any additional errors found by the const-checker to be silenced. I used this flag to preserve diagnostic parity with `qualify_min_const_fn.rs`, which has since been removed.

However, simply removing the flag caused a deluge of errors in some cases, since an error would be emitted any time a local or temporary had a wrong type. To remedy this, I added an alternative system (`DiagnosticImportance`) to silence additional error messages that were likely to distract the user from the underlying issue. When an error of the highest importance occurs, all less important errors are silenced. When no error of the highest importance occurs, all less important errors are emitted after checking is complete. Following the suggestions from the important error is usually enough to fix the less important errors, so this should lead to better UX most of the time.

There's also some unrelated diagnostics improvements in this PR isolated in their own commits. Splitting them out would be possible, but a bit of a pain. This isn't as tidy as some of my other PRs, but it should *only* affect diagnostics, never whether or not something passes const-checking. Note that there are a few trivial exceptions to this, like banning `Yield` in all const-contexts, not just `const fn`.

As always, meant to be reviewed commit-by-commit.

r? `@oli-obk`
2020-10-01 07:38:47 +00:00
Oliver Scherer
8f9472cc9e Only mention that a stack frame is being popped when starting to do so 2020-10-01 08:32:24 +02:00
David Tolnay
75c2fdf34a
Warn on method call mutating const, even if it has destructor 2020-09-30 22:19:45 -07:00
David Tolnay
41baa090ad
Skip dropck::check_drop_impl in is_const_item_without_destructor
adt_destructor by default also validates the Drop impl using
dropck::check_drop_impl, which contains an expect_local(). This
leads to ICE in check_const_item_mutation if the const's type is
not a local type.

    thread 'rustc' panicked at 'DefId::expect_local: `DefId(5:4805 ~ alloc[d7e9]::vec::{impl#50})` isn't local', compiler/rustc_span/src/def_id.rs:174:43
    stack backtrace:
       0: rust_begin_unwind
       1: rustc_span::def_id::DefId::expect_local::{{closure}}
       2: rustc_typeck::check::dropck::check_drop_impl
       3: rustc_middle::ty::util::<impl rustc_middle::ty::context::TyCtxt>::calculate_dtor::{{closure}}
       4: rustc_middle::ty::trait_def::<impl rustc_middle::ty::context::TyCtxt>::for_each_relevant_impl
       5: rustc_middle::ty::util::<impl rustc_middle::ty::context::TyCtxt>::calculate_dtor
       6: rustc_typeck::check::adt_destructor
       7: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::adt_destructor>::compute
       8: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
       9: rustc_query_system::query::plumbing::get_query_impl
      10: rustc_mir::transform::check_const_item_mutation::ConstMutationChecker::is_const_item_without_destructor
2020-09-30 21:58:13 -07:00
David Tolnay
bb760b53bf
Simplify defid destructor check 2020-09-30 21:45:56 -07:00
David Tolnay
0dfe7b6434
Add justification of the destructor filter 2020-09-30 21:45:56 -07:00
David Tolnay
17db1cb5d5
Bypass const_item_mutation if const's type has Drop impl 2020-09-30 21:45:56 -07:00
bors
3bbc443cc6 Auto merge of #77379 - camelid:improve-wording-crate-resolution-error, r=davidtwco
Improve wording for external crate resolution error

I think it reads better this way.
2020-10-01 03:28:50 +00:00
Dylan DPC
85e77edc82
Rollup merge of #77371 - camelid:remove-extra-space-in-diagnostic, r=varkor
Remove trailing space in error message

- Add test for error message
- Remove trailing space in error message
2020-10-01 02:13:49 +02:00
Dylan DPC
cc1513b860
Rollup merge of #77360 - oli-obk:zst_const_pat_regression, r=RalfJung
References to ZSTs may be at arbitrary aligned addresses

fixes #77320

r? @RalfJung
2020-10-01 02:13:48 +02:00
Dylan DPC
849e5636ea
Rollup merge of #77343 - varkor:rustc_args_required_const-validation, r=lcnr
Validate `rustc_args_required_const`

Fixes https://github.com/rust-lang/rust/issues/74608.
2020-10-01 02:13:44 +02:00
Dylan DPC
73258f87ea
Rollup merge of #77324 - Aaron1011:fix/const-item-mutation-ptr, r=petrochenkov
Don't fire `const_item_mutation` lint on writes through a pointer

Fixes #77321
2020-10-01 02:13:43 +02:00
Dylan DPC
0044a9c084
Rollup merge of #77319 - tgnottingham:siphasher_endianness, r=nnethercote
Stable hashing: add comments and tests concerning platform-independence

SipHasher128 implements short_write in an endian-independent way, yet
its write_xxx Hasher trait methods undo this endian-independence by byte
swapping the integer inputs on big-endian hardware. StableHasher then
adds endian-independence back by also byte-swapping on big-endian
hardware prior to invoking SipHasher128.

This double swap may have the appearance of being a no-op, but is in
fact by design. In particular, we really do want SipHasher128 to be
platform-dependent, in order to be consistent with the libstd SipHasher.
Try to clarify this intent. Also, add and update a couple of unit tests.

---

Previous commit text:

~SipHasher128: fix platform-independence confusion~

~StableHasher is supposed to ensure platform independence by converting
integers to little-endian and extending isize and usize to 64 bits as
necessary, but in fact, much of that work is already handled by
SipHasher128.~

~In particular, SipHasher128 implements short_write in an
endian-independent way, yet both StableHasher and SipHasher128
additionally attempt to achieve endian-independence by byte swapping on
BE hardware before invoking short writes. This double swap has no
effect, so let's remove it.~

~Because short_write is endian-independent, SipHasher128 is already
handling part of the platform-independence, and it would be somewhat
difficult to make it *not* handle that part with the current
implementation. As splitting platform-independence responsibilities
between StableHasher and SipHasher128 would be confusing, let's make
SipHasher128 handle all of it.~

~Finally, update some incorrect comments and increase test coverage.
Unit tests pass on both LE and BE systems.~
2020-10-01 02:13:41 +02:00
Dylan DPC
6d3cfd9d51
Rollup merge of #77305 - lcnr:candidate_from_obligation, r=davidtwco
move candidate_from_obligation_no_cache

It's only called from `candidate_from_obligation` which is already in this file.
2020-10-01 02:13:37 +02:00
Dylan DPC
f23559451b
Rollup merge of #77303 - lcnr:const-evaluatable-TooGeneric, r=oli-obk,varkor
const evaluatable: improve `TooGeneric` handling

Instead of emitting an error in `fulfill`, we now correctly stall on inference variables.

As `const_eval_resolve` returns `ErrorHandled::TooGeneric` when encountering generic parameters on which
we actually do want to error, we check for inference variables and eagerly emit an error if they don't exist, returning `ErrorHandled::Reported` instead.

Also contains a small bugfix for `ConstEquate` where we previously only stalled on type variables. This is probably a leftover from
when we did not yet support stalling on const inference variables.

r? @oli-obk cc @varkor @eddyb
2020-10-01 02:13:35 +02:00
Dylan DPC
37df40bd1c
Rollup merge of #77202 - ehuss:defer-apple-sdkroot, r=petrochenkov
Defer Apple SDKROOT detection to link time.

This defers the detection of the SDKROOT for Apple iOS/tvOS targets to link time, instead of when the `Target` is defined. This allows commands that don't need to link to work (like `rustdoc` or `rustc --print=target-list`). This also makes `--print=target-list` a bit faster.

This also removes the note in the platform support documentation about these targets being missing. When I wrote it, I misunderstood how the SDKROOT stuff worked.

Notes:
* This means that JSON spec targets can't explicitly override these flags. I think that is probably fine, as I believe the value is generally required, and can be set with the SDKROOT environment variable.
* This changes `x86_64-apple-tvos` to use `appletvsimulator`. I think the original code was wrong (it was using `iphonesimulator`). Also, `x86_64-apple-tvos` seems broken in general, and I cannot build it locally. The `data_layout` does not appear to be correct (it is a copy of the arm64 layout instead of the x86_64 layout). I have not tried building Apple's LLVM to see if that helps, but I suspect it is just wrong (I'm uncertain since I don't know how the tvOS simulator works with its bitcode-only requirements).
* I'm tempted to remove the use of `Result` for built-in target definitions, since I don't think they should be fallible. This was added in https://github.com/rust-lang/rust/pull/34980, but that only relates to JSON definitions. I think the built-in targets shouldn't fail. I can do this now, or not.

Fixes #36156
Fixes #76584
2020-10-01 02:13:34 +02:00
Dylan DPC
8ccc063fbc
Rollup merge of #77153 - Aaron1011:fix/better-recursive-expand, r=petrochenkov
Fix recursive nonterminal expansion during pretty-print/reparse check

Makes progress towards #43081

In PR #73084, we started recursively expanded nonterminals during the
pretty-print/reparse check, allowing them to be properly compared
against the reparsed tokenstream.

Unfortunately, the recursive logic in that PR only handles the case
where a nonterminal appears inside a `TokenTree::Delimited`. If a
nonterminal appears directly in the expanded tokens of another
nonterminal, the inner nonterminal will not be expanded.

This PR fixes the recursive expansion of nonterminals, ensuring that
they are expanded wherever they occur.
2020-10-01 02:13:32 +02:00
Camelid
2c5e2a6fc6 Improve wording for external crate resolution error
I think it reads better this way.
2020-09-30 16:03:01 -07:00
bors
ef663a8a48 Auto merge of #77372 - jonas-schievink:rollup-e5bdzga, r=jonas-schievink
Rollup of 12 pull requests

Successful merges:

 - #77037 (more tiny clippy cleanups)
 - #77233 (BTreeMap: keep an eye out on the size of the main components)
 - #77280 (Ensure that all LLVM components requested by tests are available on CI)
 - #77284 (library: Forward compiler-builtins "mem" feature)
 - #77296 (liveness: Use Option::None to represent absent live nodes)
 - #77322 (Add unstable book docs for `-Zunsound-mir-opts`)
 - #77328 (Use `rtassert!` instead of `assert!` from the child process after fork() in std::sys::unix::process::Command::spawn())
 - #77331 (Add test for async/await combined with const-generics.)
 - #77338 (Fix typo in alloc vec comment)
 - #77340 (Alloc vec use imported path)
 - #77345 (Add test for issue #74761)
 - #77348 (Update books)

Failed merges:

r? `@ghost`
2020-09-30 20:49:27 +00:00
Vadim Petrochenkov
384eb2691f rustc_metadata: Do not forget to encode inherent impls for foreign types 2020-09-30 22:58:35 +03:00
Jonas Schievink
d4add198be
Rollup merge of #77296 - tmiasko:liveness-option, r=ecstatic-morse
liveness: Use Option::None to represent absent live nodes

No functional changes intended.
2020-09-30 20:56:12 +02:00
Jonas Schievink
248d6bf1e2
Rollup merge of #77037 - matthiaskrgr:cl42ppy, r=Dylan-DPC
more tiny clippy cleanups

commits stand alone and can be reviewed one by one
2020-09-30 20:56:05 +02:00
Camelid
b2ce3e5344 Remove trailing space in error message 2020-09-30 11:52:42 -07:00
bors
867bd42c38 Auto merge of #75810 - hug-dev:cmse-nonsecure-entry, r=jonas-schievink
Add support for cmse_nonsecure_entry attribute

This pull request adds the `cmse_nonsecure_entry` attribute under an unstable feature.

I was not sure if it was fine for me to send directly the pull-request or if I should submit a RFC first. I was told on Zulip that it was fine to do so but please close it if I need first submit a RFC or follow another process instead.

The `cmse_nonsecure_entry` attribute is a LLVM attribute that will be available in LLVM 11. I plan to rebase on the [upgrade PR](https://github.com/rust-lang/rust/pull/73526) once merged to make this one compile.

This attribute modifies code generation of the function as explained [here](https://developer.arm.com/documentation/ecm0359818/latest/) to make it work with the TrustZone-M hardware feature. This feature is only available on `thumbv8m` targets so I created an error for that if one tries to use this attribute for another target.

I added this attribute in Rust as any other LLVM attribute are added but since this one is target-dependent I am not sure if it was the best thing to do. Please indicate me if you think of other ways, like isolating target-dependent attributes together.

----------------

Tracking issue: https://github.com/rust-lang/rust/issues/75835
2020-09-30 18:43:48 +00:00
Dylan MacKenzie
1301f43119 Remove E0019, use E0015 for inline assembly in a const 2020-09-30 11:29:25 -07:00
Dylan MacKenzie
0c26144b1a Better span for attribute suggestions
`def_span` has the same issues as `body.span`, so do it this way instead.
2020-09-30 11:29:16 -07:00
Hugues de Valon
2588287def Add more tests and check for ABI
Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
2020-09-30 18:10:17 +01:00
Jake Vossen
dffb9d6a26 cargo fmt 2020-09-30 10:55:34 -06:00
Jake Vossen
5032674065 fixed merge conflicts 2020-09-30 10:54:27 -06:00
Jake Vossen
f69a88b7d3 updated p! macro to accept literals 2020-09-30 10:52:51 -06:00
Jake Vossen
d103fe15d1 Fixed more write literals after master merge 2020-09-30 10:12:48 -06:00
Jake Vossen
916d23614b updated p! macro to accept literals 2020-09-30 10:07:15 -06:00
est31
7f5008c829 Backport LLVM apfloat commit to rustc_apfloat
Backports LLVM commit: e34bd1e0b0

Fixes #69532
2020-09-30 17:48:26 +02:00
Hugues de Valon
1aaafac6ff Add support for cmse_nonsecure_entry attribute
This patch adds support for the LLVM cmse_nonsecure_entry attribute.
This is a target-dependent attribute that only has sense for the
thumbv8m Rust targets.
You can find more information about this attribute here:
https://developer.arm.com/documentation/ecm0359818/latest/

Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
2020-09-30 15:48:59 +01:00
Hugues de Valon
d255d70e7a Update LLVM and add Unsupported diagnostic
Secure entry functions do not support if arguments are passed on the
stack. An "unsupported" diagnostic will be emitted by LLVM if that is
the case.
This commits adds support in Rust for that diagnostic so that an error
will be output if that is the case!

Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
2020-09-30 14:57:37 +01:00
bors
939cc3e445 Auto merge of #77281 - tmiasko:liveness-everybody, r=oli-obk
Liveness analysis for everybody

Perform liveness analysis for every body instead of limiting it to fns.

Fixes #77169.
2020-09-30 12:44:31 +00:00
varkor
609786dbd8 Validate rustc_args_required_const 2020-09-30 11:59:44 +01:00
Oliver Scherer
ce6c25da58 References to ZSTs may be at arbitrary aligned addresses 2020-09-30 10:40:49 +02:00
Tyson Nottingham
d061fee177 Stable hashing: add comments and tests concerning platform-independence
SipHasher128 implements short_write in an endian-independent way, yet
its write_xxx Hasher trait methods undo this endian-independence by byte
swapping the integer inputs on big-endian hardware. StableHasher then
adds endian-independence back by also byte-swapping on big-endian
hardware prior to invoking SipHasher128.

This double swap may have the appearance of being a no-op, but is in
fact by design. In particular, we really do want SipHasher128 to be
platform-dependent, in order to be consistent with the libstd SipHasher.
Try to clarify this intent. Also, add and update a couple of unit tests.
2020-09-30 00:57:35 -07:00
Dylan MacKenzie
7c6d685551 Rewrite E0019 example
Inline assembly is now the only user of E0019. What is it doing that
E0015 is not?
2020-09-29 21:17:48 -07:00
Dylan MacKenzie
1513904c1c Remove default build_error impl
Now all structured errors must have their own error code
2020-09-29 21:17:48 -07:00
bors
6ac6c67574 Auto merge of #77069 - sexxi-goose:closure_print_2, r=nikomatsakis
pretty.rs: Update Closure and Generator print

More detailed outline: https://github.com/rust-lang/project-rfc-2229/pull/17

Closes: https://github.com/rust-lang/project-rfc-2229/issues/11

r? `@nikomatsakis`
cc `@eddyb` `@davidtwco` `@estebank`
2020-09-30 03:10:47 +00:00
Dylan MacKenzie
287993c961 Remove machinery for halting error output 2020-09-29 19:20:33 -07:00
Dylan MacKenzie
e02ea835a7 Don't stop const-checking after erroneous trait bound 2020-09-29 19:20:33 -07:00
Dylan MacKenzie
37f37dc5ba Emit multiple function pointer errors from const-checker 2020-09-29 19:20:33 -07:00
Dylan MacKenzie
b400871b9c Don't emit duplicate errors for the return place 2020-09-29 19:20:33 -07:00
Dylan MacKenzie
5b3145574e Priority levels 2020-09-29 19:20:33 -07:00
Dylan MacKenzie
a23297f5c0 Bless mut tests 2020-09-29 19:20:33 -07:00
Dylan MacKenzie
b518ccb4c3 Give MutDeref a real error message 2020-09-29 19:20:33 -07:00
Dylan MacKenzie
de35c4293d Remove ops::non_const
This helper function was meant to reduce code duplication between
const-checking pre- and post-drop-elaboration. Most of the functionality
is only relevant for the pre-drop-elaboration pass.
2020-09-29 19:20:33 -07:00
Dylan MacKenzie
ce50939952 Fix "unstable in stable" error
The "otherwise" note is printed before the suggestion currently.
2020-09-29 19:20:33 -07:00
Dylan MacKenzie
782a595d7c Return a DiagnosticBuilder from structured errors
This ensures that `emit_error` will actually cause compilation to fail.
2020-09-29 19:20:33 -07:00
Dylan MacKenzie
20e07e7b8e Forbid generator-specific MIR in all const-contexts 2020-09-29 19:20:33 -07:00
Dylan MacKenzie
c38aca0502 delay_span_bug if const-checking an async function
This errors during AST lowering. Any errors we emit here are just noise.
2020-09-29 19:20:33 -07:00
Dylan MacKenzie
25c7753eee Continue after impl Trait in const fn 2020-09-29 19:13:11 -07:00
Dylan MacKenzie
325b7d42ec Continue const-checking after errors when easy
This doesn't change any UI test output
2020-09-29 17:38:28 -07:00
Dylan MacKenzie
4d343a5e59 Useful derives on mir::LocalKind 2020-09-29 17:38:28 -07:00
Tomasz Miąsko
93e3db30e9 liveness: Use Option::None to represent absent live nodes
No functional changes intended.
2020-09-30 00:00:00 +00:00
Tomasz Miąsko
924e8aaaf2 Liveness analysis for everybody
Perform liveness analysis for every body instead of limiting it to fns.
2020-09-29 23:45:31 +02:00
bors
381b445ff5 Auto merge of #77274 - tmiasko:liveness-cnd, r=lcnr
Liveness refactoring continued

* Move body_owner field from IrMaps to Liveness (the only user of the field).
* Use upvars instead of FnKind to check for closures (avoids FnKind, will be useful when checking all bodies, not just fns).
* Use visit_param to add variables corresponding to params.
* Store upvars_mentioned inside Liveness struct.
* Inline visitor implementation for IrMaps, avoiding unnecessary indirection.
* Test interaction with automatically_derived attribute (not covered by any of existing tests).

No functional changes intended.
2020-09-29 19:25:10 +00:00
bors
4d52dc4790 Auto merge of #76754 - varkor:diagnostic-cleanup-ii, r=ecstatic-morse
Clean up diagnostics for arithmetic operation errors

Plus a small tweak to a range pattern error message.
2020-09-29 14:28:58 +00:00
bors
26373fb4ba Auto merge of #77275 - petrochenkov:interpid, r=varkor
expand: Stop normalizing `NtIdent`s before passing them to built-in macros

Built-in macros should be able to deal with `NtIdents` in the input by themselves like any other parser code.

You can't imagine how bad mutable AST visitors are, *especially* if they are modifying tokens.
This is one step towards removing token visiting from the visitor infrastructure (https://github.com/rust-lang/rust/pull/77271 also works in this direction.)
2020-09-29 05:14:36 +00:00
Aaron Hill
c6107c53d7
Don't fire const_item_mutation lint on writes through a pointer
Fixes #77321
2020-09-28 23:51:57 -04:00
bors
48cab67447 Auto merge of #77257 - ecstatic-morse:optimize-int-range-from-pat, r=Mark-Simulacrum
Optimize `IntRange::from_pat`, then shrink `ParamEnv`

Resolves #77058.

r? `@Mark-Simulacrum`
cc `@vandenheuvel`

Looking at the output of `perf report` for #76244, the hot instructions seemed to be around the call to `pat_constructor` in `IntRange::from_pat`. I carried out an obvious optimization, but it actually made the instruction count higher (see #77075). However, it seems to have mitigated whatever was causing the pipeline stalls, so when combined with #76244, it's a net win.

As you can see below, the regression in #76244 seems to have originated from something measured by `stalled-cycles-backend`. I'll try to collect some finer-grained stats to see if I can isolate it. I wish I had a better idea of what was going on here. I'd like to prevent the regression from reappearing in the future due to small changes in unrelated code.

<details>
<summary>Current `master`:</summary>

```
 Performance counter stats for 'cargo +baseline-stage1 check':

          2,275.67 msec task-clock:u              #    0.998 CPUs utilized
                 0      context-switches:u        #    0.000 K/sec
                 0      cpu-migrations:u          #    0.000 K/sec
            49,826      page-faults:u             #    0.022 M/sec
     5,117,221,678      cycles:u                  #    2.249 GHz
       299,655,943      stalled-cycles-frontend:u #    5.86% frontend cycles idle
     2,284,213,395      stalled-cycles-backend:u  #   44.64% backend cycles idle
     8,051,871,959      instructions:u            #    1.57  insn per cycle
                                                  #    0.28  stalled cycles per insn
     1,359,589,402      branches:u                #  597.447 M/sec
         7,359,347      branch-misses:u           #    0.54% of all branches

       2.281030026 seconds time elapsed

       2.108197000 seconds user
       0.164183000 seconds sys
```
</details>

<details>
<summary>Shrink `ParamEnv` without changing `IntRange::from_pat`:</summary>

```
 Performance counter stats for 'cargo +perf-stage1 check':

          2,751.79 msec task-clock:u              #    0.996 CPUs utilized
                 0      context-switches:u        #    0.000 K/sec
                 0      cpu-migrations:u          #    0.000 K/sec
            50,103      page-faults:u             #    0.018 M/sec
     6,260,590,019      cycles:u                  #    2.275 GHz
       317,355,920      stalled-cycles-frontend:u #    5.07% frontend cycles idle
     3,397,743,582      stalled-cycles-backend:u  #   54.27% backend cycles idle
     8,276,224,367      instructions:u            #    1.32  insn per cycle
                                                  #    0.41  stalled cycles per insn
     1,370,453,386      branches:u                #  498.023 M/sec
         7,281,031      branch-misses:u           #    0.53% of all branches

       2.763265838 seconds time elapsed

       2.544578000 seconds user
       0.204548000 seconds sys
```
</details>

<details>
<summary>Shrink `ParamEnv` and change `IntRange::from_pat`: </summary>

```
 Performance counter stats for 'cargo +perf-stage1 check':

          2,295.57 msec task-clock:u              #    0.996 CPUs utilized
                 0      context-switches:u        #    0.000 K/sec
                 0      cpu-migrations:u          #    0.000 K/sec
            49,959      page-faults:u             #    0.022 M/sec
     5,151,407,066      cycles:u                  #    2.244 GHz
       324,517,829      stalled-cycles-frontend:u #    6.30% frontend cycles idle
     2,301,671,001      stalled-cycles-backend:u  #   44.68% backend cycles idle
     8,130,868,329      instructions:u            #    1.58  insn per cycle
                                                  #    0.28  stalled cycles per insn
     1,356,618,512      branches:u                #  590.972 M/sec
         7,323,800      branch-misses:u           #    0.54% of all branches

       2.304509653 seconds time elapsed

       2.128090000 seconds user
       0.163909000 seconds sys
```
</details>
2020-09-29 02:29:13 +00:00