bors [Sat, 18 Jan 2020 01:29:28 +0000 (01:29 +0000)]
Auto merge of #68330 - tmandry:rollup-5v29y9r, r=tmandry
Rollup of 9 pull requests
Successful merges:
- #66660 (Don't warn about snake case for field puns.)
- #68093 (Fix deref impl typedef)
- #68204 (Use named fields for `{ast,hir}::ItemKind::Impl`)
- #68256 (Do not ICE on malformed suggestion spans)
- #68279 (Clean up E0198 explanation)
- #68291 (Update sanitizer tests)
- #68312 (Add regression test for integer literals in generic arguments in where clauses)
- #68314 (Stop treating `FalseEdges` and `FalseUnwind` as having semantic value for const eval)
- #68317 (Clean up E0199 explanation)
Tyler Mandry [Sat, 18 Jan 2020 01:28:18 +0000 (17:28 -0800)]
Rollup merge of #68291 - tmiasko:sanitizer-tests, r=nikomatsakis
Update sanitizer tests
* Move tests from src/test/run-make-fulldeps to src/test/ui.
* Fix memory sanitizer test to detect the intended issue rather than
an unrelated one caused by the use of an uninstrumented std.
Tyler Mandry [Sat, 18 Jan 2020 01:28:15 +0000 (17:28 -0800)]
Rollup merge of #68256 - estebank:bad-sugg-span, r=petrochenkov
Do not ICE on malformed suggestion spans
Under the assumption that suggestions are by their very nature always "best effort", it is ok if we don't display them instead of having an ICE. The underlying issue of the malformed span being _created_ is left unaddressed.
Tyler Mandry [Sat, 18 Jan 2020 01:28:14 +0000 (17:28 -0800)]
Rollup merge of #68204 - ecstatic-morse:item-kind-impl, r=oli-obk
Use named fields for `{ast,hir}::ItemKind::Impl`
Currently, the widely used `ItemKind::Impl` variant is a tuple with seven fields. I want to add an eighth in #68140, which means I have to update most matches on this variant anyways. Giving a name to each field improves readability and makes future changes of this nature much simpler.
This change will cause several tools to break. I will fix them once this is merged.
bors [Fri, 17 Jan 2020 21:43:23 +0000 (21:43 +0000)]
Auto merge of #67476 - mark-i-m:simplify-borrow_check-5, r=matthewjasper
Region naming refactoring [6/N]
Followup to #67474
EDIT: this PR is probably best read commit-by-commit...
The major changes in this PR include:
- moving many functions around to modules that better suit them. In particular, a lot of methods were moved from `borrow_check::diagnostics::region_errors` to `borrow_check::region_infer`, and `report_region_errors` was moved from `borrow_check` to `borrow_check::diagnostics::region_errors`.
- `borrow_check::diagnostics::{region_errors, region_name}` are now most comprised of methods on `MirBorrowckCtxt` instead of `RegionInferenceContext`, allowing us to get rid of the annoying `pub(in crate::borrow_check)` on most of the fields of the latter, along with a number of method arguments on many methods.
- I renamed `MirBorrowckCtxt.nonlexical_regioncx` to just `regioncx` because their is no lexical lifetimes any more, and the old name was annoyingly verbose, causing many lines to wrap unnecessarily.
- I got rid of `ErrorRegionNamingContext`. Region naming is implemented as inherent methods on `MirBorrowckCtxt`, so we just move the naming stuff into that struct.
The PR is rather large, but the commits are fairly self-contained (though they don't all compile). There was one minor output change to one test with `compare-mode=nll`, which I think is acceptable.
Between this PR and the last one, a net of 200 lines are removed, most of which was function parameters and context structs :tada:
bors [Fri, 17 Jan 2020 15:58:24 +0000 (15:58 +0000)]
Auto merge of #68311 - Dylan-DPC:rollup-wzgqw9t, r=Dylan-DPC
Rollup of 4 pull requests
Successful merges:
- #66564 (Document unsafe blocks in core::{cell, str, sync})
- #67791 (Implement Lift using interners instead of in_arena)
- #68278 ([self-profiler] Add example to `-Z help` to turn on query key recording)
- #68300 (Allow added string.insert benchmarks to compile)
bors [Fri, 17 Jan 2020 09:17:18 +0000 (09:17 +0000)]
Auto merge of #68305 - Dylan-DPC:rollup-aoohsz8, r=Dylan-DPC
Rollup of 6 pull requests
Successful merges:
- #67956 (Detail transitive containment in E0588 diagnostic)
- #68153 (resolve: Point at the private item definitions in privacy errors)
- #68195 (Account for common `impl Trait`/`dyn Trait` return type errors)
- #68288 (Fix some of the rustfmt fallout in Miri)
- #68292 (don't clone types that are copy)
- #68301 (Don't propagate __RUST_TEST_INVOKE to subprocess)
Dylan DPC [Fri, 17 Jan 2020 05:46:42 +0000 (11:16 +0530)]
Rollup merge of #68301 - tmandry:dont-propagate-test-invoke, r=alexcrichton
Don't propagate __RUST_TEST_INVOKE to subprocess
When -Z panic_abort_tests is enabled, we use an environment variable to
tell the subprocess which test to invoke. If that subprocess then
invokes another Rust test binary, chaos ensues.
Dylan DPC [Fri, 17 Jan 2020 05:46:37 +0000 (11:16 +0530)]
Rollup merge of #68195 - estebank:impl-trait-2000, r=Centril
Account for common `impl Trait`/`dyn Trait` return type errors
- When all return paths have the same type, suggest `impl Trait`.
- When all return paths implement the expected `trait`, suggest `Box<dyn Trait>` and mention using an `enum`.
- When multiple different types are returned and `impl Trait` is expected, extend the explanation.
- When return type is `impl Trait` and the return paths do not implement `Trait`, point at the returned values.
- Split `src/librustc/traits/error_reporting.rs` into multiple files to keep size under control.
Tyler Mandry [Fri, 17 Jan 2020 00:29:32 +0000 (16:29 -0800)]
Don't propagate __RUST_TEST_INVOKE to subprocess
When -Z panic_abort_tests is enabled, we use an environment variable to
tell the subprocess which test to invoke. If that subprocess then
invokes another Rust test binary, chaos ensues.
bors [Fri, 17 Jan 2020 00:20:48 +0000 (00:20 +0000)]
Auto merge of #66716 - derekdreery:debug_non_exhaustive, r=dtolnay
Implement `DebugStruct::non_exhaustive`.
This patch adds a function (finish_non_exhaustive) to add ellipsis before the closing brace when formatting using `DebugStruct`.
## Example
```rust
#![feature(debug_non_exhaustive)]
use std::fmt;
struct Bar {
bar: i32,
hidden: f32,
}
impl fmt::Debug for Bar {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Bar")
.field("bar", &self.bar)
.non_exhaustive(true) // Show that some other field(s) exist.
.finish()
}
}
assert_eq!(
format!("{:?}", Bar { bar: 10, hidden: 1.0 }),
"Bar { bar: 10, .. }",
);
```
bors [Thu, 16 Jan 2020 17:43:19 +0000 (17:43 +0000)]
Auto merge of #68286 - Dylan-DPC:rollup-x7ssgov, r=Dylan-DPC
Rollup of 5 pull requests
Successful merges:
- #68033 (Don't use f64 shims for f32 cmath functions on non 32-bit x86 MSVC)
- #68244 (Enable leak sanitizer test case)
- #68255 (Remove unused auxiliary file that was replaced with rust_test_helpers)
- #68263 (rustdoc: HTML escape codeblocks which fail syntax highlighting)
- #68274 (remove dead code)
Esteban Küber [Tue, 14 Jan 2020 00:12:44 +0000 (16:12 -0800)]
Elide E0308 errors in favor of E0746
When a type error involves a `dyn Trait` as the return type, do not emit
the type error, as the "return type is not `Sized`" error will provide
enough information to the user.
Dylan DPC [Thu, 16 Jan 2020 15:23:26 +0000 (20:53 +0530)]
Rollup merge of #68033 - ollie27:win_f32, r=dtolnay
Don't use f64 shims for f32 cmath functions on non 32-bit x86 MSVC
These shims are only needed on 32-bit x86. Additionally since https://reviews.llvm.org/rL268875 LLVM handles adding the shims itself for the intrinsics.
bors [Thu, 16 Jan 2020 07:20:52 +0000 (07:20 +0000)]
Auto merge of #68272 - Dylan-DPC:rollup-vrb90gu, r=Dylan-DPC
Rollup of 5 pull requests
Successful merges:
- #67780 (Move some queries from rustc::ty to librustc_ty.)
- #68096 (Clean up some diagnostics by making them more consistent)
- #68223 (Use 3.6 instead of 3.5 in float fract() documentation)
- #68265 (Fix some issue numbers of unstable features)
- #68266 (Changed docs for f32 and f64.)
Failed merges:
- #68204 (Use named fields for `{ast,hir}::ItemKind::Impl`)
Dylan DPC [Thu, 16 Jan 2020 06:28:04 +0000 (11:58 +0530)]
Rollup merge of #68223 - SOF3:float-fract-doc, r=varkor
Use 3.6 instead of 3.5 in float fract() documentation
It is not self-explanatory whether the fract() function inverts the fractional part of negative numbers. This change clarifies this possible question (so that it is `.6` not `.4`)
Dylan DPC [Thu, 16 Jan 2020 06:28:02 +0000 (11:58 +0530)]
Rollup merge of #68096 - varkor:diagnostic-cleanup, r=Centril
Clean up some diagnostics by making them more consistent
In general:
- Diagnostic should start with a lowercase letter.
- Diagnostics should not end with a full stop.
- Ellipses contain three dots.
- Backticks should encode Rust code.
I also reworded a couple of messages to make them read more clearly.
It might be sensible to create a style guide for diagnostics, so these informal conventions are written down somewhere, after which we could audit the existing diagnostics.
The current implementation of (`A`)`Rc::into_raw` uses the `Deref::deref` implementation to get the pointer-to-data that is returned. This is problematic in the proposed Stacked Borrow rules, as this only gets shared provenance over the data location. (Note that the strong/weak counts are `UnsafeCell` (`Cell`/`Atomic`) so shared provenance can still mutate them, but the data itself is not.) When promoted back to a real reference counted pointer, the restored pointer can be used for mutation through `::get_mut` (if it is the only surviving reference). However, this mutates through a pointer ultimately derived from a `&T` borrow, violating the Stacked Borrow rules.
There are three known potential solutions to this issue:
- Stacked Borrows is wrong, liballoc is correct.
- Fully admit (`A`)`Rc` as an "internal mutability" type and store the data payload in an `UnsafeCell` like the strong/weak counts are. (Note: this is not needed generally since the `RcBox`/`ArcInner` is stored behind a shared `NonNull` which maintains shared write provenance as a raw pointer.)
- Adjust `into_raw` to do direct manipulation of the pointer (like `from_raw`) so that it maintains write provenance and doesn't derive the pointer from a reference.
This PR implements the third option, as recommended by @RalfJung.
Potential future work: provide `as_raw` and `clone_raw` associated functions to allow the [`&T` -> (`A`)`Rc<T>` pattern](https://internals.rust-lang.org/t/rc-and-internal-mutability/11463/2?u=cad97) to be used soundly without creating (`A`)`Rc` from references.
Tomasz Miąsko [Thu, 16 Jan 2020 00:00:00 +0000 (00:00 +0000)]
Update sanitizer tests
* Move tests from src/test/run-make-fulldeps to src/test/ui.
* Fix memory sanitizer test to detect the intended issue rather than
an unrelated one caused by the use of an uninstrumented std.