Commit Graph

86733 Commits

Author SHA1 Message Date
kennytm
ef2cbec5a6
Rollup merge of #55869 - SimonSapin:iterate, r=alexcrichton
Add std::iter::unfold

This adds an **unstable** ~`std::iter::iterate`~ `std::iter::unfold` function and ~`std::iter::Iterate`~ `std::iter::Unfold` type that trivially wrap a ~`FnMut() -> Option<T>`~ `FnMut(&mut State) -> Option<T>` closure to create an iterator. ~Iterator state can be kept in the closure’s environment or captures.~

This is intended to help reduce amount of boilerplate needed when defining an iterator that is only created in one place. Compare the existing example of the `std::iter` module: (explanatory comments elided)

```rust
struct Counter {
    count: usize,
}

impl Counter {
    fn new() -> Counter {
        Counter { count: 0 }
    }
}

impl Iterator for Counter {
    type Item = usize;

    fn next(&mut self) -> Option<usize> {
        self.count += 1;
        if self.count < 6 {
            Some(self.count)
        } else {
            None
        }
    }
}
```

… with the same algorithm rewritten to use this new API:

```rust
fn counter() -> impl Iterator<Item=usize> {
    std::iter::unfold(0, |count| {
        *count += 1;
        if *count < 6 {
            Some(*count)
        } else {
            None
        }
    })
}
```

-----

This also add unstable `std::iter::successors` which takes an (optional) initial item and a closure that takes an item and computes the next one (its successor).

```rust
let powers_of_10 = successors(Some(1_u16), |n| n.checked_mul(10));
assert_eq!(powers_of_10.collect::<Vec<_>>(), &[1, 10, 100, 1_000, 10_000]);
```
2018-11-24 01:31:50 +08:00
kennytm
738afd4f69
Rollup merge of #55838 - dralley:fix-cfg-step, r=Kimundi
Fix #[cfg] for step impl on ranges

```#[cfg(target_pointer_witdth = ...)]``` is misspelled
2018-11-24 01:31:48 +08:00
kennytm
91bceb8fc2
Rollup merge of #55767 - tromey:disable-some-pretty-printers, r=alexcrichton
Disable some pretty-printers when gdb is rust-enabled

