]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoAuto merge of #80524 - jyn514:unknown-tool-lints, r=flip1995,matthewjasper
bors [Sun, 17 Jan 2021 17:52:01 +0000 (17:52 +0000)]
Auto merge of #80524 - jyn514:unknown-tool-lints, r=flip1995,matthewjasper

Don't make tools responsible for checking unknown and renamed lints

Previously, clippy (and any other tool emitting lints) had to have their
own separate UNKNOWN_LINTS pass, because the compiler assumed any tool
lint could be valid. Now, as long as any lint starting with the tool
prefix exists, the compiler will warn when an unknown lint is present.

This may interact with the unstable `tool_lint` feature, which I don't entirely understand, but it will take the burden off those external tools to add their own lint pass, which seems like a step in the right direction to me.

- Don't mark `ineffective_unstable_trait_impl` as an internal lint
- Use clippy's more advanced lint suggestions
- Deprecate the `UNKNOWN_CLIPPY_LINTS` pass (and make it a no-op)
- Say 'unknown lint `clippy::x`' instead of 'unknown lint x'

This is tested by existing clippy tests. When https://github.com/rust-lang/rust/pull/80527 merges, it will also be tested in rustdoc tests. AFAIK there is no way to test this with rustc directly.

3 years agoAuto merge of #81113 - m-ou-se:rollup-a1unz4x, r=m-ou-se
bors [Sun, 17 Jan 2021 14:50:24 +0000 (14:50 +0000)]
Auto merge of #81113 - m-ou-se:rollup-a1unz4x, r=m-ou-se

Rollup of 13 pull requests

Successful merges:

 - #79298 (correctly deal with late-bound lifetimes in anon consts)
 - #80031 (resolve: Reject ambiguity built-in attr vs different built-in attr)
 - #80201 (Add benchmark and fast path for BufReader::read_exact)
 - #80635 (Improve diagnostics when closure doesn't meet trait bound)
 - #80765 (resolve: Simplify collection of traits in scope)
 - #80932 (Allow downloading LLVM on Windows and MacOS)
 - #80983 (Remove is_dllimport_foreign_item definition from cg_ssa)
 - #81064 (Support non-stage0 check)
 - #81080 (Force vec![] to expression position only)
 - #81082 (BTreeMap: clean up a few more comments)
 - #81084 (Use Option::map instead of open-coding it)
 - #81095 (Use Option::unwrap_or instead of open-coding it)
 - #81107 (Add NonZeroUn::is_power_of_two)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoRollup merge of #81107 - scottmcm:nonzero-is_power_of_two, r=kennytm
Mara Bos [Sun, 17 Jan 2021 12:25:01 +0000 (12:25 +0000)]
Rollup merge of #81107 - scottmcm:nonzero-is_power_of_two, r=kennytm

Add NonZeroUn::is_power_of_two

This saves instructions on both new and old machines <https://rust.godbolt.org/z/4fjTMz>
- On the default x64 target (with no fancy instructions available) it saves a few instructions by not needing to also check for zero.
- On newer targets (with BMI1) it uses `BLSR` for super-short assembly.

This can be used for things like checks against alignments stored in `NonZeroUsize`.

3 years agoRollup merge of #81095 - LingMan:unwrap, r=oli-obk
Mara Bos [Sun, 17 Jan 2021 12:24:59 +0000 (12:24 +0000)]
Rollup merge of #81095 - LingMan:unwrap, r=oli-obk

Use Option::unwrap_or instead of open-coding it

r? ```@oli-obk``` Noticed this while we were talking about the other PR just now 😆
```@rustbot``` modify labels +C-cleanup +T-compiler

3 years agoRollup merge of #81084 - LingMan:map, r=oli-obk
Mara Bos [Sun, 17 Jan 2021 12:24:58 +0000 (12:24 +0000)]
Rollup merge of #81084 - LingMan:map, r=oli-obk

Use Option::map instead of open-coding it

r? ```@oli-obk```
```@rustbot``` modify labels +C-cleanup +T-compiler

3 years agoRollup merge of #81082 - ssomers:btree_cleanup_comments, r=Mark-Simulacrum
Mara Bos [Sun, 17 Jan 2021 12:24:56 +0000 (12:24 +0000)]
Rollup merge of #81082 - ssomers:btree_cleanup_comments, r=Mark-Simulacrum

BTreeMap: clean up a few more comments

And mark `pop` as unsafe.
r? ```@Mark-Simulacrum```

3 years agoRollup merge of #81080 - bugadani:vec-diag, r=oli-obk,m-ou-se
Mara Bos [Sun, 17 Jan 2021 12:24:54 +0000 (12:24 +0000)]
Rollup merge of #81080 - bugadani:vec-diag, r=oli-obk,m-ou-se

