| Age | Commit message (Collapse) | Author | Lines |
|
|
|
|
|
|
|
Fix a number of uncovered deficiencies in diagnostics
|
|
|
|
also updated some error messages
removed the code manually checking for `receiver_ty: Deref<Target=self_ty>`, in favour of using autoderef but only doing one iteration. This will cause error messages to be more consistent. Before, a "mismatched method receiver" error would be emitted when `receiver_ty` was valid except for a lifetime parameter, but only when `feature(arbitrary_self_types)` was enabled, and without the feature flag the error would be "uncoercible receiver". Now it emits "mismatched method receiver" in both cases.
|
|
|
|
|
|
|
|
I also added `// skip-codegen` to each one, to address potential concerns
that this change would otherwise slow down our test suite spending time
generating code for files that are really just meant to be checks of
compiler diagnostics.
(However, I will say: My preference is to not use `// skip-codegen` if
one can avoid it. We can use all the testing of how we drive LLVM that
we can get...)
(Updated post rebase.)
|
|
|
|
Move parse-fail tests to UI
cc https://github.com/rust-lang/rust/issues/53353
r? @davidtwco
|
|
This gives at least some explanation for why a borrow is expected to
last for a certain free region. Also:
* Reports E0373: "closure may outlive the current function" with NLL.
* Special cases the case of returning a reference to (or value
referencing) a local variable or temporary (E0515).
* Special case assigning a reference to a local variable in a closure
to a captured variable.
|
|
|
|
This commit enhances `LaterUseKind` detection to identify when a borrow
is captured by a trait object which helps explain why there is a borrow
error.
|
|
|
|
Give a special message when the later use is from a call. Use the span
of the callee instead of the whole expression. For conflicting borrow
messages say that the later use is of the first borrow.
|
|
Rollup of 10 pull requests
Successful merges:
- #54269 (#53840: Consolidate pattern check errors)
- #54458 (Allow both explicit and elided lifetimes in the same impl header)
- #54603 (Add `crate::` to trait suggestions in Rust 2018.)
- #54648 (Update Cargo's submodule)
- #54680 (make run-pass tests with empty main just compile-pass tests)
- #54687 (Use impl_header_lifetime_elision in libcore)
- #54699 (Re-export `getopts` so custom drivers can reference it.)
- #54702 (do not promote comparing function pointers)
- #54728 (Renumber `proc_macro` tracking issues)
- #54745 (make `CStr::from_bytes_with_nul_unchecked()` a const fn)
Failed merges:
r? @ghost
|
|
|
|
|
|
|
|
Issue #54131
|
|
|
|
When dropping a self-borrowing struct we shouldn't add a "values in a
scope are dropped in the opposite order they are defined" message,
since there is only one value being dropped.
|
|
r=nikomatsakis
Report when borrow could cause `&mut` aliasing during Drop
We were already issuing an error for the cases where this cropped up, so this is not fixing any soundness holes. The previous diagnostic just wasn't accurately describing the problem in the user's code.
Fix #52059
|
|
|
|
It is worth pointing out that the reason that so few diagnostics are
effected is because of the filter I put in where it only goes down the
new path if the borrowed place is *not* a prefix of the dropped place.
(Without that filter, a *lot* of the tests would need this change, and
it would probably be a net loss for the UX, since you'd see it even in
cases like borrows of generic types where there is no explicit mention
of `Drop`.)
|
|
use structured suggestion for "missing mut" label
Fixes #54133 for both NLL and non-NLL.
r? @estebank
I'm not super happy with the existing wording here, since it's now a suggestion. I wonder if the message would work better as something like "help: make binding mutable: `mut foo`"?
Also, are the `HELP` and `SUGGESTION` comments necessary?
|
|
[NLL] Suggest let binding
Closes #49821
Also adds an alternative to `explain_why_borrow_contains_point` that allows changing error messages based on the reason that will be given. This will also be useful for #51026, #51169 and maybe further changes to does not live long enough messages.
|
|
Fixes #54133.
|
|
|
|
|
|
Use smaller span for adjustments on block expressions
When returning a mutable reference don't use the entire body of the function as the span for the adjustments at the end.
The error [in this case](https://github.com/rust-lang/rust/compare/master...matthewjasper:hair-spans?expand=1#diff-ecef8b1f15622fb48a803c9b61605c78) is worse, but neither error message is really what we want. I have some ideas on how to get a better error message that will have to wait for a future PR.
|
|
|
|
resolve_macro_to_def`
|
|
|
|
zackmdavis:dead_code_lint_should_say_2_electric_boogaloo, r=pnkfelix
dead-code lint: say "constructed" for structs
Respectively.
This is a sequel to November 2017's #46103 / 1a9dc2e9. It had been
reported (more than once—at least #19140, #44083, and #44565) that the
"never used" language was confusing for enum variants that were "used"
as match patterns, so the wording was changed to say never "constructed"
specifically for enum variants. More recently, the same issue was raised
for structs (#52325). It seems consistent to say "constructed" here,
too, for the same reasons.
~~While we're here, we can also use more specific word "called" for unused
functions and methods. (We declined to do this in #46103, but the
rationale given in the commit message doesn't actually make sense.)~~
This resolves #52325.
|
|
|
|
NLL: Better Diagnostic When "Later" means "A Future Loop Iteration"
Part of #52663.
r? @pnkfelix
|
|
(Presumably the place that borrow_check ends up reporting for the
error about is no longer the root `Local` itself, and thus the note
diagnostic here stops firing.)
|
|
iterations of loops.
|
|
NLL: sort diagnostics by span
Sorting the output diagnostics by span is a long planned revision to the NLL diagnostics that we hope will yield a less surprising user experience in some case.
Once we got them buffered, it was trivial to implement. (The hard part is skimming the resulting changes to the diagnostics to make sure nothing broke... Note that I largely rubber-stamped the `#[rustc_regions]` output change.)
Fix #51167
|
|
|
|
|
|
|
|
Don't match on region kinds when reporting NLL errors
First half (by number of tests affected) of the changes to "does not live long enough".
Now that lexical MIR borrowck is gone, region kinds are always ReVar, so matching on them to change errors does nothing.
Changes "borrowed value only lives until here" to "`x` is dropped here while still borrowed".
r? @pnkfelix cc @nikomatsakis
|
|
Do not suggest using `to_owned()` on `&str += &str`
- Don't provide incorrect suggestion for `&str += &str` (fix #52410)
- On `&str + String` suggest `&str.to_owned() + &String` as a single suggestion
|
|
With NLL region kinds are always ReVar
|
|
|
|
Reword when `_` couldn't be inferred
r? @nikomatsakis
|