]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agointroduce PredicateAtom
Bastian Kauschke [Wed, 8 Jul 2020 22:35:55 +0000 (00:35 +0200)]
introduce PredicateAtom

3 years agoadd reuse_or_mk_predicate
Bastian Kauschke [Wed, 24 Jun 2020 16:06:04 +0000 (18:06 +0200)]
add reuse_or_mk_predicate

3 years agorefactor query_outlives_constraints_into_obligations
Bastian Kauschke [Wed, 24 Jun 2020 15:54:13 +0000 (17:54 +0200)]
refactor query_outlives_constraints_into_obligations

3 years agothis might be unqualified, but at least it's now quantified
Bastian Kauschke [Wed, 24 Jun 2020 15:40:28 +0000 (17:40 +0200)]
this might be unqualified, but at least it's now quantified

3 years agofix rustdoc
Bastian Kauschke [Sun, 21 Jun 2020 12:42:47 +0000 (14:42 +0200)]
fix rustdoc

3 years agosplit ignore_qualifiers
Bastian Kauschke [Sun, 21 Jun 2020 10:26:17 +0000 (12:26 +0200)]
split ignore_qualifiers

3 years agoreview
Bastian Kauschke [Fri, 19 Jun 2020 22:21:59 +0000 (00:21 +0200)]
review

3 years agofix elaborate for predicates with unbound variables
Bastian Kauschke [Fri, 19 Jun 2020 17:19:21 +0000 (19:19 +0200)]
fix elaborate for predicates with unbound variables

3 years agoclippy
Bastian Kauschke [Fri, 19 Jun 2020 08:22:25 +0000 (10:22 +0200)]
clippy

3 years agorustdoc
Bastian Kauschke [Fri, 19 Jun 2020 08:05:05 +0000 (10:05 +0200)]
rustdoc

3 years ago`PredicateKint` -> `PredicateKind`, the beginning of the end
Bastian Kauschke [Thu, 18 Jun 2020 18:41:43 +0000 (20:41 +0200)]
`PredicateKint` -> `PredicateKind`, the beginning of the end

3 years agoprogress
Bastian Kauschke [Thu, 18 Jun 2020 18:33:52 +0000 (20:33 +0200)]
progress

3 years agoelaborate
Bastian Kauschke [Thu, 18 Jun 2020 15:43:26 +0000 (17:43 +0200)]
elaborate

3 years agosubst_supertrait
Bastian Kauschke [Wed, 17 Jun 2020 22:18:58 +0000 (00:18 +0200)]
subst_supertrait

3 years agosomewhat related cleanup
Bastian Kauschke [Wed, 17 Jun 2020 21:20:17 +0000 (23:20 +0200)]
somewhat related cleanup

3 years agowf
Bastian Kauschke [Wed, 17 Jun 2020 20:50:28 +0000 (22:50 +0200)]
wf

3 years agoconvert trivial predicates
Bastian Kauschke [Wed, 17 Jun 2020 09:30:18 +0000 (11:30 +0200)]
convert trivial predicates

3 years agoquery_outlives_constraints_into_obligations
Bastian Kauschke [Wed, 17 Jun 2020 08:46:52 +0000 (10:46 +0200)]
query_outlives_constraints_into_obligations

3 years agoanonymize_predicate
Bastian Kauschke [Tue, 16 Jun 2020 22:13:00 +0000 (00:13 +0200)]
anonymize_predicate

3 years agoHandle trait/projection predicates with bound regions correctly
Matthew Jasper [Sun, 14 Jun 2020 12:22:51 +0000 (13:22 +0100)]
Handle trait/projection predicates with bound regions correctly

3 years agominimal
Bastian Kauschke [Sat, 13 Jun 2020 13:04:28 +0000 (15:04 +0200)]
minimal

3 years agoadd `PredicateKint`, because who doesn't like bodging
Bastian Kauschke [Thu, 11 Jun 2020 19:42:39 +0000 (21:42 +0200)]
add `PredicateKint`, because who doesn't like bodging

3 years agoAuto merge of #74817 - JohnTitor:rollup-0fchdye, r=JohnTitor
bors [Mon, 27 Jul 2020 11:07:32 +0000 (11:07 +0000)]
Auto merge of #74817 - JohnTitor:rollup-0fchdye, r=JohnTitor

Rollup of 6 pull requests

Successful merges:

 - #74088 (Avoid writes without any data in `Write::write_all_vectored`)
 - #74598 (Fix sync_once_cell_does_not_leak_partially_constructed_boxes)
 - #74750 (Clean up some uses of logging in ui tests)
 - #74783 (python codes cleanup)
 - #74790 (Don't italicize comments in ayu theme)
 - #74799 (Fixed typo in `closure`)

Failed merges:

r? @ghost

3 years agoRollup merge of #74799 - Dhs92:master, r=joshtriplett
Yuki Okushi [Mon, 27 Jul 2020 10:32:02 +0000 (19:32 +0900)]
Rollup merge of #74799 - Dhs92:master, r=joshtriplett

Fixed typo in `closure`

