NLL fails to suggest "try removing `&mut` here"
Fixes#51191.
This PR adds ``try removing `&mut` here`` suggestions to functions where a mutable borrow is being taken of a `&mut self` or a `self: &mut Self`. This PR also enables the suggestion for adding a `mut` pattern to by-value implicit self arguments without `mut` patterns already.
r? @nikomatsakis
Renumber `proc_macro` tracking issues
Lots of issue links in the compiler still point to https://github.com/rust-lang/rust/issues/38356 which is a bit of a monster issue that isn't serving much purpose any more. I've split the issue into a number of more fine-grained tracking issues to track stabilizations.
do not promote comparing function pointers
This *could* break existing code that relied on fn ptr comparison getting promoted to `'static` lifetime.
Fixes https://github.com/rust-lang/rust/issues/54696
Re-export `getopts` so custom drivers can reference it.
Otherwise, custom drivers will have to use their own copy of `getopts`, which won't match the types used in `CompilerCalls`.
Use impl_header_lifetime_elision in libcore
The feature is approved for stabilization, so let's use it to remove about 300 `'a`s.
Tracking issue for the feature: https://github.com/rust-lang/rust/issues/15872
make run-pass tests with empty main just compile-pass tests
Many run-pass tests have an empty main, so there is not actually any point in running them. This makes them `compile-pass` tests instead, saving some time (generating the binary and then running it).
For now I did this only for `run-pass/issues`; if there is interest I can also do it for the other directories. I used `^\s*fn\s+main\(\s*\)\s*\{\s*\}` as regexp to identify these files.
Add `crate::` to trait suggestions in Rust 2018.
Fixes#54559.
In the 2018 edition, when suggesting traits to import that implement a
given method that is being invoked, suggestions will now include the
`crate::` prefix if the suggested trait is local to the current crate.
r? @nikomatsakis
Allow both explicit and elided lifetimes in the same impl header
While still prohibiting explicit and in-band in the same header.
Fixes#54456
As usual, I don't know the broader context of the code I'm changing, so please let me know whatever I can do better.
Pre-existing test that mixing explicit and in-band remains an error: https://github.com/rust-lang/rust/blob/master/src/test/ui/in-band-lifetimes/E0688.rs
#53840: Consolidate pattern check errors
#53840 on this PR we are aggregating `cannot bind by-move and by-ref in the same pattern` message present on the different lines into one diagnostic message. Here we are first gathering those `spans` on `vector` then we are throwing them with the help of `MultiSpan`
r? @estebank
Addresses: #53480
we are consolidating `cannot bind by-move and by-ref in the same
pattern` message present on the different lines into single diagnostic
message.
To do this, we are first gathering those spans into the vector
after that we are throwing them with the help of MultiSpan in
a separate block.
Addresses: #53840
normalize param-env type-outlives predicates last
The normalization of type-outlives predicates can depend on misc.
environment predicates, but not the other way around. Inferred lifetime
bounds can propagate type-outlives bounds far and wide, so their
normalization needs to work well.
Fixes#54467
r? @nikomatsakis
beta-nominating because this is required for inferred_outlives_bounds, which is in beta
This commit takes a different approach to add the `crate::` prefix to
item paths than previous commits. Previously, recursion was stopped
after a prelude crate name was pushed to the path. It is theorized that
this was the cause of the linking issues since the same path logic is
used for symbol names and that not recursing meant that details were
being missed that affect symbol names. As of this commit, instead of
ceasing recursion, a flag is passed through to any subsequent recursive
calls so that the same effect can be achieved by checking that flag.
Avoid hardcoding and special-casing the `std` crate name in the item
path logic by moving the prelude crate name logic into the `Session`
type so it can be reused in the item path logic and resolve module.
In the 2018 edition, when suggesting traits to import that implement a
given method that is being invoked, suggestions will now include the
`crate::` prefix if the suggested trait is local to the current crate.
This commit improves mutability error suggestions by suggesting the
removal of `&mut` where a mutable borrow is being taken of a `&mut self`
or a `self: &mut Self`.
This commit adds an `ImplicitSelfKind` to the HIR and the MIR that keeps
track of whether a implicit self argument is immutable by-value, mutable
by-value, immutable reference or mutable reference so that the addition
of the `mut` keyword can be suggested for the immutable by-value case.
do not normalize all non-scalar constants to a ConstValue::ScalarPair
We still need `ConstValue::ScalarPair` for match handling (matching slices and strings), but that will never see anything `Undef`. For non-fat-ptr `ScalarPair`, just point to the allocation like larger data structures do.
Fixes https://github.com/rust-lang/rust/issues/54387
r? @eddyb
The normalization of type-outlives predicates can depend on misc.
environment predicates, but not the other way around. Inferred lifetime
bounds can propagate type-outlives bounds far and wide, so their
normalization needs to work well.
Fixes#54467
Panic when using mem::uninitialized or mem::zeroed on an uninhabited type
All code by @japaric. This re-submits one half of https://github.com/rust-lang/rust/pull/53508. This is likely not the one that introduced the perf regression, but just to be sure I'll do a perf run anyway.
Rollup of 13 pull requests
Successful merges:
- #53784 (Document that slices cannot be larger than `isize::MAX` bytes)
- #54308 (Better user experience when attempting to call associated functions with dot notation)
- #54488 (in which we include attributes in unused `extern crate` suggestion spans)
- #54544 (Indicate how to move value out of Box in docs.)
- #54623 (Added help message for `impl_trait_in_bindings` feature gate)
- #54641 (A few cleanups and minor improvements to rustc/infer)
- #54656 (Correct doc for WorkQueue<T>::pop().)
- #54674 (update miri)
- #54676 (Remove `-Z disable_ast_check_for_mutation_in_guard`)
- #54679 (Improve bug! message for impossible case in Relate)
- #54681 (Rename sanitizer runtime libraries on OSX)
- #54708 (Make ./x.py help <cmd> invoke ./x.py <cmd> -h on its own)
- #54713 (Add nightly check for tool_lints warning)
Remove `-Z disable_ast_check_for_mutation_in_guard`
One should use `#![feature(bind_by_move_pattern_guards)]` over `-Z disable_ast_check_for_mutation_in_guard`
cc #15287
Rename sanitizer runtime libraries on OSX
Currently we ship sanitizer libraries as they're built, but these names
unfortunately conflict with the names of the sanitizer libraries
installed on the system. If a crate, for example, links in C code that
wants to use the system sanitizer and the Rust code doesn't use
sanitizers at all, then using `cargo` may accidentally pull in the
Rust-installed sanitizer library due to a conflict in names.
This change is intended to be entirely transparent for Rust users of
sanitizers, it should only hopefully improve our story with other users!
Closes#54134
Improve bug! message for impossible case in Relate
Hitting this branch [in Clippy][clippy_issue] and I think it makes sense to print
both values here in case other people hit this branch, too.
(still have to figure out why this branch is hit)
[clippy_issue]: https://github.com/rust-lang-nursery/rust-clippy/issues/2831#issuecomment-424597092
Correct doc for WorkQueue<T>::pop().
The old function doc looks like copy-pasta from WorkQueue::insert().
WorkQueue::pop() does not enqueue nor does it return a boolean false. Doc corrected accordingly.
A few cleanups and minor improvements to rustc/infer
- use unwrap_or(_else) where applicable
- convert single-branch matches to if-let
- use to_owned instead of to_string with string literals
- improve vector allocations
- readability improvements
- miscellaneous minor code improvements