A rust-enabled gdb already knows how to display string slices,
structs, tuples, and enums (and after #54004, the pretty-printers
can't handle enums at all).  This patch disables these pretty-printers
when gdb is rust-enabled.

The "gdb-pretty-struct-and-enums-pre-gdb-7-7.rs" test is renamed,
because it does not seem to depend on any behavior of that version of
gdb, and because gdb 7.7 is 4 years old now.
2018-11-24 01:31:47 +08:00
bors
821bad3a5b Auto merge of #56184 - matthiaskrgr:clippy, r=oli-obk
submodules: update clippy from 2f6881c6 to 754b4c07

Changes:
````
rustup https://github.com/rust-lang/rust/pull/54071/
dependencies: update pulldown-cmark from 0.1 to 0.2
s/file_map/source_map
````

r? @oli-obk
2018-11-23 14:22:04 +00:00
Matthias Krüger
2598a7a56d submodules: update clippy from 2f6881c6 to 754b4c07
Changes:
````
rustup https://github.com/rust-lang/rust/pull/54071/
dependencies: update pulldown-cmark from 0.1 to 0.2
s/file_map/source_map
````
2018-11-23 13:05:31 +01:00
bors
aecbcd1ce2 Auto merge of #55808 - estebank:type-arguments, r=petrochenkov
Suggest correct syntax when writing type arg instead of assoc type

- When confusing an associated type with a type argument, suggest the appropriate syntax. Given `Iterator<isize>`, suggest `Iterator<Item = isize>`.
- When encountering multiple missing associated types, emit only one diagnostic.
- Point at associated type def span for context.
- Point at each extra type argument.

Follow up to #48288, fix #20977.
2018-11-23 11:26:48 +00:00
bors
6a2d1b4e15 Auto merge of #54071 - eddyb:alignsssss, r=oli-obk
rustc_target: separate out an individual alignment quantity type from Align.

Before this PR, `rustc_target::abi::Align` combined "power-of-two alignment quantity" semantics, with a distinction between ABI (required) and preferred alignment (by having two quantities).

After this PR, `Align` is only *one* such quantity, and a new `AbiAndPrefAlign` type is introduced to hold the pair of ABI and preferred `Align` quantities.

`Align` is used everywhere one quantity is necessary/sufficient, simplifying some of the code in codegen/miri, while `AbiAndPrefAlign` only in layout computation (to propagate preferred alignment).

r? @oli-obk cc @nagisa @RalfJung @nikomatsakis
2018-11-23 01:02:21 +00:00
Guillaume Gomez
4381772695 Fix invalid panic setup message 2018-11-23 00:13:44 +01:00
Esteban Küber
510f836d23 Do not point at associated types from other crates
This is a somewhat arbitrary restriction in order to be consistent in the
output of the tests regardless of target platform.
2018-11-22 14:30:33 -08:00
Esteban Küber
a5d35631fe Reword and fix test 2018-11-22 14:14:27 -08:00
Esteban Küber
48fa974211 Suggest correct syntax when writing type arg instead of assoc type
When confusing an associated type with a type argument, suggest the
appropriate syntax.

Given `Iterator<isize>`, suggest `Iterator<Item = isize>`.
2018-11-22 14:14:27 -08:00
Esteban Küber
b6f4b29c6d Point at the associated type's def span 2018-11-22 14:14:27 -08:00
Esteban Küber
286f7ae1dd Join multiple E0191 errors in the same location under a single diagnostic 2018-11-22 14:14:27 -08:00
Esteban Küber
abdcb868ff Point at every unexpected lifetime and type argument in E0107 2018-11-22 14:14:27 -08:00
bors
00e03ee574 Auto merge of #56143 - nikomatsakis:issue-56128-segment-id-ice-nightly, r=petrochenkov
Issue 56128 segment id ice nightly

Tentative fix for #56128

From what I can tell, the problem is that if you have `pub(super) use foo::{a, b}`, then when we explode the `a` and `b`, the segment ids from the `super` path were not getting cloned. However, once I fixed *that*, then I ran into a problem that the "visibility" node-ids were not present in the final HIR -- this is because the visibility of the "stem" that is returned in this case was getting reset to inherited. I don't *think* it is a problem to undo that, so that the visibility is returned unmodified.

Fixes #55475
Fixes #56128

cc @nrc @petrochenkov
2018-11-22 20:29:51 +00:00
bjorn3
60e4158188 Move fake rustc_codegen_ssa dependency from rustc_driver to rustc-main 2018-11-22 20:20:23 +01:00
bjorn3
d6d8a330f8 Add rustc_codegen_ssa to sysroot 2018-11-22 20:20:23 +01:00
Wesley Wiser
b319715456 Disable the self-profiler unless the -Z self-profile flag is set
Related to #51648
2018-11-22 12:56:15 -05:00
Steven Fackler
d0f99ddefa Fix the tracking issue for hash_raw_entry
It used to point to the implementation PR.
2018-11-22 09:52:24 -07:00
Ralf Jung
d9de72fcac miri: restrict fn argument punning to Rust ABI 2018-11-22 17:39:07 +01:00
Ralf Jung
e1ca4f63f4 fix codegen-units tests 2018-11-22 17:26:44 +01:00
bors
c08840d5c3 Auto merge of #53586 - eddyb:top-lock, r=alexcrichton
Move Cargo.{toml,lock} to the repository root directory.

This should give us back `src/` in errors, panics and debuginfo, for free.

r? @Mark-Simulacrum @alexcrichton cc @michaelwoerister
2018-11-22 15:54:10 +00:00
Ralf Jung
af9b057156 drop glue takes in mutable references, it should reflect that in its type 2018-11-22 16:08:58 +01:00
Mark Rousskov
01fd0012a1
Include changes from 1.30.1 in release notes 2018-11-22 15:39:16 +01:00
Niko Matsakis
5f2a173f75 explain how this works 2018-11-22 09:38:47 -05:00
Niko Matsakis
b83150e6ac only reset non-restricted visibilities 2018-11-22 09:38:40 -05:00
Adrian Heine né Lang
37f719e0d3
std::str Adapt documentation to reality 2018-11-22 15:26:16 +01:00
bors
dae6c93641 Auto merge of #56136 - matthiaskrgr:clippy, r=oli-obk
submodules: update clippy from f5d868c9 to 2f6881c6

Changes:

````
missed another one in the README
run "util/dev update_lints"
rust-lang-nursery/rust-clippy => rust-lang/rust-clippy
Address 'clippy::single-match' dogfood lint
Fix nit
Address travis CI lint failure
Update trivially_copy_pass_by_ref with Trait stderr output
issue#3318 run trivially_copy_pass_by_ref for traits
Update trivially_copy_pass_by_ref with Trait examples
Fix awkward wording
Document how to lint local Clippy changes with locally built Clippy
Enable rustup clippy to refer to the correct documentation
rustup https://github.com/rust-lang/rust/pull/52591
remove unused allow() attributes, NFC
Add regression test
Don't emit suggestion when inside of a macro
````

fixes clippy toolstate
2018-11-22 13:07:30 +00:00
Matthias Krüger
8e814ae608 submodules: update clippy from f5d868c9 to 2f6881c6
````
missed another one in the README
run "util/dev update_lints"
rust-lang-nursery/rust-clippy => rust-lang/rust-clippy
Address 'clippy::single-match' dogfood lint
Fix nit
Address travis CI lint failure
Update trivially_copy_pass_by_ref with Trait stderr output
issue#3318 run trivially_copy_pass_by_ref for traits
Update trivially_copy_pass_by_ref with Trait examples
Fix awkward wording
Document how to lint local Clippy changes with locally built Clippy
Enable rustup clippy to refer to the correct documentation
rustup https://github.com/rust-lang/rust/pull/52591
remove unused allow() attributes, NFC
Add regression test
Don't emit suggestion when inside of a macro
````
2018-11-22 11:15:15 +01:00
Eduard-Mihai Burtescu
7c166f54b2 Move Cargo.{toml,lock} to the repository root directory. 2018-11-22 12:10:04 +02:00
bors
93fa2d76bd Auto merge of #56155 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 11 pull requests

Successful merges:

 - #55367 (lint if a private item has doctests)
 - #55485 (Return &T / &mut T in ManuallyDrop Deref(Mut) impl)
 - #55784 (Clarifying documentation for collections::hash_map::Entry::or_insert)
 - #55961 (Fix VecDeque pretty-printer)
 - #55980 (Suggest on closure args count mismatching with pipe span)
 - #56002 (fix #55972: Erroneous self arguments on bare functions emit subpar compilation error)
 - #56063 (Update any.rs documentation using keyword dyn)
 - #56067 (Add SGX target to rustc)
 - #56078 (Fix error message for `-C panic=xxx`.)
 - #56106 (Remove some incorrect doc comments)
 - #56126 (core/benches/num: Add `from_str/from_str_radix()` benchmarks)

Failed merges:

r? @ghost
2018-11-22 10:04:41 +00:00
Guillaume Gomez
61d7b3e9b0
Rollup merge of #56126 - Turbo87:bench-parse, r=alexcrichton
core/benches/num: Add `from_str/from_str_radix()` benchmarks

This was extracted from #55973

/cc @alexcrichton
2018-11-22 10:37:56 +01:00
Guillaume Gomez
6afecfd785
Rollup merge of #56106 - bjorn3:patch-1, r=alexcrichton
Remove some incorrect doc comments
2018-11-22 10:37:55 +01:00
Guillaume Gomez
1bc97081a5
Rollup merge of #56078 - ehuss:fix-panic-opt-msg, r=alexcrichton
Fix error message for `-C panic=xxx`.

Fixes rust-lang/cargo#6334
2018-11-22 10:37:54 +01:00
Guillaume Gomez
b473157293
Rollup merge of #56067 - jethrogb:jb/sgx-target-spec, r=alexcrichton
Add SGX target to rustc

This adds the `x86_64-fortanix-unknown-sgx` target specification to the Rust compiler. See #56066 for more details about this target.
2018-11-22 10:37:53 +01:00
Guillaume Gomez
1646fc907e
Rollup merge of #56063 - 0xrgb:patch-1, r=joshtriplett
Update any.rs documentation using keyword dyn

This will fix #56062.
2018-11-22 10:37:51 +01:00
Guillaume Gomez
75d226ed76
Rollup merge of #56002 - Axary:master, r=estebank
fix #55972: Erroneous self arguments on bare functions emit subpar compilation error

#55972

r? @estebank
2018-11-22 10:37:50 +01:00
Guillaume Gomez
636f0a9a1d
Rollup merge of #55980 - csmoe:issue-55891, r=estebank
Suggest on closure args count mismatching with pipe span

Closes #55891
r? @estebank
2018-11-22 10:37:49 +01:00
Guillaume Gomez
fa3941cb99
Rollup merge of #55961 - tromey:Bug-55944-vecdeque, r=nikomatsakis
Fix VecDeque pretty-printer

This fixes the VecDeque pretty-printer to handle cases where
head < tail.
Closes #55944
2018-11-22 10:37:48 +01:00
Guillaume Gomez
89e0fcee40
Rollup merge of #55784 - meltinglava:master, r=KodrAus
Clarifying documentation for collections::hash_map::Entry::or_insert

Previous version does not show that or_insert does not insert the passed value, as the passed value was the same value as what was already in the map.
2018-11-22 10:37:46 +01:00
Guillaume Gomez
1c57f0ab9c
Rollup merge of #55485 - petertodd:2018-10-manuallydrop-deref, r=TimNN
Return &T / &mut T in ManuallyDrop Deref(Mut) impl

Without this change the generated documentation looks like this:

    fn deref(&self) -> &<ManuallyDrop<T> as Deref>::Target

Returning the actual type directly makes the generated docs more clear:

    fn deref(&self) -> &T

Basically, compare how the impl for `Box<T>` and `ManuallyDrop<T>` looks in this screenshot:

![rust docs for ManuallyDrop as Deref](https://user-images.githubusercontent.com/7042/47673083-fc9dc280-db89-11e8-89b0-c6bde663feef.png)
2018-11-22 10:37:45 +01:00
Guillaume Gomez
9aedfd5a3b
Rollup merge of #55367 - GuillaumeGomez:private-item-doc-test-lint, r=QuietMisdreavus
lint if a private item has doctests

Fixes #55333.

r? @QuietMisdreavus
2018-11-22 10:37:43 +01:00
Petr Hosek
f41423c75f Pass additional linker flags when targeting Fuchsia
This is a follow up to 8aa9267 which changed the driver to use lld
directly rather than invoking it through Clang. This change ensures
we pass all the necessary flags to lld.
2018-11-22 00:59:37 -08:00
bors
f3adec65dd Auto merge of #53918 - Havvy:doc-sort-by, r=GuillaumeGomez
Doc total order requirement of sort(_unstable)_by

I took the definition of what a total order is from the Ord trait
docs. I specifically put "elements of the slice" because if you
have a slice of f64s, but know none are NaN, then sorting by
partial ord is total in this case. I'm not sure if I should give
such an example in the docs or not.

r? @GuillaumeGomez
2018-11-22 06:50:18 +00:00
Alex Crichton
d1cd4e8d0d Move a flaky process test out of libstd
This test ensures that everything in `env::vars()` is inherited but
that's not actually true because other tests may add env vars after we
spawn the process, causing the test to be flaky! This commit moves the
test to a run-pass test where it can execute in isolation.

Along the way this removes a lot of the platform specificity of the
test, using iteslf to print the environment instead of a foreign process.
2018-11-21 21:56:23 -08:00
Eduard-Mihai Burtescu
5b4747ded7 rustc_target: avoid using AbiAndPrefAlign where possible. 2018-11-22 05:01:49 +02:00
bors
4bec59c93b Auto merge of #56147 - petrochenkov:impice, r=nikomatsakis
resolve: Fix some asserts in import validation

The asserts are not actually correct in presence of ambiguity errors.

Fixes https://github.com/rust-lang/rust/issues/56125
2018-11-22 02:40:44 +00:00
Eduard-Mihai Burtescu
3ce8d444af rustc_target: separate out an individual Align from AbiAndPrefAlign. 2018-11-22 04:38:00 +02:00
Eduard-Mihai Burtescu
d56e892085 rustc_target: rename abi::Align to AbiAndPrefAlign. 2018-11-22 04:12:59 +02:00
ariasuni
ec3ac112e1 Make std::os::unix/linux::fs::MetadataExt::a/m/ctime* documentation clearer 2018-11-22 02:36:11 +01:00