Rollup of 11 pull requests
Successful merges:
- #54078 (Expand the documentation for the `std::sync` module)
- #54717 (Cleanup rustc/ty part 1)
- #54781 (Add examples to `TyKind::FnDef` and `TyKind::FnPtr` docs)
- #54787 (Only warn about unused `mut` in user-written code)
- #54804 (add suggestion for inverted function parameters)
- #54812 (Regression test for #32382.)
- #54833 (make `Parser::parse_foreign_item()` return a foreign item or error)
- #54834 (rustdoc: overflow:auto doesn't work nicely on small screens)
- #54838 (Fix typo in src/libsyntax/parse/parser.rs)
- #54851 (Fix a regression in 1.30 by reverting #53564)
- #54853 (Remove unneccessary error from test, revealing NLL error.)
Failed merges:
r? @ghost
Remove unneccessary error from test, revealing NLL error.
Part of #52663.
Removes unnecessary type mismatch error from test that was hiding
borrow check error from NLL stderr.
r? @nikomatsakis
rustdoc: overflow:auto doesn't work nicely on small screens
This property was introduced by 3f92ff34b5, but looks it doesn't
overwrap even without the property.
Fixes#54672.
make `Parser::parse_foreign_item()` return a foreign item or error
Fixes `Parser::parse_foreign_item()` to follow the convention of `parse_trait_item()` and `parse_impl_item()` in that it *must* parse an item or return an error, and then the caller is responsible for detecting the closing delimiter.
This prevents it from looping endlessly on an unexpected token in `ext/expand.rs` where it was also leaking memory by continually pushing to `Parser::expected_tokens` via `Parser::check_keyword()`.
closes#54441
r? @petrochenkov
cc @dtolnay
Add examples to `TyKind::FnDef` and `TyKind::FnPtr` docs
This adds two examples to the docs of `TyKind::FnDef` and `TyKind::FnPtr`.
I found these two types a bit confusing when I learned about them and I think adding these examples might help others.
Cleanup rustc/ty part 1
Part 2 will follow soon; I wouldn't want these changes to rot too quickly.
- improve stack shifting and remove related allocations
- move a faster early return up
- improve allocations
- use Cow<str> where applicable
- simplify common patterns
- whitespace fixes
Expand the documentation for the `std::sync` module
I've tried to expand the documentation for Rust's synchronization primitives. The module level documentation explains why synchronization is required when working with a multiprocessor system,
and then links to the appropiate structure in this module.
Fixes#29377, since this should be the last item on the checklist (documentation for `Atomic*` was fixed in #44854, but not ticked off the checklist).
Cleanup rustc/ty part 2
The second part of cleanups and minor improvements for rustc/ty.
- improve allocations
- calculate span after a possible early continue
- simplify some patterns
- mark a comment as FIXME
- whitespace fixes
The PR is independent from from the first part.
resolve: Some refactorings in preparation for uniform paths 2.0
The main result is that in-scope resolution performed during macro expansion / import resolution is now consolidated in a single function (`fn early_resolve_ident_in_lexical_scope`), which can now be used for resolving first import segments as well when uniform paths are enabled.
r? @ghost
Merge `proc_macro_` expansion feature gates as `proc_macro_hygiene`
Merges `proc_macro_mod`, `proc_macro_expr`, `proc_macro_non_items`, and `proc_macro_gen` into a single feature: `proc_macro_hygiene`. These features are not all blocked on implementing macro hygiene *per se*, but rather on interactions with hygiene that have not been entirely resolved.
The restrictions were introduced in https://github.com/rust-lang/rust/pull/54277 and no longer necessary now because legacy plugins are now expanded in usual left-to-right order
std: Start implementing wasm32 atomics
This commit is an initial start at implementing the standard library for
wasm32-unknown-unknown with the experimental `atomics` feature enabled. None of
these changes will be visible to users of the wasm32-unknown-unknown target
because they all require recompiling the standard library. The hope with this is
that we can get this support into the standard library and start iterating on it
in-tree to enable experimentation.
Currently there's a few components in this PR:
* Atomic fences are disabled on wasm as there's no corresponding atomic op and
it's not clear yet what the convention should be, but this will change in the
future!
* Implementations of `Mutex`, `Condvar`, and `RwLock` were all added based on
the atomic intrinsics that wasm has.
* The `ReentrantMutex` and thread-local-storage implementations panic currently
as there's no great way to get a handle on the current thread's "id" yet.
Right now the wasm32 target with atomics is unfortunately pretty unusable,
requiring a lot of manual things here and there to actually get it operational.
This will likely continue to evolve as the story for atomics and wasm unfolds,
but we also need more LLVM support for some operations like custom `global`
directives for this to work best.
adopt "placeholders" to represent universally quantified regions
This does a few preliminary refactorings that lay some groundwork for moving towards universe integration. Two things, primarily:
- Rename from "skolemized" to "placeholder"
- When instantiating `for<'a, 'b, 'c>`, just create one universe for all 3 regions, and distinguish them from one another using the `BoundRegion`.
- This is more accurate, and I think that in general we'll be moving towards a model of separating "binder" (universe, debruijn index) from "index within binder" in a number of places.
- In principle, it feels the current setup of making lots of universes could lead to us doing the wrong thing, but I've actually not been able to come up with an example where this is so.
r? @scalexm
cc @arielb1
[NLL] Improve "borrow later used here" messages
* In the case of two conflicting borrows, the later used message says which borrow it's referring to
* If the later use is a function call (from the users point of view) say that the later use is for the call. Point just to the function.
r? @pnkfelix
Closes#48643