Commit Graph

161655 Commits

Author SHA1 Message Date
Matthias Krüger
3148a322d8
Rollup merge of #92124 - AngelicosPhosphoros:remove_extra_alloc_in_cstring_new_35838, r=Mark-Simulacrum
Little improves in CString `new` when creating from slice

Old code already contain optimization for cases with `&str` and `&[u8]` args. This commit adds a specialization for `&mut[u8]` too.

Also, I added usage of old slice in search for zero bytes instead of new buffer because it produce better code for constant inputs on Windows LTO builds. For other platforms, this wouldn't cause any difference because it calls `libc` anyway.

Inlined `_new` method into spec trait to reduce amount of code generated to `CString::new` callers.
2022-01-19 10:42:15 +01:00
Matthias Krüger
3a1db90efb
Rollup merge of #91278 - SparrowLii:place, r=spastorino
Use iterator instead of recursion in `codegen_place`

This PR fixes the FIXME in `codegen_place` about using iterator instead of recursion when processing the `projection` field in `mir::PlaceRef`. At the same time, it also reduces the right drift.
2022-01-19 10:42:14 +01:00
Matthias Krüger
2a4381d8ea
Rollup merge of #89621 - digama0:patch-2, r=yaahc
doc: guarantee call order for sort_by_cached_key

`slice::sort_by_cached_key` takes a caching function `f: impl FnMut(&T) -> K`, which means that the order that calls to the caching function are made is user-visible. This adds a clause to the documentation to promise the current behavior, which is that `f` is called on all elements of the slice from left to right, unless the slice has len < 2 in which case `f` is not called.

For example, this can be used to ensure that the following code is a correct way to involve the index of the element in the sort key:
```rust
let mut index = 0;
slice.sort_by_cached_key(|x| (my_key(index, x), index += 1).0);
```
2022-01-19 10:42:13 +01:00
Matthias Krüger
5d2928f7b9
Rollup merge of #88642 - c410-f3r:let_chains_2, r=matthewjasper
Formally implement let chains

## Let chains

My longest and hardest contribution since #64010.

Thanks to `@Centril` for creating the RFC and special thanks to `@matthewjasper` for helping me since the beginning of this journey. In fact, `@matthewjasper` did much of the complicated MIR stuff so it's true to say that this feature wouldn't be possible without him. Thanks again `@matthewjasper!`

With the changes proposed in this PR, it will be possible to chain let expressions along side local variable declarations or ordinary conditional expressions. In other words, do much of what the `if_chain` crate already does.

## Other considerations

* `if let guard` and `let ... else` features need special care and should be handled in a following PR.

* Irrefutable patterns are allowed within a let chain context

* ~~Three Clippy lints were already converted to start dogfooding and help detect possible corner cases~~

cc #53667
2022-01-19 10:42:12 +01:00
bors
2f004d2d40 Auto merge of #93063 - ehuss:update-cargo, r=ehuss
Update cargo

