Commit graph

100943 commits

Author SHA1 Message Date
Santiago Pastorino
5f5903df31
Add ignore-tidy-filelength on ty/context
This is so we avoid a massive break of other people's code. Gonna run
rustfmt and split the file on a different PR.
2019-10-22 10:33:37 -03:00
Santiago Pastorino
180fc413fb
Move Place::elem methods and friends to TyCtxt 2019-10-22 10:33:36 -03:00
Santiago Pastorino
d32c2865d6
Intern place projection 2019-10-22 10:33:36 -03:00
Santiago Pastorino
a19aed2226
Add intern table for List<PlaceElem<'tcx>> 2019-10-22 10:33:36 -03:00
Santiago Pastorino
190802cfca
Pattern match over PlaceRef rather than Place
This prepares the code base for when projection is interned. Place's
projection field is going to be `&List<PlaceElem<'tcx>>` so we won't be
able to pattern match against it.
2019-10-22 10:33:30 -03:00
Santiago Pastorino
270541221f
Move as_local impl to from Place to PlaceRef 2019-10-21 20:20:47 -03:00
Santiago Pastorino
0b5ee56da8
PlaceElem<'tcx> should be Copy 2019-10-21 18:53:44 -03:00
bors
10f12fe3e7 Auto merge of #65661 - JohnTitor:rollup-68la1fq, r=JohnTitor
Rollup of 5 pull requests

Successful merges:

 - #65544 (Added doc on keyword break)
 - #65620 (Correctly note code as Ok not error for E0573)
 - #65624 ([mir-opt] Improve SimplifyLocals pass so it can remove unused consts)
 - #65650 (use unwrap_or in lint code)
 - #65652 (Fix `canonicalize_const_var` leaking inference variables)

Failed merges:

r? @ghost
2019-10-21 15:50:37 +00:00
Yuki Okushi
1c94a4475b
Rollup merge of #65652 - skinny121:const_infer_leak, r=eddyb
Fix `canonicalize_const_var` leaking inference variables

Fixes #61338
Fixes #61516
Fixes #62536
Fixes #64087
Fixes #64863
Fixes #65623

I added regression tests for all these issues apart from #64863, which is very similar to #61338.

r? @varkor
2019-10-21 19:53:06 +09:00
Yuki Okushi
865e46b4ba
Rollup merge of #65650 - guanqun:use-unwrap-or, r=eddyb
use unwrap_or in lint code
2019-10-21 19:53:05 +09:00
Yuki Okushi
bcc59ac229
Rollup merge of #65624 - wesleywiser:improve_simplify_locals, r=oli-obk
[mir-opt] Improve SimplifyLocals pass so it can remove unused consts

The `ConstProp` can cause many locals to be initialized to a constant
value and then never read from. `ConstProp` can also evaluate ZSTs into
constant values. Previously, many of these would be removed by other
parts of the MIR optimization pipeline. However, evaluating ZSTs
(especially `()`) into constant values defeated those parts of the
optimizer and so in a2e3ed5, I added a
hack to `ConstProp` that skips evaluating ZSTs to avoid that regression.

This commit changes `SimplifyLocals` so that it doesn't consider writes
of const values to a local to be a use of that local. In doing so,
`SimplifyLocals` is able to remove otherwise unused locals left behind
by other optimization passes (`ConstProp` in particular).

r? @oli-obk
2019-10-21 19:53:04 +09:00
Yuki Okushi
7ea9cfc1fb
Rollup merge of #65620 - ryoqun:remove-unneeded-comment, r=varkor
Correctly note code as Ok not error for E0573

Hi, this is my first pull request to the Rust project.

The fix is very small one just to fix an oversight in a comment.

