Commit Graph

91466 Commits

Author SHA1 Message Date
ljedrz
7dd8b776b5 hir: replace NodeId with HirId in ItemId 2019-03-25 13:08:46 +01:00
Tobias Bucher
0bb36a2f90 Clarify {Ord,f32,f64}::clamp docs a little
Explicitly call out when it returns NaN, adhere to the panic doc
guidelines.
2019-03-25 12:52:42 +01:00
Felix S Klock II
0e83e96852
add missing braces
add missing braces analogous to those suggested by killercup
2019-03-25 11:50:11 +01:00
gnzlbg
cfa76c438a black_box should inhibit optimizations on platforms without inline assembly 2019-03-25 11:49:08 +01:00
Pascal Hertleif
6315221b39
Update src/libcore/option.rs
Co-Authored-By: pnkfelix <pnkfelix@pnkfx.org>
2019-03-25 11:48:08 +01:00
gnzlbg
f2443831e9 Remove dupplicated config 2019-03-25 11:44:06 +01:00
gnzlbg
f5d6b3af69 Moves test::black_box to core::hint
This changes removes a cyclic dependency between the "test" and "libtest"
crates, where "libtest" depends on "test" for "black_box", but "test" depends on
"libtest" for everything else.

I've chosen the "hint" module because there seems to be enough consensus in the
discussion of RFC2360 that this module is where such an intrinsic would belong,
but this PR does not implement that RFC! (note: if that RFC ever gets merged,
the API, docs, etc. of this API will need to change).

For backwards compatibility reasons I've chosen to also keep the "test" feature
gate for these instead of adding a new feature gate. If we change the feature
gate, we'll potentially all benchmarks, and while that's something that we could
do, it seems unnecessary to do that now - if RFC2360 gets merged, we'll need to
do that anyways.
2019-03-25 11:44:06 +01:00
bors
3f36ac4e83 Auto merge of #59242 - euclio:asm-ice, r=nagisa
make asm diagnostic instruction optional

`DiagnosticInfoInlineAsm::getInstruction` may return a null pointer, so
the instruction shouldn't be blindly unwrapped.

Reopening from #55193. I was unable to trigger the assertion on Windows after rebasing.

Fixes #23458.
Fixes #55216.
2019-03-25 09:05:00 +00:00
Philipp Hansch
98d7c5463b
s/lints/diagnostics
Not all suggestions come from lints
2019-03-25 06:58:30 +01:00
Philipp Hansch
d485ebfc21
Fix two bootstrap tests 2019-03-25 06:57:32 +01:00
bors
60eca54a7c Auto merge of #59240 - euclio:struct-field-span, r=oli-obk
use the identifier span for missing struct field
2019-03-25 05:40:12 +00:00
Andy Russell
695dfe7dff
compiletest: make path normalization smarter 2019-03-25 01:06:45 -04:00
Esteban Küber
4beea1720a Deduplicate code for path suggestion 2019-03-24 19:43:02 -07:00
Esteban Küber
5390414379 Provide suggestion when using field access instead of path
When trying to access an associated constant as if it were a field of
an instance, provide a suggestion for the correct syntax.
2019-03-24 19:21:54 -07:00
bors
46914715e2 Auto merge of #59195 - estebank:for-loop-move, r=petrochenkov
When moving out of a for loop head, suggest borrowing it

When encountering code like the following, suggest borrowing the for loop
head to avoid moving it into the for loop pattern:

```
fn main() {
    let a = vec![1, 2, 3];
    for i in &a {
        for j in a {
            println!("{} * {} = {}", i, j, i * j);
        }
    }
}
```

Fix #25534.
2019-03-25 00:38:15 +00:00
bors
3752b3d3a5 Auto merge of #59382 - davidtwco:rfc-2008-refactoring, r=petrochenkov
Separate `DefId`s for variants and their constructors

Part of #44109. Split off from #59376. See [Zulip topic](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/rfc-2008/near/132663140) for previous discussion.

r? @petrochenkov
2019-03-24 21:26:57 +00:00
Esteban Küber
66202c113a Add nll test 2019-03-24 12:58:30 -07:00
Esteban Küber
ae883dc826 When moving out of a for loop head, suggest borrowing it
When encountering code like the following, suggest borrowing the for loop
head to avoid moving it into the for loop pattern:

```
fn main() {
    let a = vec![1, 2, 3];
    for i in &a {
        for j in a {
            println!("{} * {} = {}", i, j, i * j);
        }
    }
}
```
2019-03-24 11:46:13 -07:00
David Wood
23cae1d3f0
Re-order fields in Def::Ctor.
This commit moves the `DefId` field of `Def::Ctor` to be the first
field.
2019-03-24 19:16:44 +01:00
David Wood
88f8f07794
Move CtorOf into hir::def.
This commit moves the definition of `CtorOf` from `rustc::hir` to
`rustc::hir::def` and adds imports wherever it is used.
2019-03-24 18:54:56 +01:00
bors
0576ac109b Auto merge of #59397 - kennytm:rollup, r=kennytm
Rollup of 7 pull requests

