Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #70617

Merged
merged 22 commits into from
Mar 31, 2020
Merged

Rollup of 9 pull requests #70617

merged 22 commits into from
Mar 31, 2020

Conversation

Centril
Copy link
Contributor

@Centril Centril commented Mar 31, 2020

Successful merges:

Failed merges:

r? @ghost

Aelerinya and others added 22 commits March 30, 2020 02:51
Constructing a Searcher in strip_prefix and strip_suffix is
unnecessarily slow when the pattern is a fixed-length string. Add
strip_prefix and strip_suffix methods to the Pattern trait, and add
optimized implementations of these methods in the str implementation.
The old implementation is retained as the default for these methods.
Co-Authored-By: Mazdak Farrokhzad <[email protected]>
The wasm32-wasi target delegates its malloc implementation to the
functions in wasi-libc, but the invocation of `aligned_alloc` was
incorrect by passing the number of bytes requested first rather than the
alignment. This commit swaps the order of these two arguments to ensure
that we allocate over-aligned memory correctly.
use is_empty() instead of len comparison (clippy::len_zero)
use if let instead of while let loop that never loops (clippy::never_loop)
remove redundant returns (clippy::needless_return)
remove redundant closures (clippy::redundant_closure)
use if let instead of match and wildcard pattern (clippy::single_match)
don't repeat field names redundantly (clippy::redundant_field_names)
…=kennytm

Optimize strip_prefix and strip_suffix with str patterns

As mentioned in rust-lang#67302 (comment).
I'm not sure whether adding these methods to `Pattern` is desirable—but they have default implementations so the change is backwards compatible. Plus it seems like they're slated for wholesale replacement soon anyway? rust-lang#56345

----

Constructing a Searcher in strip_prefix and strip_suffix is
unnecessarily slow when the pattern is a fixed-length string. Add
strip_prefix and strip_suffix methods to the Pattern trait, and add
optimized implementations of these methods in the str implementation.
The old implementation is retained as the default for these methods.
Add long error code for error E0226

Added a long description message for error E0226, which previously did not exist.
As requested in issue rust-lang#61137

r? @GuillaumeGomez
resolve, `try_resolve_as_non_binding`: use `delay_span_bug` due to parser recovery

Fixes rust-lang#70549

r? @petrochenkov
…henkov

remove obsolete comment

Made obsolete by b5e35b1
infer array len from pattern

closes rust-lang#70529

This still errors in the following case

```rust
#![feature(const_generics)]
fn arr<const N: usize>() -> [u8; N] {
    todo!()
}

fn main() {
    match arr() {
        [5, ..] => (),
        //~^ ERROR cannot pattern-match on an array without a fixed length
        [_, _] => (),
    }
}
```
Considering that this should be rare and is harder to implement I would merge this PR without *fixing* the above.
…r=Mark-Simulacrum

std: Fix over-aligned allocations on wasm32-wasi

The wasm32-wasi target delegates its malloc implementation to the
functions in wasi-libc, but the invocation of `aligned_alloc` was
incorrect by passing the number of bytes requested first rather than the
alignment. This commit swaps the order of these two arguments to ensure
that we allocate over-aligned memory correctly.
Add `Rust` to the code snippet

Adds `Rust` to the snippet where the code causing the ICE should be placed, so github can render it as Rust code rather than plain code.
…n-DPC

Fix incorrect documentation for `str::{split_at, split_at_mut}`

The documentation for each method currently states:

> Panics if `mid` is not on a UTF-8 code point boundary, or if it is beyond the last code point of the string slice.

However, this is not consistent with the real behavior, or that of the corresponding methods for `[T]` slices. A comment inside each of the `str` methods states:

> is_char_boundary checks that the index is in [0, .len()]

That is what I would expect the behavior to be, and in fact this seems to be the real behavior. For example ([playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=8e03dcc209d4dd176df2297523f9fee1)):

```rust
fn main() {
    // Prints ("abc", "") and doesn't panic
    println!("{:?}", "abc".split_at(3));
}
```

In this case, I would interpret "the last code point of the string slice" to mean the byte at index 2 in UTF-8. However, it is possible to pass an index of 3, which is definitely "beyond the last code point of the string slice".

I think that this is much clearer, but feel free to bikeshed.
…tril

more clippy fixes

* use is_empty() instead of len comparison (clippy::len_zero)
* use if let instead of while let loop that never loops (clippy::never_loop)
* remove redundant returns (clippy::needless_return)
* remove redundant closures (clippy::redundant_closure)
* use if let instead of match and wildcard pattern (clippy::single_match)
* don't repeat field names redundantly (clippy::redundant_field_names)

r? @Centril
@Centril
Copy link
Contributor Author

Centril commented Mar 31, 2020

@bors r+ p=9 rollup=never

@bors
Copy link
Contributor

bors commented Mar 31, 2020

📌 Commit 976f8d5 has been approved by Centril

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Mar 31, 2020
@bors
Copy link
Contributor

bors commented Mar 31, 2020

⌛ Testing commit 976f8d5 with merge 75ff311...

@bors
Copy link
Contributor

bors commented Mar 31, 2020

☀️ Test successful - checks-azure
Approved by: Centril
Pushing 75ff311 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 31, 2020
@bors bors merged commit 75ff311 into rust-lang:master Mar 31, 2020
@Centril Centril deleted the rollup-063ycso branch March 31, 2020 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.