Force vec![] to expression position only

r? `@oli-obk`

I went with the lazy way of only changing what broke. I moved the test to ui/macros because the diagnostics no longer give suggestions.

Closes #61933

3 years agoRollup merge of #81064 - Mark-Simulacrum:support-stage1-check, r=jyn514
Mara Bos [Sun, 17 Jan 2021 12:24:53 +0000 (12:24 +0000)]
Rollup merge of #81064 - Mark-Simulacrum:support-stage1-check, r=jyn514

Support non-stage0 check

Seems to work locally - a full stage 1 check succeeds, building std (because we can't get away with checking it), and then checking the compiler and other tools. This ran into the problem that a unconditional x.py check in stage 1 *both* checks and builds stage 1 std, and then has to clean up because for some reason the rmeta and rlib artifacts conflict (though I'm not actually entirely sure why, but it doesn't seem worth digging in in too much detail).

Ideally we wouldn't be building and checking like that but it's a minor worry as checking std is pretty fast and you can avoid it if you're aiming for speed by passing the compiler (e.g., compiler/rustc) explicitly.

r? ```@jyn514```

3 years agoRollup merge of #80983 - bjorn3:no_dup_is_dllimport_foreign_item, r=nagisa
Mara Bos [Sun, 17 Jan 2021 12:24:51 +0000 (12:24 +0000)]
Rollup merge of #80983 - bjorn3:no_dup_is_dllimport_foreign_item, r=nagisa

Remove is_dllimport_foreign_item definition from cg_ssa

It overwrites the definition from rustc_metadata.

cc https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/query.20provided.20twice/near/218927806

Marked as draft to test if this breaks anything.

3 years agoRollup merge of #80932 - jyn514:download-windows-llvm, r=Mark-Simulacrum
Mara Bos [Sun, 17 Jan 2021 12:24:49 +0000 (12:24 +0000)]
Rollup merge of #80932 - jyn514:download-windows-llvm, r=Mark-Simulacrum

Allow downloading LLVM on Windows and MacOS

- 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
- Only special case MacOS when dynamic linking. Static linking works fine.
- 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.

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

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

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

# Current Status

This works on both MacOS and Windows! :tada: :tada: Thanks to ```@nagisa,``` ```@halkcyon,``` ```@Lokathor,``` ```@jryans,``` and ```@poliorcetics``` for helping me test!

The `if-available` check now supports all tier 1 platforms. Although only x64 apple and x64 msvc have been tested, none of the changes here are Windows or Mac specific, and I expect this to work anywhere that LLVM artifacts are uploaded to CI (i.e. the `rust-dev` component exists).

## Windows

Note that if you have an old version of MSVC build tools you'll need to update them. VS Build Tools 2019 14.28 and later are known to work. With old tools, you may see an error like the following:

```
error LNK2001: unresolved external symbol __imp___std_init_once_complete
```

3 years agoRollup merge of #80765 - petrochenkov:traitsinscope, r=matthewjasper
Mara Bos [Sun, 17 Jan 2021 12:24:47 +0000 (12:24 +0000)]
Rollup merge of #80765 - petrochenkov:traitsinscope, r=matthewjasper

resolve: Simplify collection of traits in scope

"Traits in scope" for a given location are collected by walking all scopes in type namespace, collecting traits in them and pruning traits that don't have an associated item with the given name and namespace.

Previously we tried to prune traits using some kind of hygienic resolution for associated items, but that was complex and likely incorrect, e.g. in #80762 correction to visibilites of trait items caused some traits to not be in scope anymore.
I previously had some comments and concerns about this in https://github.com/rust-lang/rust/pull/65351.

In this PR we are doing some much simpler pruning based on `Symbol` and `Namespace` comparisons, it should be enough to throw away 99.9% of unnecessary traits.
It is not necessary for pruning to be precise because for trait aliases, for example, we don't do any pruning at all, and precise hygienic resolution for associated items needs to be done in typeck anyway.

The somewhat unexpected effect is that trait imports introduced by macros 2.0 now bring traits into scope due to the removed hygienic check on associated item names.
I'm not sure whether it is desirable or not, but I think it's acceptable for now.
The old check was certainly incorrect because macros 2.0 did bring trait aliases into scope.
If doing this is not desirable, then we should come up with some other way to avoid bringing traits from macros 2.0 into scope, that would accommodate for trait aliases as well.

---

The PR also contains a couple of pure refactorings
- Scope walk is done by using `visit_scopes` instead of a hand-rolled version.
- Code is restructured to accomodate for rustdoc that also wants to query traits in scope, but doesn't want to filter them by associated items at all.

r? ```@matthewjasper```

3 years agoRollup merge of #80635 - sexxi-goose:use-place-instead-of-symbol, r=nikomatsakis`
Mara Bos [Sun, 17 Jan 2021 12:24:44 +0000 (12:24 +0000)]
Rollup merge of #80635 - sexxi-goose:use-place-instead-of-symbol, r=nikomatsakis`

Improve diagnostics when closure doesn't meet trait bound

Improves the diagnostics when closure doesn't meet trait bound by modifying `TypeckResuts::closure_kind_origins` such that `hir::Place` is used instead of `Symbol`. Using `hir::Place` to describe which capture influenced the decision of selecting a trait a closure satisfies to (Fn/FnMut/FnOnce, Copy) allows us to show precise path in the diagnostics when `capture_disjoint_field` feature is enabled.

Closes rust-lang/project-rfc-2229/issues/21

r? ```@nikomatsakis```

3 years agoRollup merge of #80201 - saethlin:bufreader-read-exact, r=KodrAus
Mara Bos [Sun, 17 Jan 2021 12:24:42 +0000 (12:24 +0000)]
Rollup merge of #80201 - saethlin:bufreader-read-exact, r=KodrAus

Add benchmark and fast path for BufReader::read_exact

At work, we have a wrapper type that implements this optimization. It would be nice if the standard library were faster.

Before:
```
test io::buffered::tests::bench_buffered_reader_small_reads       ... bench:       7,670 ns/iter (+/- 45)
```
After:
```
test io::buffered::tests::bench_buffered_reader_small_reads       ... bench:       4,457 ns/iter (+/- 41)
```

3 years agoRollup merge of #80031 - petrochenkov:builtina, r=estebank
Mara Bos [Sun, 17 Jan 2021 12:24:41 +0000 (12:24 +0000)]
Rollup merge of #80031 - petrochenkov:builtina, r=estebank

resolve: Reject ambiguity built-in attr vs different built-in attr

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

Resolution ensures that inert attributes cannot be used through imports like this, but built-in attributes don't go through initial resolution (only through resolution validation), so we have to keep some extra data (the built-in attribute name) to prevent it from happening.

3 years agoRollup merge of #79298 - lcnr:new-elysium, r=matthewjasper
Mara Bos [Sun, 17 Jan 2021 12:24:39 +0000 (12:24 +0000)]
Rollup merge of #79298 - lcnr:new-elysium, r=matthewjasper

correctly deal with late-bound lifetimes in anon consts

adds support for using late bound lifetimes of the parent context in anon consts.
```rust
#![feature(const_generics)]
const fn inner<'a>() -> usize where &'a (): Sized { 3 }

fn test<'a>() {
    let _: [u8; inner::<'a>()];
}
```
The lifetime `'a` is late bound in `test` so it's not included in its generics but is instead dealt with separately in borrowck.
This didn't previously work for anon consts as they have to use the late bound lifetimes of their parent which has
to be explicitly handled.

r? ```@matthewjasper``` cc ```@varkor``` ```@eddyb```

3 years agoAuto merge of #81058 - Smittyvb:wasm-num-tests, r=Mark-Simulacrum
bors [Sun, 17 Jan 2021 11:51:47 +0000 (11:51 +0000)]
Auto merge of #81058 - Smittyvb:wasm-num-tests, r=Mark-Simulacrum

Re-enable all num tests on WASM

This was partially done by #47365, but a few tests were missed in that PR.

3 years agoForce vec! to expressions only
Dániel Buga [Sat, 16 Jan 2021 15:32:51 +0000 (16:32 +0100)]
Force vec! to expressions only

3 years agoRemove dead code
Ryan Levick [Fri, 18 Dec 2020 11:27:36 +0000 (12:27 +0100)]
Remove dead code

3 years agoAuto merge of #81083 - ssomers:btree_drainy_refactor_1, r=Mark-Simulacrum
bors [Sun, 17 Jan 2021 08:44:12 +0000 (08:44 +0000)]
Auto merge of #81083 - ssomers:btree_drainy_refactor_1, r=Mark-Simulacrum

BTreeMap: expose new_internal function and sanitize from_new_internal

`new_internal` is the functional core of the imperative `push_internal_level`, and `from_new_internal` can easily do a proper job instead of returning a half-baked node.

r? `@Mark-Simulacrum`

3 years agoAuto merge of #78818 - scottmcm:as_rchunks, r=KodrAus
bors [Sun, 17 Jan 2021 05:43:55 +0000 (05:43 +0000)]
Auto merge of #78818 - scottmcm:as_rchunks, r=KodrAus

Add `as_rchunks` (and friends) to slices

`@est31` mentioned (https://github.com/rust-lang/rust/issues/76354#issuecomment-717027175) that, for completeness, there needed to be an `as_chunks`-like method that chunks from the end (with the remainder at the beginning) like `rchunks` does.

So here's a PR for `as_rchunks: &[T] -> (&[T], &[[T; N]])` and `as_rchunks_mut: &mut [T] -> (&mut [T], &mut [[T; N]])`.

But as I was doing this and copy-pasting `from_raw_parts` calls, I thought that I should extract that into an unsafe method.  It started out a private helper, but it seemed like `as_chunks_unchecked` could be reasonable as a "real" method, so I added docs and made it public.  Let me know if you think it doesn't pull its weight.

3 years agoAdd NonZeroUn::is_power_of_two
Scott McMurray [Sun, 17 Jan 2021 03:27:51 +0000 (19:27 -0800)]
Add NonZeroUn::is_power_of_two

This saves instructions on both new and old machines.

3 years agoAuto merge of #80942 - c410-f3r:tests-tests-tests, r=petrochenkov
bors [Sun, 17 Jan 2021 02:48:07 +0000 (02:48 +0000)]
Auto merge of #80942 - c410-f3r:tests-tests-tests, r=petrochenkov

Move some tests to more reasonable directories - 2

All tests with a score equal or greater than 1.0 were moved to their respective directories by issuing

```bash
cat FILE | tr -s " " | tr -d '():' | sort -k3 | awk '$3 >= 1' | cut -d " " -f1-2 | sed 's;\\;/;g' | xargs -n2 git mv
```
**Observation**: The first column values is the only column with results greater zero

To attest the confidentiality of the model, some manual revision of at least of tests is needed and this process will be tracked in the following list:

* `src/test/ui/abi/issue-28676.rs` OK #28676
* `src/test/ui/array-slice-vec/issue-15730.rs` OK
* `src/test/ui/associated-types/issue-24338.rs` OK #54823
* `src/test/ui/associated-types/issue-48551.rs` Looks OK #48551
* `src/test/ui/associated-types/issue-50301.rs` Looks OK #63577

...

cc #73494
r? `@petrochenkov`

3 years agoAdd benchmark and fast path for BufReader::read_exact
Ben Kimock [Sat, 19 Dec 2020 20:02:01 +0000 (15:02 -0500)]
Add benchmark and fast path for BufReader::read_exact

3 years agoAuto merge of #81093 - calebcartwright:update-rustfmt, r=Mark-Simulacrum
bors [Sat, 16 Jan 2021 23:15:35 +0000 (23:15 +0000)]
Auto merge of #81093 - calebcartwright:update-rustfmt, r=Mark-Simulacrum

bump rustfmt to v1.4.32

Fixes an indentation bug with bounds reported in https://github.com/rust-lang/rust/pull/80843#discussion_r554476529

r? `@Mark-Simulacrum`

3 years agoTry ignore-debug in the codegen test
Scott McMurray [Sat, 16 Jan 2021 22:52:48 +0000 (14:52 -0800)]
Try ignore-debug in the codegen test

This fixed things the last time I had a problem like this.  And plausibly will here too -- the check it's failing on is for the high bit being set in the length of the slice, which is a check that's only in a debug_assert.

3 years agoresolve: Reject ambiguity built-in attr vs different built-in attr
Vadim Petrochenkov [Sun, 13 Dec 2020 16:34:04 +0000 (19:34 +0300)]
resolve: Reject ambiguity built-in attr vs different built-in attr

3 years agoMove some tests to more reasonable directories - 2
Caio [Sat, 16 Jan 2021 18:54:05 +0000 (15:54 -0300)]
Move some tests to more reasonable directories - 2

Address comments

Update limits

3 years agoAuto merge of #81089 - m-ou-se:rollup-z7iac6i, r=m-ou-se
bors [Sat, 16 Jan 2021 20:26:20 +0000 (20:26 +0000)]
Auto merge of #81089 - m-ou-se:rollup-z7iac6i, r=m-ou-se

Rollup of 17 pull requests

Successful merges:

 - #78455 (Introduce {Ref, RefMut}::try_map for optional projections in RefCell)
 - #80144 (Remove giant badge in README)
 - #80614 (Explain why borrows can't be held across yield point in async blocks)
 - #80670 (TrustedRandomAaccess specialization composes incorrectly for nested iter::Zips)
 - #80681 (Clarify what the effects of a 'logic error' are)
 - #80764 (Re-stabilize Weak::as_ptr and friends for unsized T)
 - #80901 (Make `x.py --color always` apply to logging too)
 - #80902 (Add a regression test for #76281)
 - #80941 (Do not suggest invalid code in pattern with loop)
 - #80968 (Stabilize the poll_map feature)
 - #80971 (Put all feature gate tests under `feature-gates/`)
 - #81021 (Remove doctree::Import)
 - #81040 (doctest: Reset errors before dropping the parse session)
 - #81060 (Add a regression test for #50041)
 - #81065 (codegen_cranelift: Fix redundant semicolon warn)
 - #81069 (Add sample code for Rc::new_cyclic)
 - #81081 (Add test for #34792)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agobump rustfmt to v1.4.32
Caleb Cartwright [Sat, 16 Jan 2021 18:29:38 +0000 (12:29 -0600)]
bump rustfmt to v1.4.32

3 years agoUse Option::unwrap_or instead of open-coding it
LingMan [Sat, 16 Jan 2021 19:13:06 +0000 (20:13 +0100)]
Use Option::unwrap_or instead of open-coding it

3 years agoUse Option::map instead of open-coding it
LingMan [Wed, 30 Dec 2020 17:22:41 +0000 (18:22 +0100)]
Use Option::map instead of open-coding it

3 years agoDeprecate unknown_clippy_lints
flip1995 [Sat, 16 Jan 2021 16:30:31 +0000 (17:30 +0100)]
Deprecate unknown_clippy_lints

This is now handled by unknown_lints

3 years agoMore advanced unknown lint suggestion
flip1995 [Sat, 16 Jan 2021 16:11:26 +0000 (17:11 +0100)]
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.

3 years agocorrectly deal with late-bound lifetimes in anon consts
Bastian Kauschke [Sun, 22 Nov 2020 12:57:11 +0000 (13:57 +0100)]
correctly deal with late-bound lifetimes in anon consts

3 years agoRollup merge of #81081 - bugadani:double-partialeq, r=Mark-Simulacrum
Mara Bos [Sat, 16 Jan 2021 17:30:17 +0000 (17:30 +0000)]
Rollup merge of #81081 - bugadani:double-partialeq, r=Mark-Simulacrum

Add test for #34792

Closes #34792

3 years agoRollup merge of #81069 - ogoffart:rc_new_cyclic_doc, r=Mark-Simulacrum
Mara Bos [Sat, 16 Jan 2021 17:30:15 +0000 (17:30 +0000)]
Rollup merge of #81069 - ogoffart:rc_new_cyclic_doc, r=Mark-Simulacrum

Add sample code for Rc::new_cyclic

3 years agoRollup merge of #81065 - osa1:cranelift_semicolon_warning, r=jyn514
Mara Bos [Sat, 16 Jan 2021 17:30:13 +0000 (17:30 +0000)]
Rollup merge of #81065 - osa1:cranelift_semicolon_warning, r=jyn514

codegen_cranelift: Fix redundant semicolon warn

3 years agoRollup merge of #81060 - nagisa:nagisa/regression-50041, r=Mark-Simulacrum
Mara Bos [Sat, 16 Jan 2021 17:30:12 +0000 (17:30 +0000)]
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.

3 years agoRollup merge of #81040 - osa1:fix_80992, r=jyn514
Mara Bos [Sat, 16 Jan 2021 17:30:10 +0000 (17:30 +0000)]
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

3 years agoRollup merge of #81021 - CraftSpider:rustdoc-remove-import, r=jyn514
Mara Bos [Sat, 16 Jan 2021 17:30:08 +0000 (17:30 +0000)]
Rollup merge of #81021 - CraftSpider:rustdoc-remove-import, r=jyn514

Remove doctree::Import

Per the title. Part of cleaning up doctree

3 years agoRollup merge of #80971 - camelid:feature-gate-testsuite-organization, r=Mark-Simulacrum
Mara Bos [Sat, 16 Jan 2021 17:30:06 +0000 (17:30 +0000)]
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/`.

3 years agoRollup merge of #80968 - KodrAus:stabilize/poll_map, r=Mark-Simulacrum
Mara Bos [Sat, 16 Jan 2021 17:30:04 +0000 (17:30 +0000)]
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).

3 years agoRollup merge of #80941 - JohnTitor:ref-mut-pat-in-loops, r=varkor
Mara Bos [Sat, 16 Jan 2021 17:30:02 +0000 (17:30 +0000)]
Rollup merge of #80941 - JohnTitor:ref-mut-pat-in-loops, r=varkor

Do not suggest invalid code in pattern with loop

Fixes #80913

3 years agoRollup merge of #80902 - JohnTitor:issue-76281, r=Mark-Simulacrum
Mara Bos [Sat, 16 Jan 2021 17:30:00 +0000 (17:30 +0000)]
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

3 years agoRollup merge of #80901 - jyn514:better-colors, r=Mark-Simulacrum
Mara Bos [Sat, 16 Jan 2021 17:29:58 +0000 (17:29 +0000)]
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```

3 years agoRollup merge of #80764 - CAD97:weak-unsized-as-ptr-again, r=RalfJung
Mara Bos [Sat, 16 Jan 2021 17:29:56 +0000 (17:29 +0000)]
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.

3 years agoRollup merge of #80681 - ChrisJefferson:logic-error-doc, r=m-ou-se
Mara Bos [Sat, 16 Jan 2021 17:29:53 +0000 (17:29 +0000)]
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

3 years agoRollup merge of #80670 - the8472:fix-zip-trusted-random-access-composition, r=m-ou-se
Mara Bos [Sat, 16 Jan 2021 17:29:51 +0000 (17:29 +0000)]
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)

3 years agoRollup merge of #80614 - 1000teslas:issue-78938-fix, r=tmandry
Mara Bos [Sat, 16 Jan 2021 17:29:49 +0000 (17:29 +0000)]
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.

3 years agoRollup merge of #80144 - rust-lang:frewsxcv-patch-3, r=nikomatsakis
Mara Bos [Sat, 16 Jan 2021 17:29:47 +0000 (17:29 +0000)]
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

3 years agoRollup merge of #78455 - udoprog:refcell-opt-map, r=KodrAus
Mara Bos [Sat, 16 Jan 2021 17:29:45 +0000 (17:29 +0000)]
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).

