Fix release channel detection
We detect toolchain's release channel by looking at pre-release identifier of cargo/rustc's version string. It's empty for stable, "beta" or "beta.x" for beta, and "nightly" for nightly.
See rust-lang/rust's [bootstrap code] for how the version string is determined.
[bootstrap code]: e49122fb1c/src/bootstrap/lib.rs (L1244)
Restrict "sort items" assist for traits & impls
This restricts the "sort items alphabetically" assist when the selection is inside a `Impl` or `Trait` node & intersects with one of the associated items.
It re-orders the conditional checks of AST nodes in the `sort_items` function to check for more specific nodes first before checking `Trait` or `Impl` nodes. The `AssistContext` is passed into the `add_sort_methods_assist` function to check if the selection intersects with any inner items, e.g. associated const or type alias, function. In this case the assist does not apply.
Fixes: #14516
This fixes the applicability of the "sort items alphabetically" assist
when the selection is inside a `Trait` or `Impl`. It's now tested if the
selection is inside or overlaps with an inner node, e.g. associated
const or type alias, function.
internal: Report macro definition errors on the definition
We still report them on the call site as well for the time being, and the diagnostic doesn't know where the error in the definition comes from, but that can be done later on
Parse more exclusive range patterns and inline const patterns
Closes#13955
This PR
- implements exclusive range pattern without start bound (tracking issue: rust-lang/rust#37854)
- additionally moves rest pattern handling into the same place since they only differ in whether another pattern follows; this actually solves some FIXMEs
- updates `PATTERN_FIRST` token set to include `const` token so we can parse inline const pattern in nested patterns
Fix explicit deref problems in closure capture
fix the `need-mut` part of #14562
Perhaps surprisingly, it wasn't unique immutable borrow. The code still doesn't emit any of them, and I think those won't happen in edition 2021 (which is currently the only thing implemented), since we always capture `&mut *x` instead of `&mut x`. But I'm not very sure about it.