105529 Commits

Author SHA1 Message Date
Dylan DPC
de01a29fbe
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.

Fix #68110, cc #66523.
2020-01-17 11:16:37 +05:30
Dylan DPC
ecf42a3d62
Rollup merge of #68153 - petrochenkov:privdiag, r=estebank
resolve: Point at the private item definitions in privacy errors

A basic version of https://github.com/rust-lang/rust/pull/67951.
r? @estebank
2020-01-17 11:16:36 +05:30
Dylan DPC
9f4b328da2
Rollup merge of #67956 - varkor:E0588-provide-context, r=estebank
Detail transitive containment in E0588 diagnostic

Fixes https://github.com/rust-lang/rust/issues/67383.
2020-01-17 11:16:32 +05:30
bors
8cacf50563 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, .. }",
 );
 ```
2020-01-17 00:20:48 +00:00
bors
ecbc222855 Auto merge of #68287 - flip1995:clippyup, r=oli-obk
Update Clippy

cc rust-lang/rust-clippy#5054

No issue were opened for this.

r? @Manishearth
2020-01-16 20:59:57 +00:00
Richard Dodd
73124df6eb Rust ./x.py fmt 2020-01-16 20:11:16 +00:00
Esteban Küber
029a9c6253 review comments 2020-01-16 11:32:50 -08:00
Vadim Petrochenkov
0b60f1f2ae Ignore some tests on platforms without libstd spans 2020-01-16 22:19:55 +03:00
Vadim Petrochenkov
c84efe9b6c resolve: Say "import" when reporting private imports 2020-01-16 21:59:11 +03:00
Vadim Petrochenkov
28c3f6eb40 resolve: Point at the private item definitions in privacy errors 2020-01-16 21:59:11 +03:00
Vadim Petrochenkov
0f70daa9b0 resolve: Move privacy error reporting into a separate method
Give named fields to `struct PrivacyError`
Move `fn report_ambiguity_error` to `diagnostics.rs`
2020-01-16 21:59:11 +03:00
Esteban Küber
00e2626895 Account for object safety when suggesting Box<dyn Trait> 2020-01-16 09:49:14 -08:00
Esteban Küber
d7a6212401 review comments 2020-01-16 09:49:14 -08:00
Esteban Küber
c305ac31c0 Fix error index test 2020-01-16 09:49:13 -08:00
Esteban Küber
509cb33dbc review comments 2020-01-16 09:49:13 -08:00
Esteban Küber
5b36c187dc review comments 2020-01-16 09:49:13 -08:00
Esteban Küber
4a75ef91f3 fix error code index comment 2020-01-16 09:49:13 -08:00
Esteban Küber
00c8272612 Split librustc/traits/error_reporting.rs 2020-01-16 09:49:13 -08:00
bors
4884061838 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)

Failed merges:

r? @ghost
2020-01-16 17:43:19 +00:00
Esteban Küber
4c13d2555c Add E0746 explanation to the index 2020-01-16 09:37:24 -08:00
Esteban Küber
93293c56e8 fmt 2020-01-16 09:37:24 -08:00
Esteban Küber
e1dd8a9095 When trait bounds are missing for return values, point at them 2020-01-16 09:37:24 -08:00
Esteban Küber
b4bbe784a9 Make impl Trait suggestion in E0746 MachineApplicable 2020-01-16 09:37:24 -08:00
Esteban Küber
ea7e885204 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.
2020-01-16 09:37:24 -08:00
Esteban Küber
75eabb17ae Account for diverging types in return impl Trait 2020-01-16 09:37:24 -08:00
Esteban Küber
6fd564112f Specific error for unsized dyn Trait return type
Suggest `impl Trait` when possible, and `Box<dyn Trait>` otherwise.
2020-01-16 09:37:24 -08:00
Dylan DPC
a529e70be1
Rollup merge of #68274 - matthiaskrgr:dead_code, r=Dylan-DPC
remove dead code

The condition
`if obligation.recursion_depth >= 0`
is always true since `recursion_depth` is `usize`.

The else branch is dead code and can be removed.

Found by Clippy.

Fixes #68251
2020-01-16 20:53:32 +05:30
Dylan DPC
6e797ff8d9
Rollup merge of #68263 - ollie27:rustdoc_invalid_syntax_highlight_escape, r=GuillaumeGomez
rustdoc: HTML escape codeblocks which fail syntax highlighting

r? @GuillaumeGomez
2020-01-16 20:53:30 +05:30
Dylan DPC
c0ff382cb5
Rollup merge of #68255 - tmiasko:unused-aux, r=Dylan-DPC
Remove unused auxiliary file that was replaced with rust_test_helpers
2020-01-16 20:53:29 +05:30
Dylan DPC
678f662e54
Rollup merge of #68244 - tmiasko:leak, r=Centril
Enable leak sanitizer test case

* Use `black_box` to avoid memory leak removal during optimization.
* Leak multiple objects to make test case more robust.
2020-01-16 20:53:27 +05:30
Dylan DPC
c8125fb36a
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.
2020-01-16 20:53:26 +05:30
flip1995
25f1bf9a66
Update Clippy 2020-01-16 16:07:54 +01:00
bors
117ceeba40 Auto merge of #68258 - RalfJung:miri, r=RalfJung
update miri

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

r? @ghost Cc @oli-obk
2020-01-16 14:16:54 +00:00
Matthias Krüger
c4d91aae5a remove dead code
The condition
if obligation.recursion_depth >= 0
is always true since recursion_depth is usize.

The else branch is dead code and can be removed.

Found by Clippy.

Fixes #68251
2020-01-16 08:27:41 +01:00
bors
9fe05e9456 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`)