3 years agoAuto merge of #80290 - RalfJung:less-intrinsic-write, r=lcnr
bors [Sat, 16 Jan 2021 17:28:32 +0000 (17:28 +0000)]
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).

3 years agoAdd test for #34792
Dániel Buga [Sat, 16 Jan 2021 15:41:53 +0000 (16:41 +0100)]
Add test for #34792

3 years agoBTreeMap: expose new_internal function and sanitize from_new_internal
Stein Somers [Wed, 18 Nov 2020 17:19:38 +0000 (18:19 +0100)]
BTreeMap: expose new_internal function and sanitize from_new_internal

3 years agoBTreeMap: clean up a few more comments
Stein Somers [Wed, 18 Nov 2020 17:19:38 +0000 (18:19 +0100)]
BTreeMap: clean up a few more comments

3 years agoAllow configuring the default stage for `x.py check`
Joshua Nelson [Sat, 16 Jan 2021 03:41:39 +0000 (22:41 -0500)]
Allow configuring the default stage for `x.py check`

3 years agoPrint which stage is being checked (now that it may not be stage0)
Joshua Nelson [Sat, 16 Jan 2021 03:34:00 +0000 (22:34 -0500)]
Print which stage is being checked (now that it may not be stage0)

3 years agoSupport non-stage0 check
Mark Rousskov [Sat, 16 Jan 2021 02:43:23 +0000 (21:43 -0500)]
Support non-stage0 check