3 years agoRollup merge of #74790 - Cldfire:ayu-no-italic-comments, r=GuillaumeGomez
Yuki Okushi [Mon, 27 Jul 2020 10:32:00 +0000 (19:32 +0900)]
Rollup merge of #74790 - Cldfire:ayu-no-italic-comments, r=GuillaumeGomez

Don't italicize comments in ayu theme

Closes #74770.

Before:

![image](https://user-images.githubusercontent.com/13814214/88486217-2bf18700-cf4a-11ea-896d-e7787b94e7a7.png)

After:

![image](https://user-images.githubusercontent.com/13814214/88486225-3a3fa300-cf4a-11ea-929f-90461799dc01.png)

3 years agoRollup merge of #74783 - jnozsc:python_cleanup, r=Mark-Simulacrum
Yuki Okushi [Mon, 27 Jul 2020 10:31:58 +0000 (19:31 +0900)]
Rollup merge of #74783 - jnozsc:python_cleanup, r=Mark-Simulacrum

python codes cleanup

3 years agoRollup merge of #74750 - oli-obk:logging_and_test_cleanups, r=JohnTitor
Yuki Okushi [Mon, 27 Jul 2020 10:31:56 +0000 (19:31 +0900)]
Rollup merge of #74750 - oli-obk:logging_and_test_cleanups, r=JohnTitor

Clean up some uses of logging in ui tests

The removed test can't possibly trigger anything today as we don't have logging in libstd.

The `exec-env` flag was mistakenly used for adding env vars to rustc invocations both in test and in the test suite and there were some accidental renames from RUST_LOG to RUSTC_LOG that I reverted.

3 years agoRollup merge of #74598 - mzohreva:mz/fix-test, r=KodrAus
Yuki Okushi [Mon, 27 Jul 2020 10:31:55 +0000 (19:31 +0900)]
Rollup merge of #74598 - mzohreva:mz/fix-test, r=KodrAus

Fix sync_once_cell_does_not_leak_partially_constructed_boxes

Spinning multiple threads in this test causes a deadlock in
SGX where thread scheduling is not preemptive.

cc @jethrogb @AdrianCX

3 years agoRollup merge of #74088 - tmiasko:write-all-vectored-empty, r=KodrAus
Yuki Okushi [Mon, 27 Jul 2020 10:31:53 +0000 (19:31 +0900)]
Rollup merge of #74088 - tmiasko:write-all-vectored-empty, r=KodrAus

Avoid writes without any data in `Write::write_all_vectored`

Previously, when non-empty sequence of empty IoSlices have been provided
to `Write::write_all_vectored`, the buffers would be written as is with
`Write::write_vectored` and subsequently the return value `Ok(0)` would
be misinterpreted as an error.

Avoid writes without any data by advancing the buffers first. This
matches the documented behaviour of `Write::write_all_vectored`
and is analogous to what happens in `Write::write_all`.

3 years agoAuto merge of #74737 - smmalis37:astconv-factor, r=davidtwco
bors [Mon, 27 Jul 2020 09:22:09 +0000 (09:22 +0000)]
Auto merge of #74737 - smmalis37:astconv-factor, r=davidtwco

Pull out some duplicated code into a new function

I debated pulling the actual struct_span_err calls into the new method, but I felt like having to pass in multiple arguments for it and wiring up string formatting outweighed the benefits.

Viewing the diff with whitespace ignored is recommended.

3 years agoAuto merge of #74653 - petrochenkov:pmenv, r=dtolnay
bors [Mon, 27 Jul 2020 05:50:29 +0000 (05:50 +0000)]
Auto merge of #74653 - petrochenkov:pmenv, r=dtolnay

proc_macro: Add API for tracked access to environment variables

Continuation of https://github.com/rust-lang/rust/pull/71858.

`proc_macro::tracked_env::var` is similar to regular `env::var` called from a proc macro, except that it also adds the accessed variable to depinfo.

3 years agoAuto merge of #74784 - anp:track-vtables, r=eddyb
bors [Mon, 27 Jul 2020 03:47:17 +0000 (03:47 +0000)]
Auto merge of #74784 - anp:track-vtables, r=eddyb

Fix #[track_caller] shims for trait objects.

We were missing an Instance::resolve_for_fn_ptr in resolve_for_vtable.

Closes #74764.

3 years agoAuto merge of #72121 - Aaron1011:final-hygiene-rebase, r=petrochenkov
bors [Mon, 27 Jul 2020 01:54:27 +0000 (01:54 +0000)]
Auto merge of #72121 - Aaron1011:final-hygiene-rebase, r=petrochenkov

Serialize span hygiene data

Fixes #68686
Fixes #70963

This PR serializies global hygiene data into both the incremental compilation cache and the crate metadata. This allows hygiene information to be preserved across compilation sessions (both incremental and cross-crate).

When serializing a `SyntaxContext`, we simply write out the raw id from the current compilation session. Whenever we deserialize a `SyntaxContext`, we 'remap' the id to a fresh id in our current compilation session, and load the associated `SyntaxContextData`.

As a result, some 'upstream' `SyntaxContextData` will end up getting duplicated in 'downstream' crates. This only happens when we actually need to use an 'upstream' `SyntaxContext`, which occurs when we deserialize a `Span` that requires it.

We serialize an `ExpnData` into the metadata of the crate which generated it. An `ExpnId` is serialized as a reference into the crate which 'owns' the corresponding `ExpnData`, which avoids duplication in downstream crates.

I've included a macros 2.0 test which requires hygiene serialization to compile successfully.

TODO:

- [x] <strike>Determine how many additional `DefId`s we end up creating for `ExpnId`s - this may be significant for `libcore`, which uses macros heavily. Alternatively, we could try to compute a `DefPathHash` without making a corresponding `DefId` - however, this might significantly complicate the implementation.</strike> (We no longer create `DefId`s)
- [x] Investigate the overhead of duplicating `SyntaxContextData` in crate metadata.
- [x] Investigate how `resolve_crate_root` behaves with deserialized hygiene data - the current logic may be wrong.
- [x] Add additional tests. The effects of this PR are usually only noticeable when working with headache-inducing macro expansions (e.g. macros expanding to macros), so there are lots of corner cases to test.
- [x] Determine what to do about this:

https://github.com/rust-lang/rust/blob/4774f9b523c942cb5c0236542b5bcac76f6b6b9a/src/librustc_resolve/build_reduced_graph.rs#L892

- [x] Determine if we need to do anything here - I think the fact that `src/test/ui/hygiene/cross_crate_hygiene.rs` passes means that this is working.

https://github.com/rust-lang/rust/blob/3d5d0f898c2f3998e50c2180c6202f193c3acdbc/src/librustc_resolve/imports.rs#L1389-L1392

3 years agoFixed typo in `closure`
Alex [Mon, 27 Jul 2020 00:05:49 +0000 (17:05 -0700)]
Fixed typo in `closure`

3 years agoNormalize the test output of hygiene-related tests
Aaron Hill [Mon, 27 Jul 2020 00:00:35 +0000 (20:00 -0400)]
Normalize the test output of hygiene-related tests

A raw SyntaxContext id is implicitly dependent on the target platform,
since libstd and libcore have platform-dependent #[cfg]s which affect
which macros are invoked. As a result, we must strip out any
SyntaxContext ids from test output to ensure that the captured stdout is
not platform-dependent.

3 years agoRemove explicit `extern crate` from proc-macro test
Aaron Hill [Sun, 26 Jul 2020 20:49:55 +0000 (16:49 -0400)]
Remove explicit `extern crate` from proc-macro test

We only want to load this auxiliary crate from a proc-macro, so that it
only ever needs to get built for the host platform.

3 years agoShare serialization optimization between incr and metadata
Aaron Hill [Fri, 24 Jul 2020 07:01:07 +0000 (03:01 -0400)]
Share serialization optimization between incr and metadata

3 years agoProperly reset `orig_id` when loading from incremental cache
Aaron Hill [Thu, 23 Jul 2020 22:47:05 +0000 (18:47 -0400)]
Properly reset `orig_id` when loading from incremental cache

3 years agoAdd test for hygiene caching issue
Aaron Hill [Thu, 23 Jul 2020 21:45:30 +0000 (17:45 -0400)]
Add test for hygiene caching issue

3 years agoIgnore `orig_id` for stable hashing
Aaron Hill [Wed, 22 Jul 2020 19:11:25 +0000 (15:11 -0400)]
Ignore `orig_id` for stable hashing

This does not affect semantic equality, and was causing an enormous
number of Span hash invalidations.

3 years agoAdd test for serializing hygiene *into* a proc-macro crate
Aaron Hill [Tue, 21 Jul 2020 23:51:07 +0000 (19:51 -0400)]
Add test for serializing hygiene *into* a proc-macro crate

This is a very obscure corner case, and should never be hit in practice.

3 years agoAdd test for use of $crate in nested foreign macro_rules!
Aaron Hill [Wed, 15 Jul 2020 03:21:59 +0000 (23:21 -0400)]
Add test for use of $crate in nested foreign macro_rules!

3 years agoHygiene serialization implementation
Aaron Hill [Tue, 17 Mar 2020 15:45:02 +0000 (11:45 -0400)]
Hygiene serialization implementation

3 years agoAuto merge of #74708 - kanru:issue-74564, r=davidtwco
bors [Sun, 26 Jul 2020 22:35:13 +0000 (22:35 +0000)]
Auto merge of #74708 - kanru:issue-74564, r=davidtwco

Ensure stack when type checking and building MIR for large if expressions

Fixes #74564

3 years agoAuto merge of #74792 - flip1995:clippyup, r=Manishearth
bors [Sun, 26 Jul 2020 20:08:45 +0000 (20:08 +0000)]
Auto merge of #74792 - flip1995:clippyup, r=Manishearth

Update Clippy

Biweekly Clippy Sync

r? @Manishearth

3 years agoMerge commit 'da5a6fb1b65ec6581a67e942a3850f6bc15a552c' into clippyup
flip1995 [Sun, 26 Jul 2020 19:07:07 +0000 (21:07 +0200)]
Merge commit 'da5a6fb1b65ec6581a67e942a3850f6bc15a552c' into clippyup

3 years agoDon't italicize comments in ayu theme
Jarek Samic [Sun, 26 Jul 2020 18:11:10 +0000 (14:11 -0400)]
Don't italicize comments in ayu theme

3 years agoAuto merge of #5845 - giraffate:fix_fp_useless_conversion, r=yaahc
bors [Sun, 26 Jul 2020 17:50:54 +0000 (17:50 +0000)]
Auto merge of #5845 - giraffate:fix_fp_useless_conversion, r=yaahc

Fix FP `useless_conversion`

Fix #5833.

changelog: none

3 years agoFix #[track_caller] shims for trait objects.
Adam Perry [Sun, 26 Jul 2020 16:53:24 +0000 (09:53 -0700)]
Fix #[track_caller] shims for trait objects.

We were missing an Instance::resolve_for_fn_ptr in resolve_for_vtable.

Closes #74764.

3 years agopython codes cleanup
jnozsc [Sun, 26 Jul 2020 16:56:12 +0000 (09:56 -0700)]
python codes cleanup

3 years agoBless you
Oliver Scherer [Sun, 26 Jul 2020 15:03:38 +0000 (17:03 +0200)]
Bless you

3 years agoAuto merge of #74772 - JohnTitor:add-tests, r=lcnr
bors [Sun, 26 Jul 2020 14:09:36 +0000 (14:09 +0000)]
Auto merge of #74772 - JohnTitor:add-tests, r=lcnr

Add some regression tests

cc #56445
Fixes #72911

3 years agoRemove more obsolete test flags
Oliver Scherer [Sun, 26 Jul 2020 11:24:19 +0000 (13:24 +0200)]
Remove more obsolete test flags

3 years agoproc_macro: Add API for tracked access to environment variables
Vadim Petrochenkov [Wed, 22 Jul 2020 18:08:01 +0000 (21:08 +0300)]
proc_macro: Add API for tracked access to environment variables

3 years agoAvoid writes without any data in `Write::write_all_vectored`
Tomasz MiÄ…sko [Mon, 6 Jul 2020 00:00:00 +0000 (00:00 +0000)]
Avoid writes without any data in `Write::write_all_vectored`

Previously, when non-empty sequence of empty IoSlices have been provided
to `Write::write_all_vectored`, the buffers would be written as is with
`Write::write_vectored` and subsequently the return value `Ok(0)` would
be misinterpreted as an error.

Avoid writes without any data by advancing the buffers first. This
matches the documented behaviour of `Write::write_all_vectored`
and is analogous to what happens in `Write::write_all`.

3 years agoAdd test for issue-72911
Yuki Okushi [Sun, 26 Jul 2020 09:54:54 +0000 (18:54 +0900)]
Add test for issue-72911

3 years agoAdd test for issue-56445
Yuki Okushi [Sun, 26 Jul 2020 09:54:24 +0000 (18:54 +0900)]
Add test for issue-56445

3 years agoAuto merge of #74664 - pnadon:Miri-rename-undef-uninit, r=RalfJung
bors [Sun, 26 Jul 2020 09:09:43 +0000 (09:09 +0000)]
Auto merge of #74664 - pnadon:Miri-rename-undef-uninit, r=RalfJung

Miri rename undef uninit

Renamed parts of code within the `librustc_middle/mir/interpret/` directory.

Related issue [#71193](https://github.com/rust-lang/rust/issues/71193)

3 years agoAuto merge of #74060 - kpp:remove_length_at_most_32, r=dtolnay
bors [Sun, 26 Jul 2020 05:50:51 +0000 (05:50 +0000)]
Auto merge of #74060 - kpp:remove_length_at_most_32, r=dtolnay

Remove trait LengthAtMost32

This is a continuation of https://github.com/rust-lang/rust/pull/74026 preserving the original burrbull's commit.

I talked to @burrbull, he suggested me to finish his PR.

3 years agoAuto merge of #74735 - Aaron1011:fix/wf-impl-self-type, r=estebank
bors [Sun, 26 Jul 2020 03:03:19 +0000 (03:03 +0000)]
Auto merge of #74735 - Aaron1011:fix/wf-impl-self-type, r=estebank

Use the proper span when WF-checking an impl self type

3 years agoAuto merge of #74728 - 16yuki0702:fix_typo, r=jonas-schievink
bors [Sun, 26 Jul 2020 01:20:15 +0000 (01:20 +0000)]
Auto merge of #74728 - 16yuki0702:fix_typo, r=jonas-schievink

Fix rustc docs typo.

3 years agoAuto merge of #74670 - tmandry:issue-73818, r=matthewjasper
bors [Sat, 25 Jul 2020 23:37:07 +0000 (23:37 +0000)]
Auto merge of #74670 - tmandry:issue-73818, r=matthewjasper

Normalize bounds fully when checking defaulted types

When checking that the default type for `<T as X>::Y` is valid in this example:

```
trait X { type Y: PartialEq<<Self as X>::Y> }
impl X for T { default type Y = S; }
```

We will have to prove the bound `S: PartialEq<<T as X>::Y>`. In this case
we want `<T as X>::Y` to normalize to `S`. This is valid because we are
checking the default value specifically here. Add `<T as X>::Y = S` to the
ParamEnv for normalization _of the bound we are checking_ only.

Fixes #73818.

---

I noticed that adding this to the env for bounds checking didn't break any tests. Not sure if this is because we can't rely on it to prove anything, or because of missing test coverage.

r? @matthewjasper, @nikomatsakis

3 years agoAuto merge of #74760 - tmandry:roll, r=tmandry
bors [Sat, 25 Jul 2020 21:53:56 +0000 (21:53 +0000)]
Auto merge of #74760 - tmandry:roll, r=tmandry

Update rustfmt and rls

Closes #74080, #74081.

rls changes:
- deps: update racer and cargo

rustfmt changes:
- preparation for potential rustfmt 1.4.19 (#4283)
- chore: backport 8157a3f0afe978d3e953420577f8344db7e905bf
- deps: bump rustc-ap to v669
- deps: bump rustc-ap-* to v668
- deps: bump rustc-ap* to v666
- Use correct span for match arms with the leading pipe and attributes (#3975)

3 years agoUpdate Cargo.lock
Tyler Mandry [Sat, 25 Jul 2020 21:25:16 +0000 (14:25 -0700)]
Update Cargo.lock

3 years agoUpdate rustfmt
Tyler Mandry [Sat, 25 Jul 2020 21:24:37 +0000 (14:24 -0700)]
Update rustfmt

Changes:
- preparation for potential rustfmt 1.4.19 (#4283)
- chore: backport 8157a3f0afe978d3e953420577f8344db7e905bf
- deps: bump rustc-ap to v669
- deps: bump rustc-ap-* to v668
- deps: bump rustc-ap* to v666
- Use correct span for match arms with the leading pipe and attributes (#3975)

3 years agoUpdate rls
Tyler Mandry [Sat, 25 Jul 2020 21:19:30 +0000 (14:19 -0700)]
Update rls

Changes:
- deps: update racer and cargo

3 years agoFix diagnostic by using predicate in GATs too
Tyler Mandry [Sat, 25 Jul 2020 20:52:47 +0000 (13:52 -0700)]
Fix diagnostic by using predicate in GATs too

3 years agoRemove manual normalization in compare_projection_bounds
Tyler Mandry [Sat, 25 Jul 2020 20:48:29 +0000 (13:48 -0700)]
Remove manual normalization in compare_projection_bounds

3 years agoAuto merge of #74246 - GuillaumeGomez:cleanup-e0719, r=Dylan-DPC
bors [Sat, 25 Jul 2020 20:11:20 +0000 (20:11 +0000)]
Auto merge of #74246 - GuillaumeGomez:cleanup-e0719, r=Dylan-DPC

Clean up E0719 explanation

r? @Dylan-DPC

3 years agoAuto merge of #74687 - estebank:bracketless-turbofish, r=matthewjasper
bors [Sat, 25 Jul 2020 18:16:43 +0000 (18:16 +0000)]
Auto merge of #74687 - estebank:bracketless-turbofish, r=matthewjasper

Detect turbofish missing surrounding angle brackets

Fix #74065.

3 years agoMiri: rename "undef" to "uninit"
Philippe Nadon [Wed, 22 Jul 2020 15:08:59 +0000 (09:08 -0600)]
Miri: rename "undef" to "uninit"

renamed Allocation::check_defined_and_ptr to Allocation::check_init_and_ptr

renamed Allocation::check_defined_and_ptr to Allocation::check_init_and_ptr

in src/librustc_middle/mir/interpret/allocation.rs

renamed Allocation::is_defined and Allocation::check_defined, fixed documentation

renamed Allocation::is_defined and Allocation::check_defined to is_init and check_init respectively.

Fixed documentation so it correctly refers to "initialization" instead of "defined"-ness

renamed Allocation::mark_definedness

renamed Allocation::mark_definedness to Allocation::mark_init

Renamed new_state parameter in Allocation::mark_init

Renamed new_state to is_init, as the latter is more descriptive.

renamed functions in AllocationDefinedness

renamed AllocationDefinedness::all_bytes_undef and AllocationDefinedness::mark_compressed_undef_range to no_bytes_init and mark_compressed_init_range respectively.

renamed AllocationDefinedness to InitMaskCompressed

renamed Immediate::to_scalar_or_undef

renamed to to_scalar_or_uninit

fixed comment references to "undef"

Changed comments referring to "undef" and "definedness" to "initialization" and "initialization state" in src/librustc_mir/interpret/memory.rs and src/librustc_middle/mir/interpret/allocation.rs

changed references to "undef" in comments and a variable

Changed some comments referring to "undef" to use "uninitialized" instead. Also changed a variable from "undef_end" to "uninit_end".
All changes were made within src/librustc_middle/mir/interpret/allocation.rs.

Changed more comments referring to undef

Changed comments to use "uninitialized" instead of "undef" in src/librustc_middle/mir/interpret/allocation.rs.

3 years agoClean up some uses of logging in ui tests
Oliver Scherer [Sat, 25 Jul 2020 16:36:44 +0000 (18:36 +0200)]
Clean up some uses of logging in ui tests

3 years agoAuto merge of #74510 - LukasKalbertodt:fix-range-from-index-panic, r=hanna-kruppe
bors [Sat, 25 Jul 2020 16:27:24 +0000 (16:27 +0000)]
Auto merge of #74510 - LukasKalbertodt:fix-range-from-index-panic, r=hanna-kruppe

Fix panic message when `RangeFrom` index is out of bounds

Before, the `Range` method was called with `end = slice.len()`. Unfortunately, because `Range::index` first checks the order of the indices (start has to be smaller than end), an out of bounds index leads to `core::slice::slice_index_order_fail` being called. This prints the message 'slice index starts at 27 but ends at 10', which is worse than 'index 27 out of range for slice of length 10'. This is not only useful to normal users reading panic messages, but also for people inspecting assembly and being confused by `slice_index_order_fail` calls.

You can see the produced assembly [here](https://rust.godbolt.org/z/GzMGWf) and try on Playground [here](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=aada5996b2f3848075a6d02cf4055743). (By the way. this is only about which panic function is called; I'm pretty sure it does not improve anything about performance).

3 years agoFix FP `useless_conversion`
Takayuki Nakata [Sat, 25 Jul 2020 14:58:22 +0000 (23:58 +0900)]
Fix FP `useless_conversion`

Fix #5833.

3 years agoAuto merge of #74488 - CAD97:layout_for_value_raw, r=hanna-kruppe
bors [Sat, 25 Jul 2020 14:01:41 +0000 (14:01 +0000)]
Auto merge of #74488 - CAD97:layout_for_value_raw, r=hanna-kruppe

re-add Layout::for_value_raw

Tracking issue: #69835

This was accidentally removed in #70362 56cbf2f22aeb6448acd7eb49e9b2554c80bdbf79.
Originally added in #69079.

3 years agoAuto merge of #74741 - aticu:master, r=jonas-schievink
bors [Sat, 25 Jul 2020 12:17:21 +0000 (12:17 +0000)]
Auto merge of #74741 - aticu:master, r=jonas-schievink

Improve documentation of `String::from_raw_parts`

3 years agoDocument UTF-8 validity of String::from_raw_parts
aticu [Sat, 25 Jul 2020 12:06:32 +0000 (14:06 +0200)]
Document UTF-8 validity of String::from_raw_parts

3 years agoFix wrong name in `String::from_raw_parts` docs
aticu [Sat, 25 Jul 2020 12:04:56 +0000 (14:04 +0200)]
Fix wrong name in `String::from_raw_parts` docs

3 years agoEnsure stack when parsing large if expressions
Kan-Ru Chen [Sat, 25 Jul 2020 09:57:35 +0000 (18:57 +0900)]
Ensure stack when parsing large if expressions

3 years agoEnsure stack when type checking and building MIR for large if expressions
Kan-Ru Chen [Fri, 24 Jul 2020 08:00:10 +0000 (17:00 +0900)]
Ensure stack when type checking and building MIR for large if expressions

3 years agoFix commas.
Steven Malis [Sat, 25 Jul 2020 09:47:16 +0000 (02:47 -0700)]
Fix commas.

3 years agoPull out some shared code into a new function
Steven Malis [Sat, 25 Jul 2020 09:03:50 +0000 (02:03 -0700)]
Pull out some shared code into a new function

3 years agoUse the proper span when WF-checking an impl self type
Aaron Hill [Sat, 25 Jul 2020 06:05:19 +0000 (02:05 -0400)]
Use the proper span when WF-checking an impl self type

3 years agoAuto merge of #74652 - poliorcetics:clarify-vec-drain-doc, r=jyn514
bors [Sat, 25 Jul 2020 03:38:30 +0000 (03:38 +0000)]
Auto merge of #74652 - poliorcetics:clarify-vec-drain-doc, r=jyn514

Improve the documentation for Vec::drain

Fixes #73844.

@rusbot modify labels: A-collections, C-enhancement, T-doc, T-libs

3 years agoAuto merge of #74017 - poliorcetics:where-keyword, r=jyn514
bors [Sat, 25 Jul 2020 01:44:22 +0000 (01:44 +0000)]
Auto merge of #74017 - poliorcetics:where-keyword, r=jyn514

Document the where keyword

Partial fix of #34601 (and last PR for it ðŸŽ‰).

This documents the `where` keyword.

@rustbot modify labels: T-doc,C-enhancement

3 years agoFix rustc docs typo.
16yuki0702 [Sat, 25 Jul 2020 01:14:14 +0000 (10:14 +0900)]
Fix rustc docs typo.

3 years agoAuto merge of #73645 - poliorcetics:ref-keyword, r=jyn514
bors [Fri, 24 Jul 2020 23:55:16 +0000 (23:55 +0000)]
Auto merge of #73645 - poliorcetics:ref-keyword, r=jyn514

Document the ref keyword

Partial fix for #34601.

This documents the `ref` keyword with two examples, one failing to compile because the `ref` keyword is missing, and the same example fixed with the keyword inserted in the correct place.

It also explains (very *very* rapidly) the differences between `&` and `ref`.

I put a link to the best place I could find in the Reference but there may be something better that I didn't find.

3 years agoAuto merge of #74681 - RalfJung:miri-extern-fn, r=oli-obk
bors [Fri, 24 Jul 2020 22:00:23 +0000 (22:00 +0000)]
Auto merge of #74681 - RalfJung:miri-extern-fn, r=oli-obk

 Miri: use extern fn to expose interpreter operations to program; fix leak checker on Windows

This PR realizes an idea that @oli-obk has been suggesting for a while: to use Miri-specific `extern` functions to provide some extra capabilities to the program. Initially, we have two of these methods, which libstd itself needs:
* `miri_start_panic`, which replaces the intrinsic of the same name (mostly for consistency, to avoid having multiple mechanisms for Miri-specific functionality).
* `miri_static_root`, which adds an allocation to a list of static "roots" that Miri considers as not having leaked (including all memory reachable through them). This is needed for https://github.com/rust-lang/miri/issues/1302.

We use `extern` functions instead of intrinsics for this so that user code can more easily call these Miri hoolks -- e.g. `miri_static_root` should be useful for https://github.com/rust-lang/miri/issues/1318.

The Miri side of this is at https://github.com/rust-lang/miri/pull/1485.

r? @oli-obk

3 years agoAuto merge of #74507 - lcnr:const-prop-into-op, r=oli-obk
bors [Fri, 24 Jul 2020 20:10:34 +0000 (20:10 +0000)]
Auto merge of #74507 - lcnr:const-prop-into-op, r=oli-obk

add `visit_operand` to const prop

r? @oli-obk

3 years agoAuto merge of #74724 - Manishearth:rollup-plbt8fe, r=Manishearth
bors [Fri, 24 Jul 2020 18:03:55 +0000 (18:03 +0000)]
Auto merge of #74724 - Manishearth:rollup-plbt8fe, r=Manishearth

Rollup of 8 pull requests

Successful merges:

 - #72954 (revise RwLock for HermitCore)
 - #74367 (Rearrange the pipeline of `pow` to gain efficiency)
 - #74491 (Optimize away BitAnd and BitOr when possible)
 - #74639 (Downgrade glibc to 2.11.1 for ppc, ppc64 and s390x)
 - #74661 (Refactor `region_name`: add `RegionNameHighlight`)
 - #74692 (delay_span_bug instead of silent ignore)
 - #74698 (fixed error reporting for mismatched traits)
 - #74715 (Add a system for creating diffs across multiple mir optimizations.)

Failed merges:

r? @ghost

3 years agoApply suggestion from review
Alexis Bourget [Fri, 24 Jul 2020 17:55:08 +0000 (19:55 +0200)]
Apply suggestion from review

3 years agoFix nits, rework the second example of select (the one deliberately failing to compile)
Alexis Bourget [Fri, 24 Jul 2020 17:33:52 +0000 (19:33 +0200)]
Fix nits, rework the second example of select (the one deliberately failing to compile)

3 years agoFix nits
Alexis Bourget [Fri, 24 Jul 2020 17:06:26 +0000 (19:06 +0200)]
Fix nits

3 years agoRollup merge of #74715 - oli-obk:mir_pass_diff, r=wesleywiser
Manish Goregaokar [Fri, 24 Jul 2020 17:01:41 +0000 (10:01 -0700)]
Rollup merge of #74715 - oli-obk:mir_pass_diff, r=wesleywiser

Add a system for creating diffs across multiple mir optimizations.

r? @wesleywiser

3 years agoRollup merge of #74698 - ayrtonm:handle-traitref-mismatch, r=estebank
Manish Goregaokar [Fri, 24 Jul 2020 17:01:39 +0000 (10:01 -0700)]
Rollup merge of #74698 - ayrtonm:handle-traitref-mismatch, r=estebank

fixed error reporting for mismatched traits

mismatched traits were previously referred to as types

closes #72217

3 years agoRollup merge of #74692 - Mark-Simulacrum:delay-bug, r=pnkfelix
Manish Goregaokar [Fri, 24 Jul 2020 17:01:38 +0000 (10:01 -0700)]
Rollup merge of #74692 - Mark-Simulacrum:delay-bug, r=pnkfelix

delay_span_bug instead of silent ignore

This is a follow-up to #74557.

r? @pnkfelix

3 years agoRollup merge of #74661 - SNCPlay42:lifetime-names-refactor, r=estebank
Manish Goregaokar [Fri, 24 Jul 2020 17:01:36 +0000 (10:01 -0700)]
Rollup merge of #74661 - SNCPlay42:lifetime-names-refactor, r=estebank

Refactor `region_name`: add `RegionNameHighlight`

This PR does not change any diagnostics itself, rather it enables further code changes, but I would like to get approval for the refactoring first before making use of it.

In `rustc_mir::borrow_check::diagnostics::region_name`, there is code that allows for, when giving a synthesized name like `'1` to an anonymous lifetime, pointing at e.g. the exact '`&`' that introduces the lifetime.

This PR decouples that code from the specific case of arguments, adding a new enum `RegionNameHighlight`, enabling future changes to use it in other places.

This allows:

* We could change the other `AnonRegionFrom*` variants to use `RegionNameHighlight` to precisely point at where lifetimes are introduced in other locations when they have type annotations, e.g. a closure return `|...| -> &i32`.
  * Because of how async functions are lowered this affects async functions as well, see #74072
* for #74597, we could add a second, optional `RegionNameHighlight` to the `AnonRegionFromArgument` variant that highlights a lifetime in the return type of a function when, due to elision, this is the same as the argument lifetime.
* in https://github.com/rust-lang/rust/issues/74497#issuecomment-6606229707 I noticed that a diagnostic was trying to introduce a lifetime `'2` in the opaque type `impl std::future::Future`. The code for the case of arguments has [code to handle cases like this](https://github.com/rust-lang/rust/blob/bbebe7351fcd29af1eb9a35e315369b15887ea09/src/librustc_mir/borrow_check/diagnostics/region_name.rs#L365) but not the others. This refactoring would allow the same code path to handle this.
  * It might be appropriate to add another variant of `RegionNameHighlight` to say something like `lifetime '1 appears in the opaque type impl std::future::Future`.

These are quite a few changes so I thought I would make sure the refactoring is OK before I start making changes that rely on it. :)

3 years agoRollup merge of #74639 - msirringhaus:master, r=cuviper
Manish Goregaokar [Fri, 24 Jul 2020 17:01:34 +0000 (10:01 -0700)]
Rollup merge of #74639 - msirringhaus:master, r=cuviper

Downgrade glibc to 2.11.1 for ppc, ppc64 and s390x

As discussed in #73782
I've tested these changes on rust 1.43.0 for all the specified archs and used the resulting binaries to bootstrap building rust 1.43.1.
I've also shortly tested these changes on master on ppc64.

3 years agoRollup merge of #74491 - xldenis:constant-binop-opt, r=oli-obk
Manish Goregaokar [Fri, 24 Jul 2020 17:01:32 +0000 (10:01 -0700)]
Rollup merge of #74491 - xldenis:constant-binop-opt, r=oli-obk

Optimize away BitAnd and BitOr when possible

This PR lets `const_prop` optimize away `a | true == true` , `a & false == false` and `a * 0 = 0`. While I was writing this I've realized that constant propagation misses a lot of opportunities. For example:  https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=2a4b45e772f214210a36749b27223bb0

Constant propagation doesn't seem to... propagate constants, additionally the way constant propagation is currently setup makes it tricky to add cases like `a | false == a`.

I tried to organize `eval_rvalue_with_identities` to make the pattern of the optimizations easier to see but it still obscurs what should be a simple peephole optmization.

cc @oli-obk

3 years agoRollup merge of #74367 - Neutron3529:patch-1, r=nagisa
Manish Goregaokar [Fri, 24 Jul 2020 17:01:30 +0000 (10:01 -0700)]
Rollup merge of #74367 - Neutron3529:patch-1, r=nagisa

Rearrange the pipeline of `pow` to gain efficiency

The check of the `exp` parameter seems useless if we execute the while-loop more than once.
The original implementation of `pow` function using one more comparison if the `exp==0` and may break the pipeline of the cpu, which may generate a slower code.
The performance gap between the old and the new implementation may be small, but IMO, at least the newer one looks more beautiful.

---

bench prog:
```
#![feature(test)]
extern crate test;
#[macro_export]macro_rules! timing{
($a:expr)=>{let time=std::time::Instant::now();{$a;}print!("{:?} ",time.elapsed())};
($a:expr,$b:literal)=>{let time=std::time::Instant::now();let mut a=0;for _ in 0..$b{a^=$a;}print!("{:?} {} ",time.elapsed(),a)}
}
#[inline]
pub fn pow_rust(x:i64, mut exp: u32) -> i64 {
    let mut base = x;
    let mut acc = 1;
    while exp > 1 {
        if (exp & 1) == 1 {
            acc = acc * base;
        }
        exp /= 2;
        base = base * base;
    }
    if exp == 1 {
        acc = acc * base;
    }
    acc
}
#[inline]
pub fn pow_new(x:i64, mut exp: u32) -> i64 {
    if exp==0{
        1
    }else{
        let mut base = x;
        let mut acc = 1;
        while exp > 1 {
            if (exp & 1) == 1 {
                acc = acc * base;
            }
            exp >>= 1;
            base = base * base;
        }
        acc * base
    }
}

fn main(){
let a=2i64;
let b=1_u32;
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
}
```
bench in my laptop:
```
neutron@Neutron:/me/rust$ rc commit.rs
rustc commit.rs  && ./commit

3.978419716s 0 4.079765171s 0 3.964630622s 0
3.997127013s 0 4.260304804s 0 3.997638211s 0
3.963195544s 0 4.11657718s 0 4.176054164s 0
3.830128579s 0 3.980396122s 0 3.937258567s 0
3.986055948s 0 4.127804162s 0 4.018943411s 0
4.185568857s 0 4.217512517s 0 3.98313603s 0
3.863018225s 0 4.030447988s 0 3.694878237s 0
4.206987927s 0 4.137608047s 0 4.115564664s 0
neutron@Neutron:/me/rust$ rc commit.rs -O
rustc commit.rs -O && ./commit

162.111993ms 0 165.107125ms 0 166.26924ms 0
175.20479ms 0 205.062565ms 0 176.278791ms 0
174.408975ms 0 166.526899ms 0 201.857604ms 0
146.190062ms 0 168.592821ms 0 154.61411ms 0
199.678912ms 0 168.411598ms 0 162.129996ms 0
147.420765ms 0 209.759326ms 0 154.807907ms 0
165.507134ms 0 188.476239ms 0 157.351524ms 0
121.320123ms 0 126.401229ms 0 114.86428ms 0
```