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
rust: Add a `-C default-linker-libraries` option
This commit adds a new codegen option for the compiler which disables
rustc's passing of `-nodefaultlibs` by default on relevant platforms.
Sometimes Rust is linked with C code which fails to link with
`-nodefaultlibs` and is unnecessarily onerous to get linking correctly
with `-nodefaultlibs`.
An example of this is that when you compile C code with sanitizers and
then pass `-fsanitize=address` to the linker, it's incompatible with
`-nodefaultlibs` also being passed to the linker.
In these situations it's easiest to turn off Rust's default passing of
`-nodefaultlibs`, which was more ideological to start with than
anything! Preserving the default is somewhat important but having this
be opt-in shouldn't cause any breakage.
Closes#54237