16 commits in 358e79fe56fe374649275ca7aebaafd57ade0e8d..95bb3c92bf516017e812e7f1c14c2dea3845b30e
2022-01-04 18:39:45 +0000 to 2022-01-18 17:39:35 +0000
- Error when setting crate type of both dylib and cdylib in library (rust-lang/cargo#10243)
- Include `help` in `--list` (rust-lang/cargo#10300)
- Add report subcommand to bash completion. (rust-lang/cargo#10295)
- Downgrade some log messages. (rust-lang/cargo#10296)
- Enable shortcut for triage bot (rust-lang/cargo#10298)
- Bump to 0.61.0, update changelog (rust-lang/cargo#10294)
- use new cargo fmt option (rust-lang/cargo#10291)
- Add `run-fail` to semver-check for docs (rust-lang/cargo#10287)
- Use `is_symlink()` method (rust-lang/cargo#10290)
- Stabilize namespaced and weak dependency features. (rust-lang/cargo#10269)
- Port cargo to clap3 (rust-lang/cargo#10265)
- feat: support rustflags per profile (rust-lang/cargo#10217)
- Make bors ignore the PR template so it doesn't end up in merge messages (rust-lang/cargo#10267)
- Be resilient to most IO error and filesystem loop while walking dirs (rust-lang/cargo#10214)
- Remove the option to disable pipelining (rust-lang/cargo#10258)
- Always ask rustc for messages about artifacts, and always process them (rust-lang/cargo#10255)
2022-01-19 06:17:07 +00:00
David Tolnay
4d3faae5cd
Eliminate left and right cursors in favor of ring buffer 2022-01-18 20:19:44 -08:00
David Tolnay
cc66a7ff20
Eliminate eof token state 2022-01-18 20:08:52 -08:00
David Tolnay
6e8b06015e
Simplify the buffer push done by scan_break 2022-01-18 19:35:43 -08:00
Eric Huss
84e0d9db6c Update books 2022-01-18 19:23:45 -08:00
David Tolnay
fe5c4eab2d
Eliminate a check_stack call on an empty scan stack 2022-01-18 19:23:22 -08:00
David Tolnay
377c9dbabf
Index a single time in check_stack 2022-01-18 19:21:18 -08:00
David Tolnay
a37d272892
Implement check_stack nonrecursively 2022-01-18 19:20:33 -08:00
David Tolnay
0490e43422
Implement check_stream nonrecursively 2022-01-18 19:19:18 -08:00
David Tolnay
947a09a4a8
Replace if + unwrap with if let in check_stack 2022-01-18 19:18:47 -08:00
David Tolnay
80139a0f02
Ensure Printer buf is always indexed using self.left or self.right 2022-01-18 19:18:04 -08:00
David Tolnay
ae28ec5a9c
Inline Printer's scan_pop_bottom method 2022-01-18 19:16:33 -08:00
David Tolnay
2a14275500
Inline Printer's scan_top method 2022-01-18 19:16:32 -08:00
David Tolnay
e20d5abdfb
Inline Printer's scan_pop method 2022-01-18 19:16:32 -08:00
Eric Huss
bfacc5cc73 Update cargo 2022-01-18 19:14:33 -08:00
David Tolnay
50d722a691
Simplify ring buffer pushes 2022-01-18 19:07:12 -08:00
David Tolnay
e219b2b5f9
Inline Printer's scan_push method 2022-01-18 19:04:12 -08:00
David Tolnay
fdb95f54e8
Inline Printer's advance_right method 2022-01-18 19:02:49 -08:00
Jacob Hoffman-Andrews
fa9a8430ea Remove horizontal lines at top of page
They are not needed to separate the search bar and the title, which are
visually distinct on their own.
2022-01-18 18:45:43 -08:00
Noah Lev
7c4eca0687 Make suggestions verbose 2022-01-18 16:38:06 -08:00
Noah Lev
7507fb6306 Shorten and improve messages 2022-01-18 16:32:58 -08:00
Noah Lev
29a2d6b505 intra-doc: Use the impl's assoc item where possible
Before, the trait's associated item would be used. Now, the impl's
associated item is used. The only exception is for impls that use
default values for associated items set by the trait. In that case,
the trait's associated item is still used.

As an example of the old and new behavior, take this code:

    trait MyTrait {
        type AssocTy;
    }

    impl MyTrait for String {
        type AssocTy = u8;
    }

Before, when resolving a link to `String::AssocTy`,
`resolve_associated_trait_item` would return the associated item for
`MyTrait::AssocTy`. Now, it would return the associated item for
`<String as MyTrait>::AssocTy`, as it claims in its docs.
2022-01-18 16:05:12 -08:00
Mara Bos
5fee3e7a9c Fix is_some_with tests. 2022-01-19 00:12:35 +01:00
bors
e5e2b0be26 Auto merge of #93048 - matthiaskrgr:rollup-cz5ma34, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #90782 (Implement raw-dylib support for windows-gnu)
 - #91150 (Let qpath contain NtTy: `<$:ty as $:ty>::…`)
 - #92425 (Improve SIMD casts)
 - #92692 (Simplify and unify rustdoc sidebar styles)
 - #92780 (Directly use ConstValue for single literals in blocks)
 - #92924 (Delete pretty printer tracing)
 - #93018 (Remove some unused `Ord` derives based on `Span`)
 - #93026 (fix typo in `max` description for f32/f64)
 - #93035 (Fix stdarch submodule pointing to commit outside tree)

Failed merges:

 - #92861 (Rustdoc mobile: put out-of-band info on its own line)

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-18 22:46:47 +00:00
Eric Holk
76f6b57125 Fix build after rebase 2022-01-18 14:42:39 -08:00
Caio
5f74ef4fb1 Formally implement let chains 2022-01-18 19:38:17 -03:00
Eric Holk
d840d0c62e Use .. patterns in cfg_build.rs 2022-01-18 14:25:31 -08:00
Eric Holk
e0a5370ef0 Respond to code review comments 2022-01-18 14:25:31 -08:00
Eric Holk
32930d9ea7 Safely handle partial drops
We previously weren't tracking partial re-inits while being too
aggressive around partial drops. With this change, we simply ignore
partial drops, which is the safer, more conservative choice.
2022-01-18 14:25:30 -08:00
Eric Holk
78c5644de5 drop_ranges: Add TrackedValue enum
This makes it clearer what values we are tracking and why.
2022-01-18 14:25:30 -08:00
Eric Holk
887e843eeb Update async-fn-nonsend.rs
The previous commit made the non_sync_with_method_call case pass due to
the await being unreachable. Unfortunately, this isn't actually the
behavior the test was verifying. This change lifts the panic into a
helper function so that the generator analysis still thinks the await
is reachable, and therefore we preserve the same testing behavior.
2022-01-18 14:25:30 -08:00
Eric Holk
787f4cbd15 Handle uninhabited return types
This changes drop range analysis to handle uninhabited return types such
as `!`. Since these calls to these functions do not return, we model
them as ending in an infinite loop.
2022-01-18 14:25:30 -08:00
Eric Holk
f730bd0dad Track changed bitsets in CFG propagation
This reduces the amount of work done, especially in later iterations,
by only processing nodes whose predecessors changed in the previous
iteration, or earlier in the current iteration. This also has the side
effect of completely ignoring all unreachable nodes.
2022-01-18 14:25:29 -08:00
Eric Holk
7d11b336f3 Remove clones and most allocations from propagate_to_fixpoint 2022-01-18 14:25:29 -08:00
Eric Holk
a7df4e8d2f Handle empty loops better 2022-01-18 14:25:29 -08:00
Eric Holk
6e281a7782 Explicitly list all ExprKinds in cfg_build
Also rearranges the existing arms to be more logical. For example, Break
and Continue come closer to Loop now.
2022-01-18 14:25:29 -08:00
Eric Holk
4a70de7932 Handle reinits in match guards 2022-01-18 14:25:29 -08:00
Eric Holk
2af02cf2c4 More comments and refactoring
The refactoring mainly keeps the separation between the modules clearer.
For example, process_deferred_edges function moved to cfg_build.rs since
that is really part of building the CFG, not finding the fixpoint.

Also, we use PostOrderId instead of usize in a lot more places now.
2022-01-18 14:25:28 -08:00
Eric Holk
7d82e4f764 Update stderr files 2022-01-18 14:25:28 -08:00
Eric Holk
6a28afb2a3 Fixing formatting 2022-01-18 14:25:28 -08:00
Eric Holk
9347bf498a Additional cleanup
This cleans up the refactoring from the previous patch and cleans things
up a bit. Each module has a clear entry point and everything else is
private.
2022-01-18 14:25:28 -08:00
Eric Holk
f5f98d7ee4 Refactor drop_ranges
Splits drop_ranges into drop_ranges::record_consumed_borrow,
drop_ranges::cfg_build, and drop_ranges::cfg_propagate. The top level
drop_ranges module has an entry point that does all the coordination of
the other three phases, using code original in generator_interior.
2022-01-18 14:25:27 -08:00
Eric Holk
30e1b1e92e Address code review comments
1. Add test case for partial drops
2. Simplify code in `propagate_to_fixpoint` and remove most clones
3. Clean up PostOrderIndex creation
2022-01-18 14:25:27 -08:00
Eric Holk
006f547162 Add more comments 2022-01-18 14:25:27 -08:00
Eric Holk
46760b4e67 Update async-fn-nonsend.stderr 2022-01-18 14:25:27 -08:00
Eric Holk
5feb4d0106 Refactor code to keep most drop range analysis in drop_ranges.rs 2022-01-18 14:25:27 -08:00