]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoExpand docs on Iterator::intersperse
Lukas Lueg [Mon, 18 Jan 2021 19:40:25 +0000 (20:40 +0100)]
Expand docs on Iterator::intersperse

3 years agoAuto merge of #81165 - KodrAus:rollup-s7llxis, r=KodrAus
bors [Mon, 18 Jan 2021 14:36:30 +0000 (14:36 +0000)]
Auto merge of #81165 - KodrAus:rollup-s7llxis, r=KodrAus

Rollup of 12 pull requests

Successful merges:

 - #81038 (Update Clippy)
 - #81071 (rustc_parse_format: Fix character indices in find_skips)
 - #81100 (prevent potential bug in `encode_with_shorthand`.)
 - #81105 (Initialize a few variables directly)
 - #81116 (ConstProp: Copy body span instead of querying it)
 - #81121 (Avoid logging the whole MIR body in SimplifyCfg)
 - #81123 (Update cmp.rs)
 - #81125 (Add track_caller to .steal())
 - #81128 (validation test: turn some const_err back into validation failures)
 - #81131 (Edit rustc_middle::ty::cast docs)
 - #81142 (Replace let Some(..) = with .is_some())
 - #81153 (Remove unused linkcheck exceptions)

Failed merges:

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

3 years agoRollup merge of #81153 - jyn514:linkcheck, r=Manishearth
Ashley Mannix [Mon, 18 Jan 2021 11:53:43 +0000 (21:53 +1000)]
Rollup merge of #81153 - jyn514:linkcheck, r=Manishearth

Remove unused linkcheck exceptions

Found while working on https://github.com/deadlinks/cargo-deadlinks/issues/133.

r? `@Manishearth`

3 years agoRollup merge of #81142 - wcampbell0x2a:replace-Some-with-is-some, r=jonas-schievink
Ashley Mannix [Mon, 18 Jan 2021 11:53:41 +0000 (21:53 +1000)]
Rollup merge of #81142 - wcampbell0x2a:replace-Some-with-is-some, r=jonas-schievink

Replace let Some(..) = with .is_some()

3 years agoRollup merge of #81131 - pierwill:edit-rustc_middle-cast, r=varkor
Ashley Mannix [Mon, 18 Jan 2021 11:53:40 +0000 (21:53 +1000)]
Rollup merge of #81131 - pierwill:edit-rustc_middle-cast, r=varkor

Edit rustc_middle::ty::cast docs

Link to RFC 401 and add missing punctuation.

3 years agoRollup merge of #81128 - RalfJung:validation-testing, r=oli-obk
Ashley Mannix [Mon, 18 Jan 2021 11:53:37 +0000 (21:53 +1000)]
Rollup merge of #81128 - RalfJung:validation-testing, r=oli-obk

validation test: turn some const_err back into validation failures

This resolves the problem I raised at https://github.com/rust-lang/rust/pull/78407#discussion_r556732926.
r? `@oli-obk`

3 years agoRollup merge of #81125 - jyn514:track-caller, r=lcnr
Ashley Mannix [Mon, 18 Jan 2021 11:53:35 +0000 (21:53 +1000)]
Rollup merge of #81125 - jyn514:track-caller, r=lcnr

Add track_caller to .steal()

Before:

```
thread 'rustc' panicked at 'attempt to read from stolen value', /home/joshua/rustc/compiler/rustc_data_structures/src/steal.rs:43:15
```

After:

```
thread 'rustc' panicked at 'attempt to steal from stolen value', compiler/rustc_mir/src/transform/mod.rs:423:25
```

r? `@lcnr`

3 years agoRollup merge of #81123 - sirh3e:sirh3e-patch-1, r=sfackler
Ashley Mannix [Mon, 18 Jan 2021 11:53:33 +0000 (21:53 +1000)]
Rollup merge of #81123 - sirh3e:sirh3e-patch-1, r=sfackler

Update cmp.rs

Fixed space

3 years agoRollup merge of #81121 - tmiasko:simplify-cfg-no-dbg, r=jonas-schievink
Ashley Mannix [Mon, 18 Jan 2021 11:53:31 +0000 (21:53 +1000)]
Rollup merge of #81121 - tmiasko:simplify-cfg-no-dbg, r=jonas-schievink

Avoid logging the whole MIR body in SimplifyCfg

