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 8 pull requests #70601

Closed
wants to merge 24 commits into from
Closed

Conversation

Centril
Copy link
Contributor

@Centril Centril commented Mar 31, 2020

Successful merges:

Failed merges:

r? @ghost

rcoh and others added 24 commits March 27, 2020 22:02
This diff improves error messages around raw strings in a few ways:
- Catch extra trailing `#` in the parser. This can't be handled in the lexer because we could be in a macro that actually expects another # (see test)
- Refactor & unify error handling in the lexer between ByteStrings and RawByteStrings
- Detect potentially intended terminators (longest sequence of "#*" is suggested)
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 <twingoow@gmail.com>
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.
…=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.
…rochenkov

Improve error messages for raw strings (rust-lang#60762)

This diff improves error messages around raw strings in a few ways:
- Catch extra trailing `#` in the parser. This can't be handled in the lexer because we could be in a macro that actually expects another # (see test)
- Refactor & unify error handling in the lexer between ByteStrings and RawByteStrings
- Detect potentially intended terminators (longest sequence of "#*" is suggested)

Fixes rust-lang#60762
cc @estebank who reviewed the original (abandoned) PR for the same ticket.
r? @Centril
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.
@Centril
Copy link
Contributor Author

Centril commented Mar 31, 2020

@bors r+ p=8 rollup=never

@bors
Copy link
Contributor

bors commented Mar 31, 2020

📌 Commit bf7870d has been approved by Centril

@bors
Copy link
Contributor

bors commented Mar 31, 2020

🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened

@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
@Centril Centril added the rollup A PR which is a rollup label Mar 31, 2020
@Centril
Copy link
Contributor Author

Centril commented Mar 31, 2020

@bors p=1500

@bors
Copy link
Contributor

bors commented Mar 31, 2020

⌛ Testing commit bf7870d with merge f9dff1746b31226cffb8dcf6403b4da0e8d6c2a3...

@bors
Copy link
Contributor

bors commented Mar 31, 2020

💔 Test failed - checks-azure

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 31, 2020
@Centril Centril closed this Mar 31, 2020
@Centril Centril deleted the rollup-za49bdh branch March 31, 2020 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants