Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 17 pull requests #76944

Closed
wants to merge 68 commits into from

Conversation

Dylan-DPC-zz
Copy link

Successful merges:

Failed merges:

r? @ghost

davidtwco and others added 30 commits September 4, 2020 13:00
This commit adjusts MIR shim construction so that substitutions are
applied to function pointer shims during construction, rather than
during codegen (as determined by `substs_for_mir_body`) - as
substitutions will no longer occur during codegen, function pointer
shims can now be polymorphic without incurring double substitutions.

Signed-off-by: David Wood <[email protected]>
glibc destroys[1] the passed pthread_attr_t if pthread_getattr_np()
fails.  Destroying it again leads to a segfault.  Fix it by only
destroying it on success for glibc.

[1]: https://sourceware.org/git/?p=glibc.git;a=blob;f=nptl/pthread_getattr_np.c;h=ce437205e41dc05653e435f6188768cccdd91c99;hb=HEAD#l205
…ibcs

The calling convention of pthread_getattr_np() is to initialize the
pthread_attr_t, so _destroy() is only necessary on success (and _init()
isn't necessary beforehand).  On the other hand, FreeBSD wants the
attr_t to be initialized before pthread_attr_get_np(), and therefore it
should always be destroyed afterwards.
Make the following methods unstable const under the `const_pin` feature:
- `new`
- `new_unchecked`
- `into_inner`
- `into_inner_unchecked`
- `get_ref`
- `into_ref`

Also adds tests for these methods in a const context.

Tracking issue: rust-lang#76654
Only insert StorageDeads if we actually removed one.
Fixes an issue where we added StorageDead to a place with no StorageLive
This is heavily dependent on MIR inlining running to actually see the drop statement
Co-authored-by: Andreas Jonson <[email protected]>
Use `SyncOnceCell` to only compile it once.
I believe this still adds some kind of locking mechanism?
The use of arith_offset was added in 803e9ae
before the stable wrapper of the intrinsic was available.

https://doc.rust-lang.org/stable/std/intrinsics/fn.arith_offset.html
The latter is on the path to stabilization.
This moves build triple discovery for rustbuild from bootstrap.py into a build
script, meaning it will "just work" if building rustbuild via Cargo rather than
Python.
This requires that bootstrap is run from the same worktree as the sources it'll
build, but this is basically required for the build to work anyway. You can
still run it from a different directory, just that the files it builds must be
beside it.
Make the following methods unstable const under the `const_pin` feature:
- `into_ref`
- `get_mut`
- `get_unchecked_mut`
As a side effect, we now represent most promoteds as `ConstValue::Scalar` again. This is useful because all implict promoteds are just references anyway and most explicit promoteds are numeric arguments to `asm!` or SIMD instructions.
RalfJung and others added 21 commits September 19, 2020 22:14
in particular allow a few more promotions for consistency when they were already allowed in other contexts
…RalfJung

Validate constants during `const_eval_raw`

This PR implements the groundwork for rust-lang#72396

* constants are now validated during `const_eval_raw`
* to prevent cycle errors, we do not validate references to statics anymore beyond the fact that they are not dangling
* the `const_eval` query ICEs if used on `static` items
* as a side effect promoteds are now evaluated to `ConstValue::Scalar` again (since they are just a reference to the actual promoted allocation in most cases).
…nstancedef-fnptrshim, r=nikomatsakis

shim: monomorphic `FnPtrShim`s during construction

Fixes rust-lang#69925.

This PR adjusts MIR shim construction so that substitutions are applied to function pointer shims during construction, rather than during codegen (as determined by `substs_for_mir_body`).

r? @eddyb
…tatic-morse

Some promotion cleanup

Based on top of both rust-lang#75502 and rust-lang#75585, this does some cleanup of the promotion code. The last 2 commits are new.

* Remove the remaining cases where `const fn` is treated different from `fn`. This means no longer promoting ptr-to-int casts, raw ptr operations, and union field accesses in `const fn` -- or anywhere, for that matter. These are all unstable in const-context so this should not break any stable code. Fixes rust-lang#75586.
* ~~Promote references to statics even outside statics (i.e., in functions) for consistency.~~
* Promote `&mut []` everywhere, not just in non-`const` functions, for consistency.
* Explain why we do not promote deref's of statics outside statics. ~~(This is the only remaining direct user of `const_kind`.)~~

This can only land once the other two PRs land; I am mostly putting this up already because I couldn't wait ;) and to get some feedback from @rust-lang/wg-const-eval .
…roy, r=Amanieu

Fix segfault if pthread_getattr_np fails

glibc [destroys][1] the passed pthread_attr_t if pthread_getattr_np()
fails.  Destroying it again leads to a segfault.  Fix it by only
destroying it on success for glibc.

[1]: https://sourceware.org/git/?p=glibc.git;a=blob;f=nptl/pthread_getattr_np.c;h=ce437205e41dc05653e435f6188768cccdd91c99;hb=HEAD#l205
…crichton

De-couple Python and bootstrap slightly

This revises rustbuild's entry points from Python to rely less on magic environment variables, preferring to use Cargo-provided environment variables where feasible.

Notably, BUILD_DIR and BOOTSTRAP_CONFIG are *not* moved, because both more-or-less have some non-trivial discovery logic and replicating it in rustbuild seems unfortunate; if it moved to Cargo that would be a different story.

Best reviewed by-commit.
do not ICE on bound variables, return `TooGeneric` instead

fixes rust-lang#73260, fixes rust-lang#74634, fixes rust-lang#76595

r? @nikomatsakis
Make some methods of `Pin` unstable const

Make the following methods unstable const under the `const_pin` feature:
- `new`
- `new_unchecked`
- `into_inner`
- `into_inner_unchecked`
- `get_ref`
- `into_ref`
- `get_mut`
- `get_unchecked_mut`

Of these, `into_inner` and `into_inner_unchecked` require the unstable `const_precise_live_drops`.

Also adds tests for these methods in a const context.

Tracking issue: rust-lang#76654

r? @ecstatic-morse
SimplifyComparisonIntegral: fix miscompilation

Fixes rust-lang#76432
Only insert StorageDeads if we actually removed one.
Fixes an issue where we added StorageDead to a place with no StorageLive

r? @oli-obk
…r=oli-obk

MIR pass to remove unneeded drops on types not needing drop

This is heavily dependent on MIR inlining running to actually see the drop statement.

Do we want to special case replacing a call to std::mem::drop with a goto aswell?
simplfy condition in ItemLowerer::with_trait_impl_ref()
…me, r=ecstatic-morse

Don't compile regex at every function call.

Use `SyncOnceCell` to only compile it once.
I believe this still adds some kind of locking mechanism?

Related issue: rust-lang#76817
…ures, r=oli-obk,Mark-Simulacrum

Remove redundant nightly features

Removes a bunch of redundant/outdated nightly features. The first commit removes a `core_intrinsics` use for which a stable wrapper has been provided since. The second commit replaces the `const_generics` feature with `min_const_generics` which might get stabilized this year. The third commit is the result of a trial/error run of removing every single feature and then adding it back if compile failed. A bunch of unused features are the result that the third commit removes.
…lett

black_box: silence unused_mut warning when building with cfg(miri)
use `array_windows` instead of `windows` in the compiler

I do think these changes are beautiful, but do have to admit that using type inference for the window length
can easily be confusing. This seems like a general issue with const generics, where inferring constants adds an additional
complexity which users have to learn and keep in mind.
…=lcnr

use strip_prefix over starts_with and manual slicing based on pattern length (clippy::manual_strip)
@Dylan-DPC-zz
Copy link
Author

@bors r rollup=never p=17

@bors
Copy link
Contributor

bors commented Sep 19, 2020

📌 Commit 1fad825 has been approved by Dylan-DPC

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Sep 19, 2020
@Aaron1011
Copy link
Member

@bors r-

Test failed:

2020-09-19T23:03:26.0942369Z failures:
2020-09-19T23:03:26.0976406Z 
2020-09-19T23:03:26.0977129Z ---- [ui] ui/const-generics/issues/issue-76595.rs stdout ----
2020-09-19T23:03:26.0980716Z diff of stderr:
2020-09-19T23:03:26.0981401Z 
2020-09-19T23:03:26.0982102Z 8	  --> $DIR/issue-76595.rs:15:5
2020-09-19T23:03:26.0982409Z 9	   |
2020-09-19T23:03:26.0982795Z 10	LL | fn test<T, const P: usize>() where Bool<{core::mem::size_of::<T>() > 4}>: True {
2020-09-19T23:03:26.0983417Z -	   |    ---- required by a bound in this
2020-09-19T23:03:26.0984024Z  	   |                                                                           ---- required by this bound in `test`
2020-09-19T23:03:26.0987789Z 12	...
2020-09-19T23:03:26.0988434Z 13	LL |     test::<2>();
2020-09-19T23:03:26.0988748Z 14	   |     ^^^^^^^^^
2020-09-19T23:03:26.0988901Z 
2020-09-19T23:03:26.0989105Z 15	   |
2020-09-19T23:03:26.0989520Z 16	   = note: this may fail depending on what value the parameter takes
2020-09-19T23:03:26.0990389Z -	   = note: required by this bound in `test`
2020-09-19T23:03:26.0990696Z 18	
2020-09-19T23:03:26.0991062Z 19	error: aborting due to 2 previous errors

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 19, 2020
@Dylan-DPC-zz Dylan-DPC-zz deleted the rollup-lgsmkt2 branch September 19, 2020 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.