Successful merges:

 - #59213 (Track changes to robots.txt)
 - #59239 (Remove inline assembly from hint::spin_loop)
 - #59251 (Use a valid name for graphviz graphs)
 - #59296 (Do not encode gensymed imports in metadata)
 - #59328 (Implement specialized nth_back() for Box and Windows.)
 - #59355 (Fix ICE with const generic param in struct)
 - #59377 (Correct minimum system LLVM version in tests)
2019-03-24 17:53:45 +00:00
David Wood
db4770f699
Remove CtorOf from Node::Ctor.
This commit removes `CtorOf` from `Node::Ctor` as the parent of the
constructor can be determined by looking at the node's parent in the few
places where knowing this is necessary.
2019-03-24 18:21:59 +01:00
Andy Russell
4728433c9e
make asm diagnostic instruction optional
`DiagnosticInfoInlineAsm::getInstruction` may return a null pointer, so
the instruction shouldn't be blindly unwrapped.
2019-03-24 12:21:03 -04:00
Philipp Hansch
02b8533ac8
Add a way to track Rustfix UI test coverage
This came out of the first Rustfix WG meeting.

One of the goals is to enable Rustfix tests for all UI tests that
trigger lints with `MachineApplicable` suggestions. In order to do that
we first want to create a tracking issue that lists all files with
missing `// run-rustfix` headers.

This PR adds a `--rustfix-coverage` flag to `./x.py` and compiletest to
list the files with the missing headers in `/tmp/rustfix_missing_coverage.txt`.

From that file we can create the tracking issue and at some point also
enforce the `// run-rustfix` flag on UI tests with `MachineApplicable`
lints.
2019-03-24 17:04:40 +01:00
Vadim Petrochenkov
782a6debe4 Revert changes to creation of fictive constructors for struct variants 2019-03-24 18:41:09 +03:00
Andy Russell
8d7c2bb06a
replace redundant note in deprecation warning 2019-03-24 11:02:37 -04:00
Vadim Petrochenkov
2cbc25e6fc Merge DefPathData::VariantCtor and DefPathData::StructCtor 2019-03-24 17:59:18 +03:00
kennytm
00478a0f3c
Rollup merge of #59377 - smaeul:patch/system-llvm, r=nikic
Correct minimum system LLVM version in tests

Since commit 9452a8dfa3, the new debug info format is only generated
for LLVM 8 and newer versions. However, the tests still assume that LLVM
7 will use the new debug info format. Fix the tests (and a comment in
the code) to match the actual version check.
2019-03-24 22:43:48 +08:00
Vadim Petrochenkov
5bcf9f4f11 Slightly more uniform treatment of struct and variant constructors 2019-03-24 17:36:43 +03:00
bors
c7b5f4d0f7 Auto merge of #58305 - scalexm:chalk-continued, r=nikomatsakis
(WIP) Small fixes in chalkification

Small fixes around region constraints and builtin impls. There are still some type inference errors, for example the following code errors out:
```rust
fn main() {
    let mut x: Vec<i32> = Vec::new();
    //                    ^^^^^^^^ cannot infer type for `std::vec::Vec<_>`
}
```
but explicitly specifying `Vec::<i32>::new` works.

With these few fixes, the following code now passes type-checking:
```rust
fn main() {
    let mut x: Vec<i32> = Vec::<i32>::new();
    x.push(5);
    println!("{:?}", x);
}
```

I also fixed the implied bounds bug as discussed on Zulip and in https://github.com/rust-lang-nursery/chalk/pull/206

cc @tmandry
r? @nikomatsakis
2019-03-24 14:26:11 +00:00
Vadim Petrochenkov
7f5a8dcdb9 Remove VariantDef::parent_did 2019-03-24 14:41:35 +03:00
kennytm
70cf325502
Rollup merge of #59355 - varkor:const-param-struct-ice, r=petrochenkov
Fix ICE with const generic param in struct

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

r? @petrochenkov
2019-03-24 19:00:18 +08:00
kennytm
cb2dde63d5
Rollup merge of #59328 - koalatux:iter-nth-back, r=scottmcm
Implement specialized nth_back() for Box and Windows.

Hi there, this is my first pull request to rust :-)

I started implementing some specializations for DoubleEndedIterator::nth_back() and these are the first two. The problem has been discussed in #54054 and nth_back() is tracked in #56995.