Namely, [this documentation PR](https://github.com/rust-lang/rust/pull/65234) added a longer explanation for E0573. It illustrated the error using erroneous/corrected contrasting examples. But it accidentally forgot to remove `// error` from the corrected example.

Sadly, I found the error after the PR got merged. [As suggested by the original author](https://github.com/rust-lang/rust/pull/65234/files#r336518549) of the PR, I created an PR to fix this.

Part of #61137.
2019-10-21 19:53:02 +09:00
Yuki Okushi
d56466ff5f
Rollup merge of #65544 - dorfsmay:doc_keyword_break, r=Dylan-DPC
Added doc on keyword break

RE: #34601
2019-10-21 19:53:01 +09:00
bors
b7a9c285a5 Auto merge of #65594 - RalfJung:miri, r=oli-obk
bump miri

Fixes https://github.com/rust-lang/rust/issues/65529
2019-10-21 07:50:52 +00:00
ben
aa3d28f9a8 Fix canonicalize_const_var from leaking inference variables through
it's type.
2019-10-21 19:52:32 +13:00
Guanqun Lu
642da6e12a use unwrap_or in lint code 2019-10-21 14:18:09 +08:00
bors
1ba7b4ecef Auto merge of #65630 - ecstatic-morse:graphviz-tidy, r=Mark-Simulacrum
Check all files in `src/test` for `borrowck_graphviz_postflow`

This attribute causes DOT files to be generated in the top-level directory. It is intended to be used only temporarily and should never appear on master. This also tells git to ignore DOT files in the root or the  `mir_dump` directory, which `-Z dump-mir` uses by default.

This will prevent #65071 from occurring again. It needs to be merged after #65629, otherwise `tidy` will start failing.

r? @Mark-Simulacrum
2019-10-21 04:01:37 +00:00
Wesley Wiser
2ec73395b9 Improve SimplifyLocals pass so it can remove unused consts
The `ConstProp` can cause many locals to be initialized to a constant
value and then never read from. `ConstProp` can also evaluate ZSTs into
constant values. Previously, many of these would be removed by other
parts of the MIR optimization pipeline. However, evaluating ZSTs
(especially `()`) into constant values defeated those parts of the
optimizer and so in a2e3ed5c05, I added a
hack to `ConstProp` that skips evaluating ZSTs to avoid that regression.

This commit changes `SimplifyLocals` so that it doesn't consider writes
of const values to a local to be a use of that local. In doing so,
`SimplifyLocals` is able to remove otherwise unused locals left behind
by other optimization passes (`ConstProp` in particular).
2019-10-20 23:49:42 -04:00
Wesley Wiser
4592a9eb3f Cleanup ConstProp::visit_statement() 2019-10-20 23:49:12 -04:00
Ryo Onodera
101e1f6f8f
Correctly note code as Ok not error for E0573 2019-10-21 09:25:57 +09:00
bors
770b9e3012 Auto merge of #65644 - Centril:rollup-gez1xhe, r=Centril
Rollup of 8 pull requests

Successful merges:

 - #65314 (rustdoc: forward -Z options to rustc)
 - #65592 (clarify const_prop ICE protection comment)
 - #65603 (Avoid ICE when include! is used by stdin crate)
 - #65614 (Improve error message for APIT with explicit generic arguments)
 - #65629 (Remove `borrowck_graphviz_postflow` from test)
 - #65633 (Remove leading :: from paths in doc examples)
 - #65638 (Rename the default argument 'def' to 'default')
 - #65639 (Fix parameter name in documentation)

Failed merges:

r? @ghost
2019-10-20 23:40:12 +00:00
Mazdak Farrokhzad
836e45d26b
Rollup merge of #65639 - adrianheine:patch-2, r=jonas-schievink
Fix parameter name in documentation
2019-10-21 01:39:21 +02:00
Mazdak Farrokhzad
5a29bd9f9b
Rollup merge of #65638 - dsincl12:master, r=Centril
Rename the default argument 'def' to 'default'

Fixes: #65492
2019-10-21 01:39:20 +02:00
Mazdak Farrokhzad
8bdae3af17
Rollup merge of #65633 - Rantanen:doc-example-paths, r=Centril
Remove leading :: from paths in doc examples

Noted some pre-2018 path syntax in the doc examples, for example:
https://doc.rust-lang.org/std/process/fn.exit.html

```rust
fn main() {
    ::std::process::exit(match run_app() {
       Ok(_) => 0,
       ...
```

Couldn't find an existing issue on this (then again, "::" makes for an annoying thing to search for) so if there is already something fixing this and/or there's a reason to not fix it, just close this PR.

(Also fixed indentation in the `process::exit()` docs)
2019-10-21 01:39:18 +02:00
Mazdak Farrokhzad
041c654105
Rollup merge of #65629 - ecstatic-morse:remove-graphviz, r=Mark-Simulacrum
Remove `borrowck_graphviz_postflow` from test

Resolves #65071 (again).

Sorry. I've added a commit hook to prevent this from happening in the future.

r? @petrochenkov
2019-10-21 01:39:17 +02:00
Mazdak Farrokhzad
4de42a7a0b
Rollup merge of #65614 - varkor:apit-explicit-generics, r=matthewjasper
Improve error message for APIT with explicit generic arguments

This is disallowed with type or const generics. cc https://github.com/rust-lang/rust/issues/61410.
2019-10-21 01:39:16 +02:00
Mazdak Farrokhzad
c9c32a7e7d
Rollup merge of #65603 - mystor:resolve_path_ice, r=petrochenkov
Avoid ICE when include! is used by stdin crate

This should hopefully also eliminate the ICE when using `include_bytes!`, `include_str!` and `#[doc(include = "...")]` with a stdio input.

I couldn't see a clear way to write a compile-fail test using compiletest with a stdio input, so I haven't written any tests for this change.

Fixes #63900
2019-10-21 01:39:14 +02:00
Mazdak Farrokhzad
f8d1c3589e
Rollup merge of #65592 - RalfJung:const-prop-comment, r=wesleywiser
clarify const_prop ICE protection comment

This is based on discussion at https://github.com/rust-lang/rust/pull/64890/files#r334555787.

That said, why are function arguments the only unsized locals that could remain uninitialized? Couldn't we also fail to initialize some local but still go on with const_prop, and then hit a line that takes a reference to that? Cc @wesleywiser @oli-obk ; I don't know enough about const-prop to understand why this can happen only for function arguments.

~~The PR includes https://github.com/rust-lang/rust/pull/64890; the only new commit is 05e4e6ba0d5.~~
2019-10-21 01:39:13 +02:00
Mazdak Farrokhzad
194d1935d3
Rollup merge of #65314 - tmiasko:rustdoc-z, r=ollie27
rustdoc: forward -Z options to rustc

Currently rustdoc does not forward `-Z` options to rustc when building
test executables. This makes impossible to use rustdoc to run test
samples when crate under test is instrumented with one of sanitizers
`-Zsanitizer=...`, since the final linking step will not include
sanitizer runtime library.

Forward `-Z` options to rustc to solve the issue.

Helps with #43031.
2019-10-21 01:39:11 +02:00
Adrian Heine né Lang
e697ffbbcb
Fix parameter name in documentation 2019-10-20 23:13:41 +02:00
David Sinclair
2a5c31ca51 Rename the default argument 'def' to 'default'
Fixes: #65492
2019-10-20 22:22:44 +02:00
bors
7979016aff Auto merge of #65632 - JohnTitor:rollup-adb16gb, r=JohnTitor
Rollup of 5 pull requests

Successful merges:

 - #65460 (Clean up `contains()` `insert()` chains on HashSet)
 - #65463 (Avoid unnecessary arena allocations in `expand_pattern()`.)
 - #65579 (Changed `resolve_type_vars_with_obligations` to also resolve const inference variables)
 - #65605 (Remove unreachable unit tuple compare binop codegen)
 - #65626 (trivial typo fix)

Failed merges:

r? @ghost
2019-10-20 19:45:09 +00:00
Mikko Rantanen
040d88dda1
Remove leading :: from paths in doc examples 2019-10-20 21:13:47 +03:00
Yuki Okushi
c609a5aafc
Rollup merge of #65626 - guanqun:patch-1, r=varkor
trivial typo fix
2019-10-21 03:10:59 +09:00
Yuki Okushi
4f74fd745f
Rollup merge of #65605 - bjorn3:fix_63906, r=eddyb
Remove unreachable unit tuple compare binop codegen

Closes #63906
Fixes #63551

This is based on #63906 by @luigishat, who had trouble with rebasing his PR.
2019-10-21 03:10:58 +09:00
Yuki Okushi
3e8acaf68c
Rollup merge of #65579 - skinny121:resolve_const_vars, r=varkor
Changed `resolve_type_vars_with_obligations` to also resolve const inference variables

Fixes #65380
r? @varkor
2019-10-21 03:10:57 +09:00
Yuki Okushi
cc42adf3a2
Rollup merge of #65463 - nnethercote:rm-arena-allocation-from-expand_pattern, r=varkor
Avoid unnecessary arena allocations in `expand_pattern()`.

`expand_pattern()` has two callsites. One of them needs arena
allocation, but the other does not.

This commit moves the arena allocation out of the function. This avoids
the allocation of many 4 KiB page arena chunks that only hold a single
small allocation. It reduces the number of bytes allocated by up to 2%
for various benchmarks, albeit without only a very small improvement in
runtime.
2019-10-21 03:10:55 +09:00
Yuki Okushi
2518bbd5a3
Rollup merge of #65460 - sinkuu:contains_insert, r=varkor
Clean up `contains()` `insert()` chains on HashSet

They can be merged to a single `insert()` call, which may avoid double-hashing/lookup of the value.
2019-10-21 03:10:54 +09:00
Dylan MacKenzie
efcae577bf Ignore DOT files in .gitignore 2019-10-20 11:03:13 -07:00
Dylan MacKenzie
c9e361fcd1 Check all files in src/test for borrowck_graphviz_postflow
This attribute causes DOT files to be generated in the top-level
directory. It is intended to be used only temporarily and should never
appear on master.

This will prevent #65071 from occurring again.
2019-10-20 10:53:10 -07:00
Dylan MacKenzie
51a5b49bda Remove borrowck_graphviz_postflow from test 2019-10-20 09:44:21 -07:00
guanqun
379733e8a0
typo fix 2019-10-20 23:03:33 +08:00
bors
89e645ace8 Auto merge of #65622 - Centril:rollup-l8orba7, r=Centril
Rollup of 6 pull requests

Successful merges:

 - #64996 (Inline `ptr::null(_mut)` even in debug builds)
 - #65551 (Avoid realloc in `CString::new`)
 - #65593 (add test for calling non-const fn)
 - #65595 (move `parse_cfgspecs` to `rustc_interface`)
 - #65600 (Remove unneeded `ref` from docs)
 - #65602 (Fix plural mistake in emitter.rs)

Failed merges:

r? @ghost
2019-10-20 14:07:46 +00:00
Mazdak Farrokhzad
ba42fc27fd
Rollup merge of #65602 - varkor:other-candidates, r=Centril
Fix plural mistake in emitter.rs
2019-10-20 12:40:22 +02:00
Mazdak Farrokhzad
1c0e67ad06
Rollup merge of #65600 - integer32llc:bye-bye-ref, r=Centril
Remove unneeded `ref` from docs

Will reduce confusion like in https://users.rust-lang.org/t/help-understanding-the-ref-t-syntax/33779 since match ergonomics means you (almost) never have to say `ref` anymore!

There might be more like this, but I don't have a checkout on my computer right this second and I'm on slow wifi and GitHub search isn't powerful enough and that's my story.
2019-10-20 12:40:20 +02:00
Mazdak Farrokhzad
ed9cc70768
Rollup merge of #65595 - Centril:cfgspecs, r=Mark-Simulacrum
move `parse_cfgspecs` to `rustc_interface`

Part of https://github.com/rust-lang/rust/pull/65324.

r? @Mark-Simulacrum
2019-10-20 12:40:19 +02:00
Mazdak Farrokhzad
663125cac2
Rollup merge of #65593 - RalfJung:non-const-fn, r=oli-obk
add test for calling non-const fn

The good news is that there is an error. But I expected to see [this error](9578272d68/src/librustc_mir/const_eval.rs (L346)) surface. @oli-obk any idea why that message is not shown anywhere?

r? @oli-obk
2019-10-20 12:40:18 +02:00
Mazdak Farrokhzad
766073aeb4
Rollup merge of #65551 - sinkuu:cstring_spec, r=sfackler
Avoid realloc in `CString::new`

If `&[u8]` or `&str` is given, `CString::new` allocates a new `Vec` with the exact capacity, and then `CString::from_vec_unchecked` calls `.reserve_exact(1)` for nul byte. This PR avoids the reallocation by allocationg `len + 1` bytes beforehand. In microbenchmark this PR speeds up `CString::new(&[u8])` by 30%.
2019-10-20 12:40:16 +02:00
Mazdak Farrokhzad
f01ffbc7f1
Rollup merge of #64996 - lzutao:inline-ptr-null, r=oli-obk
Inline `ptr::null(_mut)` even in debug builds

I think we should treat `ptr::null(_mut)` as a constant. As It may help reduce code size
in debug build.
See godbolt link: https://godbolt.org/z/b9YMtD
2019-10-20 12:40:15 +02:00
bors
857a55b8f0 Auto merge of #65497 - choller:master, r=tmiasko
Avoid injecting sanitizer runtimes into staticlibs (#64629).

This fixes the remaining issue in `creader.rs` and also fixes the expected test failure. I have explicitly turned the `$(CC)` call into a negative check with the `!` to ensure that this command is really failing (if it is not, then either the runtime is attached to the lib or the lib has not been instrumented and both would be an error).

I've also borrowed `program.rs` and the additional `rustc` invocation from @tmiasko 's PR since he pointed out that using `-fsanitize=address` with `$(CC)` for linking could fail if the sanitizer runtimes on the system are incompatible.

With this toolchain I was able to compile Firefox locally without any linker errors. I am still seeing races with Rust in TSan but I assume that is because I did not build with `-Z build-std`.
2019-10-20 10:11:10 +00:00