3 years agoRollup merge of #81116 - bugadani:body-span, r=wesleywiser
Ashley Mannix [Mon, 18 Jan 2021 11:53:30 +0000 (21:53 +1000)]
Rollup merge of #81116 - bugadani:body-span, r=wesleywiser

ConstProp: Copy body span instead of querying it

3 years agoRollup merge of #81105 - LingMan:init_directly, r=nagisa
Ashley Mannix [Mon, 18 Jan 2021 11:53:28 +0000 (21:53 +1000)]
Rollup merge of #81105 - LingMan:init_directly, r=nagisa

Initialize a few variables directly

Currently they are declared as `mut`, get initialized to a default value, and
then possibly overwritten.

By initializing to the final value directly, they don't need to be `mut` and
it's clear that they don't get mutated elsewhere later on.

3 years agoRollup merge of #81100 - lcnr:encode_with_shorthand, r=oli-obk
Ashley Mannix [Mon, 18 Jan 2021 11:53:26 +0000 (21:53 +1000)]
Rollup merge of #81100 - lcnr:encode_with_shorthand, r=oli-obk

prevent potential bug in `encode_with_shorthand`.

see https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Remove.20PredicateKind.20in.20favor.20of.20only.20Bin.E2.80.A6.20compiler-team.23397/near/223012169

3 years agoRollup merge of #81071 - osa1:fix_81006, r=estebank
Ashley Mannix [Mon, 18 Jan 2021 11:53:24 +0000 (21:53 +1000)]
Rollup merge of #81071 - osa1:fix_81006, r=estebank

rustc_parse_format: Fix character indices in find_skips

Fixes #81006

3 years agoRollup merge of #81038 - flip1995:clippyup, r=Manishearth
Ashley Mannix [Mon, 18 Jan 2021 11:53:22 +0000 (21:53 +1000)]
Rollup merge of #81038 - flip1995:clippyup, r=Manishearth

Update Clippy

Biweekly Clippy update

r? ``@Manishearth``

3 years agoAuto merge of #81015 - jyn514:feature-gate-ptr, r=camelid
bors [Mon, 18 Jan 2021 11:35:19 +0000 (11:35 +0000)]
Auto merge of #81015 - jyn514:feature-gate-ptr, r=camelid

Feature-gate `pointer` and `reference` in intra-doc links

r? `@camelid`

Addresses (but does not close) https://github.com/rust-lang/rust/issues/80896.

3 years agoAuto merge of #80995 - tmandry:instrument-method-checker, r=lcnr
bors [Mon, 18 Jan 2021 08:39:31 +0000 (08:39 +0000)]
Auto merge of #80995 - tmandry:instrument-method-checker, r=lcnr

Add tracing instrumentation to method typeck

I was recently digging into how this code works, and this instrumentation was helpful.

3 years agoAuto merge of #80865 - oliviacrain:proj_based, r=RalfJung
bors [Mon, 18 Jan 2021 05:44:40 +0000 (05:44 +0000)]
Auto merge of #80865 - oliviacrain:proj_based, r=RalfJung

Use PlaceRef projection abstractions more consistently in rustc_mir

PlaceRef contains abstractions for dealing with the `projections` array. This PR uses these abstractions more consistently within the `rustc_mir` crate.

See associated issue: rust-lang/rust#80647.

r? `@RalfJung`

3 years agoRemove unused linkcheck exceptions
Joshua Nelson [Mon, 18 Jan 2021 03:19:03 +0000 (22:19 -0500)]
Remove unused linkcheck exceptions

3 years agoAuto merge of #81090 - ssomers:btree_drainy_refactor_2, r=Mark-Simulacrum
bors [Mon, 18 Jan 2021 02:43:19 +0000 (02:43 +0000)]
Auto merge of #81090 - ssomers:btree_drainy_refactor_2, r=Mark-Simulacrum

BTreeMap: offer merge in variants with more clarity

r? `@Mark-Simulacrum`

3 years agoReplace let Some(..) = with .is_some()
wcampbell [Mon, 18 Jan 2021 00:06:12 +0000 (19:06 -0500)]
Replace let Some(..) = with .is_some()

Signed-off-by: wcampbell <wcampbell1995@gmail.com>
3 years agoAuto merge of #80537 - ehuss:macos-posix-spawn-chdir, r=dtolnay
bors [Sun, 17 Jan 2021 23:44:46 +0000 (23:44 +0000)]
Auto merge of #80537 - ehuss:macos-posix-spawn-chdir, r=dtolnay