I'm stuck with the next implementation so I though I do a PR for the ones I'm confident with to get some feedback.
2019-03-24 19:00:10 +08:00
kennytm
1d286f7918
Rollup merge of #59296 - petrochenkov:stdup, r=estebank
Do not encode gensymed imports in metadata

(Unless they are underscore `_` imports which are re-gensymed on crate loading, see https://github.com/rust-lang/rust/pull/56392.)

We cannot encode gensymed imports properly in metadata and if we encode them improperly, we can get erroneous name conflicts downstream.
Gensymed imports are produced by the compiler, so we control their set, and can be sure that none of them needs being encoded for use from other crates.

A workaround that fixes https://github.com/rust-lang/rust/issues/59243.
2019-03-24 19:00:04 +08:00
kennytm
42b7d2c170
Rollup merge of #59251 - matthewjasper:fix-graphviz, r=petrochenkov
Use a valid name for graphviz graphs

Hiridification has broken graphviz output because `HirId` has a more complex display implemetation than `NodeId`. Since the id was just used to generate a distinct identifier, we just pull out the various constituent indexed.
2019-03-24 18:59:42 +08:00
Vadim Petrochenkov
c667c2fc08 Remove methods is_struct/is_tuple/is_unit from VariantData 2019-03-24 12:10:16 +03:00
David Wood
5c3d1e5d76 Separate variant id and variant constructor id.
This commit makes two changes - separating the `NodeId` that identifies
an enum variant from the `NodeId` that identifies the variant's
constructor; and no longer creating a `NodeId` for `Struct`-style enum
variants and structs.

Separation of the variant id and variant constructor id will allow the
rest of RFC 2008 to be implemented by lowering the visibility of the
variant's constructor without lowering the visbility of the variant
itself.

No longer creating a `NodeId` for `Struct`-style enum variants and
structs mostly simplifies logic as previously this `NodeId` wasn't used.
There were various cases where the `NodeId` wouldn't be used unless
there was an unit or tuple struct or enum variant but not all uses of
this `NodeId` had that condition, by removing this `NodeId`, this must
be explicitly dealt with. This change mostly applied cleanly, but there
were one or two cases in name resolution and one case in type check
where the existing logic required a id for `Struct`-style enum variants
and structs.
2019-03-24 12:10:16 +03:00
kennytm
48dc8efc85
Rollup merge of #59239 - gnzlbg:fix_spin_loop, r=nagisa
Remove inline assembly from hint::spin_loop

This PR removes the inline assembly which was not required since these
instructions are available in core::arch, and extends support of
the spin_loop hint to arm targets with the v6 feature which also
support the yield instruction.
2019-03-24 15:32:45 +08:00
kennytm
6c5e1d151a
Rollup merge of #59213 - kornelski:robots, r=Mark-Simulacrum
Track changes to robots.txt

Currently `robots.txt` of doc.rust-lang.org is not part of any repo, so there's [no way to contribute any changes to it](https://internals.rust-lang.org/t/deadlock-about-fixing-outdated-documentation-links-in-search-engines/9374), such as needed for #44894 and countless dupes of this issue.

I propose adding it to this repo. I'm not in control of the infrastructure, so I can't help to automate deployment of it, but even just having the file under source control is IMHO a step forward.
2019-03-24 15:32:42 +08:00
bors
fb5ed488ff Auto merge of #59199 - estebank:untrack-errors, r=eddyb
Remove `track_errors` from `check_match`, `typeck_item_bodies` and `register_plugins`

In the spirit of continuing through errors in type checking (#39275), remove `track_errors` from a couple of locations in the codebase.
2019-03-24 05:38:10 +00:00
Saleem Jaffer
fb93f10dac code review fixes 2019-03-24 08:59:11 +05:30
Chris Gregory
00716b480f Make ptr::eq documentation mention smart-pointer behavior
Resolves #59214
2019-03-23 19:43:32 -04:00
bors
93f5ba0ee5 Auto merge of #59084 - estebank:diagnostic-spans, r=davidtwco
Tweak some diagnostic spans
2019-03-23 22:26:11 +00:00
Esteban Küber
59f0f2edc1 Fix span after rebase 2019-03-23 14:10:39 -07:00
Peter Hall
3eb4eae96d Fixes #59361 2019-03-23 20:41:57 +00:00
Esteban Küber
81394ce9ae Fix rebase 2019-03-23 13:05:30 -07:00
Esteban Küber
0a4ecf3438 Mark duplicate import removal suggestion tool only 2019-03-23 13:05:30 -07:00
Esteban Küber
ce90db1ff1 Deduplicate const eval error spans for better output 2019-03-23 13:05:30 -07:00
Esteban Küber
44730271f7 Hide obvious suggestion from cli output 2019-03-23 13:05:30 -07:00
Esteban Küber
3211f38828 Tweak unnecessary import suggestion 2019-03-23 13:05:30 -07:00