Commit Graph

78588 Commits

Author SHA1 Message Date
kennytm
e0e598bb76
Rollup merge of #51056 - tbu-:pr_once_new, r=dtolnay
Mention and use `Once::new` instead of `ONCE_INIT`
2018-05-26 19:32:24 +08:00
kennytm
08b417084d
Rollup merge of #51048 - GuillaumeGomez:formatter-examples, r=QuietMisdreavus
Add more missing examples for Formatter

r? @QuietMisdreavus
2018-05-26 19:32:23 +08:00
kennytm
e667e7be60
Rollup merge of #51047 - spastorino:use_polonius_engine_facts, r=nikomatsakis
Use AllFacts from polonius-engine
2018-05-26 19:32:22 +08:00
kennytm
e66ba0fe8b
Rollup merge of #51034 - oli-obk:lowering, r=pnkfelix
Remove unused lowering field and method

r? @nikomatsakis

So while trying to understand lowering better, I found out that there's something related to creating definitions. Analyzing that further, I realized that it is entirely dead code.

The `parent_def` field was only ever used for setting and resetting the field itself. The field was never read anywhere else and thus its value was entirely unused.

Maybe the `unused_field` lint should detect when the only use of a field is the field being read without using the read value other than writing back to the field?

The diff is best viewed without whitespace changes getting in the way: https://github.com/rust-lang/rust/pull/51034/files?w=1
2018-05-26 19:32:21 +08:00
kennytm
ee18e92684
Rollup merge of #51014 - GuillaumeGomez:env_docs, r=QuietMisdreavus
Add documentation about env! second argument

Fixes #48044.

r? @QuietMisdreavus
2018-05-26 19:32:20 +08:00
kennytm
103abdb75c
Rollup merge of #50987 - estebank:underline-multiple-suggestions, r=petrochencov
Underline multiple suggested replacements in the same line

<img width="685" alt="screen shot 2018-05-22 at 21 06 48" src="https://user-images.githubusercontent.com/1606434/40403051-174f3180-5e04-11e8-86b6-261630c5ff80.png">

Follow up to #50943.

Fix #50977.
2018-05-26 19:32:18 +08:00
bors
444a9c3f1a Auto merge of #50364 - LukasKalbertodt:improve-duration-debug-impl, r=KodrAus
Improve `Debug` impl of `time::Duration`

Hi there!

For a long time now, I was getting annoyed by the derived `Debug` impl of `Duration`. Usually, I use `Duration` to either do quick'n'dirty benchmarking or measuring the time of some operation in general. The output of the derived Debug impl is hard to parse for humans: is { secs: 0, nanos: 968360102 } or { secs: 0, nanos 98507324 } longer?

So after running into the annoyance several times (sometimes building my own function to print the Duration properly), I decided to tackle this. Now the output looks like this:

```
Duration::new(1, 0)                 => 1s
Duration::new(1, 1)                 => 1.000000001s
Duration::new(1, 300)               => 1.0000003s
Duration::new(1, 4000)              => 1.000004s
Duration::new(1, 600000)            => 1.0006s
Duration::new(1, 7000000)           => 1.007s
Duration::new(0, 0)                 => 0ns
Duration::new(0, 1)                 => 1ns
Duration::new(0, 300)               => 300ns
Duration::new(0, 4001)              => 4.001µs
Duration::new(0, 600300)            => 600.3µs
Duration::new(0, 7000000)           => 7ms
```

Note that I implemented the formatting manually and didn't use floats. No information is "lost" when printing. So `Duration::new(123_456_789_000, 900_000_001)` prints as `123456789000.900000001s`.

~~This is not yet finished~~, but I wanted to open the PR now already in order to get some feedback (maybe everyone likes the derived impl).

### Still ToDo:

