103488 Commits

Author SHA1 Message Date
bors
d99e0c6d02 Auto merge of #66697 - petrochenkov:nocstore, r=eddyb
rustc_metadata: Privatize more things and a couple of other refactorings

This PR continues https://github.com/rust-lang/rust/pull/66496 and hits the point of diminishing returns.
All fields of `CrateRoot` and `CrateMetadata` are privatized.
For read-only fields this certainly makes sense, but for a few fields updateable from outside of `rmeta.rs` (mostly `creader.rs`) it was done mostly for consistency, I can make them `pub(crate)` again if requested.

`cstore.rs` (which became small after #66496) was merged into `creader.rs`.

A few things noticed while making the privacy changes were addressed in the remaining refactoring commits.

Fixes https://github.com/rust-lang/rust/issues/66550
r? @eddyb @Mark-Simulacrum
2019-11-29 14:51:59 +00:00
Mikhail Babenko
f07bd06137 allow customising ty::TraitRef's printing behavior
fix clippy

allow customising ty::TraitRef's printing behavior

fix clippy

stylistic fix
2019-11-29 17:30:21 +03:00
bors
c4375c9dfd Auto merge of #66645 - RalfJung:dereferenceable, r=pnkfelix
remove the 'dereferenceable' attribute from Box

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

r? @eddyb @rkruppe
2019-11-29 11:35:03 +00:00
Oliver Scherer
735a610f47 Only memoize const fn calls during const eval
Miri and other engines may want to execute the function in order to detect UB inside of them.
2019-11-29 11:57:17 +01:00
bors
fe969f4ec6 Auto merge of #66590 - Aaron1011:fix/real-impl-trait-coherence, r=varkor
Apply proper commit from PR #63934

While working on PR #63934, I accidentally reverted to an older version
of the PR while working on a rebase. The PR was then merged, not with
the later, approved changes, but with earlier, unapproved changes.

This PR applies the changes that were *suppoesd* to be mereged in
PR #63934. All of the proper tests appear to have been merged
in PR #63934, so this PR adds no new tests
2019-11-29 08:12:43 +00:00
bors
3907d59bcf Auto merge of #66547 - leo60228:procfs-fallback, r=dtolnay
Fallback to .init_array when no arguments are available on glibc Linux

Linux is one of the only platforms where `std::env::args` doesn't work in a cdylib.
2019-11-29 05:04:51 +00:00
Victor Ding
b41b1d3407 Use LLVMAddAnalysisPasses instead of Rust's wrapper
LLVM exposes a C API `LLVMAddAnalysisPasses` and hence Rust's own
wrapper `LLVMRustAddAnalysisPasses` is not needed anymore.
2019-11-29 14:31:09 +11:00
bors
861e96f2e9 Auto merge of #66567 - estebank:suggest-copy, r=Centril
Use structured suggestion when requiring `Copy` constraint in type param
2019-11-29 00:23:23 +00:00
bors
61e1c3d343 Auto merge of #66843 - RalfJung:miri, r=RalfJung
update Miri

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

r? @ghost
2019-11-28 20:39:41 +00:00
Eduard-Mihai Burtescu
71710608f0 rustc: hide HirId's fmt::Debug output from -Z span_free_formats. 2019-11-28 22:32:43 +02:00
Esteban Küber
0f530ecb68 review comments 2019-11-28 12:22:07 -08:00
Esteban Küber
9fb446d472 Deduplicate type param constraint suggestion code 2019-11-28 12:20:28 -08:00
Esteban Küber
02bc412d19 Use structured suggestion when requiring Copy constraint in type param 2019-11-28 12:20:28 -08:00
David Tolnay
423a5d3e85
Allow any identifier as format arg name
Previously:

    error: invalid format string: invalid argument name `_x`
     --> src/main.rs:2:16
      |
    2 |     println!("{_x}", a=0);
      |                ^^ invalid argument name in format string
      |
      = note: argument names cannot start with an underscore

Not supporting identifiers starting with underscore appears to have been
an arbitrary limitation from 2013 in code that was most likely never
reviewed:
https://github.com/rust-lang/rust/pull/8245/files#diff-0347868ef389c805e97636623e4a4ea6R277

The error message was dutifully improved in #50610 but is there any
reason that leading underscore would be a special case?

This commit updates the format_args parser to accept identifiers with
leading underscores.
2019-11-28 11:24:51 -08:00
Aaron Hill
79fcaf8f12
Apply proper commit from PR #63934
While working on PR #63934, I accidentally reverted to an older version
of the PR while working on a rebase. The PR was then merged, not with
the later, approved changes, but with earlier, unapproved changes.

This PR applies the changes that were *suppoesd* to be mereged in
PR #63934. All of the proper tests appear to have been merged
in PR #63934, so this PR adds no new tests

Fixes #66580
2019-11-28 13:52:08 -05:00
Ralf Jung
3048d7e5b5 do not consider memory allocated by caller_location leaked 2019-11-28 19:15:32 +01:00
Vadim Petrochenkov
e84c926d47 rustc: Move some queries to rustc_metadata 2019-11-28 20:59:57 +03:00
Vadim Petrochenkov
e0b329a186 rustc_metadata: Avoid some side effects during speculative crate resolution
Namely, `update_extern_crate`.

Also, stop tracking visited crates in `update_extern_crate`, the rank check does the same thing (prevents visiting dependencies if the rank didn't change), but more precisely.
2019-11-28 20:59:57 +03:00
Vadim Petrochenkov
e4710ade6d rustc_metadata: Pass SVH by value 2019-11-28 20:59:57 +03:00
Vadim Petrochenkov
9be526e8eb rustc_metadata: Move has_global_allocator from session to cstore 2019-11-28 20:59:57 +03:00
Vadim Petrochenkov
4c8105e8b7 rustc_metadata: Privatize some fields and methods of CStore
After it's moved to `creader.rs`
2019-11-28 20:59:56 +03:00
Vadim Petrochenkov
753ce4518e rustc_metadata: Merge cstore.rs into creader.rs 2019-11-28 20:59:56 +03:00
Vadim Petrochenkov
3b1d60a6bc rustc_metadata: Privatize CrateMetadata::root 2019-11-28 20:59:56 +03:00
Vadim Petrochenkov
a9cef4945f rustc_metadata: Privatize all fields of CrateRoot
All of them are read-only
2019-11-28 20:59:56 +03:00
Vadim Petrochenkov
765133ac2e rustc_metadata: Privatize CrateMetadata::dep_kind 2019-11-28 20:59:56 +03:00
Vadim Petrochenkov
32aa58c96b rustc_metadata: Privatize CrateMetadata::source 2019-11-28 20:59:56 +03:00
Vadim Petrochenkov
e2414852b1 rustc_metadata: Privatize CrateMetadata::extern_crate 2019-11-28 20:59:56 +03:00
Vadim Petrochenkov
37304cda63 rustc_metadata: Privatize CrateMetadata::dependencies 2019-11-28 20:59:56 +03:00
Vadim Petrochenkov
0525cf9d68 rustc_metadata: Cleanup generation of crate dependency lists 2019-11-28 20:58:46 +03:00
Ralf Jung
9e940f0277 update Miri 2019-11-28 18:40:05 +01:00
bors
bbb664a99c Auto merge of #66642 - ecstatic-morse:promotion-in-const, r=eddyb
Create promoted MIR fragments for `const` and `static`s

Resolves #65732.

The previous strategy of removing `Drop` and `StorageDead` for promoted locals only worked for rvalue lifetime extension and only if no `loop`s were present. This PR applies the approach currently used for `fn` and `const fn`s to `const` and `statics`.

This may have some performance impacts.

r? @eddyb
2019-11-28 17:30:24 +00:00
bors
f453d1127d Auto merge of #66603 - Nadrieril:fix-65413, r=varkor
Fix #65413

#65413 was due to an oversight in `pat_constructor` that didn't check if a particular const value was maybe a slice/array const.
2019-11-28 14:22:47 +00:00
Ohad Ravid
85a468b8cf Clarify {f32,f64}::EPSILON docs 2019-11-28 13:49:58 +01:00
bors
4752c05af4 Auto merge of #66246 - matthewjasper:simplify-mem-cat, r=pnkfelix
Simplify memory categorization

With AST borrowck gone, mem_categorization can be simplified, a lot.

* `cmt_` is now called `Place`. Most local variable names have been updated to reflect this, but the `cat_*` methods retain their names.
* `MemCategorizationContext` no longer needs a `ScopeTree` and always needs an `InferCtxt`.
* `Place` now uses a similar representation to `mir::Place` with a `Vec` of projections.
* `Upvar` places don't include the implicit environment and capture derefs. These are now handled by `regionck` when needed.
* Various types, methods and variants only used by AST borrowck have been removed.
* `ExprUseVisitor` now lives in `rustc_typeck::expr_use_visitor`.
* `MemCategorizationContext` and `Place` live in `rustc_typeck::mem_categorization`.
* `Place` is re-exported in `rustc_typeck::expr_use_visitor` so that Clippy can access it.

The loss of an error in `issue-4335.rs` is due to a change in capture inference in ill-formed programs. If any projection from a variable is moved from then we capture that variable by move, whether or not the place being moved from allows this.

Closes #66270
2019-11-28 10:36:56 +00:00
David Haig
6531ba882e Moved tests and fixed merge conflict 2019-11-28 08:24:19 +00:00
Ralf Jung
5d23518a12 const_prop: detect and avoid catching Miri errors that require allocation 2019-11-28 09:03:00 +01:00
David Haig
e88948a196 Fail fast if generator_kind is None 2019-11-28 07:46:34 +00:00
David Haig
ed66492a6a Block indent formatting 2019-11-28 07:46:33 +00:00
David Haig
65c399613c Fixed unit test 2019-11-28 07:46:33 +00:00
David Haig
63b36e7127 Reduced repetition by refactoring new body to constructor function 2019-11-28 07:46:33 +00:00
David Haig
eda2d416f6 Removed FIXME comment 2019-11-28 07:43:53 +00:00
David Haig
4b85ee2c05 Fixed tidy errors 2019-11-28 07:43:53 +00:00
David Haig
6ef625fb41 Remove duplication using single variant for error 2019-11-28 07:43:53 +00:00
David Haig
88821ed54d Fixed merge issue 2019-11-28 07:43:53 +00:00
David Haig
fb0972dadf Fixed merge issue 2019-11-28 07:43:53 +00:00
David Haig
ec41fda58b Squash 2019-11-28 07:43:53 +00:00
bors
2539b5f157 Auto merge of #66294 - davidhewitt:const_fn_memoization, r=oli-obk
Add memoization for const function evaluations

When a const function is being evaluated, as long as all its arguments are zero-sized-types (or it has no arguments) then we can trivially memoize the evaluation result using the existing query mechanism.

With thanks to @oli-obk for mentoring me through this at RustFest Barcelona.

r? @oli-obk
2019-11-28 07:06:40 +00:00
bors
96ad8e5fbc Auto merge of #65013 - petertodd:2019-maybeuninit-debug, r=sfackler
Implement Debug for MaybeUninit

Precedent: `UnsafeCell` implements `Debug` even though it can't actually display the value. I noticed this omission while writing the following:

```
#[derive(Debug)]
 pub struct SliceInitializer<'a, T> {
    marker: PhantomData<&'a mut T>,
    uninit: &'a mut [MaybeUninit<T>],
    written: usize,
}
```

...which currently unergonomically fails to compile.

`UnsafeCell` does require `T: Debug`. Because of things like the above I think it'd be better to leave that requirement off. In fact, I'd also suggest removing that requirement for `UnsafeCell` too, which again I noticed in some low-level real world code.
2019-11-28 03:41:29 +00:00
bors
42f93dedbe Auto merge of #66829 - Manishearth:clippyup, r=Manishearth
Update clippy

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

r? @ghost
2019-11-28 00:36:23 +00:00
Dylan DPC
77f2ac4a49
Update CONTRIBUTING.md 2019-11-28 01:26:45 +01:00