3 years agoAuto merge of #81077 - bugadani:shrink, r=Mark-Simulacrum
bors [Sat, 16 Jan 2021 14:04:43 +0000 (14:04 +0000)]
Auto merge of #81077 - bugadani:shrink, r=Mark-Simulacrum

Remove unnecessary manual shrink_to_fit calls

3 years agoRemove unnecessary manual shrink_to_fit calls
Dániel Buga [Sat, 16 Jan 2021 13:02:36 +0000 (14:02 +0100)]
Remove unnecessary manual shrink_to_fit calls

3 years agoAuto merge of #77435 - hanmertens:binary_heap_append, r=scottmcm
bors [Sat, 16 Jan 2021 11:10:13 +0000 (11:10 +0000)]
Auto merge of #77435 - hanmertens:binary_heap_append, r=scottmcm

Always use extend in BinaryHeap::append

This is faster, see #77433.

Fixes #77433

3 years agoClarify what the effects of a 'logic error' are
Chris Jefferson [Mon, 4 Jan 2021 09:22:56 +0000 (09:22 +0000)]
Clarify what the effects of a 'logic error' are

3 years agoAdd sample code for Rc::new_cyclic
Olivier Goffart [Sat, 16 Jan 2021 09:29:21 +0000 (10:29 +0100)]
Add sample code for Rc::new_cyclic

