Commit Graph

109125 Commits

Author SHA1 Message Date
Dylan DPC
c0369c4523
Rollup merge of #70048 - TyPR124:mutable_osstr, r=dtolnay
Allow obtaining &mut OsStr

```rust
impl DerefMut for OsString {...}              // type Target = OsStr
impl IndexMut<RangeFull> for OsString {...}   // type Output = OsStr
```

---

This change is pulled out of #69937 per @dtolnay

This implements `DerefMut for OsString` to allow obtaining a `&mut OsStr`. This also implements `IndexMut for OsString`, which is used by `DerefMut`. This pattern is the same as is used by `Deref`.

This is necessary to for methods like `make_ascii_lowercase` which need to mutate the underlying value.
2020-03-27 01:23:51 +01:00
Dylan DPC
f635c3757b
Rollup merge of #69936 - Aaron1011:fix/suggestion-cycle, r=varkor
Fix cycle error when emitting suggestion for mismatched `fn` type

Fixes #66667

Previously, we called `tcx.typeck_tables_of` when determining whether or
not to emit a suggestion for a type error. However, we might already be
type-checking the `DefId` we pass to `typeck_tables_of` (it could be
anywhere in the query stack).

Fortunately, we only need the function signature, not the entire
`TypeckTables`. By using `tcx.fn_sig`, we avoid the possibility of cycle
errors while retaining the ability to emit a suggestion.
2020-03-27 01:23:49 +01:00
Dylan DPC
0f6144a115
Rollup merge of #69644 - ecstatic-morse:unified-dataflow-cleanup, r=eddyb
Remove framework in `dataflow/mod.rs` in favor of "generic" one

This is the culmination of the work described in rust-lang/compiler-team#202. All dataflow analyses (including the one in `clippy`) have been ported to use the framework in `dataflow/generic`, which can efficiently handle both gen/kill and generic problems. This PR moves the framework in `dataflow/generic` to `dataflow/framework`, and removes the gen/kill framework in `dataflow/mod.rs`.

More comprehensive documentation for the new framework is tracked in rust-lang/rustc-guide#564.

`clippy` will need to change the path it uses to import the dataflow analysis traits.
2020-03-27 01:23:47 +01:00
Dylan MacKenzie
89d6009461 Make framework a private module 2020-03-26 16:20:00 -07:00
Dylan MacKenzie
fe0e7c3cba Update framework module docs 2020-03-26 16:20:00 -07:00
Dylan MacKenzie
7108cea14e Move BottomValue into framework/mod.rs 2020-03-26 16:20:00 -07:00
Dylan MacKenzie
a8cc89f975 Update imports from dataflow::generic to dataflow 2020-03-26 16:19:58 -07:00
Dylan MacKenzie
93ce5ff587 Update use statements in dataflow/mod.rs 2020-03-26 16:19:21 -07:00
Dylan MacKenzie
bae1114e75 Rename dataflow::generic to dataflow::framework 2020-03-26 16:19:21 -07:00
Dylan MacKenzie
9978afb5d6 Move MoveDataParamEnv to beginning of module 2020-03-26 16:19:21 -07:00
Dylan MacKenzie
15346ed53c Remove BitDenotation framework 2020-03-26 16:19:19 -07:00
bors
62c6006450 Auto merge of #70441 - Dylan-DPC:rollup-qv7h2ph, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #70384 (Refactor object file handling)
 - #70397 (add 'fn write_u16s' to Memory)
 - #70413 (Fix incorrect pattern warning "unreachable pattern")
 - #70428 (`error_bad_item_kind`: add help text)
 - #70429 (Clean up E0459 explanation)
 - #70437 (Miri float->int casts: be explicit that this is saturating)

Failed merges:

r? @ghost
2020-03-26 20:45:47 +00:00
Dylan DPC
195147c7ae
Rollup merge of #70437 - RalfJung:miri-saturate, r=hanna-kruppe
Miri float->int casts: be explicit that this is saturating

r? @hanna-kruppe
Cc https://github.com/rust-lang/miri/issues/1264
2020-03-26 21:44:09 +01:00
Dylan DPC
e5c5e025ac
Rollup merge of #70429 - GuillaumeGomez:cleanup-e0459, r=Dylan-DPC
Clean up E0459 explanation

