]> git.lizzy.rs Git - rust.git/log
rust.git
6 years agoupdate openssl{,-sys} to fix build with libressl 2.6.x
Marc-Antoine Perennou [Fri, 17 Nov 2017 19:28:03 +0000 (20:28 +0100)]
update openssl{,-sys} to fix build with libressl 2.6.x

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
6 years agoAuto merge of #45996 - eddyb:even-mirer-1, r=arielb1
bors [Fri, 17 Nov 2017 13:30:24 +0000 (13:30 +0000)]
Auto merge of #45996 - eddyb:even-mirer-1, r=arielb1

MIR: hide .rodata constants vs by-ref ABI clash in trans.

Back in #45380, constants were copied into locals during MIR creation to ensure that arguments ' memory can be used by the callee, if the constant is placed in `.rodata` and the ABI passes it by-ref.

However, there are several drawbacks (see https://github.com/rust-lang/rust/pull/45380#discussion_r150447709), most importantly the complication of constant propagation (UB if a constant ends up in `Call` arguments) and inconveniencing analyses.

Instead, I've modified the `rustc_trans` implementation of calls to copy an `Operand::Constant` argument locally if it's not immediate, and added a test that segfaults without the copy.

cc @dotdash @arielb1

6 years agoAuto merge of #46004 - michaelwoerister:cached-mir-wip-3, r=nikomatsakis
bors [Fri, 17 Nov 2017 10:12:21 +0000 (10:12 +0000)]
Auto merge of #46004 - michaelwoerister:cached-mir-wip-3, r=nikomatsakis

incr.comp.: Implement query result cache and use it to cache type checking tables.

This is a spike implementation of caching more than LLVM IR and object files when doing incremental compilation. At the moment, only the `typeck_tables_of` query is cached but MIR and borrow-check will follow shortly. The feature is activated by running with `-Zincremental-queries` in addition to `-Zincremental`, it is not yet active by default.

r? @nikomatsakis

6 years agoAuto merge of #45595 - scottmcm:iter-try-fold, r=dtolnay
bors [Fri, 17 Nov 2017 07:43:08 +0000 (07:43 +0000)]
Auto merge of #45595 - scottmcm:iter-try-fold, r=dtolnay

Short-circuiting internal iteration with Iterator::try_fold & try_rfold

These are the core methods in terms of which the other methods (`fold`, `all`, `any`, `find`, `position`, `nth`, ...) can be implemented, allowing Iterator implementors to get the full goodness of internal iteration by only overriding one method (per direction).

Based off the `Try` trait, so works with both `Result` and `Option` (:tada: https://github.com/rust-lang/rust/pull/42526).  The `try_fold` rustdoc examples use `Option` and the `try_rfold` ones use `Result`.

AKA continuing in the vein of PRs https://github.com/rust-lang/rust/pull/44682 & https://github.com/rust-lang/rust/pull/44856 for more of `Iterator`.

New bench following the pattern from the latter of those:
```
test iter::bench_take_while_chain_ref_sum          ... bench:   1,130,843 ns/iter (+/- 25,110)
test iter::bench_take_while_chain_sum              ... bench:     362,530 ns/iter (+/- 391)
```

I also ran the benches without the `fold` & `rfold` overrides to test their new default impls, with basically no change.  I left them there, though, to take advantage of existing overrides and because `AlwaysOk` has some sub-optimality due to https://github.com/rust-lang/rust/issues/43278 (which 45225 should fix).

If you're wondering why there are three type parameters, see issue https://github.com/rust-lang/rust/issues/45462

Thanks for @bluss for the [original IRLO thread](https://internals.rust-lang.org/t/pre-rfc-fold-ok-is-composable-internal-iteration/4434) and the rfold PR and to @cuviper for adding so many folds, [encouraging me](https://github.com/rust-lang/rust/pull/45379#issuecomment-339424670) to make this PR, and finding a catastrophic bug in a pre-review.

6 years agoAuto merge of #45991 - gnzlbg:fix_i586, r=alexcrichton
bors [Fri, 17 Nov 2017 05:18:45 +0000 (05:18 +0000)]
Auto merge of #45991 - gnzlbg:fix_i586, r=alexcrichton

fix linking error on i586

Try to fix this linking error on i586 in cross:

https://travis-ci.org/japaric/cross/builds/302095949#L8670

The problem is that `std` is built in Ubuntu 16.04 and `cross` uses a linker from 12.04.

Currently this fix solves the problem for `i686-musl`  making it "supercompatible", this PR applies the fix to `i586` as well.

The cross PR is here: https://github.com/japaric/cross/pull/157

6 years agoAuto merge of #45980 - Keruspe:master, r=alexcrichton
bors [Fri, 17 Nov 2017 02:34:08 +0000 (02:34 +0000)]
Auto merge of #45980 - Keruspe:master, r=alexcrichton

rustbuild: Install rustfmt as part of extended build

Now that we distribute it, this allows `./x.py install` to install it too

6 years agoMIR: hide .rodata constants vs by-ref ABI clash in trans.
Eduard-Mihai Burtescu [Wed, 15 Nov 2017 01:35:35 +0000 (03:35 +0200)]
MIR: hide .rodata constants vs by-ref ABI clash in trans.

6 years agoAuto merge of #45897 - tromey:trait-object-debug, r=michaelwoerister
bors [Thu, 16 Nov 2017 23:28:00 +0000 (23:28 +0000)]
Auto merge of #45897 - tromey:trait-object-debug, r=michaelwoerister

Trait object debug

This enables better debugging of trait objects.  See the individual commits for explanations.  This required an LLVM bump.

6 years agoAuto merge of #45825 - nikomatsakis:nll-factor-region-inference, r=arielb1
bors [Thu, 16 Nov 2017 20:56:26 +0000 (20:56 +0000)]
Auto merge of #45825 - nikomatsakis:nll-factor-region-inference, r=arielb1

integrate MIR type-checker with NLL inference

This branch refactors NLL type inference so that it uses the MIR type-checker to gather constraints. Along the way, it also refactors how region constraints are gathered in the normal inference context mildly. The new setup is like this:

- What used to be `region_inference` is split into two parts:
    - `region_constraints`, which just collects up sets of constraints
    - `lexical_region_resolve`, which does the iterative, lexical region resolution
- When `resolve_regions_and_report_errors` is invoked, the inference engine converts the constraints into final values.
- In the MIR type checker, however, we do not invoke this method, but instead periodically take the region constraints and package them up for the NLL solver to use later.
    - This allows us to track when and where those constraints were incurred.
    - We also remove the central fulfillment context from the MIR type checker, instead instantiating new fulfillment contexts at each point. This allows us to capture the set of obligations that occurred at a particular point, and also to ensure that if the same obligation arises at two points, we will enforce the region constraints at both locations.
- The MIR type checker is also enhanced to instantiate late-bound-regions with fresh variables and handle a few other corner cases that arose.
- I also extracted some of the 'outlives' logic from the regionck, which will be needed later (see future work) to handle the type-outlives relationships.

One concern I have with this branch: since the MIR type checker is used even without the `-Znll` switch, I'm not sure if it will impact performance. One simple fix here would be to only enable the MIR type-checker if debug-assertions are enabled, since it just serves to validate the MIR. Longer term I hope to address this by improving the interface to the trait solver to be more query-based (ongoing work).

There is plenty of future work left. Here are two things that leap to mind:

- **Type-region outlives.** Currently, the NLL solver will ICE if it is required to handle a constraint like `T: 'a`. Fixing this will require a small amount of refactoring to extract the implied bounds code. I plan to follow a file-up bug on this (hopefully with mentoring instructions).
- **Testing.** It's a good idea to enumerate some of the tricky scenarios that need testing, but I think it'd be nice to try and parallelize some of the actual test writing (and resulting bug fixing):
    - Same obligation occurring at two points.
    - Well-formedness and trait obligations of various kinds (which are not all processed by the current MIR type-checker).
    - More tests for how subtyping and region inferencing interact.
    - More suggestions welcome!

r? @arielb1

6 years agoAuto merge of #46029 - GuillaumeGomez:rollup, r=GuillaumeGomez
bors [Thu, 16 Nov 2017 18:24:17 +0000 (18:24 +0000)]
Auto merge of #46029 - GuillaumeGomez:rollup, r=GuillaumeGomez

Rollup of 6 pull requests

- Successful merges: #45951, #45973, #45984, #45993, #46005, #46010
- Failed merges:

6 years agoAdd doc comment for LocalDefId.
Michael Woerister [Thu, 16 Nov 2017 17:07:49 +0000 (18:07 +0100)]
Add doc comment for LocalDefId.

6 years agoFix some tidy errors in ty::codec.
Michael Woerister [Thu, 16 Nov 2017 16:42:39 +0000 (17:42 +0100)]
Fix some tidy errors in ty::codec.

6 years agoincr.comp.: Remove default serialization implementations for things in rustc::hir...
Michael Woerister [Thu, 16 Nov 2017 16:13:39 +0000 (17:13 +0100)]
incr.comp.: Remove default serialization implementations for things in rustc::hir::def_id so that we get an ICE instead of silently doing the wrong thing.

6 years agoAuto merge of #45528 - alexcrichton:avx512, r=arielb1
bors [Thu, 16 Nov 2017 15:32:13 +0000 (15:32 +0000)]
Auto merge of #45528 - alexcrichton:avx512, r=arielb1

rustc: Add some more compatibility with AVX-512

* Increase the maximum vector size in the ABI calculations to ensure that
  AVX-512 operands are immediates.
* Add a few more `target_feature` matchings for AVX-512 features

6 years agoincr.comp.: Remove some code duplication around TyDecoder by factoring things into...
Michael Woerister [Thu, 16 Nov 2017 14:26:00 +0000 (15:26 +0100)]
incr.comp.: Remove some code duplication around TyDecoder by factoring things into a macro.

6 years agoincr.comp.: Encode DefIds as DefPathHashes instead of recomputing those during deseri...
Michael Woerister [Thu, 16 Nov 2017 13:09:44 +0000 (14:09 +0100)]
incr.comp.: Encode DefIds as DefPathHashes instead of recomputing those during deserialization.

6 years agoIntroduce LocalDefId which provides a type-level guarantee that the DefId is from...
Michael Woerister [Thu, 16 Nov 2017 13:04:01 +0000 (14:04 +0100)]
Introduce LocalDefId which provides a type-level guarantee that the DefId is from the local crate.

6 years agoAuto merge of #46028 - oli-obk:clippy, r=kennytm
bors [Thu, 16 Nov 2017 10:59:39 +0000 (10:59 +0000)]
Auto merge of #46028 - oli-obk:clippy, r=kennytm

Reenable Clippy

r? @kennytm

6 years agoinfer/outlives/obligations.rs: wrap some long lines
Niko Matsakis [Thu, 16 Nov 2017 01:45:03 +0000 (20:45 -0500)]
infer/outlives/obligations.rs: wrap some long lines

6 years agoobligations.rs: rustfmt
Niko Matsakis [Thu, 16 Nov 2017 01:44:02 +0000 (20:44 -0500)]
obligations.rs: rustfmt

6 years agoNit: fix typo
Niko Matsakis [Wed, 15 Nov 2017 21:37:34 +0000 (16:37 -0500)]
Nit: fix typo

6 years agoNit: reset more state after `take_and_reset_data`
Niko Matsakis [Tue, 14 Nov 2017 22:17:53 +0000 (17:17 -0500)]
Nit: reset more state after `take_and_reset_data`

6 years agoNit: improve comment to explain why we wait until regionck
Niko Matsakis [Tue, 14 Nov 2017 22:12:16 +0000 (17:12 -0500)]
Nit: improve comment to explain why we wait until regionck

6 years agoNit: rework region obligations to a snapshotted vector
Niko Matsakis [Tue, 14 Nov 2017 20:12:36 +0000 (15:12 -0500)]
Nit: rework region obligations to a snapshotted vector

6 years agoNit: fix wording in README
Niko Matsakis [Tue, 14 Nov 2017 20:09:01 +0000 (15:09 -0500)]
Nit: fix wording in README

6 years agoleak the affects of closures on the free-region-map, like we used to
Niko Matsakis [Tue, 7 Nov 2017 18:18:42 +0000 (13:18 -0500)]
leak the affects of closures on the free-region-map, like we used to

This restores the behavior of regionck with respect to the
free-region-map: that is, it collects all the relations from the fn
and its closures. This feels a bit fishy but it's the behavior we've
had for some time, and it will go away with NLL, so seems best to just
keep it.

6 years agofactor out `free_region_binding_scope` helper
Niko Matsakis [Tue, 7 Nov 2017 18:18:14 +0000 (13:18 -0500)]
factor out `free_region_binding_scope` helper

6 years agofix mir-opt NLL tests -- variable `'_#0r` is now `'static`
Niko Matsakis [Tue, 7 Nov 2017 11:16:09 +0000 (06:16 -0500)]
fix mir-opt NLL tests -- variable `'_#0r` is now `'static`

6 years agoadd FIXME for converting RegionVid to use `newtype_index!`
Niko Matsakis [Tue, 7 Nov 2017 10:55:34 +0000 (05:55 -0500)]
add FIXME for converting RegionVid to use `newtype_index!`

6 years agoconvert TODO in traits into a FIXME
Niko Matsakis [Tue, 7 Nov 2017 10:54:31 +0000 (05:54 -0500)]
convert TODO in traits into a FIXME

6 years agoinfer/outlives: add license
Niko Matsakis [Tue, 7 Nov 2017 10:54:22 +0000 (05:54 -0500)]
infer/outlives: add license

6 years agoupdate READMEs to describe the new situation
Niko Matsakis [Tue, 7 Nov 2017 10:41:57 +0000 (05:41 -0500)]
update READMEs to describe the new situation

The inference README, in particular, was VERY out of date!

6 years agointegrate NLL with MIR type-checker
Niko Matsakis [Mon, 6 Nov 2017 12:26:34 +0000 (07:26 -0500)]
integrate NLL with MIR type-checker

6 years agoregion_infer: improved debug logging
Niko Matsakis [Tue, 7 Nov 2017 09:31:21 +0000 (04:31 -0500)]
region_infer: improved debug logging

6 years agorenumber: debug logs, use `visit_region` rather than `visit_rvalue`
Niko Matsakis [Tue, 7 Nov 2017 09:30:43 +0000 (04:30 -0500)]
renumber: debug logs, use `visit_region` rather than `visit_rvalue`

6 years agorenumber: handle ReturnTy better
Niko Matsakis [Tue, 7 Nov 2017 09:30:06 +0000 (04:30 -0500)]
renumber: handle ReturnTy better

6 years agoMIR-dump: print return type from local_decls for `_0`
Niko Matsakis [Tue, 7 Nov 2017 09:29:10 +0000 (04:29 -0500)]
MIR-dump: print return type from local_decls for `_0`

We've kind of got the same information twice in the MIR, between the
return-type field and the local-decls. Seems un-great.

6 years agoerase regions in MIR borrowck when checking if type moves by default
Niko Matsakis [Mon, 6 Nov 2017 16:52:39 +0000 (11:52 -0500)]
erase regions in MIR borrowck when checking if type moves by default

6 years agosimplify lifetime annotations for `MirBorrowckCtxt`
Niko Matsakis [Tue, 7 Nov 2017 09:44:41 +0000 (04:44 -0500)]
simplify lifetime annotations for `MirBorrowckCtxt`

6 years agoformalize giving ownership of region vars to region inf. context
Niko Matsakis [Mon, 6 Nov 2017 10:21:48 +0000 (05:21 -0500)]
formalize giving ownership of region vars to region inf. context

6 years agoinfer: extract total number of region variables from infcx
Niko Matsakis [Mon, 6 Nov 2017 09:33:15 +0000 (04:33 -0500)]
infer: extract total number of region variables from infcx

We are heading towards deeper integration with the region inference
system in infcx; in particular, prior to the creation of the
`RegionInferenceContext`, it will be the "owner" of the set of region
variables.

6 years agoinfer: give access to region variable origins
Niko Matsakis [Mon, 6 Nov 2017 09:29:50 +0000 (04:29 -0500)]
infer: give access to region variable origins

6 years agoIndexVec: add `'_` to make clear where borrowing is happening
Niko Matsakis [Mon, 6 Nov 2017 09:29:23 +0000 (04:29 -0500)]
IndexVec: add `'_` to make clear where borrowing is happening

6 years agoreplace `RegionIndex` with `RegionVid` (which now impls Idx)
Niko Matsakis [Mon, 6 Nov 2017 09:15:38 +0000 (04:15 -0500)]
replace `RegionIndex` with `RegionVid` (which now impls Idx)

6 years agoreplace `usize` with `RegionIndex` in indices map
Niko Matsakis [Mon, 6 Nov 2017 09:04:45 +0000 (04:04 -0500)]
replace `usize` with `RegionIndex` in indices map

6 years agoMIR typeck: refactor to track region constraints
Niko Matsakis [Sun, 5 Nov 2017 23:47:09 +0000 (18:47 -0500)]
MIR typeck: refactor to track region constraints

6 years agoMIR typeck: rustfmt
Niko Matsakis [Tue, 7 Nov 2017 09:40:35 +0000 (04:40 -0500)]
MIR typeck: rustfmt

6 years agorustfmt `lexical_region_resolve`
Niko Matsakis [Sun, 5 Nov 2017 19:46:58 +0000 (14:46 -0500)]
rustfmt `lexical_region_resolve`

6 years agoadd method `take_and_reset_region_constraints` to `InferCtxt`
Niko Matsakis [Sun, 5 Nov 2017 19:42:56 +0000 (14:42 -0500)]
add method `take_and_reset_region_constraints` to `InferCtxt`

6 years agosplit the `var_origins` from the `RegionConstraintData`
Niko Matsakis [Sun, 5 Nov 2017 19:37:55 +0000 (14:37 -0500)]
split the `var_origins` from the `RegionConstraintData`

6 years agoregion_constraints: only push givens into undo-log if in a snapshot
Niko Matsakis [Sun, 5 Nov 2017 23:46:37 +0000 (18:46 -0500)]
region_constraints: only push givens into undo-log if in a snapshot

6 years agomake `RegionVid` implement `Idx` and use `IndexVec`
Niko Matsakis [Sun, 5 Nov 2017 19:06:46 +0000 (14:06 -0500)]
make `RegionVid` implement `Idx` and use `IndexVec`

6 years agofix error messages relating to removing lint for E0276
Niko Matsakis [Sun, 5 Nov 2017 17:03:49 +0000 (12:03 -0500)]
fix error messages relating to removing lint for E0276

6 years agoseparate the `Collector` from the `Data` it is collecting
Niko Matsakis [Sun, 5 Nov 2017 16:59:49 +0000 (11:59 -0500)]
separate the `Collector` from the `Data` it is collecting

6 years agomake the `region_constraints` field an `Option`
Niko Matsakis [Sun, 5 Nov 2017 12:22:39 +0000 (07:22 -0500)]
make the `region_constraints` field an `Option`

This way, we can `take()` ownership of it when we are going to resolve regions.

6 years agorename RegionVarBindings to RegionConstraintCollector
Niko Matsakis [Sun, 5 Nov 2017 12:01:48 +0000 (07:01 -0500)]
rename RegionVarBindings to RegionConstraintCollector

6 years agoinfer: rename `region_vars` field to `region_constraints`
Niko Matsakis [Sun, 5 Nov 2017 11:55:40 +0000 (06:55 -0500)]
infer: rename `region_vars` field to `region_constraints`

6 years agorename `region_inference` module to `region_constraints`
Niko Matsakis [Sun, 5 Nov 2017 11:34:22 +0000 (06:34 -0500)]
rename `region_inference` module to `region_constraints`

6 years agomove refcells out from `RegionVarBindings` and up into `InferCtxt`
Niko Matsakis [Sun, 5 Nov 2017 11:25:23 +0000 (06:25 -0500)]
move refcells out from `RegionVarBindings` and up into `InferCtxt`

6 years agoextract the `tcx` out from `RegionVarBindings`
Niko Matsakis [Sun, 5 Nov 2017 11:07:22 +0000 (06:07 -0500)]
extract the `tcx` out from `RegionVarBindings`

6 years agoregion_inference: rustfmt
Niko Matsakis [Sun, 5 Nov 2017 10:52:59 +0000 (05:52 -0500)]
region_inference: rustfmt

6 years agoextract storage of region values from `RegionVarBindings`
Niko Matsakis [Sun, 5 Nov 2017 10:48:16 +0000 (05:48 -0500)]
extract storage of region values from `RegionVarBindings`

6 years agomove `RegionResolutionError` into `lexical_region_resolve`
Niko Matsakis [Sun, 5 Nov 2017 10:28:22 +0000 (05:28 -0500)]
move `RegionResolutionError` into `lexical_region_resolve`

6 years agoregion_inference: extract taint into a sub-module
Niko Matsakis [Sun, 5 Nov 2017 10:23:53 +0000 (05:23 -0500)]
region_inference: extract taint into a sub-module

6 years agoregion_inference: tighten up `pub`, stop re-exporting enum variants
Niko Matsakis [Sun, 5 Nov 2017 10:23:30 +0000 (05:23 -0500)]
region_inference: tighten up `pub`, stop re-exporting enum variants

6 years agofix rename to block_data in type_check.rs
Niko Matsakis [Wed, 15 Nov 2017 22:00:03 +0000 (17:00 -0500)]
fix rename to block_data in type_check.rs

6 years agorustbuild: Install rustfmt as part of extended build
Marc-Antoine Perennou [Tue, 14 Nov 2017 08:57:56 +0000 (09:57 +0100)]
rustbuild: Install rustfmt as part of extended build

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
6 years agoRollup merge of #46010 - lnicola:escape-root, r=GuillaumeGomez
Guillaume Gomez [Thu, 16 Nov 2017 09:05:07 +0000 (10:05 +0100)]
Rollup merge of #46010 - lnicola:escape-root, r=GuillaumeGomez

rustdoc: Escape doc root URLs

This fixes a small HTML injection issue.

6 years agoRollup merge of #46005 - GuillaumeGomez:short-unstable, r=nrc
Guillaume Gomez [Thu, 16 Nov 2017 09:05:06 +0000 (10:05 +0100)]
Rollup merge of #46005 - GuillaumeGomez:short-unstable, r=nrc

Set short-message feature unstable

Fixes #45995.

r? @nrc

6 years agoRollup merge of #45993 - QuietMisdreavus:anti-cow, r=kennytm
Guillaume Gomez [Thu, 16 Nov 2017 09:05:05 +0000 (10:05 +0100)]
Rollup merge of #45993 - QuietMisdreavus:anti-cow, r=kennytm

examples in Cow::into_owned don't need to wrap result in Cows

This totally confused me until i triple-checked the actual return value and opened the examples in the playground myself.

r? @rust-lang/docs

6 years agoRollup merge of #45984 - ExpHP:attr-error-context, r=estebank
Guillaume Gomez [Thu, 16 Nov 2017 09:05:04 +0000 (10:05 +0100)]
Rollup merge of #45984 - ExpHP:attr-error-context, r=estebank

Add context to E0084, E0517, E0518

A small diagnostic enhancement to get my feet wet.  Please scrutinize!

This modifies errors E0084, E0517, and E0518 to include both the annotation and the annotated item.  All of these errors already had labels; I moved the label to the other span, and rephrased it as necessary.

Fixes #45886

6 years agoRollup merge of #45973 - arielb1:fast-path, r=estebank
Guillaume Gomez [Thu, 16 Nov 2017 09:05:03 +0000 (10:05 +0100)]
Rollup merge of #45973 - arielb1:fast-path, r=estebank

avoid the pprust infrastructure in macro expansion

This changes macro expansion to format the path of a macro directly
instead of usng the pprust infrastructure. The pprust infrastructure
tries to perform line-breaking in a slow fashion, which is undesired
when formatting the path of a macro.

This should to speed up expansion by a fair amount (I saw 20% on a
profiler on `rustc_mir`, and 50% of the time marked as "expansion" in
the profiler/time-passes is actually spent loading dependencies).

r? @jseyfried

6 years agoRollup merge of #45951 - CrockAgile:master, r=michaelwoerister
Guillaume Gomez [Thu, 16 Nov 2017 09:05:02 +0000 (10:05 +0100)]
Rollup merge of #45951 - CrockAgile:master, r=michaelwoerister

incr: Update hash tests to use `except`-style checking

Part of #44924

r? @michaelwoerister

6 years agoReenable Clippy
Oliver Schneider [Thu, 16 Nov 2017 08:35:53 +0000 (09:35 +0100)]
Reenable Clippy

6 years agoAuto merge of #45985 - arielb1:unsafe-dedup, r=eddyb
bors [Thu, 16 Nov 2017 08:31:59 +0000 (08:31 +0000)]
Auto merge of #45985 - arielb1:unsafe-dedup, r=eddyb

check_unsafety: fix unused unsafe block duplication

The duplicate error message is later removed by error message
deduplication, but it still appears on beta and is still a bug.

r? @eddyb

6 years agoAuto merge of #45920 - sunfishcode:trap-on-unreachable, r=Zoxc
bors [Thu, 16 Nov 2017 06:10:36 +0000 (06:10 +0000)]
Auto merge of #45920 - sunfishcode:trap-on-unreachable, r=Zoxc

Enable TrapUnreachable in LLVM.

This patch enables LLVM's TrapUnreachable flag, which tells it to translate `unreachable` instructions into hardware trap instructions, rather than allowing control flow to "fall through" into whatever code happens to follow it in memory.

This follows up on https://github.com/rust-lang/rust/issues/28728#issuecomment-332581533. For example, for @zackw's testcase [here](https://github.com/rust-lang/rust/issues/42009#issue-228745924), the output function contains a `ud2` instead of no code, so it won't "fall through" into whatever happens to be next in memory.

(I'm also working on the problem of LLVM optimizing away infinite loops, but the patch here is useful independently.)

I tested this patch on a few different codebases, and the code size increase ranged from 0.0% to 0.1%.

6 years agoAuto merge of #46025 - nrc:rustfmt-fix, r=Mark-Simulacrum
bors [Thu, 16 Nov 2017 03:49:13 +0000 (03:49 +0000)]
Auto merge of #46025 - nrc:rustfmt-fix, r=Mark-Simulacrum

Fix a bug where the rustfmt tarball was not being produced

r? @alexcrichton

This makes rustfmt a dep of 'extended', which seems to be necessary for the rustfmt dist step to actually get run.

6 years agoFix a bug where the rustfmt tarball was not being produced
Nick Cameron [Thu, 16 Nov 2017 03:02:18 +0000 (16:02 +1300)]
Fix a bug where the rustfmt tarball was not being produced

6 years agoAuto merge of #45692 - steveklabnik:ship-cargo-book, r=alexcrichton
bors [Thu, 16 Nov 2017 01:16:58 +0000 (01:16 +0000)]
Auto merge of #45692 - steveklabnik:ship-cargo-book, r=alexcrichton

 Start shipping the Cargo book

Fixes #44910
Fixes #39588

See both of those bugs for more details.

6 years agoUpdate the compiler-builtins to latest master.
Dan Gohman [Thu, 16 Nov 2017 00:07:48 +0000 (16:07 -0800)]
Update the compiler-builtins to latest master.

6 years agoAuto merge of #45918 - chrisvittal:impl-trait-pr, r=nikomatsakis
bors [Wed, 15 Nov 2017 22:47:54 +0000 (22:47 +0000)]
Auto merge of #45918 - chrisvittal:impl-trait-pr, r=nikomatsakis

Implement `impl Trait` in argument position (RFC1951, Universal quantification)

Implements the remainder of #44721, part of #34511.

**Note**: This PR currently allows argument position `impl Trait` in trait functions. The machinery is there to prevent this if we want to, but it currently does not.

Rename `hir::TyImplTrait` to `hir::TyImplTraitExistential` and add `hir::TyImplTraitUniversal(DefId, TyParamBounds)`. The `DefId` is needed to extract the index of the parameter in `ast_ty_to_ty`.

Introduce an `ImplTraitContext` enum to lowering to keep track of the kind and allowedness of `impl Trait` in that position. This new argument is passed through many places, all ending up in `lower_ty`.

Modify `generics_of` and `explicit_predicates_of` to collect the `impl Trait` args into anonymous synthetic generic parameters and to extend the predicates with the appropriate bounds.

Add a comparison of the 'syntheticness' of type parameters, that is, prevent the following.
```rust
trait Foo {
    fn foo(&self, &impl Debug);
}
impl Foo for Bar {
    fn foo<U: Debug>(&self, x: &U) { ... }
}
```
And vice versa.

Incedentally, supress `unused type parameter` errors if the type being compared is already a `TyError`.

**TODO**: I have tried to annotate open questions with **FIXME**s. The most notable ones that haven't been resolved are the names of the `impl Trait` types and the questions surrounding the new `compare_synthetic_generics` method.
1. For now, the names used for `impl Trait` parameters are `keywords::Invalid.name()`. I would like them to be `impl ...` if possible, but I haven't figured out a way to do that yet.
2. For `compare_synthetic_generics` I have tried to outline the open questions in the [function itself](https://github.com/chrisvittal/rust/blob/3fc9e3705f7bd01f3cb0ea470cf2892f17a92350/src/librustc_typeck/check/compare_method.rs#L714-L725)

r? @nikomatsakis

6 years agomove region resolution to be a sibling of `region_inference`
Niko Matsakis [Wed, 15 Nov 2017 21:58:14 +0000 (16:58 -0500)]
move region resolution to be a sibling of `region_inference`

Temporary make various fields public.

6 years agoextract lexical region resolution into its own sub-module
Niko Matsakis [Sun, 5 Nov 2017 10:05:31 +0000 (05:05 -0500)]
extract lexical region resolution into its own sub-module

6 years agomodify MIR type-checker to process obligations as they are incurred
Niko Matsakis [Sun, 5 Nov 2017 00:21:28 +0000 (20:21 -0400)]
modify MIR type-checker to process obligations as they are incurred

6 years agoapply rustfmt to `type_check`
Niko Matsakis [Sat, 4 Nov 2017 21:56:27 +0000 (17:56 -0400)]
apply rustfmt to `type_check`

6 years agothread location info through mir typeck (but do not use)
Niko Matsakis [Sat, 4 Nov 2017 13:08:11 +0000 (09:08 -0400)]
thread location info through mir typeck (but do not use)

6 years agomove the `OutlivesEnvironment` into `infer` so that `nll` can use it
Niko Matsakis [Sat, 4 Nov 2017 11:36:00 +0000 (07:36 -0400)]
move the `OutlivesEnvironment` into `infer` so that `nll` can use it

Unquestionably there is more cleanup to be done, but I'm not sure what
it should look like yet, so leaving it roughly as is.

6 years agorename mod `region_obligations` to `outlives::obligations`
Niko Matsakis [Sat, 4 Nov 2017 11:23:21 +0000 (07:23 -0400)]
rename mod `region_obligations` to `outlives::obligations`

6 years agoextract out the implied bounds code from `regionck`
Niko Matsakis [Sat, 4 Nov 2017 11:13:46 +0000 (07:13 -0400)]
extract out the implied bounds code from `regionck`

6 years agoregionck: only add implied bounds from root fn to `free_region_map`
Niko Matsakis [Sat, 4 Nov 2017 09:58:57 +0000 (05:58 -0400)]
regionck: only add implied bounds from root fn to `free_region_map`

6 years agodo not invoke `required_region_bounds` in `region_obligations`
Niko Matsakis [Sat, 4 Nov 2017 09:37:18 +0000 (05:37 -0400)]
do not invoke `required_region_bounds` in `region_obligations`

Instead, just search the param env predicates directly. This is
equivalent to what we were doing before but more efficient.

6 years agorefactor how we extract outlives bounds from trait definitions
Niko Matsakis [Fri, 3 Nov 2017 22:03:43 +0000 (18:03 -0400)]
refactor how we extract outlives bounds from trait definitions

This new way is **slightly** less expressive (I would be shocked if it
affects any code, though) when it comes to higher-ranked bounds or a
few other weird tricks. But we don't handle those consistently
regardless, and the new way does not require normalization and is just
wildly simpler.

6 years agomove the `region_obligations` processing code into `InferCtxt`
Niko Matsakis [Fri, 3 Nov 2017 09:31:19 +0000 (05:31 -0400)]
move the `region_obligations` processing code into `InferCtxt`

6 years agoextract `regionck_outlives` into a separate helper function
Niko Matsakis [Thu, 2 Nov 2017 10:06:09 +0000 (06:06 -0400)]
extract `regionck_outlives` into a separate helper function

This helps make its inputs and outputs more clear.

6 years agoassert that we are consuming all of the region obligations
Niko Matsakis [Wed, 1 Nov 2017 18:52:24 +0000 (14:52 -0400)]
assert that we are consuming all of the region obligations

When we get around to resolving regions, we really ought to take region
obligations into account. There is one case where they are presently
being ignored. Keep ignoring them there for now but leave a TODO.

6 years agoconvert EXTRA_REQUIREMENT_IN_IMPL into a hard error
Niko Matsakis [Wed, 1 Nov 2017 18:23:30 +0000 (14:23 -0400)]
convert EXTRA_REQUIREMENT_IN_IMPL into a hard error

cc #37166

6 years agomove region constraints into inference context
Niko Matsakis [Wed, 1 Nov 2017 17:41:07 +0000 (13:41 -0400)]
move region constraints into inference context

6 years agofulfill: remove dead code
Niko Matsakis [Wed, 1 Nov 2017 16:26:31 +0000 (12:26 -0400)]
fulfill: remove dead code

6 years agoChange clippy to broken after hir::Ty enum change
Christopher Vittal [Wed, 15 Nov 2017 20:38:54 +0000 (15:38 -0500)]
Change clippy to broken after hir::Ty enum change

6 years agoadd a new test featuring two impl traits to show what it looks like
Niko Matsakis [Wed, 15 Nov 2017 18:28:35 +0000 (13:28 -0500)]
add a new test featuring two impl traits to show what it looks like