Commit Graph

136780 Commits

Author SHA1 Message Date
LingMan 5a706cfc49 Use Option::unwrap_or instead of open-coding it 2021-01-16 20:13:06 +01:00
LingMan 76003f31f1 Use Option::map instead of open-coding it 2021-01-16 20:05:02 +01:00
flip1995 13728b8975
Deprecate unknown_clippy_lints
This is now handled by unknown_lints
2021-01-16 19:44:46 +01:00
flip1995 5e3df4266a
More advanced unknown lint suggestion
This copies the unknown_lints code clippy uses for its
unknown_clippy_lints lint to rustc. The unknown_clippy_lints code is
more advanced, because it doesn't suggest renamed or removed lints and
correctly suggest lower casing lints.
2021-01-16 19:44:46 +01:00
Bastian Kauschke 15f0921d0c correctly deal with late-bound lifetimes in anon consts 2021-01-16 19:27:42 +01:00
Stein Somers bb61cc48b3 BTreeMap: offer merge in variants with more clarity 2021-01-16 18:56:03 +01:00
Mara Bos a6b2e1f046
Rollup merge of #81081 - bugadani:double-partialeq, r=Mark-Simulacrum
Add test for #34792

Closes #34792
2021-01-16 17:30:17 +00:00
Mara Bos dd86fc6228
Rollup merge of #81069 - ogoffart:rc_new_cyclic_doc, r=Mark-Simulacrum
Add sample code for Rc::new_cyclic
2021-01-16 17:30:15 +00:00
Mara Bos 61be4e8024
Rollup merge of #81065 - osa1:cranelift_semicolon_warning, r=jyn514
codegen_cranelift: Fix redundant semicolon warn
2021-01-16 17:30:13 +00:00
Mara Bos b67689bdf5
Rollup merge of #81060 - nagisa:nagisa/regression-50041, r=Mark-Simulacrum
Add a regression test for #50041

AFAICT the test case never landed alongside the fix for the issue.
2021-01-16 17:30:12 +00:00
Mara Bos 9df8dcbcde
Rollup merge of #81040 - osa1:fix_80992, r=jyn514
doctest: Reset errors before dropping the parse session

The first parse is to collect whether the code contains macros, has
`main`, and uses other crates. In that pass we ignore errors as those
will be reported when the test file is actually built.

For that we need to reset errors in the `Diagnostic` otherwise when
dropping it unhandled errors will be reported as compiler bugs.

Fixes #80992
2021-01-16 17:30:10 +00:00
Mara Bos 1368e81bcb
Rollup merge of #81021 - CraftSpider:rustdoc-remove-import, r=jyn514
Remove doctree::Import

Per the title. Part of cleaning up doctree
2021-01-16 17:30:08 +00:00
Mara Bos 4a48651b0e
Rollup merge of #80971 - camelid:feature-gate-testsuite-organization, r=Mark-Simulacrum
Put all feature gate tests under `feature-gates/`

There was one directory that had only a single test and there was also a
test in the top-level directory. This moves both of them to
`feature-gates/`.
2021-01-16 17:30:06 +00:00
Mara Bos dba6c9c6d1
Rollup merge of #80968 - KodrAus:stabilize/poll_map, r=Mark-Simulacrum
Stabilize the poll_map feature

Stabilizes the `poll_map` feature as tracked by #63514 (with a completed FCP).
2021-01-16 17:30:04 +00:00
Mara Bos 79a8499f77
Rollup merge of #80941 - JohnTitor:ref-mut-pat-in-loops, r=varkor
Do not suggest invalid code in pattern with loop

Fixes #80913
2021-01-16 17:30:02 +00:00
Mara Bos b3aa880cb4
Rollup merge of #80902 - JohnTitor:issue-76281, r=Mark-Simulacrum
Add a regression test for #76281

This has been fixed between 1.47.0-nightly (663d2f5cd 2020-08-22) and 1.47.0-nightly (5180f3da5 2020-08-23). Maybe fixed by #73526?

Created `wasm` dir, it currently has only one test but I'll move some wasm-related tests there as a follow-up.

Closes #76281
2021-01-16 17:30:00 +00:00
Mara Bos 5b5aa102b9
Rollup merge of #80901 - jyn514:better-colors, r=Mark-Simulacrum
Make `x.py --color always` apply to logging too