r? @ghost
2020-01-16 07:20:52 +00:00
Dylan DPC
90b9a627bf
Rollup merge of #68266 - Stromberg90:patch-2, r=Dylan-DPC
Changed docs for f32 and f64.
2020-01-16 11:58:07 +05:30
Dylan DPC
4d5e5a6ec0
Rollup merge of #68265 - JohnTitor:fix-issue-number, r=Dylan-DPC
Fix some issue numbers of unstable features

Looking into the unstable book, some issue numbers are outdated.
2020-01-16 11:58:05 +05:30
Dylan DPC
69eee569d6
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`)
2020-01-16 11:58:04 +05:30
Dylan DPC
1389caf860
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.

r? @Centril
2020-01-16 11:58:02 +05:30
Dylan DPC
6b83862d09
Rollup merge of #67780 - cjgillot:passes-ty, r=Zoxc
Move some queries from rustc::ty to librustc_ty.

cc #65031
2020-01-16 11:58:00 +05:30
Yuki Okushi
91c6a5aaee Fix issue number of infer_static_outlives_requirements 2020-01-16 11:59:04 +09:00
Yuki Okushi
49d8aebbf3 Fix issue number of repr128 2020-01-16 11:58:28 +09:00
Strømberg
d0db6d5791
Update f32.rs 2020-01-16 03:35:31 +01:00
Strømberg
3f337b312d
Update f64.rs 2020-01-16 03:34:23 +01:00
Strømberg
54b961658b
Update f32.rs 2020-01-16 03:30:27 +01:00
Yuki Okushi
bf0a7845d7 Fix issue number of member_constraints 2020-01-16 11:18:36 +09:00
bors
e02c475da5 Auto merge of #67339 - CAD97:rc-provenance, r=sfackler
Use pointer offset instead of deref for A/Rc::into_raw

Internals thread: https://internals.rust-lang.org/t/rc-and-internal-mutability/11463/2?u=cad97

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.
2020-01-16 00:47:45 +00:00
Oliver Middleton
baf2921ebc rustdoc: HTML escape codeblocks which fail syntax highlighting 2020-01-15 22:42:04 +00:00
bors
3291ae3390 Auto merge of #68254 - Dylan-DPC:rollup-9vhc59u, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #68123 (Implement Cursor for linked lists. (RFC 2570).)
 - #68212 (Suggest to shorten temporary lifetime during method call inside generator)
 - #68232 (Optimize size/speed of Unicode datasets)
 - #68236 (Add some regression tests)
 - #68237 (Account for `Path`s in `is_suggestable_infer_ty`)
 - #68252 (remove redundant clones, found by clippy)

Failed merges:

r? @ghost
2020-01-15 19:40:45 +00:00
Ralf Jung
d9d7877f0e update miri 2020-01-15 20:03:22 +01:00