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

A few cleanups and minor improvements to rustc/traits #54295

Merged
merged 1 commit into from
Sep 21, 2018

Conversation

ljedrz
Copy link
Contributor

@ljedrz ljedrz commented Sep 17, 2018

It's a little bigger than usual, so bear with me ^^:

  • introduce TyCtxt::all_impls and use it to avoid inefficiently allocating push loops
  • modify ArgKind::from_expected_ty to take an Option<Span> argument to make it more versatile
  • replace ArgKind::Arg("_".to_owned(), "_".to_owned()) with ArgKind::empty
  • move early returns earlier where possible
  • if all branches of a match end with the same expression, move it after it
  • change a hacky match expression to an if else chain
  • move the push out from a push loop closure to reduce the number of allocations
  • correct the vector size for pretty_predicates (under specialize)
  • take advantage of the fact that if else is an expression
  • prefer cloned() to map(|&x| x) and map(|x| *x)
  • prefer vec![x; y.len()] to y.map(|_| x).collect()
  • use unwrap_or_else instead of match where applicable
  • use if let instead of match when only one branch matters
  • prefer to_owned to to_string for string literals
  • remove explicit returns
  • remove superfluous braces
  • whitespace fixes
  • several other minor improvements

@rust-highfive
Copy link
Collaborator

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 17, 2018
@ljedrz
Copy link
Contributor Author

ljedrz commented Sep 18, 2018

I just noticed that I forgot to take advantage of the predicate_to_obligation (previously push) closure in select; that's the only update.

@eddyb
Copy link
Member

eddyb commented Sep 18, 2018

r? @nikomatsakis

@rust-highfive rust-highfive assigned nikomatsakis and unassigned eddyb Sep 18, 2018
@nikomatsakis
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Sep 18, 2018

📌 Commit a8ec8e5 has been approved by nikomatsakis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 18, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Sep 20, 2018
…omatsakis

A few cleanups and minor improvements to rustc/traits

It's a little bigger than usual, so bear with me ^^:

- introduce `TyCtxt::all_impls` and use it to avoid inefficiently allocating push loops
- modify `ArgKind::from_expected_ty` to take an `Option<Span>` argument to make it more versatile
- replace `ArgKind::Arg("_".to_owned(), "_".to_owned())` with `ArgKind::empty`
- move early `return`s earlier where possible
- if all branches of a `match` end with the same expression, move it after it
- change a hacky `match` expression to an `if else` chain
- move the `push` out from a push loop closure to reduce the number of allocations
- correct the vector size for `pretty_predicates` (under `specialize`)
- take advantage of the fact that `if else` is an expression
- prefer `cloned()` to `map(|&x| x)` and `map(|x| *x)`
- prefer `vec![x; y.len()]` to `y.map(|_| x).collect()`
- use `unwrap_or_else` instead of `match` where applicable
- use `if let` instead of `match` when only one branch matters
- prefer `to_owned` to `to_string` for string literals
- remove explicit `return`s
- remove superfluous braces
- whitespace fixes
- several other minor improvements
bors added a commit that referenced this pull request Sep 20, 2018
Rollup of 15 pull requests

Successful merges:

 - #52813 (Duration div mul extras)
 - #53470 (Warn about metadata loader errors)
 - #54233 (Remove LLVM 3.9 workaround.)
 - #54257 (Switch wasm math symbols to their original names)
 - #54258 (Enable fatal warnings for the wasm32 linker)
 - #54266 (Update LLVM to fix "bool" arguments on PPC32)
 - #54290 (Switch linker for aarch64-pc-windows-msvc from LLD to MSVC)
 - #54292 (Suggest array indexing when tuple indexing on an array)
 - #54295 (A few cleanups and minor improvements to rustc/traits)
 - #54298 (miri: correctly compute expected alignment for field)
 - #54333 (Update The Book to latest)
 - #54337 (Remove unneeded clone() from tests in librustdoc)
 - #54346 (rustc: future-proof error reporting for polymorphic constants in types.)
 - #54362 (Pass --batch to gdb)
 - #54367 (Add regression test for thread local static mut borrows)
@bors bors merged commit a8ec8e5 into rust-lang:master Sep 21, 2018
@ljedrz ljedrz deleted the cleanups_rustc_traits branch September 21, 2018 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

5 participants