- [x] Respect precision ~~and width~~ parameter of the formatter (see [this comment](https://github.com/rust-lang/rust/pull/50364#issuecomment-386107107))

### Alternatives/Decisions

- Should large durations displayed in minutes, hours, days, ...? For now, I decided not to because the current formatting is close the how a `Duration` is stored. From this new `Debug` output, you can still easily see what the values of `secs` and `nanos` are. A formatting like `3h 27m 12s 9ms` might be more appropriate for a `Display` impl?
- Should this rather be a `Display` impl and should `Debug` be derived? Maybe this formatting is too fancy for `Debug`? In my opinion it's not and, as already mentioned, from the current format one can still very easily determine the values for `secs` and `nanos`.
- Whitespace between the number and the unit?

### Notes for reviewers

- ~~The combined diff sucks. Rather review both commits individually.~~
- ~~In the unit test, I am building my own type implementing `fmt::Write` to test the output. Maybe there is already something like that which I can use?~~
- My `Debug` impl block is marked as `#[stable(...)]`... but that's fine since the derived Debug impl was stable already, right?

---

~~Apart from the main change, I moved all `time` unit tests into the `tests` directory. All other `libcore` tests are there, so I guess it was simply an oversight. Prior to this change, the `time` tests weren't run, so I guess this is kind of a bug fix. If my `Debug` impl is rejected, I can of course just send the fix as PR.~~ (this was already merged in #50466)
2018-05-26 07:33:06 +00:00
bors
67d99d91e5 Auto merge of #51035 - oli-obk:unsupported_crate_type, r=eddyb
Don't ICE if crate has no valid crate types left

fixes #50993
2018-05-26 03:22:39 +00:00
bors
49a97ef010 Auto merge of #50070 - toidiu:ak-2093-outlives, r=nikomatsakis
2093 infer outlives requirements

Tracking issue:  #44493
RFC: https://github.com/rust-lang/rfcs/pull/2093

- [x] add `rustc_attrs` flag
- [x] use `RequirePredicates` type
- [x]  handle explicit predicates on `dyn` Trait
- [x] handle explicit predicates on projections
- [x] more tests
- [x]  remove `unused`, `dead_code` and etc..
- [x]  documentation
2018-05-26 01:09:02 +00:00
bors
07c415c215 Auto merge of #51033 - coryshrmn:master, r=dtolnay
stabilize RangeBounds collections_range #30877

The FCP for #30877 closed last month, with the decision to:
1. move from `collections::range::RangeArgument` to `ops::RangeBounds`, and
2. rename `start()` and `end()` to `start_bounds()` and `end_bounds()`.

Simon Sapin already moved it to `ops::RangeBounds` in #49163.

I renamed the functions, and removed the old `collections::range::RangeArgument` alias.

This is my first Rust PR, please let me know if I can improve anything. This passes all tests for me, except the `clippy` tool (which uses `RangeArgument::start()`).

I considered deprecating `start()` and `end()` instead of removing them, but the contribution guidelines indicate we can break `clippy` temporarily. I thought it was best to remove the functions, since we're worried about name collisions with `Range::start` and `end`.

Closes #30877.
2018-05-25 22:18:27 +00:00
bors
990d8aa743 Auto merge of #50967 - oli-obk:miri_api_refactor, r=eddyb
Miri api refactor

r? @eddyb

cc @Zoxc

based on https://github.com/rust-lang/rust/pull/50916
2018-05-25 13:59:48 +00:00
toidiu
3da712381d Implement outlives requirements inference for dyn and projections.
Add tests, documentation and attr for feature.
2018-05-25 09:58:00 -04:00
Oliver Schneider
5f599bb490 Adjust test for 32 bit targets 2018-05-25 15:13:54 +02:00
Oliver Schneider
50d3783b95 Sanity abort to_bits if used on zsts 2018-05-25 11:56:33 +02:00
bors
9823cb99c5 Auto merge of #51051 - nikomatsakis:turbofish-impl-trait-method, r=eddyb
prohibit turbofish in `impl Trait` methods

Fix #50950
2018-05-25 09:01:11 +00:00
Oliver Schneider
eceeb63d11 Update comment 2018-05-25 10:18:57 +02:00
bors
910e29a45b Auto merge of #50998 - bobtwinkles:nll_facts_invalidate_followup, r=nikomatsakis
NLL facts invalidate followup

Refactors to share code with the rest of borrow-check.

r? @nikomatsakis
2018-05-25 06:26:26 +00:00
bors
7942022bf7 Auto merge of #50986 - estebank:main-start-span, r=nikomatsakis
Tweak `main` type arguments and where clause spans

Tweak the spans for error when finding type arguments or where clauses
in main and start functions.
2018-05-25 03:46:14 +00:00
bors
c8e10e386a Auto merge of #50879 - petrochenkov:lintconv, r=nikomatsakis
Fix naming conventions for new lints

We actually have an RFC from Oct 2014 specifying naming conventions for lints that is still relevant - https://github.com/rust-lang/rfcs/blob/master/text/0344-conventions-galore.md#lints.
Unfortunately, human memory doesn't work for such prolonged periods of time, so a number of recently added edition-related lints don't follow the conventions.
This PR fixes names for those lints.

Unstable lints, simply renamed:
- `unused_lifetime` -> `unused_lifetimes`
- `absolute_path_not_starting_with_crate` -> `absolute_paths_not_starting_with_crate`
- `unnecessary_extern_crate` -> `unnecessary_extern_crates`

New lints stabilized in the last couple of releases, registered as renamed (old names still work with a warning):
- `single_use_lifetime` -> `single_use_lifetimes`
- `elided_lifetime_in_path` -> `elided_lifetimes_in_paths`
- `bare_trait_object` -> `bare_trait_objects`
- `unstable_name_collision` -> `unstable_name_collisions`
- `unused_doc_comment` -> `unused_doc_comments`

NOT changed, too old to rename:
- `const_err` -> `const_errors`
- `unused_allocation` -> `unused_allocations`

NOT changed, deprecation lints, no need to rename, they are going to be removed anyway:
- `invalid_type_param_default` -> `invalid_type_param_defaults`
- `missing_fragment_specifier` -> `missing_fragment_specifiers`
- `tyvar_behind_raw_pointer` -> `tyvars_behind_raw_pointer`
- `illegal_floating_point_literal_pattern` -> `illegal_floating_point_literal_patterns`
2018-05-25 01:33:45 +00:00
Vadim Petrochenkov
e60eaf59df Fix naming conventions for new lints 2018-05-25 02:35:07 +03:00
bors
b86d909f86 Auto merge of #50937 - nikomatsakis:chalkify-engine-2, r=scalexm
implement the chalk-engine traits

Preliminary implementation for the Chalk traits in rustc. Lots of `panic!()` placeholders to be filled in later.

This is currently blocked on us landing https://github.com/rust-lang-nursery/chalk/pull/131  in chalk and issuing a new release, which should occur later today.

r? @scalexm
cc @leodasvacas
2018-05-24 23:10:18 +00:00
Santiago Pastorino
8429d11a0b
Use AllFacts from polonius-engine 2018-05-24 19:56:02 -03:00
Niko Matsakis
558cbfb19b prohibit turbofish in impl Trait methods 2018-05-24 18:43:48 -04:00
bors
c2d46037fa Auto merge of #50984 - cramertj:unpin-changes, r=aturon
Unpin changes

r? @aturon

cc @withoutboats, @RalfJung, @pythonesque, #49150
2018-05-24 20:58:12 +00:00
Guillaume Gomez
6ff9409637 Add more missing examples for Formatter 2018-05-24 22:27:19 +02:00
Oliver Schneider
0b1b26f17f
Update issue-50993.rs 2018-05-24 21:03:48 +02:00
Oliver Schneider
fb9060ac06 Revert "Ensure llvm doesn't trigger an assert for crazy transmutes"
This reverts commit 776c632e2a9a044fd134321a9d561e28994ff3ff.
2018-05-24 20:49:38 +02:00
Oliver Schneider
85de4efdd8 Rename amt variables to shift 2018-05-24 20:49:38 +02:00
Oliver Schneider
5c8741f32e Use in-band-lifetimes instead of unused explicit lifetimes 2018-05-24 20:49:38 +02:00
Oliver Schneider
80a1488601 Prefer to_value_with_len over manual expanison of it 2018-05-24 20:49:38 +02:00
Oliver Schneider
6d513f752f Remove dead code 2018-05-24 20:49:38 +02:00
Oliver Schneider
d0610fd26e Add missing newlines 2018-05-24 20:49:38 +02:00
Oliver Schneider
bdd23bf215 tcx.lift_to_global > tcx.global_tcx().lift 2018-05-24 20:49:38 +02:00
Oliver Schneider
569ae80a0a Wrongly named a closure clamp when it was doing truncation 2018-05-24 20:49:38 +02:00
Oliver Schneider
1f9fa53738 Sanity check the bits argument to the from_bits function 2018-05-24 20:49:38 +02:00
Oliver Schneider
f1ea9ef315 Remove ty_to_primitive 2018-05-24 20:49:38 +02:00
Oliver Schneider
879d8f7070 Properly check defined bits range 2018-05-24 20:49:38 +02:00
Oliver Schneider
cfd5fb5102 Reuse to_bits instead of badly reinventing it 2018-05-24 20:49:38 +02:00
Oliver Schneider
50628b7373 Only defined bits are relevant 2018-05-24 20:49:38 +02:00
Oliver Schneider
c6d25dc224 Don't ICE on horrible transmutes in pattern constants 2018-05-24 20:49:38 +02:00
Oliver Schneider
1a2964a541 Simplify a ScalarPair creation 2018-05-24 20:49:38 +02:00
Oliver Schneider
ca8c27e1c1 Ensure llvm doesn't trigger an assert for crazy transmutes 2018-05-24 20:49:38 +02:00
Oliver Schneider
bc3ba91737 Printing a fn definition needs to know nothing about its ZST's value 2018-05-24 20:49:38 +02:00
Oliver Schneider
09a996b0a6 Printing values should ignore whether bits are undefined 2018-05-24 20:49:38 +02:00
Oliver Schneider
98e5129375 Better variable naming 2018-05-24 20:49:38 +02:00
Oliver Schneider
97da01f8ad Remove the last mention of Undef 2018-05-24 20:49:38 +02:00
Oliver Schneider
c420531304 Replace ScalarKind with Primitive 2018-05-24 20:49:37 +02:00
Oliver Schneider
cc60a22b10 Get rid of scalar_size 2018-05-24 20:49:37 +02:00
Oliver Schneider
0da702a6d4 Remove an instance of scalar_size in a Debug impl 2018-05-24 20:49:37 +02:00
Oliver Schneider
ff652b8a01 Update outdated comment 2018-05-24 20:49:37 +02:00