Don't use posix_spawn_file_actions_addchdir_np on macOS.

There is a bug on macOS where using `posix_spawn_file_actions_addchdir_np` with a relative executable path will cause `posix_spawnp` to return ENOENT, even though it successfully spawned the process in the given directory.

`posix_spawn_file_actions_addchdir_np` was introduced in macOS 10.15 first released in Oct 2019.  I have tested macOS 10.15.7 and 11.0.1.

Example offending program:

```rust
use std::fs;
use std::os::unix::fs::PermissionsExt;
use std::process::*;

fn main() {
    fs::create_dir_all("bar").unwrap();
    fs::create_dir_all("foo").unwrap();
    fs::write("foo/foo.sh", "#!/bin/sh\necho hello ${PWD}\n").unwrap();
    let perms = fs::Permissions::from_mode(0o755);
    fs::set_permissions("foo/foo.sh", perms).unwrap();
    let c = Command::new("../foo/foo.sh").current_dir("bar").spawn();
    eprintln!("{:?}", c);
}
```

This prints:

```
Err(Os { code: 2, kind: NotFound, message: "No such file or directory" })
hello /Users/eric/Temp/bar
```

I wanted to open this PR to get some feedback on possible solutions.  Alternatives:
* Do nothing.
* Document the bug.
* Try to detect if the executable is a relative path on macOS, and avoid using `posix_spawn_file_actions_addchdir_np` only in that case.