3 years agoAuto merge of #80873 - ssomers:btree_cleanup_slices_4, r=Mark-Simulacrum
bors [Sat, 16 Jan 2021 07:12:12 +0000 (07:12 +0000)]
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`

3 years agoAdd a regression test for #76281
Yuki Okushi [Mon, 11 Jan 2021 04:20:18 +0000 (13:20 +0900)]
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).

3 years agoRename as_chunks_mut_unchecked -> as_chunks_unchecked_mut
Scott McMurray [Sat, 16 Jan 2021 05:25:30 +0000 (21:25 -0800)]
Rename as_chunks_mut_unchecked -> as_chunks_unchecked_mut

3 years agoAdd `as_rchunks` (and friends) to slices
Scott McMurray [Fri, 6 Nov 2020 21:51:44 +0000 (13:51 -0800)]
Add `as_rchunks` (and friends) to slices

3 years agocodegen_cranelift: Fix redundant semicolon warn
Ömer Sinan Ağacan [Sat, 16 Jan 2021 04:17:13 +0000 (07:17 +0300)]
codegen_cranelift: Fix redundant semicolon warn

3 years agoAdd a test
Ömer Sinan Ağacan [Sat, 16 Jan 2021 03:55:16 +0000 (06:55 +0300)]
Add a test

3 years agodoctest: Reset errors before dropping the parse session
Ömer Sinan Ağacan [Fri, 15 Jan 2021 12:51:32 +0000 (15:51 +0300)]
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

3 years agoAuto merge of #77885 - erikdesjardins:probeasm, r=cuviper
bors [Sat, 16 Jan 2021 03:10:52 +0000 (03:10 +0000)]
Auto merge of #77885 - erikdesjardins:probeasm, r=cuviper

Use probe-stack=inline-asm in LLVM 11+

Fixes (?) #74405, related to #43241

r? `@cuviper`

3 years agoAdd all tier 1 platforms to supported platforms for "if-available"
Joshua Nelson [Wed, 13 Jan 2021 14:32:48 +0000 (09:32 -0500)]
Add all tier 1 platforms to supported platforms for "if-available"

... and update the comment in `config.toml.example`

3 years agoAllow downloading LLVM on Windows
Joshua Nelson [Tue, 12 Jan 2021 01:28:17 +0000 (20:28 -0500)]
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.

3 years agoadd tracking issue to cell_filter_map
Ashley Mannix [Sat, 16 Jan 2021 00:40:36 +0000 (10:40 +1000)]
add tracking issue to cell_filter_map

3 years agoAuto merge of #81057 - GuillaumeGomez:rollup-yl2kqst, r=GuillaumeGomez
bors [Sat, 16 Jan 2021 00:13:26 +0000 (00:13 +0000)]
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

3 years agoAdd a regression test for #50041
Simonas Kazlauskas [Thu, 14 Jan 2021 18:10:13 +0000 (20:10 +0200)]
Add a regression test for #50041

AFAICT the test case never landed alongside the fix for the issue.

3 years agoDon't mark `ineffective_unstable_trait_impl` as an internal lint
Joshua Nelson [Fri, 15 Jan 2021 20:21:20 +0000 (15:21 -0500)]
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.

3 years agoRollup merge of #81054 - LingMan:rem_as_ref, r=jyn514
Guillaume Gomez [Fri, 15 Jan 2021 22:31:03 +0000 (23:31 +0100)]
Rollup merge of #81054 - LingMan:rem_as_ref, r=jyn514

Drop a few unneeded borrows

`@rustbot` modify labels +C-cleanup +T-compiler

3 years agoRollup merge of #81049 - tmiasko:layout-cost, r=oli-obk
Guillaume Gomez [Fri, 15 Jan 2021 22:31:01 +0000 (23:31 +0100)]
Rollup merge of #81049 - tmiasko:layout-cost, r=oli-obk

inline: Round word-size cost estimates up

3 years agoRollup merge of #81033 - jyn514:nested-variant, r=CraftSpider
Guillaume Gomez [Fri, 15 Jan 2021 22:31:00 +0000 (23:31 +0100)]
Rollup merge of #81033 - jyn514:nested-variant, r=CraftSpider

Remove useless `clean::Variant` struct

It had exactly one field and no special behavior, so there was no point in having it.

r? `@CraftSpider`

3 years agoRollup merge of #81030 - ehuss:update-mdbook, r=Mark-Simulacrum
Guillaume Gomez [Fri, 15 Jan 2021 22:30:58 +0000 (23:30 +0100)]
Rollup merge of #81030 - ehuss:update-mdbook, r=Mark-Simulacrum

Update mdbook

Just a few small fixes and changes, see https://github.com/rust-lang/mdBook/blob/master/CHANGELOG.md#mdbook-046 for a list.

3 years agoRollup merge of #80515 - GuillaumeGomez:js-for-loop-perf, r=Nemo157,jyn514
Guillaume Gomez [Fri, 15 Jan 2021 22:30:53 +0000 (23:30 +0100)]
Rollup merge of #80515 - GuillaumeGomez:js-for-loop-perf, r=Nemo157,jyn514

Improve JS performance by storing length before comparing to it in loops

Since https://github.com/rust-lang/rust/pull/79052 is quite complicated to review, I suggested to split into smaller parts. This first part is mostly about saving the array length into a variable (I tried to not change anything else as much as possible :smiley: ).

r? `@jyn514`

3 years agoRollup merge of #77693 - bugadani:issue-59352, r=oli-obk
Guillaume Gomez [Fri, 15 Jan 2021 22:30:51 +0000 (23:30 +0100)]
Rollup merge of #77693 - bugadani:issue-59352, r=oli-obk

Add test for #59352

Issue #59352 reported an optimization regression with rustc 1.32.0+. That regression could be tracked to a change that caused a function to miss the size limit of llvm's inlining, which results in an unreachable panicing branch being generated.
Enabling mir inline solves the issue, but is currently only done for `mir-opt-level>=2`.

This PR adds a test that can serve as a regression test for #59352, if/when mir inlining gets mature enough for opt-level 1, or some other optimization can remove the panic.

3 years agoRe-enable all num tests on WASM
Smitty [Fri, 15 Jan 2021 21:58:44 +0000 (16:58 -0500)]
Re-enable all num tests on WASM

This was partially done by #47365, but a few tests
were missed in that PR.

3 years agoUse Array.some instead of onEach to have better performance
Guillaume Gomez [Fri, 8 Jan 2021 13:52:12 +0000 (14:52 +0100)]
Use Array.some instead of onEach to have better performance

3 years agoImprove JS performance by storing length before comparing to it in loops
Guillaume Gomez [Wed, 30 Dec 2020 15:36:08 +0000 (16:36 +0100)]
Improve JS performance by storing length before comparing to it in loops

3 years agoAuto merge of #80602 - tgnottingham:cratemetadata_you_aint_special, r=michaelwoerister
bors [Fri, 15 Jan 2021 21:13:35 +0000 (21:13 +0000)]
Auto merge of #80602 - tgnottingham:cratemetadata_you_aint_special, r=michaelwoerister

Remove DepKind::CrateMetadata and pre-allocation of DepNodes

Remove much of the special-case handling around crate metadata
dependency tracking by replacing `DepKind::CrateMetadata` and the
pre-allocation of corresponding `DepNodes` with on-demand invocation
of the `crate_hash` query.

3 years agoDon't make tools responsible for checking unknown and renamed lints
Joshua Nelson [Wed, 30 Dec 2020 18:49:28 +0000 (13:49 -0500)]
Don't make tools responsible for checking unknown and renamed lints

Previously, clippy (and any other tool emitting lints) had to have their
own separate UNKNOWN_LINTS pass, because the compiler assumed any tool
lint could be valid. Now, as long as any lint starting with the tool
prefix exists, the compiler will warn when an unknown lint is present.

3 years agoChange rebuild heuristic in BinaryHeap::append
Han Mertens [Fri, 15 Jan 2021 20:50:05 +0000 (21:50 +0100)]
Change rebuild heuristic in BinaryHeap::append

See #77433 for why the new heuristic was chosen.

Fixes #77433

3 years agoDrop a few unneeded borrows
LingMan [Fri, 15 Jan 2021 20:29:28 +0000 (21:29 +0100)]
Drop a few unneeded borrows

3 years agoRename VariantKind -> Variant
Joshua Nelson [Fri, 15 Jan 2021 06:17:23 +0000 (01:17 -0500)]
Rename VariantKind -> Variant

There's no `Variant`, so it seems silly to have `Kind`.

3 years agoRemove useless `clean::Variant` struct
Joshua Nelson [Fri, 15 Jan 2021 02:42:59 +0000 (21:42 -0500)]
Remove useless `clean::Variant` struct

It had exactly one field and no special behavior, so there was no point.

3 years agoAuto merge of #81043 - hyd-dev:update-miri, r=RalfJung
bors [Fri, 15 Jan 2021 18:17:09 +0000 (18:17 +0000)]
Auto merge of #81043 - hyd-dev:update-miri, r=RalfJung

Update Miri

Fixes #80907.

r? `@RalfJung`

3 years agoAdd warning to compare.py about error messages
Rune Tynan [Fri, 15 Jan 2021 00:39:59 +0000 (19:39 -0500)]
Add warning to compare.py about error messages

3 years agoFix JSON test
Rune Tynan [Fri, 15 Jan 2021 00:01:48 +0000 (19:01 -0500)]
Fix JSON test

3 years agoAddress nit
Rune Tynan [Thu, 14 Jan 2021 20:03:17 +0000 (15:03 -0500)]
Address nit

3 years agoRemove doctree::Import
Rune Tynan [Thu, 14 Jan 2021 19:49:58 +0000 (14:49 -0500)]
Remove doctree::Import

3 years agoAdd test for #59352
Dániel Buga [Wed, 7 Oct 2020 20:59:18 +0000 (22:59 +0200)]
Add test for #59352

3 years agoUse Result and rename to filter_map
John-John Tedro [Thu, 17 Dec 2020 00:46:06 +0000 (01:46 +0100)]
Use Result and rename to filter_map

The use of Result allows for making use of a reconstructed original value on failed
projections.

3 years agoUpdate compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs
1000teslas [Fri, 15 Jan 2021 16:32:54 +0000 (03:32 +1100)]
Update compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs

Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>