Commit graph

153660 commits

Author SHA1 Message Date
Guillaume Gomez
3b1e7b1fc9
Rollup merge of #87166 - de-vri-es:show-discriminant-before-overflow, r=jackh726
Show discriminant before overflow in diagnostic for duplicate values.

This PR adds the value before overflow for explicit discriminant values in the error for duplicate discriminant values.
I found it rather confusing to see only the overflowed value.

It only does this for literals, since overflows in const evaluated arithmetic are already a hard error.

This is my first PR to the compiler, so please let me know if the implementation can be improved :)

Before:
![image](https://user-images.githubusercontent.com/786213/125850097-bf5fb7e0-d800-4386-a738-c30f41822964.png)

After:
![image](https://user-images.githubusercontent.com/786213/125850120-e2bb765d-ad86-4888-a6cb-dec34fba3fea.png)
2021-08-22 20:52:51 +02:00
Guillaume Gomez
2627db6a3c
Rollup merge of #86747 - FabianWolff:issue-86653, r=GuillaumeGomez
Improve wording of the `drop_bounds` lint

This PR addresses #86653. The issue is sort of a false positive of the `drop_bounds` lint, but I would argue that the best solution for #86653 is simply a rewording of the warning message and lint description, because even if the lint is _technically_ wrong, it still forces the programmer to think about what they are doing, and they can always use `#[allow(drop_bounds)]` if they think that they really need the `Drop` bound.

There are two issues with the current warning message and lint description:
- First, it says that `Drop` bounds are "useless", which is technically incorrect because they actually do have the effect of allowing you e.g. to call methods that also have a `Drop` bound on their generic arguments for some reason. I have changed the wording to emphasize not that the bound is "useless", but that it is most likely not what was intended.
- Second, it claims that `std::mem::needs_drop` detects whether a type has a destructor. But I think this is also technically wrong: The `Drop` bound says whether the type has a destructor or not, whereas `std::mem::needs_drop` also takes nested types with destructors into account, even if the top-level type does not itself have one (although I'm not 100% sure about the exact terminology here, i.e. whether the "drop glue" of the top-level type counts as a destructor or not).

cc `@jonhoo,` does this solve the issue for you?

r? `@GuillaumeGomez`
2021-08-22 20:52:50 +02:00
bors
91f9806208 Auto merge of #88166 - BoxyUwU:const-equate-canon, r=lcnr
canonicalize consts before calling try_unify_abstract_consts query

Fixes #88022
Fixes #86953
Fixes #77708
Fixes #82034
Fixes #85031

these ICEs were all caused by calling the `try_unify_abstract_consts` query with inference vars in substs

r? `@lcnr`
2021-08-22 18:00:22 +00:00
Frank Steffahn
2f9ddf3bc7 Fix typos “an”→“a” and a few different ones that appeared in the same search 2021-08-22 18:15:49 +02:00
Frank Steffahn
2396fad095 Fix more “a”/“an” typos 2021-08-22 17:27:18 +02:00
Joshua Nelson
d933edd5c6 Revert "Revert "Don't load all extern crates unconditionally""
This reverts commit 5f0c54db4e.
2021-08-22 15:25:42 +00:00
Mara Bos
abab99e02b Stop tracking namespce in used_imports.
The information was tracked, but unused.
2021-08-22 16:50:59 +02:00
Santiago Pastorino
10b3325d26
Test TAITs different lifetimes in defining uses fail 2021-08-22 11:42:53 -03:00
Frank Steffahn
b08b92eb42 Revert a change of “an --extern” (can be read with “dash dash”) 2021-08-22 16:37:47 +02:00
Frank Steffahn
be9d2699ca Fix more “a”/“an” typos 2021-08-22 16:35:29 +02:00
Frank Steffahn
bf88b113ea Fix typos “a”→“an” 2021-08-22 15:35:11 +02:00
bors
7481e6d1a4 Auto merge of #88163 - camsteffen:collapsible-match-fix, r=Manishearth
Fix clippy::collapsible_match with let expressions

This fixes rust-lang/rust-clippy#7575 which is a regression from #80357. I am fixing the bug here instead of in the clippy repo (if that's okay) because a) the regression has not been synced yet and b) I would like to land the fix on nightly asap.

The fix is basically to re-generalize `match` and `if let` for the lint implementation (they were split because `if let` no longer desugars to `match` in the HIR).

Also fixes rust-lang/rust-clippy#7586 and fixes rust-lang/rust-clippy#7591
cc `@rust-lang/clippy`
`@xFrednet` do you want to review this?
2021-08-22 13:26:32 +00:00
ccQpein
6eefee1077 Add doctests for 's into_values and into_keys methods 2021-08-22 09:21:00 -04:00
Mara Bos
bcc5ecb969 Suggest importing the right kind of macro. 2021-08-22 14:07:41 +02:00
bors
1eb187c16e Auto merge of #88139 - lcnr:marker-trait-attr, r=nikomatsakis
marker_traits: require `EvaluatedToOk` during winnowing

closes #84955, while it doesn't really fix it in a way that makes me happy it should prevent the issue for now and this
test can't be reproduced anyways, so it doesn't make much sense to keep it open.

fixes #84917 as only one of the impls depends on regions, so we now drop the ambiguous one instead of the correct one.

cc https://rust-lang.zulipchat.com/#narrow/stream/144729-wg-traits/topic/winnowing.20soundly/near/247899832

r? `@nikomatsakis`
2021-08-22 10:44:38 +00:00
bors
80dad64775 Auto merge of #88122 - Seppel3210:master, r=dtolnay
Fix example in `Extend<(A, B)>` impl

After looking over the examples in my last PR (#85835) on doc.rust-lang.org/nightly I realized that the example didn't actually show what I wanted it to show 😅
So here's the better example
2021-08-22 08:03:47 +00:00
bors
2ad56d5c90 Auto merge of #85166 - mbhall88:file-prefix, r=dtolnay
add file_prefix method to std::path

This is an initial implementation of `std::path::Path::file_prefix`. It is effectively a "left" variant of the existing [`file_stem`](https://doc.rust-lang.org/std/path/struct.Path.html#method.file_stem) method. An illustration of the difference is

```rust
use std::path::Path;

let path = Path::new("foo.tar.gz");
assert_eq!(path.file_stem(), Some("foo.tar"));
assert_eq!(path.file_prefix(), Some("foo"));
```

In my own development, I generally find I almost always want the prefix, rather than the stem, so I thought it might be best to suggest it's addition to libstd.

Of course, as this is my first contribution, I expect there is probably more work that needs to be done. Additionally, if the libstd team feel this isn't appropriate then so be it.

There has been some [discussion about this on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/file_lstem/near/238076313) and a user there suggested I open a PR to see whether someone in the libstd team thinks it is worth pursuing.
2021-08-22 05:19:48 +00:00
Joshua Nelson
90ac1ab26a Move Cache from Context to SharedContext 2021-08-22 03:38:04 +00:00
Dan Gohman
be483ff4c1 Implement AsFd etc. for UnixListener.
Implement `AsFd`, `From<OwnedFd>`, and `Into<OwnedFd>` for
`UnixListener`. This is a follow-up to #87329.
2021-08-21 19:42:30 -07:00
bors
50731df24e Auto merge of #88217 - jackh726:rollup-3k74o2m, r=jackh726
Rollup of 13 pull requests

Successful merges:

 - #87604 (CI: Verify commits in beta & stable are in upstream branches.)
 - #88057 (Update RELEASES to clarify attribute macro values.)
 - #88072 (Allow the iOS toolchain to be built on Linux)
 - #88170 (Update release note for 1.55.0.)
 - #88172 (Test that type alias impl trait happens in a submodule)
 - #88179 (Mailmap entry for myself)
 - #88182 (We meant to use a trait instead of lifetime here)
 - #88183 (test TAIT in different positions)
 - #88189 (Add TAIT struct test)
 - #88192 (Use of impl trait in an impl as the value for an associated type in a dyn)
 - #88194 (Test use of impl Trait in an impl as the value for an associated type in an impl trait)
 - #88197 (Test tait use in a fn type)
 - #88201 (Test that incomplete inference for TAITs fail)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-08-22 02:16:35 +00:00
Aaron Hill
41f9f38d6e
Remove Session.trait_methods_not_found
Instead, avoid registering the problematic well-formed obligation
to begin with. This removes global untracked mutable state,
and avoids potential issues with incremental compilation.
2021-08-21 20:45:11 -05:00
Noah Lev
19f45101e7 Bless tests 2021-08-21 18:41:34 -07:00
Jack Huey
b9b53c8ed4
Rollup merge of #88201 - spastorino:tait-incomplete-inference-test, r=oli-obk
Test that incomplete inference for TAITs fail

r? `@oli-obk`

Related to #86727
2021-08-21 20:56:39 -04:00
Jack Huey
1d0d7c34e8
Rollup merge of #88197 - spastorino:tait-test-fn-type, r=oli-obk
Test tait use in a fn type

r? `@oli-obk`

I thought this was going to work but doesn't, quickly checked with Niko and he told me that we ruled this out for now. I'm not exactly sure why and how but here we have a test with a FIXME :)

Related to #86727
2021-08-21 20:56:38 -04:00
Jack Huey
66b04c6501
Rollup merge of #88194 - spastorino:test-tait-assoc-impl-trait, r=oli-obk
Test use of impl Trait in an impl as the value for an associated type in an impl trait

r? `@oli-obk`

Related to #86727
2021-08-21 20:56:37 -04:00
Jack Huey
d6492b13d4
Rollup merge of #88192 - spastorino:add-tait-test-for-assoc-dyn, r=oli-obk
Use of impl trait in an impl as the value for an associated type in a dyn

r? `@oli-obk`

Related to #86727
2021-08-21 20:56:36 -04:00
Jack Huey
73d9758680
Rollup merge of #88189 - spastorino:add-tait-struct-test, r=oli-obk
Add TAIT struct test

r? `@oli-obk`

Related to #86727
2021-08-21 20:56:35 -04:00
Jack Huey
ae58c51fe7
Rollup merge of #88183 - spastorino:add-tait-in-different-tuple-position, r=oli-obk
test TAIT in different positions

r? `@oli-obk`

Related to #86727
2021-08-21 20:56:34 -04:00
Jack Huey
5be51f27b4
Rollup merge of #88182 - spastorino:use-trait-in-tait-tests, r=oli-obk
We meant to use a trait instead of lifetime here

r? `@oli-obk`

Related to #86727
2021-08-21 20:56:33 -04:00
Jack Huey
1a48b566c0
Rollup merge of #88179 - steffahn:mailmap, r=Mark-Simulacrum
Mailmap entry for myself
2021-08-21 20:56:32 -04:00
Jack Huey
0689152b1e
Rollup merge of #88172 - spastorino:tait-defining-use-submodule-test, r=oli-obk
Test that type alias impl trait happens in a submodule

r? `@oli-obk`

Related to #86727
2021-08-21 20:56:31 -04:00
Jack Huey
908b2ead9c
Rollup merge of #88170 - nebkor:release-note-1.55, r=Mark-Simulacrum
Update release note for 1.55.0.

Added a line about new formatting option, `{lib}`, for `cargo
tree` (https://github.com/rust-lang/cargo/pull/9663).
2021-08-21 20:56:29 -04:00
Jack Huey
5ffff5ccf2
Rollup merge of #88072 - kit-981:feature/build-ios-toolchain-on-linux, r=Mark-Simulacrum
Allow the iOS toolchain to be built on Linux

The iOS toolchain can be built on Linux with minor changes. The compilation will invoke `xcrun` to find the path to the iPhone SDK but a fake `xcrun` executable can be used.

```
#!/bin/sh
echo "/path/to/sdk"
```

The iOS toolchain can then be built and linked with rustup.

```
$ ./x.py build --stage 2 --host x86_64-unknown-linux-gnu \
  	 --target aarch64-apple-ios
$ rustup toolchain link stage1 build/x86_64-unknown-linux-gnu/stage1
```

It's possible to take this toolchain and compile an iOS executable with it. This requires the ld64 linker and an iOS SDK. The ld64 linker can be taken from [cctools](https://github.com/tpoechtrager/cctools-port). A project's .cargo/config can then be edited to use the linker for this target.

```
[target.aarch64-apple-ios]
linker = "/path/to/cctools/bin/arm-apple-darwin-ld"
rustflags = [
    "-C",
    """
link-args=
    -F/path/to/sdk/System/Library/Frameworks
    -L/path/to/sdk/usr/lib
    -L/path/to/sdk/usr/lib/system/
    -adhoc_codesign
    """,
]
```
2021-08-21 20:56:29 -04:00
Jack Huey
9e8b143e6a
Rollup merge of #88057 - ehuss:releases-doc-macros, r=Mark-Simulacrum
Update RELEASES to clarify attribute macro values.

As noted in #87681, macros do not work with the `#[path]` attribute.  Since the places where macros *can* be used is very limited, I have changed this to just focus on `#[doc]` which is the only attribute where this is really useful.
2021-08-21 20:56:28 -04:00
Jack Huey
8660e3d16b
Rollup merge of #87604 - yaymukund:verify-backported-commits, r=Mark-Simulacrum
CI: Verify commits in beta & stable are in upstream branches.

Closes #74721

I think this does the trick. https://github.com/rust-lang/rust/pull/87597 is an example of it failing as it should.
2021-08-21 20:56:27 -04:00
bors
9faa714154 Auto merge of #88075 - Xuanwo:vec_deque_retain, r=dtolnay
Optimize unnecessary check in VecDeque::retain

This pr is highly inspired by https://github.com/rust-lang/rust/pull/88060 which shared the same idea: we can split the `for` loop into stages so that we can remove unnecessary checks like `del > 0`.

## Benchmarks

Before

```rust
test collections::vec_deque::tests::bench_retain_half_10000  ... bench:     290,125 ns/iter (+/- 8,717)
test collections::vec_deque::tests::bench_retain_odd_10000   ... bench:     291,588 ns/iter (+/- 9,621)
test collections::vec_deque::tests::bench_retain_whole_10000 ... bench:     287,426 ns/iter (+/- 9,009)
```

After

```rust
test collections::vec_deque::tests::bench_retain_half_10000  ... bench:     243,940 ns/iter (+/- 8,563)
test collections::vec_deque::tests::bench_retain_odd_10000   ... bench:     242,768 ns/iter (+/- 3,903)
test collections::vec_deque::tests::bench_retain_whole_10000 ... bench:     202,926 ns/iter (+/- 6,332)
```

Based on the current benchmark, this PR will improve the perf of `VecDeque::retain` by around 16%. For special cases, the improvement will be up to 30%.

Signed-off-by: Xuanwo <github@xuanwo.io>
2021-08-21 23:35:54 +00:00
Noah Lev
08ceac8ee3 Add cross-crate tuple field count error test 2021-08-21 16:15:09 -07:00
Noah Lev
02ed23c031 Use an exhaustive match in Node::ident() and add docs
This should cause a compiler error in the future if more variants are
added without `Node::ident()` being updated.
2021-08-21 16:15:09 -07:00
Noah Lev
0fa3b4f940 Make E0023 spans even more precise 2021-08-21 16:15:09 -07:00
Noah Lev
d0b482a27c Add more tuple pattern too many fields test cases 2021-08-21 16:15:05 -07:00
Kornel
f1e860757e Don't stabilize creation of TryReserveError instances 2021-08-21 23:40:02 +01:00
Scott McMurray
65bfc3130a Remove the TryV2 alias
Post-bootstrap-update cleanup.
2021-08-21 15:09:03 -07:00
bors
d3e2578c31 Auto merge of #88135 - crlf0710:trait_upcasting_part_3, r=nikomatsakis
Trait upcasting coercion (part 3)

By using separate candidates for each possible choice, this fixes type-checking issues in previous commits.

r? `@nikomatsakis`
2021-08-21 21:14:07 +00:00
Aaron Hill
62aea8c913
Address review comments 2021-08-21 14:11:36 -05:00
bors
b1928aa3b4 Auto merge of #82776 - jyn514:extern-url-fallback, r=GuillaumeGomez
Give precedence to `html_root_url` over `--extern-html-root-url` by default, but add a way to opt-in to the previous behavior

## What is an HTML root url?

It tells rustdoc where it should link when documentation for a crate is
not available locally; for example, when a crate is a dependency of a
crate documented with `cargo doc --no-deps`.

 ## What is the difference between `html_root_url` and `--extern-html-root-url`?

Both of these tell rustdoc what the HTML root should be set to.
`doc(html_root_url)` is set by the crate author, while
`--extern-html-root-url` is set by the person documenting the crate.
These are often different. For example, docs.rs uses
`--extern-html-root-url https://docs.rs/crate-name/version` to ensure
all crates have documentation, even if `html_root_url` is not set.
Conversely, crates such as Rocket set `doc(html_root_url =
"https://api.rocket.rs")`, because they prefer users to view the
documentation on their own site.

Crates also set `html_root_url` to ensure they have
documentation when building locally when offline. This is unfortunate to
require, because it's more work from the library author. It also makes
it impossible to distinguish between crates that want to be viewed on a
different site (e.g. Rocket) and crates that just want documentation to
be visible offline at all (e.g. Tokio). I have authored a separate
change to the API guidelines to no longer recommend doing this:
rust-lang/api-guidelines#230.

 ## Why change the default?

In the past, docs.rs has been the main user of `--extern-html-root-url`.
However, it's useful for other projects as well. In particular, Cargo
wants to pass it by default when running `--no-deps`
(rust-lang/cargo#8296).

Unfortunately, for these other use cases, the priority order is
inverted. They want to give *precedence* to the URL the crate picks, and
only fall back to the `--extern-html-root` if no `html_root_url` is
present. That allows passing `--extern-html-root` unconditionally,
without having to parse the source code to see what attributes are
present.

For docs.rs, however, we still want to keep the old behavior, so that
all links on docs.rs stay on the site.
2021-08-21 18:32:37 +00:00
Aaron Hill
17aef21b30
Remove NonMacroAttr.mark_used 2021-08-21 13:27:29 -05:00
Aaron Hill
af46699f81
Remove Session.used_attrs and move logic to CheckAttrVisitor
Instead of updating global state to mark attributes as used,
we now explicitly emit a warning when an attribute is used in
an unsupported position. As a side effect, we are to emit more
detailed warning messages (instead of just a generic "unused" message).

`Session.check_name` is removed, since its only purpose was to mark
the attribute as used. All of the callers are modified to use
`Attribute.has_name`

Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed
used' attribute is implemented by simply not performing any checks
in `CheckAttrVisitor` for a particular attribute.

We no longer emit unused attribute warnings for the `#[rustc_dummy]`
attribute - it's an internal attribute used for tests, so it doesn't
mark sense to treat it as 'unused'.

With this commit, a large source of global untracked state is removed.
2021-08-21 13:27:27 -05:00
bors
99b73e81b3 Auto merge of #88134 - rylev:force-warn-improvements, r=nikomatsakis
Force warn improvements

As part of stablization of the `--force-warn` option (#86516) I've made the following changes:
* Error when the `warnings` lint group is based to the `--force-warn` option
* Tests have been updated to make it easier to understand the semantics of `--force-warn`

r? `@nikomatsakis`
2021-08-21 15:51:50 +00:00
Vadim Petrochenkov
1df0b73196 cleanup: Span::new -> Span::with_lo 2021-08-21 18:07:21 +03:00
bors
b6e334d873 Auto merge of #88128 - cuviper:needs-asm-support, r=Mark-Simulacrum
Add needs-asm-support to more tests

These were found as test failures on s390x for RHEL and Fedora.
2021-08-21 12:57:00 +00:00