Follow-up to https://github.com/rust-lang/rust/pull/78548, https://github.com/rust-lang/rust/pull/79004.

r? ```@Mark-Simulacrum```
2021-01-16 17:29:58 +00:00
Mara Bos 5702cfa255
Rollup merge of #80764 - CAD97:weak-unsized-as-ptr-again, r=RalfJung
Re-stabilize Weak::as_ptr and friends for unsized T

As per [T-lang consensus](https://hackmd.io/7r3_is6uTz-163fsOV8Vfg), this uses a branch to handle the dangling case. The discussed optimization of only doing the branch in the T: ?Sized case is left for a followup patch, as doing so is not trivial (as it requires specialization) and not _obviously_ better (as it requires using `wrapping_offset` rather than `offset` more).

<details><summary>Basically said optimization</summary>

Specialize on `T: Sized`:

```rust
fn as_ptr(&self) -> *const T {
    if [ T is Sized ] || !is_dangling(ptr) {
        (ptr as *mut T).set_ptr_value( (ptr as *mut u8).wrapping_offset(data_offset) )
    } else {
        ptr::null()
    }
}

fn from_raw(*const T) -> Self {
    if [ T is Sized ] || !ptr.is_null() {
        let ptr = (ptr as *mut RcBox).set_ptr_value( (ptr as *mut u8).wrapping_offset(-data_offset) );
        Weak { ptr }
    } else {
        Weak::new()
    }
}
```

(but with more `set_ptr_value` to avoid `Sized` restrictions and maintain metadata.)

Written in this fashion, this is not a correctness-critical specialization (i.e. so long as `[ T is Sized ]` is false for unsized `T`, it can be `rand()` for sized `T` without breaking correctness), but it's still touchy, so I'd rather do it in another PR with separate review.

---
</details>

This effectively reverts #80422 and re-establishes #74160. T-libs [previously signed off](https://github.com/rust-lang/rust/pull/74160#issuecomment-660539373) on this stable API change in #74160.
2021-01-16 17:29:56 +00:00
Mara Bos 40d2506cab
Rollup merge of #80681 - ChrisJefferson:logic-error-doc, r=m-ou-se
Clarify what the effects of a 'logic error' are

This clarifies what a 'logic error' is (which is a term used to describe what happens if you put things in a hash table or btree and then use something like a refcell to break the internal ordering). This tries to be as vague as possible, as we don't really want to promise what happens, except "bad things, but not UB". This was discussed in #80657
2021-01-16 17:29:53 +00:00
Mara Bos d8843d9d82
Rollup merge of #80670 - the8472:fix-zip-trusted-random-access-composition, r=m-ou-se
TrustedRandomAaccess specialization composes incorrectly for nested iter::Zips

I found this while working on improvements for TRA.

After partially consuming a Zip adapter and then wrapping it into another Zip where the adapters use their `TrustedRandomAccess` specializations leads to the outer adapter returning elements which should have already been consumed.

If the optimizer gets tripped up by the addition this might affect performance for chained `zip()` iterators even when the inner one is not partially advanced but it would require more extensive fixes to `TrustedRandomAccess` to communicate those offsets earlier.

Included test fails on nightly, [playground link](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=24fa1edf8a104ff31f5a24830593b01f)
2021-01-16 17:29:51 +00:00
Mara Bos af5b0d9883
Rollup merge of #80614 - 1000teslas:issue-78938-fix, r=tmandry
Explain why borrows can't be held across yield point in async blocks

For https://github.com/rust-lang/rust/issues/78938.
2021-01-16 17:29:49 +00:00
Mara Bos d2b63d455c
Rollup merge of #80144 - rust-lang:frewsxcv-patch-3, r=nikomatsakis
Remove giant badge in README

Is it meant to be this big? I haven't seen any other open source project with this sort of thing
2021-01-16 17:29:47 +00:00
Mara Bos 6bb06f4f23
Rollup merge of #78455 - udoprog:refcell-opt-map, r=KodrAus
Introduce {Ref, RefMut}::try_map for optional projections in RefCell

This fills a usability gap of `RefCell` I've personally encountered to perform optional projections, mostly into collections such as `RefCell<Vec<T>>` or `RefCell<HashMap<U, T>>`:

> This kind of API was briefly featured under Open questions in #10514 back in 2013 (!)

```rust
let values = RefCell::new(vec![1, 2, 3, 4]);
let b = Ref::opt_map(values.borrow(), |vec| vec.get(2));
```

It primarily avoids this alternative approach to accomplish the same kind of projection which is both rather noisy and panicky:
```rust
let values = RefCell::new(vec![1, 2, 3, 4]);

let b = if values.get(2).is_some() {
    Some(Ref::map(values.borrow(), |vec| vec.get(2).unwrap()))
} else {
    None
};
```

### Open questions

The naming `opt_map` is preliminary. I'm not aware of prior art in std to lean on here, but this name should probably be improved if this functionality is desirable.

Since `opt_map` consumes the guard, and alternative syntax might be more appropriate which instead *tries* to perform the projection, allowing the original borrow to be recovered in case it fails:

```rust
pub fn try_map<U: ?Sized, F>(orig: Ref<'b, T>, f: F) -> Result<Ref<'b, U>, Self>
where
    F: FnOnce(&T) -> Option<&U>;
```

This would be more in line with the `try_map` method [provided by parking lot](https://docs.rs/lock_api/0/lock_api/struct.RwLockWriteGuard.html#method.try_map).
2021-01-16 17:29:45 +00:00
bors 492b83c697 Auto merge of #80290 - RalfJung:less-intrinsic-write, r=lcnr
implement ptr::write without dedicated intrinsic

This makes `ptr::write` more consistent with `ptr::write_unaligned`, `ptr::read`, `ptr::read_unaligned`, all of which are implemented in terms of `copy_nonoverlapping`.

This means we can also remove `move_val_init` implementations in codegen and Miri, and its special handling in the borrow checker.

Also see [this Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/ptr.3A.3Aread.20vs.20ptr.3A.3Awrite).
2021-01-16 17:28:32 +00:00
Olivia Crain 65b5e4386b Use PlaceRef more consistently in rustc_mir 2021-01-16 10:44:23 -06:00
Dániel Buga bdc7ff7996 Add test for #34792 2021-01-16 17:08:33 +01:00
Stein Somers d199c5b020 BTreeMap: expose new_internal function and sanitize from_new_internal 2021-01-16 17:07:38 +01:00
Stein Somers 50ee0b2986 BTreeMap: clean up a few more comments 2021-01-16 16:20:00 +01:00
Joshua Nelson 53989e449d Allow configuring the default stage for `x.py check` 2021-01-16 10:07:09 -05:00
Joshua Nelson c17ed34da1 Print which stage is being checked (now that it may not be stage0) 2021-01-16 10:07:09 -05:00
Mark Rousskov 8b702e02c0 Support non-stage0 check 2021-01-16 10:07:09 -05:00
bors 63a83c5f55 Auto merge of #81077 - bugadani:shrink, r=Mark-Simulacrum
Remove unnecessary manual shrink_to_fit calls
2021-01-16 14:04:43 +00:00
Dániel Buga dc932cdf88 Remove unnecessary manual shrink_to_fit calls 2021-01-16 14:02:36 +01:00
bors 410a546fc5 Auto merge of #77435 - hanmertens:binary_heap_append, r=scottmcm
Always use extend in BinaryHeap::append

This is faster, see #77433.

Fixes #77433
2021-01-16 11:10:13 +00:00
Chris Jefferson 78d919280d Clarify what the effects of a 'logic error' are 2021-01-16 09:36:28 +00:00
Olivier Goffart 9952632a2f Add sample code for Rc::new_cyclic 2021-01-16 10:29:21 +01:00
bors efdb859dcd Auto merge of #80873 - ssomers:btree_cleanup_slices_4, r=Mark-Simulacrum
BTreeMap: tougher checks on code using raw into_kv_pointers

r? `@Mark-Simulacrum`
2021-01-16 07:12:12 +00:00
Yuki Okushi 8797986391 Add a regression test for #76281
This has been fixed between 1.47.0-nightly (663d2f5cd 2020-08-22) and 1.47.0-nightly (5180f3da5 2020-08-23).
2021-01-16 14:29:55 +09:00
Scott McMurray 132307c685 Rename as_chunks_mut_unchecked -> as_chunks_unchecked_mut 2021-01-15 21:25:30 -08:00
Scott McMurray ae4b5a21e6 Add `as_rchunks` (and friends) to slices 2021-01-15 21:24:38 -08:00
Ömer Sinan Ağacan b681631eff codegen_cranelift: Fix redundant semicolon warn 2021-01-16 07:17:13 +03:00
Ömer Sinan Ağacan 0ef55570fb Add a test 2021-01-16 06:55:29 +03:00
Ömer Sinan Ağacan eef383fa00 doctest: Reset errors before dropping the parse session
The first parse is to collect whether the code contains macros, has
`main`, and uses other crates. In that pass we ignore errors as those
will be reported when the test file is actually built.

For that we need to reset errors in the `Diagnostic` otherwise when
dropping it unhandled errors will be reported as compiler bugs.

Fixes #80992
2021-01-16 06:55:29 +03:00
bors 635ccfe01c Auto merge of #77885 - erikdesjardins:probeasm, r=cuviper
Use probe-stack=inline-asm in LLVM 11+

Fixes (?) #74405, related to #43241

r? `@cuviper`
2021-01-16 03:10:52 +00:00
Joshua Nelson 5c4adbe1e1 Add all tier 1 platforms to supported platforms for "if-available"
... and update the comment in `config.toml.example`
2021-01-15 22:08:47 -05:00
Joshua Nelson 6766070422 Allow downloading LLVM on Windows
- Don't ignore packaging `llvm/lib/` for `rust-dev` when LLVM is linked
statically
- Add `link-type.txt` so bootstrap knows whether llvm was linked
  statically or dynamically
- Don't assume CI LLVM is linked dynamically in `bootstrap::config`
- Fall back to dynamic linking if `link-type.txt` doesn't exist
- Fix existing bug that split the output of `llvm-config` on lines, not spaces
- Enable building LLVM tests

  This works around the following llvm bug:

  ```
  llvm-config: error: component libraries and shared library

  llvm-config: error: missing: /home/joshua/rustc2/build/x86_64-unknown-linux-gnu/llvm/build/lib/libgtest.a
  llvm-config: error: missing: /home/joshua/rustc2/build/x86_64-unknown-linux-gnu/llvm/build/lib/libgtest_main.a
  llvm-config: error: missing: /home/joshua/rustc2/build/x86_64-unknown-linux-gnu/llvm/build/lib/libLLVMTestingSupport.a
  thread 'main' panicked at 'command did not execute successfully: "/home/joshua/rustc2/build/x86_64-unknown-linux-gnu/llvm/build/bin/llvm-config" "--libfiles"
  ```

  I'm not sure why llvm-config thinks these are required, but to avoid
  the error, this builds them anyway.

- Temporarily set windows as the try builder. This should be reverted
  before merging.

- Bump version of `download-ci-llvm-stamp`

  `src/llvm-project` hasn't changed, but the generated tarball has.

- Only special case MacOS when dynamic linking. Static linking works fine.
- Store `link-type.txt` to the top-level of the tarball

  This allows writing the link type unconditionally. Previously, bootstrap
  had to keep track of whether the file IO *would* succeed (it would fail
  if `lib/` didn't exist), which was prone to bugs.

- Make `link-type.txt` required

  Anyone downloading this from CI should be using a version of bootstrap
  that matches the version of the uploaded artifacts. So a missing
  link-type indicates a bug in x.py.
2021-01-15 22:07:38 -05:00
Ashley Mannix c625b979ae
add tracking issue to cell_filter_map 2021-01-16 10:40:36 +10:00
bors 6c869d34ae Auto merge of #81057 - GuillaumeGomez:rollup-yl2kqst, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #77693 (Add test for #59352)
 - #80515 (Improve JS performance by storing length before comparing to it in loops)
 - #81030 (Update mdbook)
 - #81033 (Remove useless `clean::Variant` struct)
 - #81049 (inline: Round word-size cost estimates up)
 - #81054 (Drop a few unneeded borrows)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-01-16 00:13:26 +00:00
Simonas Kazlauskas af0d099004 Add a regression test for #50041
AFAICT the test case never landed alongside the fix for the issue.
2021-01-16 01:34:28 +02:00
Joshua Nelson c819a4c025 Don't mark `ineffective_unstable_trait_impl` as an internal lint
It's not an internal lint:
- It's not in the rustc::internal lint group
- It's on unconditionally, because it actually lints `staged_api`, not
  the compiler

This fixes a bug where `#[deny(rustc::internal)]` would warn that
`rustc::internal` was an unknown lint.
2021-01-15 17:31:10 -05:00