r? @Dylan-DPC
2020-03-26 21:44:08 +01:00
Dylan DPC
ef43cdee28
Rollup merge of #70428 - Centril:move-to-mod, r=petrochenkov
`error_bad_item_kind`: add help text

For example, this adds:
```
    = help: consider moving the `use` import out to a nearby module scope
```
r? @petrochenkov @estebank

Fixes https://github.com/rust-lang/rust/issues/37205.
2020-03-26 21:44:06 +01:00
Dylan DPC
c640b95662
Rollup merge of #70413 - AminArria:match-pattern-incorrect-warning, r=Centril,Nadrieril,varkor
Fix incorrect pattern warning "unreachable pattern"

Fixes #70372

Added `is_under_guard` parameter to `_match::is_useful` and only add it to the matrix if `false`

Tested with:
```rust
#![feature(or_patterns)]
fn main() {
    match (3,42) {
        (a,_) | (_,a) if a > 10 => {println!("{}", a)}
        _ => ()
    }

    match Some((3,42)) {
        Some((a, _)) | Some((_, a)) if a > 10 => {println!("{}", a)}
        _ => ()

    }

    match Some((3,42)) {
        Some((a, _) | (_, a)) if a > 10 => {println!("{}", a)}
        _ => ()
    }
}
```
2020-03-26 21:44:05 +01:00
Dylan DPC
de3d1e9fa9
Rollup merge of #70397 - JOE1994:write_wide_str, r=RalfJung
add 'fn write_u16s' to Memory

Added new function `Memory::write_u16s`. Needed in `MIRI` for implementing helper function to write wide_str to memory (for Windows).
2020-03-26 21:44:03 +01:00
Dylan DPC
b15423e72e
Rollup merge of #70384 - nnethercote:refactor-object-file-handling, r=alexcrichton
Refactor object file handling

Some preliminary clean-ups that grease the path to #66961.

r? @alexcrichton
2020-03-26 21:44:02 +01:00
Ralf Jung
27777e2e7b Miri float->int casts: be explicit that this is saturating 2020-03-26 19:09:31 +01:00
Amin Arria
ae7fa3042d Add tests based on issue #70372 comments 2020-03-26 12:34:36 -03:00
Amin Arria
5796e6e461 Fix incorrect pattern warning "unreachable pattern"
- Added is_under_guard parameter to _match::is_useful and
  only add to the matrix if false
- Added comments explaining behavior
2020-03-26 12:34:22 -03:00
JOE1994
4538f8953b add 'fn write_u16s'(rustc_mir::interpret::Memory) 2020-03-26 11:01:21 -04:00
Guillaume Gomez
604b7e94e0 Clean up E0459 explanation 2020-03-26 14:21:05 +01:00
Mazdak Farrokhzad
91c68c5fae error_bad_item_kind: add help text 2020-03-26 14:13:50 +01:00
bors
2fbb07525e Auto merge of #70427 - Centril:rollup-lrcad2c, r=Centril
Rollup of 5 pull requests

Successful merges:

 - #68004 (permit negative impls for non-auto traits)
 - #70385 (Miri nits: comment and var name improvement)
 - #70411 (Fix for #62691: use the largest niche across all fields)
 - #70417 (parser: recover on `...` as a pattern, suggesting `..`)
 - #70424 (simplify match stmt)

Failed merges:

r? @ghost
2020-03-26 12:33:18 +00:00
Mazdak Farrokhzad
608715bbd1
Rollup merge of #70424 - lcnr:nit, r=Centril
simplify match stmt

We actually have a surprising amount of
```rust
match expr {
    $($p:pat)|+ => true,
    _ => false,
}
```
While I would prefer this to be replaced with `matches!`, most cases are
fairly readable anyway so we can just let them be for now.
2020-03-26 13:32:20 +01:00
Mazdak Farrokhzad
37e186087c
Rollup merge of #70417 - rakshith-ravi:master, r=Centril
parser: recover on `...` as a pattern, suggesting `..`

Fixes #70388

My first PR to rust. So please let me know if I'm doing something wrong.
2020-03-26 13:32:18 +01:00
Mazdak Farrokhzad
f9d1378dd4
Rollup merge of #70411 - ogoffart:fix-62691, r=eddyb
Fix for #62691: use the largest niche across all fields