I looked at the [XNU source code](https://opensource.apple.com/source/xnu/xnu-6153.141.1/bsd/kern/kern_exec.c.auto.html), but I didn't see anything obvious that would explain the behavior.  The actual chdir succeeds, it is something else further down that fails, but I couldn't see where.

EDIT: I forgot to mention, relative exe paths with `current_dir` in general are discouraged (see #37868).  I don't know if #37868 is fixable, since normalizing it would change the semantics for some platforms. Another option is to convert the executable to an absolute path with something like joining the cwd with the new cwd and the executable, but I'm uncertain about that.

3 years agoFix test to work with remote-test-server.
Eric Huss [Sun, 17 Jan 2021 22:03:23 +0000 (14:03 -0800)]
Fix test to work with remote-test-server.

remote-test-server does not set the current_dir, and leaves it
as `/`.

3 years agoAuto merge of #80679 - jackh726:predicate-kind-take2, r=lcnr
bors [Sun, 17 Jan 2021 20:49:11 +0000 (20:49 +0000)]
Auto merge of #80679 - jackh726:predicate-kind-take2, r=lcnr

Remove PredicateKind and instead only use Binder<PredicateAtom>

Originally brought up in https://github.com/rust-lang/rust/pull/76814#discussion_r546858171

r? `@lcnr`

3 years agoFeature-gate `pointer` and `reference` in intra-doc links
Joshua Nelson [Thu, 14 Jan 2021 16:55:52 +0000 (11:55 -0500)]
Feature-gate `pointer` and `reference` in intra-doc links

- Only feature gate associated items
- Add docs to unstable book

3 years agoEdit rustc_middle::ty::cast docs
pierwill [Sun, 17 Jan 2021 19:28:02 +0000 (11:28 -0800)]
Edit rustc_middle::ty::cast docs

Link to RFC 401 and add missing punctuation.

3 years agovalidation test: turn some const_err back into validation failures
Ralf Jung [Sun, 17 Jan 2021 18:49:20 +0000 (19:49 +0100)]
validation test: turn some const_err back into validation failures

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 agoAdd test for Command::current_dir behavior.
Eric Huss [Fri, 8 Jan 2021 21:15:43 +0000 (13:15 -0800)]
Add test for Command::current_dir behavior.

3 years agoDon't use posix_spawn_file_actions_addchdir_np on macOS.
Eric Huss [Wed, 30 Dec 2020 22:56:51 +0000 (14:56 -0800)]
Don't use posix_spawn_file_actions_addchdir_np on macOS.

3 years agoWhitespace and typo
Jack Huey [Sun, 17 Jan 2021 17:50:04 +0000 (12:50 -0500)]
Whitespace and typo

3 years agoAdd comment about Encodable/Decodable impl
Jack Huey [Sun, 17 Jan 2021 17:32:05 +0000 (12:32 -0500)]
Add comment about Encodable/Decodable impl

3 years agoAdd track_caller to .steal()
Joshua Nelson [Sun, 17 Jan 2021 17:24:53 +0000 (12:24 -0500)]
Add track_caller to .steal()

Before:

```
thread 'rustc' panicked at 'attempt to read from stolen value', /home/joshua/rustc/compiler/rustc_data_structures/src/steal.rs:43:15
```

After:

```
thread 'rustc' panicked at 'attempt to steal from stolen value', compiler/rustc_mir/src/transform/mod.rs:423:25
```

3 years agoUpdate cmp.rs
Marvin Huber [Sun, 17 Jan 2021 15:11:48 +0000 (16:11 +0100)]
Update cmp.rs

Fixed space

3 years agoAvoid logging the whole MIR body in SimplifyCfg
Tomasz Miąsko [Sun, 17 Jan 2021 00:00:00 +0000 (00:00 +0000)]
Avoid logging the whole MIR body in SimplifyCfg

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 agorustc_parse_format: Fix character indices in find_skips
Ömer Sinan Ağacan [Sat, 16 Jan 2021 09:46:57 +0000 (12:46 +0300)]
rustc_parse_format: Fix character indices in find_skips

Fixes #81006

3 years agoCopy body span instead of querying it
Dániel Buga [Sun, 17 Jan 2021 13:50:47 +0000 (14:50 +0100)]
Copy body span instead of querying it

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 agoDon't derive TyEncodable/TyDecodable for Binder
Jack Huey [Sun, 17 Jan 2021 09:13:51 +0000 (04:13 -0500)]
Don't derive TyEncodable/TyDecodable for Binder

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 agoImpl EncodableWithShorthand for PredicateKind
Jack Huey [Sun, 17 Jan 2021 07:49:30 +0000 (02:49 -0500)]
Impl EncodableWithShorthand for PredicateKind

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 agoInitialize a few variables directly
LingMan [Sun, 17 Jan 2021 01:07:37 +0000 (02:07 +0100)]
Initialize a few variables directly

Currently they are declared as `mut`, get initialized to a default value, and
then possibly overwritten.

By initializing to the final value directly, they don't need to be `mut` and
it's clear that they don't get mutated elsewhere later on.

3 years agoCan't use EncodableWithShorthand for Predicate
Jack Huey [Sun, 17 Jan 2021 00:17:59 +0000 (19:17 -0500)]
Can't use EncodableWithShorthand for Predicate

3 years agoMore review comments
Jack Huey [Thu, 7 Jan 2021 23:01:03 +0000 (18:01 -0500)]
More review comments

3 years agoReview changes
Jack Huey [Thu, 7 Jan 2021 16:20:28 +0000 (11:20 -0500)]
Review changes

3 years agoUse no_bound_vars
Jack Huey [Wed, 6 Jan 2021 21:12:02 +0000 (16:12 -0500)]
Use no_bound_vars

3 years agoCleanup
Jack Huey [Mon, 4 Jan 2021 21:50:36 +0000 (16:50 -0500)]
Cleanup

3 years agoUse pred not binder
Jack Huey [Mon, 4 Jan 2021 20:30:22 +0000 (15:30 -0500)]
Use pred not binder

3 years agoCleanup
Jack Huey [Mon, 4 Jan 2021 06:58:33 +0000 (01:58 -0500)]
Cleanup

3 years agofold_with not super_fold_with in TypeFoldable impl for Predicate
Jack Huey [Mon, 4 Jan 2021 06:14:07 +0000 (01:14 -0500)]
fold_with not super_fold_with in TypeFoldable impl for Predicate

3 years agoRemove PredicateKind
Jack Huey [Wed, 23 Dec 2020 21:36:23 +0000 (16:36 -0500)]
Remove PredicateKind

3 years agoIntermediate formatting and such
Jack Huey [Wed, 23 Dec 2020 18:16:25 +0000 (13:16 -0500)]
Intermediate formatting and such

3 years agoRemove PredicateKind::Atom
Jack Huey [Tue, 22 Dec 2020 03:49:03 +0000 (22:49 -0500)]
Remove PredicateKind::Atom

3 years agoprevent potential bug in `encode_with_shorthand`.
Bastian Kauschke [Sat, 16 Jan 2021 23:25:18 +0000 (00:25 +0100)]
prevent potential bug in `encode_with_shorthand`.

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 agoBTreeMap: offer merge in variants with more clarity
Stein Somers [Wed, 18 Nov 2020 17:19:38 +0000 (18:19 +0100)]
BTreeMap: offer merge in variants with more clarity

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.