Commit Graph

862 Commits

Author SHA1 Message Date
Blitzerr 6779bb485c capture_disjoint_fields(rust-lang#53488)
Refactoring out the HirId of the UpvarId in another struct.
2018-11-14 21:18:48 -08:00
scalexm 45be1ac0fc Remove `ReCanonical` in favor of `ReLateBound` 2018-11-03 11:41:55 +01:00
bors f32f1113c9 Auto merge of #55150 - pnkfelix:issues-47215-54797-fix-ice-from-moving-out-of-thread-local-under-ast-borrowck, r=nikomatsakis
Do not allow moving out of thread local under ast borrowck

AST borrowck failed to prevent moving out of a thread-local static.

This was broken. And it also (sometimes?) caused an ICE during drop elaboration.

Fix #47215
Fix #54797
2018-10-27 09:56:37 +00:00
Shotaro Yamada 3878d24ef6 Remove redundant clone 2018-10-26 12:07:39 +09:00
Oliver Scherer 3c9258e604 Prefer `Default::default` over `FxHash*::default` in struct constructors 2018-10-19 14:34:44 +02:00
Oliver Scherer ee81739dc1 Deprecate the `FxHashMap()` and `FxHashSet()` constructor function hack 2018-10-19 14:34:44 +02:00
David Wood aa701154f0
Extend closure special-casing for generators.
This commit extends existing special-casing of closures to highlight the
use of variables within generators that are causing the generator to
borrow them.
2018-10-18 17:48:18 +02:00
Felix S. Klock II a75f7810a7 AST-borrowck: add separate mem category for thread-locals, as they are not quite rvalues
(and of course they are not quite statics either).

Namely, they *do* have a restricted region (like rvalues), but they
also cannot be moved out of (like statics).
2018-10-17 16:31:22 +02:00
bors 25a75a4d86 Auto merge of #54847 - ljedrz:kill_graphviz_intocow, r=pnkfelix
Cleanup: remove graphviz::IntoCow

It's just `Into<Cow<...>>` and the applicable methods already exist for `Vec`/`[T]` and `String`/`str`.
2018-10-08 06:50:25 +00:00
ljedrz a256a66305 rustc/middle: use Cow<'static, str> where applicable 2018-10-06 10:24:53 +02:00
Pietro Albini 3810657ae3
Rollup merge of #54787 - varkor:unused-mut-in-desugaring, r=nikomatsakis
Only warn about unused `mut` in user-written code

Fixes https://github.com/rust-lang/rust/issues/54586.

r? @pnkfelix
cc @blitzerr
2018-10-05 22:33:13 +02:00
ljedrz c30ce35705 Remove graphviz::IntoCow 2018-10-05 14:16:10 +02:00
Niko Matsakis 4cd4eae435 rename skolemized to placeholder 2018-10-04 11:02:40 -04:00
varkor 113141b6f5 Only warn about unused `mut` in user-written code 2018-10-03 14:14:11 +01:00
David Wood 43b5d725d0
Improve implicit self mutability suggestions.
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.
2018-10-02 00:35:15 +02:00
Josh Stone ce034951fb Bump to 1.31.0 and bootstrap from 1.30 beta 2018-09-27 20:52:53 -07:00
bors 992d1e4d3d Auto merge of #54241 - vi:suggest_with_applicability, r=estebank
Remove usages of span_suggestion without Applicability

Use `Applicability::Unspecified` for all of them instead.

Shall deprecations for the non-`_with_applicability` functions be added?

Shall clippy be addressed somehow?

r? @estebank
2018-09-20 06:34:22 +00:00
Vitaly _Vi Shukela d0790c490a
Whitespace fix again. 2018-09-17 20:26:05 +03:00
bors ed9439768e Auto merge of #54260 - maxdeviant:public-scope-fields, r=petrochenkov
Make rustc::middle::region::Scope's fields public

This PR makes the following changes to `rustc::middle::region::Scope`:

- [x] Makes `region::Scope`'s fields public
- [x] Removes the `impl Scope` block with constructors (as per [this comment](https://github.com/rust-lang/rust/pull/54032#discussion_r216618208))
- [x] Updates call sites throughout the compiler

Closes #54122.
2018-09-17 06:34:29 +00:00
Vitaly _Vi Shukela 2b77760944
Fill in suggestions Applicability according to @estebank
Also fix some formatting along the way.
2018-09-17 03:20:08 +03:00
Vitaly _Vi Shukela c61f4a7144
Fix tidy's too long lines. 2018-09-17 02:51:50 +03:00
Vitaly _Vi Shukela 6ebb9161ea
Fix style according to review comments. 2018-09-17 02:49:27 +03:00
Vitaly _Vi Shukela f395072c4d
Fixup inaccurate rebase 2018-09-16 22:13:41 +03:00
Vitaly _Vi Shukela b6fea3255c
Remove usages of span_suggestion without Applicability
Use Applicability::Unspecified for all of them instead.
2018-09-16 21:42:46 +03:00
Marshall Bowers fa1868d9da Make rustc::middle::region::Scope's fields public 2018-09-15 13:10:29 -04:00
Andy Russell d871b8ad4a
use structured suggestion for "missing mut" label
Fixes #54133.
2018-09-12 17:16:18 -04:00
toidiu 731f4efae5 stabalize infer outlives requirements (RFC 2093).
Co-authored-by: nikomatsakis
2018-09-11 11:40:04 -04:00
varkor e2a1cce9c5 Rename hir::map::NodeKind to hir::Node 2018-08-27 21:46:23 +01:00
varkor 11665ca45a Remove path prefixes from NodeKind 2018-08-27 21:46:13 +01:00
varkor 4b12f700db Remove Node* prefix from AnnNode 2018-08-27 21:45:46 +01:00
varkor befc4b1100 Rename hir::map::Node to hir::map::NodeKind 2018-08-27 21:45:46 +01:00
bors 70a21e89f1 Auto merge of #53441 - toidiu:ak-fix53419, r=nikomatsakis
fix for late-bound regions

Fix for https://github.com/rust-lang/rust/issues/53419

r? @nikomatsakis
2018-08-27 17:42:45 +00:00
Niko Matsakis 73fb1622b3 check that adding infer-outlives requirement to all crates works 2018-08-24 17:10:50 -04:00
Matthias Krüger ede1f7d2a5 use String::new() instead of String::from(""), "".to_string(), "".to_owned() or "".into() 2018-08-23 10:14:52 +02:00
bors f1b506af02 Auto merge of #53607 - GuillaumeGomez:rollup, r=GuillaumeGomez
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
2018-08-22 19:59:52 +00:00
Guillaume Gomez 4fa4bb5633
Rollup merge of #53504 - ekse:suggestions-applicability-2, r=estebank
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
2018-08-22 17:45:34 +02:00
Guillaume Gomez 8255f9e7a9
Rollup merge of #53418 - ekse:suggestions-applicability, r=estebank
Mark some suggestions as MachineApplicable

I think the following suggestions should be safe to mark as `MachineApplicable`.

r? @estebank
2018-08-22 17:45:29 +02:00
varkor 08f3685a82 Remove unnecessary TyKind::s 2018-08-22 16:08:49 +01:00
varkor 6f637da50c Remove Ty prefix from Ty{Adt|Array|Slice|RawPtr|Ref|FnDef|FnPtr|Dynamic|Closure|Generator|GeneratorWitness|Never|Tuple|Projection|Anon|Infer|Error} 2018-08-22 16:07:44 +01:00
varkor d37cee3b0e Rename ty::TyVariants to ty::TyKind 2018-08-22 16:05:50 +01:00
Sébastien Duquette 5a23a0d283 Set applicability for more suggestions. 2018-08-20 03:56:06 -04:00
Donato Sciarra d3fe97f3d3 mv codemap() source_map() 2018-08-19 23:01:01 +02:00
Eduard-Mihai Burtescu 14aed81d9a Use the new Entry::or_default method where possible. 2018-08-18 20:19:45 +03:00
Sébastien Duquette e6657154c4 Mark some suggestions as MachineApplicable 2018-08-15 22:59:56 -04:00
ashtneoi a05f82fd2d Suggest match ergonomics, not `ref`/`ref mut` 2018-08-15 15:14:21 -07:00
bors fa23350a46 Auto merge of #52928 - Mark-Simulacrum:borrowck-cleanup, r=cramertj
(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.
2018-08-15 00:37:52 +00:00
bors fb65d7563c Auto merge of #52788 - LukasKalbertodt:improve-index-mut-error, r=estebank
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?
2018-08-09 22:05:18 +00:00
memoryruins f8367a3450 librustc_borrowck: enable feature(nll) for bootstrap 2018-08-09 01:49:46 -04:00
Lukas Kalbertodt 764d472b1f
Make `IndexMut` note apply to more cases
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.
2018-08-07 23:08:34 +02:00
varkor c81b95f305 Remove unnecessary feature attributes that sneaked in 2018-08-05 15:54:49 +01:00