fixes #62691

(The second commit is a small optimization but it makes the code less pretty and i don't know if it is worth it.)
2020-03-26 13:32:17 +01:00
Mazdak Farrokhzad
20771ae5b9
Rollup merge of #70385 - RalfJung:miri-nits, r=eddyb
Miri nits: comment and var name improvement

r? @eddyb
2020-03-26 13:32:15 +01:00
Mazdak Farrokhzad
b0a63cb932
Rollup merge of #68004 - nikomatsakis:negative-impls, r=varkor
permit negative impls for non-auto traits

This is a prototype impl that extends `impl !Trait` beyond auto traits. It is not integrated with coherence or anything else, and hence only serves to prevent downstream impls (but not to allow downstream crates to rely on the absence of such impls for coherence purposes).

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

TODO:

- [x] need a test that you can't rely on negative impls for coherence purposes
- [x] test that negative impls cannot specialize positive ones
- [x] test that positive impls cannot specialize negative ones
- [x] extend negative impl to `Clone` in order to fully fix #66544
- [x] and maybe make `CoerceUnsized` unsafe? -- that problem is now split out into https://github.com/rust-lang/rust/issues/68015
- [x] introduce feature flag and prepare a write-up
- [x] improve diagnostics?
2020-03-26 13:32:14 +01:00
Olivier Goffart
0b00c20465 Reorganize a bit the code and add a comment 2020-03-26 13:14:25 +01:00
Niko Matsakis
0d0702623f wip pacify the merciless ui tests 2020-03-26 07:41:26 -04:00
Niko Matsakis
011215b2c7 pacify the merciless x.py fmt 2020-03-26 06:52:58 -04:00
Niko Matsakis
c35801e160 use slice pattern instead of calling is_empty() and [0] 2020-03-26 06:52:58 -04:00
Niko Matsakis
b9e09d8f65 add test for negative specializes negative 2020-03-26 06:52:58 -04:00
Niko Matsakis
f5c09ed344 move stderr file too 2020-03-26 06:52:58 -04:00
Niko Matsakis
644b9a0a94 give the negative-impls-builtin test a more sensible name 2020-03-26 06:52:58 -04:00
Niko Matsakis
7107f6e606 comment the typeck-negative-impls-builtin test 2020-03-26 06:52:58 -04:00
Niko Matsakis
f66284778a move feature-gate-negative-impls test to traits/negative-impls 2020-03-26 06:52:58 -04:00
Niko Matsakis
73a55009ac convert to doc comments 2020-03-26 06:52:58 -04:00
Niko Matsakis
68aa798436 bump negative impls version to 1.44.0 2020-03-26 06:52:58 -04:00
Niko Matsakis
cc0d6d03f6 create a tracking issue and link to it 2020-03-26 06:52:57 -04:00
Niko Matsakis
fda3378e3f introduce negative_impls feature gate and document
They used to be covered by `optin_builtin_traits` but negative impls
are now applicable to all traits, not just auto traits.

This also adds docs in the unstable book for the current state of auto traits.
2020-03-26 06:52:55 -04:00
Niko Matsakis
65071708f8 make a custom error for overlap with negative impls 2020-03-26 06:52:26 -04:00
Niko Matsakis
e8a05e201e permit negative impls for non-auto traits 2020-03-26 06:27:45 -04:00
Bastian Kauschke
c21e25c262 simplify match stmt 2020-03-26 10:52:52 +01:00
Rakshith Ravi
73c82030e8 Throw error when encountering ... instead of .. while destructing a pattern
Added tests and stderr output
2020-03-26 13:25:34 +05:30
bors
3b1d735118 Auto merge of #70391 - RalfJung:miri, r=RalfJung
update miri

Usually I'd wait until https://github.com/rust-lang/rust/pull/70226 lands which will break Miri again, but... the queue is empty (!), so whatever.^^

r? @ghost Cc @oli-obk
Fixes https://github.com/rust-lang/rust/issues/70346
2020-03-26 07:36:21 +00:00
Ralf Jung
5d12f22f35 update miri 2020-03-26 08:21:30 +01:00
Nicholas Nethercote
a50cca920d Convert a chained if-else to a match.
It makes things a little clearer.
2020-03-26 13:53:03 +11:00