Irrefut patterns refactoring - #6817
Closed
nikomatsakis wants to merge 433 commits into
Closed
Conversation
…ices, r=graydon r? @pcwalton
r? Mostly refactoring, and adding some of the remaining types described in rust-lang#4419. The [`Local`](https://github.com/brson/rust/blob/3b4ff41511cfaa5e311b03d16b47bf40c117fa2f/src/libcore/rt/local.rs#L17) trait collects some common, often unsafe patterns around task-local and thread-local values. Making all these types safe is largely the aim of rust-lang#6210.
…=graydon This adds a lint mode for detecting unnecessary allocations on the heap. This isn't super fancy, currently it only has two rules 1. For a function's arguments, if you allocate a `[~|@]str` literal, when the type of the argument is a `&str`, emit a warning. 2. For the same case, emit warnings for boxed vectors when slices are required. After adding the lint, I rampaged through the libraries and removed all the unnecessary allocations I could find.
Resolves rust-lang#6633 and removes an unnecessary import in libcore
Results of libcore and libstd tests
```
failures:
rand::tests::test_rng_seeded_custom_seed2
time::tests::run_tests
uv_ll::test::test_uv_ll_struct_size_addrinfo
uv_ll::test::test_uv_ll_struct_size_uv_timer_t
segfaults:
stackwalk::test_simple
stackwalk::test_simple_deep
```
…ents Fixes rust-lang#6578 by merging the 3 different ways to build an AST into a single `AstBuilder` trait, creating a more uniform and briefer interface. Also, converts the `ext_ctxt` trait-object to be a plain struct, as well as renaming it to `ExtCtxt`. Seems to make expansion slightly faster for the normal case (e.g. `libcore` and `libstd`), but slower for `librustc` (slightly) and `libsyntax` (0.3s -> 0.8s! I'm investigating this, but I'd prefer this patch to land relatively quickly.). `git blame` suggests maybe @graydon or @erickt are familiar with this area of the code. r?
The way we deal with unreachable expressions in trans is pretty ad hoc, but this at least doesn't make it worse, and eliminates the LLVM assertion failure reported in rust-lang#5741.
This way a cross-compiled rustc's answer to host_triple() is correct. The return value of host_triple() reflects the actual host triple that the compiler was build for, not the triple the compiler is being built on
Fix rust-lang#5984. Also, I found a problem on type inference and left a comment.
Refactor the optimization passes to explicitly use the passes. This commit just re-implements the same passes as were already being run. It also adds an option (behind `-Z`) to run the LLVM lint pass on the unoptimized IR. This should close rust-lang#2812. It is also the first step towards rust-lang#2396 ---------------- This is pretty much just an initial "get it out there" PR. With finer control over the optimization passes coming later. I also just blindly copied the passes we were already doing, so there could almost certainly be some more work in paring it down. The other thing is the addition of the `mergefunctions` pass, which is currently enabled at `--opt-level=3` and does have a small impact on the code size. However the fact that it is at the end of the optimization pipeline is probably not ideal, so some more experimentation is in order.
… r=pcwalton Move the computation of what data is moved out of `liveness` and into `borrowck`. The resulting code is cleaner, since before we had a split distribution of responsibilities, and also this avoids having multiple implementations of the dataflow code. Liveness is still used to report warnings about useless writes. This will go away when we get the control-flow graph code landed (working on that). Also adds borrow checker documentation. Fixes rust-lang#4384. Required to support once fns and to properly fix closures (rust-lang#2202). First step to generalize our treatment of moves somewhat as well.
…nger Can be removed after a snapshot I believe.
This is unlikely to alter optimized codegen much but there's no point in downgrading the known alignment to 1.
…strie Previously, FromBase64 was only implemented on ~[u8] and ~str when any pointer would do. The implementations of FromBase64 are now consistent with the implementations of ToBase64.
Fix rust-lang#5984. Resolve the problem which exists in rust-lang#6780.
Most of the relevant information can be found in the commit messages. r? @brson - I just wanted to make sure the make changes aren't completely bogus This would close rust-lang#2400, rust-lang#6517, and rust-lang#6489 (although a run through incoming-full on linux would have to confirm the latter two)
Calls to the libc versions of fmin and fmax were relatively slow (perhaps because they could not be inlined?). This pull request provides f32 and f64 with fmin and fmax written in Rust, and shows a significant speed increase on my system; I used https://github.com/thiez/rustray as my benchmark, with --opt-level 3 it brings the ray-tracing time down from 10.8 seconds to about 9.2, which seemed significant to me. r?
…mpiler invocations with ccache to attempt to reuse common results, e.g. for LLVM (re)builds.
…pport, r=catamorphism Fix rust-lang#6805: add --enable-ccache configure option to prefix compiler invocations with `ccache` to attempt to reuse common results, e.g. for LLVM (re)builds. The information at developer [Note-ccache](../../wiki/Note-ccache) and at [ccache and clang concerns](http://petereisentraut.blogspot.fr/2011/09/ccache-and-clang-part-2.html) were what drove my introduction of the `-Qunused-arguments` and `CCACHE_CPP2` options. (Though I did confirm first-hand that at least the first really is necessary.) Yes, one certainly can re-route how `gcc` and `clang` are resolved in one's PATH and use that as a way to invoke `ccache`. But I personally do not want to introduce that change to my own PATH, and this seems like a small enough change that it does not hurt to add it, at least for now. (I don't know what form it would take when we move over to `rustpkg`.)
I found that `match ~[] { x => {} }` crashed. Couldn't find an existing issue
for it.
Contributor
Author
|
Wrong base branch. |
flip1995
pushed a commit
to flip1995/rust
that referenced
this pull request
Aug 1, 2026
flip1995
pushed a commit
to flip1995/rust
that referenced
this pull request
Aug 1, 2026
… floats (rust-lang#17024) Fixes rust-lang/rust-clippy#6817 This PR modifies float_cmp to detect when a strict comparison of floating-point constants happens inside assertion macros (assert_eq!, assert_ne!, etc.) and correctly emits float_cmp_const instead of the general float_cmp lint. It avoids double-linting by skipping the standard check when the expression is inside an assertion macro. changelog: Fix [`float_cmp_const`] not triggering on `assert_eq!`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Various refactorings and bug fixes that I did as part of a branch to fix irrefutable let pattern bindings.
r? @catamorphism