| Age | Commit message (Collapse) | Author | Lines |
|
Also fix some formatting along the way.
|
|
|
|
|
|
|
|
Use Applicability::Unspecified for all of them instead.
|
|
|
|
Fixes #54133.
|
|
Co-authored-by: nikomatsakis
|
|
|
|
|
|
|
|
|
|
fix for late-bound regions
Fix for https://github.com/rust-lang/rust/issues/53419
r? @nikomatsakis
|
|
|
|
or "".into()
|
|
Rollup of 10 pull requests
Successful merges:
- #53418 (Mark some suggestions as MachineApplicable)
- #53431 (Moved some feature gate ui tests to correct location)
- #53442 (Update version of rls-data used with save-analysis)
- #53504 (Set applicability for more suggestions.)
- #53541 (Fix missing impl trait display as ret type)
- #53544 (Point at the trait argument when using unboxed closure)
- #53558 (Normalize source line and column numbers.)
- #53562 (Lament the invincibility of the Turbofish)
- #53574 (Suggest direct raw-pointer dereference)
- #53585 (Remove super old comment on function that parses items)
Failed merges:
- #53472 (Use FxHash{Map,Set} instead of the default Hash{Map,Set} everywhere in rustc.)
- #53563 (use String::new() instead of String::from(""), "".to_string(), "".to_owned() or "".into())
r? @ghost
|
|
Set applicability for more suggestions.
Converts a couple more calls to `span_suggestion_with_applicability` (#50723). To be on the safe side, I marked suggestions that depend on the intent of the user or that are potentially lossy conversions as MaybeIncorrect.
r? @estebank
|
|
Mark some suggestions as MachineApplicable
I think the following suggestions should be safe to mark as `MachineApplicable`.
r? @estebank
|
|
|
|
Ty{Adt|Array|Slice|RawPtr|Ref|FnDef|FnPtr|Dynamic|Closure|Generator|GeneratorWitness|Never|Tuple|Projection|Anon|Infer|Error}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(old) borrowck cleanup
Primarily moves dataflow code based on CFG to borrowck; this is mostly so we don't forget to delete it once it becomes unused after we fully move to MIR borrowck.
|
|
Add help message for missing `IndexMut` impl
Code:
```rust
let mut map = HashMap::new();
map.insert("peter", 23);
map["peter"] = 27;
```
Before:
```
error[E0594]: cannot assign to immutable indexed content
--> src/main.rs:7:5
|
7 | map["peter"] = 27;
| ^^^^^^^^^^^^^^^^^ cannot borrow as mutable
```
With this change (just the `help` was added):
```
error[E0594]: cannot assign to immutable indexed content
--> index-error.rs:7:5
|
7 | map["peter"] = 27;
| ^^^^^^^^^^^^^^^^^ cannot borrow as mutable
|
= help: trait `IndexMut` is required to modify indexed content, but it is not implemented for std::collections::HashMap<&str, i32>
```
---
Yesterday I did some pair programming with a Rust-beginner. We created a type and implemented `Index` for it. Trying to modify the value returned by the index operation returns in a rather vague error that was not very clear for the Rust beginner. So I tried to improve the situation.
## Notes/questions for reviewers:
- Is the formulation OK like that? I'm fine with changing it.
- Can we be absolutely sure that `IndexMut` is actually not implemented in the case my `help` message is added? I'm fairly sure myself, but there could be some cases I didn't think of. Also, I don't know the compiler very well, so I don't know what exactly certain enum variants are used for.
- It would be nice to test if `IndexMut` is in fact not implemented for the type, but I couldn't figure out how to check that. If you think that additional check would be beneficial, could you tell me how to check if a trait is implemented?
- Do you think I should change the error message instead of only adding an additional help message?
|
|
|
|
Previously it was only emitted for assigments, which was an
unnecessary restriction. Now it doesn't care where the mutability
comes from.
This commit also adds `` quotes around the printed type.
|
|
|
|
|
|
No one else uses it.
|
|
Don't format!() string literals
Prefer `to_string()` to `format!()` take 2, this time targetting string literals. In some cases (`&format!("...")` -> `"..."`) also removes allocations. Occurences of `format!("")` are changed to `String::new()`.
|
|
Prefer to_string() to format!()
Simple benchmarks suggest in some cases it can be faster by even 37%:
```
test converting_f64_long ... bench: 339 ns/iter (+/- 199)
test converting_f64_short ... bench: 136 ns/iter (+/- 34)
test converting_i32_long ... bench: 87 ns/iter (+/- 16)
test converting_i32_short ... bench: 87 ns/iter (+/- 49)
test converting_str ... bench: 54 ns/iter (+/- 15)
test formatting_f64_long ... bench: 349 ns/iter (+/- 176)
test formatting_f64_short ... bench: 145 ns/iter (+/- 14)
test formatting_i32_long ... bench: 98 ns/iter (+/- 14)
test formatting_i32_short ... bench: 93 ns/iter (+/- 15)
test formatting_str ... bench: 86 ns/iter (+/- 23)
```
|
|
|
|
Before this change it simply says "cannot assign to immutable indexed
content". This might be confusing for Rust beginners, as implementing
two traits for "one operator" is not intuitive.
|
|
Use a slice where a vector is not necessary
|
|
Rollup of bare_trait_objects PRs
All deny attributes were moved into bootstrap so they can be disabled with a line of config.
Warnings for external tools are allowed and it's up to the tool's maintainer to keep it warnings free.
r? @Mark-Simulacrum
cc @ljedrz @kennytm
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Rollup of 17 pull requests
Successful merges:
- #51962 (Provide llvm-strip in llvm-tools component)
- #52003 (Implement `Option::replace` in the core library)
- #52156 (Update std::ascii::ASCIIExt deprecation notes)
- #52280 (llvm-tools-preview: fix build-manifest)
- #52290 (Deny bare trait objects in src/librustc_save_analysis)
- #52293 (Deny bare trait objects in librustc_typeck)
- #52299 (Deny bare trait objects in src/libserialize)
- #52300 (Deny bare trait objects in librustc_target and libtest)
- #52302 (Deny bare trait objects in the rest of rust)
- #52310 (Backport 1.27.1 release notes to master)
- #52315 (Resolve FIXME(#27942))
- #52316 (task: remove wrong comments about non-existent LocalWake trait)
- #52322 (Update llvm-rebuild-trigger in light of LLVM 7 upgrade)
- #52330 (Don't silently ignore invalid data in target spec)
- #52333 (CI: Enable core dump on Linux, and print their stack trace on segfault. )
- #52346 (Fix typo in improper_ctypes suggestion)
- #52350 (Bump bootstrap compiler to 1.28.0-beta.10)
Failed merges:
r? @ghost
|
|
Also teach rustc_borrowck not to show useless help messages like
"use a mutable reference instead: `x`".
|
|
|
|
|