Commit Graph

38409 Commits

Author SHA1 Message Date
Camille GILLOT
a3776d99cc Run reveal_all on MIR more often. 2021-11-06 15:56:29 +01:00
Ellen
abb9a9853b type error go brrrrrrrr 2021-11-06 10:39:11 +00:00
bors
7276a6a117 Auto merge of #90297 - dtolnay:dotzero, r=petrochenkov
Append .0 to unsuffixed float if it would otherwise become int token

Previously the unsuffixed f32/f64 constructors of `proc_macro::Literal` would create literal tokens that are definitely not a float:

```rust
Literal::f32_unsuffixed(10.0)  // 10
Literal::f32_suffixed(10.0)    // 10f32
Literal::f64_unsuffixed(10.0)  // 10
Literal::f64_suffixed(10.0)    // 10f64
```

Notice that the `10` are actually integer tokens if you were to reparse them, not float tokens.

This diff updates `Literal::f32_unsuffixed` and `Literal::f64_unsuffixed` to produce tokens that unambiguously parse as a float. This matches longstanding behavior of the proc-macro2 crate's implementation of these APIs dating back at least 3.5 years, so it's likely an unobjectionable behavior.

```rust
Literal::f32_unsuffixed(10.0)  // 10.0
Literal::f32_suffixed(10.0)    // 10f32
Literal::f64_unsuffixed(10.0)  // 10.0
Literal::f64_suffixed(10.0)    // 10f64
```

Fixes https://github.com/dtolnay/syn/issues/1085.
2021-11-06 07:15:05 +00:00
bors
9d39f6ab7d Auto merge of #89970 - jackh726:gats_diagnostics, r=nikomatsakis
Implementation of GATs outlives lint

See #87479 for background. Closes #87479

The basic premise of this lint/error is to require the user to write where clauses on a GAT when those bounds can be implied or proven from any function on the trait returning that GAT.

## Intuitive Explanation (Attempt) ##
Let's take this trait definition as an example:
```rust
trait Iterable {
    type Item<'x>;
    fn iter<'a>(&'a self) -> Self::Item<'a>;
}
```
Let's focus on the `iter` function. The first thing to realize is that we know that `Self: 'a` because of `&'a self`. If an impl wants `Self::Item` to contain any data with references, then those references must be derived from `&'a self`. Thus, they must live only as long as `'a`. Furthermore, because of the `Self: 'a` implied bound, they must live only as long as `Self`. Since it's `'a` is used in place of `'x`, it is reasonable to assume that any value of `Self::Item<'x>`, and thus `'x`, will only be able to live as long as `Self`. Therefore, we require this bound on `Item` in the trait.

As another example:
```rust
trait Deserializer<T> {
    type Out<'x>;
    fn deserialize<'a>(&self, input: &'a T) -> Self::Out<'a>;
}
```
The intuition is similar here, except rather than a `Self: 'a` implied bound, we have a `T: 'a` implied bound. Thus, the data on `Self::Out<'a>` is derived from `&'a T`, and thus it is reasonable to expect that the lifetime `'x` will always be less than `T`.

## Implementation Algorithm ##
* Given a GAT `<P0 as Trait<P1..Pi>>::G<Pi...Pn>` declared as `trait T<A1..Ai> for A0 { type G<Ai...An>; }` used in return type of one associated function `F`
* Given env `E` (including implied bounds) for `F`
* For each lifetime parameter `'a` in `P0...Pn`:
    * For each other type parameter `Pi != 'a` in `P0...Pn`: // FIXME: this include of lifetime parameters too
        * If `E => (P: 'a)`:
            * Require where clause `Ai: 'a`

## Follow-up questions ##
* What should we do when we don't pass params exactly?
For this example:
```rust
trait Des {
    type Out<'x, D>;
    fn des<'z, T>(&self, data: &'z Wrap<T>) -> Self::Out<'z, Wrap<T>>;
}
```
Should we be requiring a `D: 'x` clause? We pass `Wrap<T>` as `D` and `'z` as `'x`, and should be able to prove that `Wrap<T>: 'z`.

r? `@nikomatsakis`
2021-11-06 04:15:22 +00:00
Caleb Zulawski
1e1886908f Disable bitmask test on big endian 2021-11-06 02:29:03 +00:00
Caleb Zulawski
3981ca076c Allow simd_select_bitmask to take byte arrays 2021-11-06 02:12:14 +00:00
Caleb Zulawski
7964942515 Allow simd_bitmask to return byte arrays 2021-11-06 02:08:09 +00:00
jackh726
b6edcbd7b5 Review comments 2021-11-05 21:33:14 -04:00
bors
18cae2680f Auto merge of #88441 - jackh726:closure_norm, r=nikomatsakis
Normalize obligations for closure confirmation

Based on #90017

Fixes #74261
Fixes #71955
Fixes #88459

r? `@nikomatsakis`
2021-11-06 01:12:39 +00:00
bors
d32993afe8 Auto merge of #90631 - matthiaskrgr:rollup-a5tzjh3, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #89942 (Reorder `widening_impl`s to make the doc clearer)
 - #90569 (Fix tests using `only-i686` to use the correct `only-x86` directive)
 - #90597 (Warn for variables that are no longer captured)
 - #90623 (Remove more checks for LLVM < 12)
 - #90626 (Properly register text_direction_codepoint_in_comment lint.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-05 22:12:31 +00:00
Josh Stone
e96a0a8681 Revert "Do not call getpid wrapper after fork in tests"
This reverts commit 12fbabd27f.

It was only needed because of using raw `clone3` instead of `fork`, but
we only do that now when a pidfd is requested.
2021-11-05 14:49:26 -07:00
Matthias Krüger
f5f6f73faf
Rollup merge of #90626 - rusticstuff:be-more-accepting, r=jyn514
Properly register text_direction_codepoint_in_comment lint.

This makes it known to the compiler so it can be configured like with `#![allow(text_direction_codepoint_in_comment)]`.

Fixes #90614.
2021-11-05 21:12:31 +01:00
Matthias Krüger
4b1cb73f1d
Rollup merge of #90597 - nikomatsakis:issue-90465, r=wesleywiser
Warn for variables that are no longer captured

r? `@wesleywiser`

cc `@rust-lang/wg-rfc-2229`

Fixes #90465
2021-11-05 21:12:29 +01:00
Matthias Krüger
cd24ffb266
Rollup merge of #90569 - wesleywiser:fix_only_i686_tests, r=Mark-Simulacrum
Fix tests using `only-i686` to use the correct `only-x86` directive

We translate `i686` to `x86` which means tests marked as `only-i686`
never ran. Update those tests to use `only-x86`.

We parse the `only-` architecture directive here

27143a9094/src/tools/compiletest/src/util.rs (L160-L168)

and we translate `i686` to `x86` here

27143a9094/src/tools/compiletest/src/util.rs (L56)
2021-11-05 21:12:28 +01:00
Hans Kratz
9db9811ddf Properly register text_direction_codepoint_in_comment lint. 2021-11-05 20:12:40 +01:00
David Tolnay
1f9807799c
Add test to confirm fnn_unsuffixed does not emit exponent notation 2021-11-05 12:06:49 -07:00
bors
0d1754e8bf Auto merge of #90583 - willcrichton:example-analyzer, r=jyn514
Fix ICE when rustdoc is scraping examples inside of a proc macro

This PR provides a clearer semantics for how --scrape-examples interacts with macros. If an expression's span AND it's enclosing item's span both are not `from_expansion`, then the example will be scraped. The added test case `rustdoc-scrape-examples-macros` shows a variety of situations.

* A macro-rules macro that takes a function call as input: good
* A macro-rules macro that generates a function call as output: bad
* A proc-macro that generates a function call as output: bad
* An attribute macro that generates a function call as output: bad
* An attribute macro that takes a function call as input: good, if the proc macro is designed to propagate the input spans

I ran this updated rustdoc on pyo3 and confirmed that it successfully scrapes examples from inside a proc macro, eg

<img width="1013" alt="Screen Shot 2021-11-04 at 1 11 28 PM" src="https://user-images.githubusercontent.com/663326/140412691-81a3bb6b-a448-4a1b-a293-f7a795553634.png">

(cc `@mejrs)`

Additionally, this PR fixes an ordering bug in the highlighting logic.

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

r? `@jyn514`
2021-11-05 19:05:36 +00:00
Niko Matsakis
4154e8acf0 apply suggestions from code review 2021-11-05 12:43:42 -04:00
Will Crichton
82b23be3c1 Fix rustdoc-scrape-examples-macros test not being cross-platform 2021-11-05 09:32:04 -07:00
Tor Hovland
d4bcee9638 Added a regression test. 2021-11-05 08:46:29 +01:00
Will Crichton
c62817bfe2 Move rustdoc-scrape-examples-macros test to run-make-fulldeps 2021-11-04 18:52:59 -07:00
Yuki Okushi
3821ab231b
Rollup merge of #90571 - GuillaumeGomez:missing-bottom-border-sidebar, r=jsha
Fix missing bottom border for headings in sidebar

Fixes #90568.

r? ```@jsha```
2021-11-05 10:32:47 +09:00
Yuki Okushi
7ee926a852
Rollup merge of #90554 - ehuss:unstable-options-cleanup, r=joshtriplett
Clean up some `-Z unstable-options` in tests.

Several of these tests were for features that have been stabilized, or otherwise don't need `-Z unstable-options`.
2021-11-05 10:32:45 +09:00
Yuki Okushi
987797bfe1
Rollup merge of #90507 - TaKO8Ki:suggest-extern-crate-alloc, r=jackh726
Suggest `extern crate alloc` when using undeclared module `alloc`

closes #90136
2021-11-05 10:32:39 +09:00
SparrowLii
926892ddc0 Add feature trigger and enable is_struct check 2021-11-05 09:30:49 +08:00
Niko Matsakis
fc8113d04e handle case of a variable not captured 2021-11-04 21:26:47 -04:00
Niko Matsakis
76bc02715e rework diagnostic reporting to be more structured 2021-11-04 20:32:44 -04:00
Richard Lowe
dbc3bf48c4 treat illumos like solaris in failing ui tests which need it 2021-11-04 17:00:19 -05:00
bors
2cff30b17a Auto merge of #90536 - crlf0710:fix_vtable_hrtb, r=jackh726
Erase regions within `vtable_trait_first_method_offset`

Fixes #90177 .

r? `@jackh726`
2021-11-04 21:52:21 +00:00
Will Crichton
4846d102e2 Fix ICE when rustdoc is scraping examples inside of a proc macro 2021-11-04 13:57:39 -07:00
Will Crichton
3ad6d12827 Sort scraped call locations before serializing 2021-11-04 13:57:09 -07:00
Guillaume Gomez
aa17e1c47f Fix missing bottom border for headings in sidebar 2021-11-04 20:07:24 +01:00
Wesley Wiser
8c56ef0878 Fix tests using only-i686 to use the correct only-x86 directive
We translate `i686` to `x86` which means tests marked as `only-i686`
never ran. Update those tests to use `only-x86`.
2021-11-04 10:39:15 -04:00
Eric Huss
754455e4f2 Clean up some -Z unstable-options in tests. 2021-11-03 20:00:00 -07:00
bors
e60e19bc65 Auto merge of #90179 - Nilstrieb:lifetime-elision-mismatch-hint, r=estebank
Add beginner friendly lifetime elision hint to E0623

Address #90170

Suggest adding a new lifetime parameter when two elided lifetimes should match up but don't.

Example:

```
error[E0623]: lifetime mismatch
  --> $DIR/issue-90170-elision-mismatch.rs:2:35
   |
LL | fn foo(slice_a: &mut [u8], slice_b: &mut [u8]) {
   |                 ---------           --------- these two types are declared with different lifetimes...
LL |     core::mem::swap(&mut slice_a, &mut slice_b);
   |                                   ^^^^^^^^^^^^ ...but data from `slice_b` flows into `slice_a` here
   |
   = note: each elided lifetime in input position becomes a distinct lifetime
help: explicitly declare a lifetime and assign it to both
   |
LL | fn foo<'a>(slice_a: &'a mut [u8], slice_b: &'a mut [u8]) {
   |       ++++           ++                     ++

```

for

```rust
fn foo(slice_a: &mut [u8], slice_b: &mut [u8]) {
    core::mem::swap(&mut slice_a, &mut slice_b);
}
```
2021-11-04 00:39:21 +00:00
Nilstrieb
4b9e4606cb Add beginner friendly lifetime elision hint to E0623
Suggest adding a new lifetime parameter when two elided lifetimes should match up but don't

Issue #90170

This also changes the tests introduced by the previous commits because of another rustc issue (#90258)
2021-11-03 20:10:44 +01:00
Charles Lew
8841204cc6 Erase regions within vtable_trait_first_method_offset. 2021-11-04 00:53:54 +08:00
Tomasz Miąsko
bc4931ed7e addr_of! grants mutable access, maybe?
The exact set of permissions granted when forming a raw reference is
currently undecided https://github.com/rust-lang/rust/issues/56604.

To avoid presupposing any particular outcome, adjust the const
qualification to be compatible with decision where raw reference
constructed from `addr_of!` grants mutable access.
2021-11-03 16:43:12 +01:00
Tomasz Miąsko
b285e0c5d8 Remove MaybeMutBorrowedLocals 2021-11-03 16:43:12 +01:00
Takayuki Maeda
6c1e194534 fix message 2021-11-03 13:53:57 +09:00
Matthias Krüger
e38844a9d8
Rollup merge of #90502 - GuillaumeGomez:split-doc-cfg-feature, r=jyn514
Split doc_cfg and doc_auto_cfg features

Part of #90497.

With this feature, `doc_cfg` won't pick up items automatically anymore.

cc `@Mark-Simulacrum`
r? `@jyn514`
2021-11-02 23:48:50 +01:00
Matthias Krüger
bc487f7dd2
Rollup merge of #90417 - lcnr:stabilize-relaxed-struct-unsizing, r=wesleywiser
stabilize `relaxed_struct_unsize`

closes #81793

the fcp is already complete.
2021-11-02 23:48:47 +01:00
Tor Hovland
0b378f008b Fix test. 2021-11-02 22:43:49 +01:00
Gary Guo
f556075459 Apply adjustments for field expression even if inaccessible
The adjustments are used later by ExprUseVisitor to build Place projections
and without adjustments it can produce invalid result.
2021-11-02 17:22:12 +00:00
Takayuki Maeda
acb9f9ba38 add a suggestion about undeclared alloc module 2021-11-03 01:44:01 +09:00
Guillaume Gomez
d50a4753b8 Split doc_cfg and doc_auto_cfg features 2021-11-02 16:55:50 +01:00
bors
db062de72b Auto merge of #90406 - nbdd0121:panic, r=cjgillot
Collect `panic/panic_bounds_check` during monomorphization

This would prevent link time errors if these functions are `#[inline]` (e.g. when `panic_immediate_abort` is used).

Fix #90405
Fix rust-lang/cargo#10019

`@rustbot` label: T-compiler A-codegen
2021-11-01 17:18:57 +00:00
bors
e9b0d99259 Auto merge of #90463 - matthiaskrgr:rollup-eljk9vo, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #89826 (Feature gate + make must_not_suspend allow-by-default)
 - #89929 (Handling submodule update failures more gracefully from x.py)
 - #90333 (rustdoc: remove flicker during page load)
 - #90349 (Fix rare ICE during typeck in rustdoc scrape_examples)
 - #90398 (Document `doc(keyword)` unstable attribute)
 - #90441 (Test that promotion follows references when looking for drop)
 - #90450 (Remove `rustc_hir::hir_id::HirIdVec`)
 - #90452 (Remove unnecessary `Option` from `promote_candidate` return type)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-01 14:00:08 +00:00
bors
db14a17e69 Auto merge of #90462 - pietroalbini:bidi-master, r=nikomatsakis,pietroalbini
[master] Fix CVE-2021-42574

This PR implements new lints to mitigate the impact of [CVE-2021-42574], caused by the presence of bidirectional-override Unicode codepoints in the compiled source code. [See the advisory][advisory] for more information about the vulnerability.

The changes in this PR will be released in tomorrow's nightly release.

[CVE-2021-42574]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-42574
[advisory]: https://blog.rust-lang.org/2021/11/01/cve-2021-42574.html
2021-11-01 10:53:49 +00:00
Matthias Krüger
365483a35b
Rollup merge of #90441 - tmiasko:test-promotion-needs-drop, r=Mark-Simulacrum
Test that promotion follows references when looking for drop

Noticed that this wasn't covered by any of existing tests.

The const checking and const qualification, which currently shares the
implementation with promotion, will likely need a different behaviour
here (see issue #90193).
2021-11-01 03:33:09 +01:00
Matthias Krüger
3730485a24
Rollup merge of #90349 - willcrichton:example-analyzer, r=jyn514
Fix rare ICE during typeck in rustdoc scrape_examples

While testing the `--scrape-examples` extension on the [wasmtime](https://github.com/bytecodealliance/wasmtime) repository, I found some additional edge cases. Specifically, when asking to typecheck a body containing a function call, I would sometimes get an ICE if:
* The body doesn't exist
* The function's HIR node didn't have a type

This adds checks for both of those conditions.

(Also this updates a test to check that the sources of a reverse-dependency are correctly generated and linked.)

r? `@jyn514`
2021-11-01 03:33:07 +01:00
Matthias Krüger
bb6901d32b
Rollup merge of #90333 - jsha:flashy-searchbar, r=GuillaumeGomez
rustdoc: remove flicker during page load

The search bar has a `:disabled` style that makes it grey, which creates a distracting flicker from grey to white when the page finishes loading. The search bar should stay the same color throughout page load.

A blank white search bar might create an incorrect impression for users with JS turned off. Since they can't use the search functionality, I've hidden the search bar in noscript.css.

Fixes #90246
r? `@GuillaumeGomez`

Demo: https://rustdoc.crud.net/jsha/flashy-searchbar/std/string/struct.String.html
2021-11-01 03:33:06 +01:00
jackh726
18421b1f08 Add lint for region pairs too 2021-10-31 21:53:26 -04:00
jackh726
b84044acff Review comments and more tests 2021-10-31 21:36:04 -04:00
Gus Wynn
185fa56256 Feature gate and make must_not_suspend allow-by-default
This lint is not yet ready for stable use, primarily due to false positives in edge
cases; we want to test it out more before stabilizing.
2021-10-31 21:22:17 -04:00
Jacob Hoffman-Andrews
a4fe76ff7c Hide search bar in noscript.css
Also, remove the highlighting of the search bar in disabled state. This
reduces flicker when loading a page.
2021-10-31 12:41:06 -07:00
Tomasz Miąsko
fadb9cc521 Test that promotion follows references when looking for drop
Noticed that this wasn't covered by any of existing tests.

The const checking and const qualification, which currently shares the
implementation with promotion, will likely need a different behaviour
here (see issue #90193).
2021-10-31 18:33:29 +01:00
Matthias Krüger
26f505c433
Rollup merge of #90430 - jkugelman:must-use-std-a-through-n, r=joshtriplett
Add #[must_use] to remaining std functions (A-N)

I've run out of compelling reasons to group functions together across crates so I'm just going to go module-by-module. This is half of the remaining items from the `std` crate, from A-N.

I added these functions myself. Clippy predictably ignored the `mut` ones, but I don't know why the rest weren't flagged. Check them closely, please? Maybe I overlooked good reasons.

```rust
std::backtrace::Backtrace                                   const fn disabled() -> Backtrace;
std::backtrace::Backtrace<'a>                               fn frames(&'a self) -> &'a [BacktraceFrame];
std::collections::hash_map::RawOccupiedEntryMut<'a, K, V>   fn key_mut(&mut self) -> &mut K;
std::collections::hash_map::RawOccupiedEntryMut<'a, K, V>   fn get_mut(&mut self) -> &mut V;
std::collections::hash_map::RawOccupiedEntryMut<'a, K, V>   fn get_key_value(&mut self) -> (&K, &V);
std::collections::hash_map::RawOccupiedEntryMut<'a, K, V>   fn get_key_value_mut(&mut self) -> (&mut K, &mut V);
std::env                                                    fn var_os<K: AsRef<OsStr>>(key: K) -> Option<OsString>;
std::env                                                    fn split_paths<T: AsRef<OsStr> + ?Sized>(unparsed: &T) -> SplitPaths<'_>;
std::io::Error                                              fn get_mut(&mut self) -> Option<&mut (dyn error::Error + Send + Sync + 'static)>;
```

Parent issue: #89692

r? `@joshtriplett`
2021-10-31 13:20:06 +01:00
Matthias Krüger
6c5aa765fb
Rollup merge of #89068 - bjorn3:restructure_rt2, r=joshtriplett
Restructure std::rt (part 2)

A couple more cleanups on top of https://github.com/rust-lang/rust/pull/89011

Blocked on #89011
2021-10-31 13:20:04 +01:00
Esteban Küber
c0b134582a
Lint against RTL unicode codepoints in literals and comments
Address CVE-2021-42574.
2021-10-31 13:14:04 +01:00
Matthias Krüger
e79e9f5e2a
Rollup merge of #89839 - jkugelman:must-use-mem-ptr-functions, r=joshtriplett
Add #[must_use] to mem/ptr functions

There's a lot of low-level / unsafe stuff here. Are there legit use cases for ignoring any of these return values?

* No regressions in `./x.py test --stage 1 library/std src/tools/clippy`.
* One regression in `./x.py test --stage 1 src/test/ui`. Fixed.
* I am unable to run `./x.py doc` on my machine so I'll need to wait for the CI to verify doctests pass. I eyeballed all the adjacent tests and they all look okay.

Parent issue: #89692

r? ```@joshtriplett```
2021-10-31 09:20:25 +01:00
John Kugelman
e129d49f88 Add #[must_use] to remaining std functions (A-N) 2021-10-30 23:44:02 -04:00
Jacob Hoffman-Andrews
69df43b041 Improve display of enum variants
Use h3 and h4 for the variant name and the "Fields" subheading.
Remove the "of T" part of the "Fields" subheading.
Remove border-bottom from "Fields" subheading.
Move docblock below "Fields" listing.
2021-10-30 16:35:26 -07:00
John Kugelman
887503ad14 Add #[must_use] to mem/ptr functions 2021-10-30 18:54:48 -04:00
bors
e249ce6b23 Auto merge of #90422 - GuillaumeGomez:rollup-s1mdag0, r=GuillaumeGomez
Rollup of 5 pull requests

Successful merges:

 - #90156 (Remove underlines from non-top docblocks.)
 - #90183 (Show all Deref implementations recursively)
 - #90202 (Improve and test cross-crate hygiene)
 - #90375 (Use `is_global` in `candidate_should_be_dropped_in_favor_of`)
 - #90399 (Skipping verbose diagnostic suggestions when calling .as_ref() on type not implementing AsRef)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-30 19:31:47 +00:00
Guillaume Gomez
197da45e18
Rollup merge of #90399 - yuvaldolev:as-ref-overly-verbose-diagnostic, r=estebank
Skipping verbose diagnostic suggestions when calling .as_ref() on type not implementing AsRef

Addresses #89806

Skipping suggestions when calling `.as_ref()` for types that do not implement the `AsRef` trait.

r? `@estebank`
2021-10-30 20:30:28 +02:00
Guillaume Gomez
06bb1ff1b5
Rollup merge of #90375 - yanok:master, r=lcnr
Use `is_global` in `candidate_should_be_dropped_in_favor_of`

This manifistated in #90195 with compiler being unable to keep
one candidate for a trait impl, if where is a global impl and more
than one trait bound in the where clause.

Before #87280 `candidate_should_be_dropped_in_favor_of` was using
`TypeFoldable::is_global()` that was enough to discard the two
`ParamCandidate`s. But #87280 changed it to use
`TypeFoldable::is_known_global()` instead, which is pessimistic, so
now the compiler drops the global impl instead (because
`is_known_global` is not sure) and then can't decide between the
two `ParamCandidate`s.

Switching it to use `is_global` again solves the issue.

Fixes #90195.
2021-10-30 20:30:27 +02:00
Guillaume Gomez
1a1f525bb0
Rollup merge of #90202 - matthewjasper:xcrate-hygiene, r=petrochenkov
Improve and test cross-crate hygiene

- Decode the parent expansion for traits and enums in `rustc_resolve`, this was already being used for resolution in typeck
- Avoid suggesting importing names with def-site hygiene, since it's often not useful
- Add more tests

r? `@petrochenkov`
2021-10-30 20:30:27 +02:00
Guillaume Gomez
73494404e9
Rollup merge of #90183 - GuillaumeGomez:recurse-deref, r=jyn514
Show all Deref implementations recursively

Fixes #87783.

This is a re-implementation of #80653, so taking the original PR comment:

This changes `rustdoc` to recursively follow `Deref` targets so that methods from all levels are added to the rendered output. This implementation displays the methods from all levels in the expanded state with separate sections for each level.

![image](https://user-images.githubusercontent.com/279572/103482863-46723b00-4ddb-11eb-972b-c463351a425c.png)

cc `@camelid`
r? `@jyn514`
2021-10-30 20:30:26 +02:00
Guillaume Gomez
ec83b95ab9
Rollup merge of #90156 - jsha:less-border-bottom-2, r=GuillaumeGomez
Remove underlines from non-top docblocks.

We still had a number of places where underlined section headings would
show up, like under Implementations.

Follow-up to #89506 (thanks `@yaymukund!)` and #90036. Related to #59829.

r? `@camelid`

Demo:

[Before](https://doc.rust-lang.org/nightly/std/string/struct.String.html#trait-implementations):

[![image](https://user-images.githubusercontent.com/220205/138402555-b0c0a3ea-ff50-4aad-bb74-6f9e57323807.png)](https://jacob.hoffman-andrews.com/rust/less-border-bottom-2/std/string/struct.String.html#trait-implementations)

[After](https://jacob.hoffman-andrews.com/rust/less-border-bottom-2/std/string/struct.String.html#trait-implementations):

[![image](https://user-images.githubusercontent.com/220205/138402669-d0835bd9-8813-4f0c-8697-f86e9759acec.png)](https://jacob.hoffman-andrews.com/rust/less-border-bottom-2/std/string/struct.String.html#trait-implementations)
2021-10-30 20:30:25 +02:00
Gary Guo
94e940dd30 Collect panic/panic_bounds_check during monomorphization 2021-10-30 18:21:44 +01:00
bors
2609fab8e4 Auto merge of #90205 - mati865:link-modifiers-in-rustc, r=petrochenkov
Repace use of `static_nobundle` with `native_link_modifiers` within Rust codebase

This fixes warnings when building Rust and running tests:
```
warning: library kind `static-nobundle` has been superseded by specifying `-bundle` on library kind `static`. Try `static:-bundle`
warning: `rustc_llvm` (lib) generated 2 warnings (1 duplicate)
```
2021-10-30 16:22:49 +00:00
Jacob Hoffman-Andrews
a65c98fefb Remove underlines from non-top docblocks.
We still had a number of places where underlined section headings would
show up, like under Implementations.
2021-10-30 09:22:28 -07:00
Guillaume Gomez
78b604569b Document tests a bit more 2021-10-30 16:30:14 +02:00
lcnr
b40aa64e48 stabilize relaxed_struct_unsize 2021-10-30 15:56:02 +02:00
Matthias Krüger
d99dc7abfa
Rollup merge of #90396 - b-naber:type_flags_ices_default_anon_consts, r=lcnr
Prevent type flags assertions being thrown in default_anon_const_substs if errors occurred

Fixes https://github.com/rust-lang/rust/issues/90364
Fixes https://github.com/rust-lang/rust/issues/88997

r? ``@lcnr``
2021-10-30 14:37:03 +02:00
Matthias Krüger
88e0bea7ca
Rollup merge of #90395 - b-naber:const-expr-type-relation, r=oli-obk
Restrict liveness of mutable borrow of inner infcx in ConstInferUnifier::consts

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

r? ``@oli-obk``
2021-10-30 14:37:02 +02:00
Matthias Krüger
a213740abe
Rollup merge of #90374 - GuillaumeGomez:unify-rustdoc-book-titles, r=camelid
Unify titles in rustdoc book doc attributes chapter

As discussed in https://github.com/rust-lang/rust/pull/90339.

I wasn't able to find out where the link to the titles was used so let's see if the CI fails. :)

r? ``@camelid``
2021-10-30 14:37:00 +02:00
bors
22f1ad75e9 Auto merge of #88268 - GuillaumeGomez:generics-search-index, r=notriddle,camelid,jyn514
rustdoc: Fix generics generation in search index

The generics were not added to the search index as they should, instead they were added as arguments. I used this opportunity to allow generics to have generics themselves (will come in very handy for my current rewrite of the search engine!).

r? `@jyn514`
2021-10-30 04:12:40 +00:00
Cameron Steffen
4cfb7add77 Fix a format_args span to be expansion 2021-10-29 17:13:15 -05:00
Will Crichton
b8ecc9fefa Fix rare ICE during typeck in rustdoc scrape_examples 2021-10-29 13:21:50 -07:00
Guillaume Gomez
0c70831171 Unify titles in rustdoc book doc attributes chapter 2021-10-29 21:27:44 +02:00
Guillaume Gomez
355e6eddfe Fix invalid handling of generics 2021-10-29 20:54:15 +02:00
Yuval Dolev
cad2d21cb6 Explicitly skipping suggestions for 'Pin' as it does not implement the 'AsRef' trait 2021-10-29 15:49:55 +03:00
Yuval Dolev
e2151497bf Skip suggestions for the AsRef trait 2021-10-29 15:49:55 +03:00
Guillaume Gomez
dd68d207a5 Don't display "Methods from Deref<...>" if no method is display (the ones which don't have self argument) 2021-10-29 14:37:01 +02:00
Guillaume Gomez
0c38f31bf2 Add tests for recursive deref 2021-10-29 14:25:15 +02:00
bors
9ed5b94b28 Auto merge of #90373 - tmiasko:union-qualification, r=oli-obk
Use type based qualification for unions

Union field access is currently qualified based on the qualification of
a value previously assigned to the union. At the same time, every union
access transmutes the content of the union, which might result in a
different qualification.

For example, consider constants A and B as defined below, under the
current rules neither contains interior mutability, since a value used
in the initial assignment did not contain `UnsafeCell` constructor.

```rust
#![feature(untagged_unions)]

union U { i: u32, c: std::cell::Cell<u32> }
const A: U = U { i: 0 };
const B: std::cell::Cell<u32> = unsafe { U { i: 0 }.c };
```

To avoid the issue, the changes here propose to consider the content of
a union as opaque and use type based qualification for union types.

Fixes #90268.

`@rust-lang/wg-const-eval`
2021-10-29 12:21:09 +00:00
SparrowLii
1ab2616b4d Add feature trigger and correct is_struct check 2021-10-29 20:08:30 +08:00
b-naber
87fbf3c5aa ignore type flags insertion in default_anon_const_substs if error occurred 2021-10-29 13:47:53 +02:00
b-naber
a39c50b64c add test 2021-10-29 12:38:28 +02:00
bors
37f70a0e1e Auto merge of #90214 - tmiasko:indirect-mutation-qualif, r=ecstatic-morse,oli-obk
Consider indirect mutation during const qualification dataflow

Previously a local would be qualified if either one of two separate data
flow computations indicated so. First determined if a local could
contain the qualif, but ignored any forms of indirect mutation. Second
determined if a local could be mutably borrowed (and so indirectly
mutated), but which in turn ignored the qualif.

The end result was incorrect because the effect of indirect mutation was
effectivelly ignored in the all but the final stage of computation.

In the new implementation the indirect mutation is directly incorporated
into the qualif data flow. The local variable becomes immediately
qualified once it is mutably borrowed and borrowed place type can
contain the qualif.

In general we will now reject additional programs, program that were
prevously unintentionally accepted.

There are also some cases which are now accepted but were previously
rejected, because previous implementation didn't consider whether
borrowed place could have the qualif under the consideration.

Fixes #90124.

r? `@ecstatic-morse`
2021-10-29 08:38:39 +00:00
bors
88a5a984fe Auto merge of #90380 - Mark-Simulacrum:revert-89558-query-stable-lint, r=lcnr
Revert "Add rustc lint, warning when iterating over hashmaps"

Fixes perf regressions introduced in https://github.com/rust-lang/rust/pull/90235 by temporarily reverting the relevant PR.
2021-10-29 04:55:51 +00:00
SparrowLii
f3679bc23e move the processing part of base_expr into check_expr_struct_fields 2021-10-29 11:16:28 +08:00
Mateusz Mikuła
533247c1c8 Add -Zunstable-options instead of feature 2021-10-28 23:38:21 +02:00
Matthew Jasper
a76a2d4ef9 Add comments to hygiene tests 2021-10-28 21:48:39 +01:00
bors
85c0558d03 Auto merge of #90218 - JakobDegen:adt_significant_drop_fix, r=nikomatsakis
Fixes incorrect handling of ADT's drop requirements

Fixes #90024 and a bunch of duplicates.

The main issue was just that the contract of `NeedsDropTypes::adt_components` was inconsistent; the list of types it might return were the generic parameters themselves or the fields of the ADT, depending on the nature of the drop impl. This meant that the caller could not determine whether a `.subst()` call was still needed on those types; it called `.subst()` in all cases, and this led to ICEs when the returned types were the generic params.

First contribution of more than a few lines, so feedback definitely appreciated.
2021-10-28 16:03:13 +00:00
Mark Rousskov
3215eeb99f
Revert "Add rustc lint, warning when iterating over hashmaps" 2021-10-28 11:01:42 -04:00
Ilya Yanok
9a0a622a04 Add test cases 2021-10-28 14:25:46 +00:00
SparrowLii
7bde18a0f3 implement type-changing-struct-update
put the test dir in test/ui/rfcs
2021-10-28 14:17:15 +08:00
Tomasz Miąsko
3f778f31b6 Use type based qualification for unions
Union field access is currently qualified based on the qualification of
a value previously assigned to the union. At the same time, every union
access transmutes the content of the union, which might result in a
different qualification.

For example, consider constants A and B as defined below, under the
current rules neither contains interior mutability, since a value used
in the initial assignment did not contain `UnsafeCell` constructor.

```rust
#![feature(untagged_unions)]

union U { i: u32, c: std::cell::Cell<u32> }
const A: U = U { i: 0 };
const B: std::cell::Cell<u32> = unsafe { U { i: 0 }.c };
```

To avoid the issue, the changes here propose to consider the content of
a union as opaque and use type based qualification for union types.
2021-10-28 00:00:00 +00:00
Matthias Krüger
f32c09b82a
Rollup merge of #90304 - vandenheuvel:test_issue_75961, r=Mark-Simulacrum
Add regression test for #75961

Closes #75961.
Closes #21203.
2021-10-27 18:25:46 +02:00
Matthias Krüger
83d5c24071
Rollup merge of #90288 - JakobDegen:import_diagnostics, r=davidtwco
Add hint for people missing `TryFrom`, `TryInto`, `FromIterator` import pre-2021

Adds a hint anytime a `TryFrom`, `TryInto`, `FromIterator` import is suggested noting that these traits are automatically imported in Edition 2021.
2021-10-27 18:25:46 +02:00
Matthias Krüger
17d1742028
Rollup merge of #90267 - EliseZeroTwo:elisezerotwo/fix_invalid_attrs_ice, r=Aaron1011
fix: inner attribute followed by outer attribute causing ICE

Fixes #87936, #88938, and #89971.

This removes the assertion that validates that there are no outer attributes following inner attributes. Where the inner attribute is invalid you get an actual error.
2021-10-27 18:25:44 +02:00
bors
337e1565d3 Auto merge of #90186 - jsha:fix-header-sizes, r=GuillaumeGomez
Fix documentation header sizes

And add a rustdoc-gui test confirming various header sizes.

Split off from #90156. This fixes a regression in #89506 where the heading level of titles within Markdown was too high (h2) for docblocks under structs, unions, and enum impls.

r? `@camelid`

Demo: https://jacob.hoffman-andrews.com/rust/fix-header-sizes/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E
Stable: https://doc.rust-lang.org/stable/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E
Beta: https://doc.rust-lang.org/beta/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E
2021-10-27 12:27:47 +00:00
bors
a8f6e614f8 Auto merge of #89652 - rcvalle:rust-cfi, r=nagisa
Add LLVM CFI support to the Rust compiler

This PR adds LLVM Control Flow Integrity (CFI) support to the Rust compiler. It initially provides forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their number of arguments.

Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by defining and using compatible type identifiers (see Type metadata in the design document in the tracking issue #89653).

LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto).

Thank you, `@eddyb` and `@pcc,` for all the help!
2021-10-27 09:19:42 +00:00
EliseZeroTwo
7f0d43a003
test: add test for inner attribute followed by outer attribute causing ICE 2021-10-27 10:13:25 +02:00
bors
47aeac648e Auto merge of #90337 - matthiaskrgr:rollup-azkr158, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #90154 (rustdoc: Remove `GetDefId`)
 - #90232 (rustdoc: Use TTF based font instead of OTF for CJK glyphs to improve readability)
 - #90278 (rustdoc: use better highlighting for *const, *mut, and &mut)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-27 06:16:47 +00:00
Bram van den Heuvel
dae7c36b42 Add regression test for #75961 2021-10-27 07:46:42 +02:00
Matthias Krüger
60cad9789c
Rollup merge of #90232 - konan8205:master, r=GuillaumeGomez
rustdoc: Use TTF based font instead of OTF for CJK glyphs to improve readability

Due to Windows' implementation of font rendering, OpenType fonts can be distorted. So the existing font, Noto Sans KR, is not very readable on Windows. This PR improves readability of Korean glyphs on Windows.

## Before
![원1](https://user-images.githubusercontent.com/11029378/138592394-16b15787-532d-4421-a5eb-ed85675290fa.png)

## After
![원2](https://user-images.githubusercontent.com/11029378/138592409-f3a440ee-f0fc-40e4-9561-42c479439c9f.png)

The fonts included in this PR are licensed under the SIL Open Font License and generated with these commands:

```sh
pyftsubset NanumBarunGothic.ttf \
--unicodes=U+AC00-D7AF,U+1100-11FF,U+3130-318F,U+A960-A97F,U+D7B0-D7FF \
--output-file=NanumBarunGothic.ttf.woff --flavor=woff
```
```sh
pyftsubset NanumBarunGothic.ttf \
--unicodes=U+AC00-D7AF,U+1100-11FF,U+3130-318F,U+A960-A97F,U+D7B0-D7FF \
--output-file=NanumBarunGothic.ttf.woff2 --flavor=woff2
```

r? ``@GuillaumeGomez``
2021-10-27 06:11:36 +02:00
bors
a9b2bfb5ed Auto merge of #89937 - JohnTitor:fix-89875, r=Amanieu
Properly check `target_features` not to trigger an assertion

Fixes #89875
I think it should be a condition instead of an assertion to check if it's a register as it's possible that `reg` is a register class.
Also, this isn't related to the issue directly, but `is_target_supported` doesn't check `target_features` attributes. Is there any way to check it on rustc_codegen_llvm?

r? `@Amanieu`
2021-10-27 03:08:47 +00:00
Jakob Degen
cb336f1f67 Reverting switching test to no_std and adjust output after rebase. 2021-10-26 22:30:15 -04:00
Jakob Degen
e41ef36435 Fix line numbers in test 2021-10-26 22:17:01 -04:00
Jakob Degen
6ce3ae4b73 Make ui/suggestions/suggest-tryinto-edition-change.rs no_std to avoid getting inconsistent output between local and CI. 2021-10-26 22:17:01 -04:00
Jakob Degen
958e645946 Adds hint if a trait fails to resolve and a newly added one in Edition 2021 is suggested 2021-10-26 22:17:01 -04:00
Jakob Degen
e91d5ca197 Add test checking that Edition 2021 is suggested for .try_into() and fix other test 2021-10-26 22:17:01 -04:00
Matthias Krüger
fcc9a9a928
Rollup merge of #90305 - vandenheuvel:test_issue_87258, r=Mark-Simulacrum
Add regression test for #87258

Closes #87258.
2021-10-26 19:32:46 +02:00
Matthias Krüger
40d3819a3c
Rollup merge of #90303 - WaffleLapkin:regression_test_90164, r=JohnTitor
Add regression test for issue 90164

Closes #90164 (previously fixed by #90181)
2021-10-26 19:32:45 +02:00
Bram van den Heuvel
f9344296c1 Add regression test for #87258 2021-10-26 16:35:48 +02:00
Maybe Waffle
60ffac07cb Add regression test for issue 90164 2021-10-26 13:23:27 +03:00
bors
c7a30c8b68 Auto merge of #90075 - pierwill:fix-79717, r=petrochenkov
Edit error messages for `rustc_resolve::AmbiguityKind` variants

Edit the language of the ambiguity descriptions for E0659. These strings now appear as notes.

Closes #79717.
2021-10-26 07:57:51 +00:00
Tomasz Miąsko
93f85f5a9d Consider indirect mutation during const qualification dataflow
Previously a local would be qualified if either one of two separate data
flow computations indicated so. First determined if a local could
contain the qualif, but ignored any forms of indirect mutation. Second
determined if a local could be mutably borrowed (and so indirectly
mutated), but which in turn ignored the qualif.

The end result was incorrect because the effect of indirect mutation was
effectivelly ignored in the all but the final stage of computation.

In the new implementation the indirect mutation is directly incorporated
into the qualif data flow. The local variable becomes immediately
qualified once it is mutably borrowed and borrowed place type can
contain the qualif.

In general we will now reject additional programs, program that were
prevously unintentionally accepted.

There are also some cases which are now accepted but were previously
rejected, because previous implementation didn't consider whether
borrowed place could have the qualif under the consideration.
2021-10-26 08:20:01 +02:00
Matthias Krüger
fc8df9b0b8
Rollup merge of #90241 - DrMeepster:thiscall_lint_upgrade, r=petrochenkov
Make thiscall abi on unsupported platforms a hard error

As suggested in https://github.com/rust-lang/rust/issues/42202#issuecomment-950205016, this PR makes use of the `thiscall` abi on unsupported a hard error instead of a lint.
2021-10-26 06:14:07 +02:00
Matthias Krüger
b0df3af5c3
Rollup merge of #90181 - notriddle:notriddle/error-pointer, r=estebank
fix(rustc_typeck): report function argument errors on matching type

Fixes #90101
2021-10-26 06:14:06 +02:00
David Tolnay
c5025f0e4e
Append .0 to unsuffixed float if it would otherwise become int token 2021-10-25 20:30:47 -07:00
Yuki Okushi
bd309e4628
Add a regression test for issue-89875 2021-10-26 11:02:51 +09:00
Shinwoo Park
9e00501c1c rustdoc: use ttf based font for cjk glyphs 2021-10-26 10:58:13 +09:00
pierwill
7de1ff1ba8 Edit error messages for rustc_resolve::AmbiguityKind variants
Emit description of the ambiguity as a note.

Co-authored-by: Noah Lev <camelidcamel@gmail.com>
Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2021-10-25 20:33:07 -05:00
bors
17e13b549f Auto merge of #85830 - bjorn3:separate_provide_extern, r=cjgillot
Avoid a branch on key being local for queries that use the same local and extern providers

Currently based on https://github.com/rust-lang/rust/pull/85810 as it slightly conflicts with it. Only the last two commits are new.
2021-10-26 00:38:58 +00:00
Jacob Hoffman-Andrews
89276ff7ed Fix documentation header sizes
And add a rustdoc-gui test confirming various header sizes.
2021-10-25 16:26:17 -07:00
Ramon de C Valle
5d30e93189 Add LLVM CFI support to the Rust compiler
This commit adds LLVM Control Flow Integrity (CFI) support to the Rust
compiler. It initially provides forward-edge control flow protection for
Rust-compiled code only by aggregating function pointers in groups
identified by their number of arguments.

Forward-edge control flow protection for C or C++ and Rust -compiled
code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code
share the same virtual address space) will be provided in later work as
part of this project by defining and using compatible type identifiers
(see Type metadata in the design document in the tracking issue #89653).

LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e.,
-Clto).
2021-10-25 16:23:01 -07:00
DrMeepster
a46daf050b make thiscall on unsupported platforms an error 2021-10-25 14:56:21 -07:00
Matthias Krüger
26e9a719f2
Rollup merge of #90266 - b-naber:uneval_substs, r=lcnr
Prevent duplicate caller bounds candidates by exposing default substs in Unevaluated

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

The changes introduced in https://github.com/rust-lang/rust/pull/87280 allowed for "duplicate" caller bounds candidates to be assembled that only differed in their default substs having been "exposed" or not and resulted in an ambiguity error during trait selection. To fix this we expose the defaults substs during the creation of the ParamEnv.

r? `@lcnr`
2021-10-25 22:59:49 +02:00
Michael Howell
8520105464 fix(rustc_typeck): report function argument errors on matching type
Fixes #90101
2021-10-25 12:23:52 -07:00
Guillaume Gomez
6c0dcb41bd
Rollup merge of #90233 - GuillaumeGomez:tooltip-overflow, r=camelid
Tooltip overflow

Fixes #89185.

r? ``@camelid``
2021-10-25 16:34:53 +02:00
Guillaume Gomez
2d85c7eea0
Rollup merge of #90017 - jackh726:issue-tests, r=nikomatsakis
Add a couple tests for normalize under binder issues

Closes #56556
Closes #76956

r? ``@nikomatsakis``
2021-10-25 16:34:52 +02:00
b-naber
0199a81304 add tests 2021-10-25 16:05:03 +02:00
bjorn3
13abc1ae30 Fix test 2021-10-25 15:15:05 +02:00
Guillaume Gomez
345519baa7 Fix scrollbars appearing on information tooltip on mac when they shouldn't 2021-10-25 11:40:13 +02:00
Matthias Krüger
c734a9e076
Rollup merge of #90127 - JohnTitor:fix-90113, r=estebank
Do not mention a reexported item if it's private

Fixes #90113
The _actual_ regression was introduced in #73652, then #88838 made it worse. This fixes the issue by not counting such an import as a candidate.
2021-10-25 07:54:13 +02:00
Matthias Krüger
b25172b504
Rollup merge of #89889 - estebank:unmet-send-bound-on-foreign-future, r=tmandry
Use the "nice E0277 errors"[1] for `!Send` `impl Future` from foreign crate

Partly address #78543 by making the error quieter.

We don't have access to the `typeck` tables from foreign crates, so we
used to completely skip the new code when checking foreign crates. Now,
we carry on and don't provide as nice output (we don't clarify *what* is
making the `Future: !Send`), but at least we no longer emit a sea of
derived obligations in the output.

[1]: https://blog.rust-lang.org/inside-rust/2019/10/11/AsyncAwait-Not-Send-Error-Improvements.html

r? `@tmandry`
2021-10-25 07:54:12 +02:00
bors
41d8c94d45 Auto merge of #89427 - estebank:collect-overlapping-impls, r=jackh726
Point at overlapping impls when type annotations are needed

Address https://github.com/rust-lang/rust/issues/89254.
2021-10-24 22:26:41 +00:00
Esteban Kuber
6dcff4e9f6 Use the "nice E0277 errors"[1] for !Send impl Future from foreign crate
Partly address #78543 by making the error quieter.

We don't have access to the `typeck` tables from foreign crates, so we
used to completely skip the new code when checking foreign crates. Now,
we carry on and don't provide as nice output (we don't clarify *what* is
making the `Future: !Send`), but at least we no longer emit a sea of
derived obligations in the output.

[1]: https://blog.rust-lang.org/inside-rust/2019/10/11/AsyncAwait-Not-Send-Error-Improvements.html
2021-10-24 20:45:33 +00:00
Esteban Kuber
881a50c0b7 Always sort suggestions before emitting them 2021-10-24 20:28:44 +00:00
Esteban Kuber
ef212e7fb3 Point at overlapping impls when type annotations are needed 2021-10-24 18:33:04 +00:00
bors
00d5e42e77 Auto merge of #90235 - matthiaskrgr:rollup-7pqtevk, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #89558 (Add rustc lint, warning when iterating over hashmaps)
 - #90100 (Skip documentation for tier 2 targets on dist-x86_64-apple-darwin)
 - #90155 (Fix alignment of method headings for scannability)
 - #90162 (Mark `{array, slice}::{from_ref, from_mut}` as const fn)
 - #90221 (Fix ICE when forgetting to `Box` a parameter to a `Self::func` call)
 - #90234 (Temporarily turn overflow checks off for rustc-rayon-core)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-24 14:12:10 +00:00
Matthias Krüger
d576393e34
Rollup merge of #90221 - JakobDegen:issue-90213, r=cjgillot
Fix ICE when forgetting to `Box` a parameter to a `Self::func` call

Closes #90213 .

Assuming we can get the `DefId` of the receiver causes an ICE if the receiver is `Self`. We can just avoid doing this though.
2021-10-24 15:48:45 +02:00
Matthias Krüger
b837605012
Rollup merge of #90155 - jsha:outdent-methods, r=GuillaumeGomez,camelid
Fix alignment of method headings for scannability

We sometimes use indentation to indicate something is a heading: The section that comes after is indented by 24px relative to the heading. However, the relationship between the "Implementations" section heading, the `impl` headings it contains, and the `pub fn` subheadings within each impl, is awkward. It goes **Implementations**, 15px indent, `impl`, 5px indent, `pub fn`, 4px indent, docblock.

I line up `impl` and `pub fn` with the `Implementations` heading, give `impl` a larger font size to indicate it is higher in the hierarchy, and indent the docblock a full 24px relative to their parent, matching the indents we use elsewhere to distinguish section headings. By letting the `pub fn` stick out to the left of the docblock, I think this makes methods significantly more scannable.

Related to #59829

r? `````@camelid`````

[Old](https://doc.rust-lang.org/nightly/std/string/struct.String.html#implementations):

[![image](https://user-images.githubusercontent.com/220205/138380233-9c63a0f2-0f80-40a3-ab3d-a1ee9fb7c5d8.png)](https://doc.rust-lang.org/nightly/std/string/struct.String.html#implementations)

[New](https://jacob.hoffman-andrews.com/rust/outdent-methods/std/string/struct.String.html#implementations):

[![image](https://user-images.githubusercontent.com/220205/138392479-b45fce3f-bf43-42e0-81ee-c4bb9ac35cda.png)](https://jacob.hoffman-andrews.com/rust/outdent-methods/std/string/struct.String.html#implementations)
2021-10-24 15:48:44 +02:00
Matthias Krüger
87822b27ee
Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank
Add rustc lint, warning when iterating over hashmaps

r? rust-lang/wg-incr-comp
2021-10-24 15:48:42 +02:00
Matthew Jasper
fabede1851 Add more tests for cross-crate hygiene 2021-10-24 12:31:42 +01:00
bors
ed08a67566 Auto merge of #85254 - cjgillot:reveal-mir, r=lcnr
Normalize MIR with RevealAll before optimizations.

Fixes #78442
2021-10-24 11:04:54 +00:00
Jakob Degen
4b970231fd Fix ICE when forgetting to Box a parameter to a Self::func call 2021-10-24 00:33:29 -04:00
Jakob Degen
eae42fd9d0 Add regresstion test for #90024.
Uses 2 MCVEs from the issue tracker that test opposite sides of the problem.
2021-10-23 22:36:50 -04:00
bors
45591408b1 Auto merge of #90175 - cuviper:min-llvm-12, r=nagisa
Update the minimum external LLVM to 12

With this change, we'll have stable support for LLVM 12 and 13.
For reference, the previous increase to LLVM 10 was #83387,
and this replaces the pending increase to LLVM 11 in #90062.

r? `@nagisa` `@nikic`
2021-10-23 20:59:29 +00:00
Jacob Hoffman-Andrews
542ab2daa6 Outdent method headings so they stand out
The makes the heading / documentation distinction clearer.
2021-10-23 11:50:11 -07:00
Josh Stone
8b1504cfb7 bless the line changes in ui/asm/aarch64/srcloc.rs 2021-10-23 10:16:09 -07:00
bors
91b931926f Auto merge of #90203 - matthiaskrgr:rollup-v215wew, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #85833 (Scrape code examples from examples/ directory for Rustdoc)
 - #88041 (Make all proc-macro back-compat lints deny-by-default)
 - #89829 (Consider types appearing in const expressions to be invariant)
 - #90168 (Reset qualifs when a storage of a local ends)
 - #90198 (Add caveat about changing parallelism and function call overhead)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-23 15:53:50 +00:00
Mateusz Mikuła
a076f2b9b4 Repace use of static_nobundle with native_link_modifiers
This fixes warning when building Rust and running tests:
```
warning: library kind `static-nobundle` has been superseded by specifying `-bundle` on library kind `static`. Try `static:-bundle`
warning: `rustc_llvm` (lib) generated 2 warnings (1 duplicate)
```
2021-10-23 15:51:22 +02:00
Matthias Krüger
74a0c492c1
Rollup merge of #90168 - tmiasko:const-qualif-storage, r=matthewjasper
Reset qualifs when a storage of a local ends

Reset qualifs when a storage of a local ends to ensure that the local qualifs
are affected by the state from previous loop iterations only if the local is
kept alive.

The change should be forward compatible with a stricter handling of indirect
assignments, since storage dead invalidates all existing pointers to the local.
2021-10-23 14:58:42 +02:00
Matthias Krüger
2b874f0242
Rollup merge of #89829 - voidc:assoc-const-variance, r=lcnr
Consider types appearing in const expressions to be invariant

This is an approach to fix #80977.
Currently, a type parameter which is only used in a constant expression is considered bivariant and will trigger error E0392 *"parameter T is never used"*.
Here is a short example:

```rust
pub trait Foo {
    const N: usize;
}

struct Bar<T: Foo>([u8; T::N])
where [(); T::N]:;
```
([playgound](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2015&gist=b51a272853f75925e72efc1597478aa5))

While it is possible to silence this error by adding a `PhantomData<T>` field, I think the better solution would be to make `T` invariant.
This would be analogous to the invariance constraints added for associated types.
However, I'm quite new to the compiler and unsure whether this is the right approach.

r? ``@varkor`` (since you authored #60058)
2021-10-23 14:58:41 +02:00
Matthias Krüger
17c602d423
Rollup merge of #88041 - Aaron1011:deny-proc-macro-hack, r=wesleywiser
Make all proc-macro back-compat lints deny-by-default

The affected crates have had plenty of time to update.
By keeping these as lints rather than making them hard errors,
we ensure that downstream crates will still be able to compile,
even if they transitive depend on broken versions of the affected
crates.

This should hopefully discourage anyone from writing any
new code which relies on the backwards-compatibility behavior.
2021-10-23 14:58:40 +02:00
Matthias Krüger
dcf9242795
Rollup merge of #85833 - willcrichton:example-analyzer, r=jyn514
Scrape code examples from examples/ directory for Rustdoc

Adds support for the functionality described in https://github.com/rust-lang/rfcs/pull/3123

Matching changes to Cargo are here: https://github.com/rust-lang/cargo/pull/9525

Live demo here: https://willcrichton.net/example-analyzer/warp/trait.Filter.html#method.and
2021-10-23 14:58:39 +02:00
bors
aa5740c715 Auto merge of #90104 - spastorino:coherence-for-negative-trait, r=nikomatsakis
Implement coherence checks for negative trait impls

The main purpose of this PR is to be able to [move Error trait to core](https://github.com/rust-lang/project-error-handling/issues/3).

This feature is necessary to handle the following from impl on box.

```rust
impl From<&str> for Box<dyn Error> { ... }
```

Without having negative traits affect coherence moving the error trait into `core` and moving that `From` impl to `alloc` will cause the from impl to no longer compiler because of a potential future incompatibility. The compiler indicates that `&str` _could_ introduce an `Error` impl in the future, and thus prevents the `From` impl in `alloc` that would cause overlap with `From<E: Error> for Box<dyn Error>`. Adding `impl !Error for &str {}` with the negative trait coherence feature will disable this error by encoding a stability guarantee that `&str` will never implement `Error`, making the `From` impl compile.

We would have this in `alloc`:

```rust
impl From<&str> for Box<dyn Error> {} // A
impl<E> From<E> for Box<dyn Error> where E: Error {} // B
```

and this in `core`:

```rust
trait Error {}
impl !Error for &str {}
```

r? `@nikomatsakis`

This PR was built on top of `@yaahc` PR #85764.

Language team proposal: to https://github.com/rust-lang/lang-team/issues/96
2021-10-23 12:51:15 +00:00
Tomasz Miąsko
e4aeeca667 Reset qualifs when a storage of a local ends
to ensure that the local qualifs are affected by the state from previous
loop iterations only if the local is kept alive.

The change should be forward compatible with a stricter handling of
indirect assignments, since storage dead invalidates all existing
pointers to the local.
2021-10-23 09:26:22 +02:00
Matthias Krüger
270c800d35
Rollup merge of #90117 - calebsander:fix/rsplit-clone, r=yaahc
Make RSplit<T, P>: Clone not require T: Clone

This addresses a TODO comment. The behavior of `#[derive(Clone)]` *does* result in a `T: Clone` requirement. Playground example:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a8b1a9581ff8893baf401d624a53d35b

Add a manual `Clone` implementation, mirroring `Split` and `SplitInclusive`.
`(R)?SplitN(Mut)?` don't have any `Clone` implementations, but I'll leave that for its own pull request.
2021-10-23 05:28:26 +02:00
Matthias Krüger
8fb194c86f
Rollup merge of #89920 - hudson-ayers:location-detail-control, r=davidtwco
Implement -Z location-detail flag

This PR implements the `-Z location-detail` flag as described in https://github.com/rust-lang/rfcs/pull/2091 .

`-Z location-detail=val` controls what location details are tracked when using `caller_location`. This allows users to control what location details are printed as part of panic messages, by allowing them to exclude any combination of filenames, line numbers, and column numbers. This option is intended to provide users with a way to mitigate the size impact of `#[track_caller]`.

Some measurements of the savings of this approach on an embedded binary can be found here: https://github.com/rust-lang/rust/issues/70579#issuecomment-942556822 .

Closes #70580 (unless people want to leave that open as a place for discussion of further improvements).

This is my first real PR to rust, so any help correcting mistakes / understanding side effects / improving my tests is appreciated :)

I have one question: RFC 2091 specified this as a debugging option (I think that is what -Z implies?). Does that mean this can never be stabilized without a separate MCP? If so, do I need to submit an MCP now, or is the initial RFC specifying this option sufficient for this to be merged as is, and then an MCP would be needed for eventual stabilization?
2021-10-23 05:28:23 +02:00
Matthias Krüger
736e8ebd1c
Rollup merge of #89730 - crlf0710:type_changing_feature, r=jackh726
add feature flag for `type_changing_struct_update`

This implements the PR0 part of the mentoring notes within #86618.

overrides the previous inactive #86646 pr.

r? ```@nikomatsakis```
2021-10-23 05:28:22 +02:00
Matthias Krüger
0f81c7faf5
Rollup merge of #89468 - FabianWolff:issue-89358, r=jackh726
Report fatal lexer errors in `--cfg` command line arguments

Fixes #89358. The erroneous behavior was apparently introduced by `@Mark-Simulacrum` in a678e31911; the idea is to silence individual parser errors and instead emit one catch-all error message after parsing. However, for the example in #89358, a fatal lexer error is created here:
edebf77e00/compiler/rustc_parse/src/lexer/mod.rs (L340-L349)

This fatal error aborts the compilation, and so the call to `new_parser_from_source_str()` never returns and the catch-all error message is never emitted. I have therefore changed the `SilentEmitter` to silence only non-fatal errors; with my changes, for the rustc invocation described in #89358:
```sh
rustc --cfg "abc\""
```
I get the following output:
```
error[E0765]: unterminated double quote string
  |
  = note: this error occurred on the command line: `--cfg=abc"`
```
2021-10-23 05:28:22 +02:00
Michael Howell
98ed5548d7 nice_region_error: Include lifetime placeholders in error output
As you can see in src/test/ui/traits/self-without-lifetime-constraint.stderr
you can get very confusing type names if you don't have this.

Fixes #87763
2021-10-22 15:26:20 -07:00
Santiago Pastorino
9534186857
Hide negative coherence checks under negative_impls feature flag 2021-10-22 17:54:20 -03:00
Will Crichton
d1c29c696e Revert def_id addition from clean::Function, add test for
scrape-examples options
2021-10-22 12:46:45 -07:00
Santiago Pastorino
9e264137e9
Be sure that we do not allow too much 2021-10-22 16:42:06 -03:00
Santiago Pastorino
da79fa964c
Add rustc_strict_coherence attribute and use it to check overlap 2021-10-22 15:49:46 -03:00
Josh Stone
e9f545b9a9 Update the minimum external LLVM to 12 2021-10-22 10:50:07 -07:00
Josh Stone
8b0e7095a0 llvm-dwp-11 fails on absolute paths 2021-10-22 09:22:18 -07:00
Josh Stone
65150af1b4 Update the minimum external LLVM to 11 2021-10-22 09:22:18 -07:00
Charles Lew
7d7ebf8805 add feature flag for type_changing_struct_update 2021-10-22 11:46:55 -04:00
Yuki Okushi
a741f682fe
Rollup merge of #90115 - samlich:test-issue-78561, r=oli-obk
Add test for issue #78561

Adds test for and closes #78561 which previously crashed compiler.
2021-10-22 19:42:52 +09:00
Yuki Okushi
49f2384513
Rollup merge of #90114 - BoxyUwU:cg_defaults_tests, r=lcnr
Add some tests for const_generics_defaults

I think this covers some of the stuff required for stabilisation report, some of these tests are probably covering stuff we already have but it can't hurt to have more :)

r? ````@lcnr````
2021-10-22 19:42:51 +09:00
Yuki Okushi
de306d77db
Rollup merge of #90078 - JohnTitor:test-83479, r=Mark-Simulacrum
Add a regression test for issue-83479

Add a regression test for https://github.com/rust-lang/rust/issues/83479#issue-841147340, but not close the issue, see https://github.com/rust-lang/rust/issues/83479#issuecomment-947255641.
2021-10-22 19:42:50 +09:00
Yuki Okushi
a656bc5b08
Rollup merge of #90069 - tmiasko:promoted-const-qualif, r=oli-obk
Fix const qualification when executed after promotion

The const qualification was so far performed before the promotion and
the implementation assumed that it will never encounter a promoted.

With `const_precise_live_drops` feature, checking for live drops is
delayed until after drop elaboration, which in turn runs after
promotion. so the assumption is no longer true. When evaluating
`NeedsNonConstDrop` it is now possible to encounter promoteds.

Use type base qualification for the promoted. It is a sound
approximation in general, and in the specific case of promoteds and
`NeedsNonConstDrop` it is precise.

Fixes #89938.
2021-10-22 19:42:49 +09:00
Yuki Okushi
9ed9025ea9
Rollup merge of #90028 - tmiasko:structural-match-closure, r=spastorino
Reject closures in patterns

Fixes #90013.
2021-10-22 19:42:48 +09:00
Yuki Okushi
327d8073e2
Rollup merge of #89922 - JohnTitor:update-e0637, r=jackh726
Update E0637 description to mention `&` w/o an explicit lifetime name

Deal with https://github.com/rust-lang/rust/issues/89824#issuecomment-941598647. Another solution would be splitting the error code into two as (I think) it's a bit unclear to users why they have the same error code.
2021-10-22 19:42:46 +09:00
Yuki Okushi
91fb223f59
Rollup merge of #89895 - camsteffen:for-loop-head-span, r=davidtwco
Don't mark for loop iter expression as desugared

We typically don't mark spans of lowered things as desugared. This helps Clippy rightly discern when code is (not) from expansion. This was discovered by ``@flip1995`` at https://github.com/rust-lang/rust-clippy/pull/7789#issuecomment-939289501.
2021-10-22 19:42:45 +09:00
Yuki Okushi
8738d5d611
Rollup merge of #89257 - aDotInTheVoid:macro-error-2, r=estebank
Give better error for `macro_rules name`

follow up to #89221

r? ``@estebank``

``@rustbot`` modify labels: +A-diagnostics +A-parser
2021-10-22 19:42:43 +09:00
Caleb Sander
afcee19d88 Make RSplit<T, P>: Clone not require T: Clone
This addresses a TODO comment. The behavior of #[derive(Clone)]
*does* result in a T: Clone requirement.

Add a manual Clone implementation, matching Split and SplitInclusive.
2021-10-21 21:25:59 -07:00
Matthew Jasper
4ecb49eba3 Handle cross-crate module ExpnIds consistently
- Always use the ExpnId serialized to `tables`
- Use the Id for traits and enums from other crates in resolution.
2021-10-21 22:07:03 +01:00
Hudson Ayers
b802629311 add tests for -Zlocation-detail 2021-10-21 10:44:22 -07:00
Yuki Okushi
3b2dd702fc
Do not mention a reexported item if it's private 2021-10-21 20:25:45 +09:00
samlich
ab44e46345
Add test for issue #78561 2021-10-21 10:11:33 +00:00
Yuki Okushi
68a5680fc5
Rollup merge of #90098 - GuillaumeGomez:add-test-foreign-impl-missing-doc-code-examples, r=jyn514
Add test to ensure that the missing_doc_code_examples is not triggered on foreign trait implementations

Fixes #76450.

r? ````@jyn514````
2021-10-21 14:11:12 +09:00
Yuki Okushi
759a8aee31
Rollup merge of #90097 - GuillaumeGomez:duplicated-sidebar-entry-reexported-macro, r=notriddle
Add test for duplicated sidebar entries for reexported macro

Fixes #90015.

r? ````@notriddle````
2021-10-21 14:11:11 +09:00
Yuki Okushi
47a1f67a8d
Rollup merge of #90048 - GuillaumeGomez:line-number-setting, r=jsha
Add test for line-number setting

The first commit updates the version of the package to be able to have multi-line commands (which looks much nicer for this test).

r? ````@jsha````
2021-10-21 14:11:08 +09:00
Yuki Okushi
a980587421
Rollup merge of #90029 - tgnottingham:incr-debug-logging-test, r=Mark-Simulacrum
Add test for debug logging during incremental compilation

Debug logging during incremental compilation had been broken for some
time, until #89343 fixed it (among other things). Add a test so this is
less likely to break without being noticed. This test is nearly a copy
of the `src/test/ui/rustc-rust-log.rs` test, but tests debug logging in
the incremental compliation code paths.
2021-10-21 14:11:06 +09:00
Ellen
e7a9e820d2 *dust dust* 2021-10-21 00:16:49 +01:00
Ellen
c75d8cb212 Ordering 2021-10-20 23:44:50 +01:00
Ellen
7a8bd2d133 add fixme 2021-10-20 23:37:36 +01:00
Ellen
8f237791d5 Inference 2021-10-20 23:36:50 +01:00
Ellen
83a1834c14 Wfness 2021-10-20 23:31:08 +01:00
Ellen
a81e489101 Return pos impl trait 2021-10-20 23:18:26 +01:00
Ellen
6469fba44e Trait objects 2021-10-20 22:56:53 +01:00
Santiago Pastorino
da8873e343
Only assemble_candidates_from_impls for polarity Negative 2021-10-20 12:10:46 -03:00
Santiago Pastorino
511076a102
Test that if we promise to not impl what would overlap it doesn't actually overlap 2021-10-20 12:10:45 -03:00
Guillaume Gomez
69ca324a53 Add test to ensure that the missing_doc_code_examples is not triggered on foreign trait implementations 2021-10-20 16:52:56 +02:00
bors
3d71e749a2 Auto merge of #90050 - michaelwoerister:fix-vtable-debug-name-crash-90019, r=wesleywiser
Erase late-bound regions before computing vtable debuginfo name.

Fixes #90019.

The `msvc_enum_fallback()` for computing enum type names needs to access the memory layout of niche enums in order to determine the type name. `compute_debuginfo_vtable_name()` did not properly erase regions before computing type names which made memory layout computation ICE when encountering un-erased regions.

r? `@wesleywiser`
2021-10-20 14:37:48 +00:00
Guillaume Gomez
50dc319ef0 Add test for duplicated sidebar entries for reexported macro 2021-10-20 15:44:16 +02:00
Guillaume Gomez
457f5782f3 Add test for line-number setting 2021-10-20 13:36:08 +02:00
Yuki Okushi
21d02bf132
Add a regression test for issue-83479 2021-10-20 11:09:06 +09:00
Yuki Okushi
d8b3764bd2
Rollup merge of #90025 - JohnTitor:revert-86011, r=estebank
Revert #86011 to fix an incorrect bound check

This reverts commit 36a1076d24, reversing
changes made to e1e9319d93.

Fixes #89935
r? ``@estebank``
2021-10-20 04:35:17 +09:00
Yuki Okushi
7ceab9ef14
Rollup merge of #90018 - GuillaumeGomez:too-long-item-names, r=jsha
Fix rustdoc UI for very long type names

Fixes #89972.

While working on it, I also discovered that when the item name is too long, it also breaks the flow of the page.

To make things right, I also renamed the `type-decl` CSS class into `item-decl` (because this PR also generates it for more than type declarations).

So here are the before/after screenshots:

![Screenshot from 2021-10-18 16-58-03](https://user-images.githubusercontent.com/3050060/137757247-637fcf04-4406-49c6-8a8a-18c2074aacd9.png)
![Screenshot from 2021-10-18 16-58-26](https://user-images.githubusercontent.com/3050060/137757252-17935e63-53b3-449f-a535-7be91ff0e257.png)

![Screenshot from 2021-10-18 16-58-07](https://user-images.githubusercontent.com/3050060/137757278-8b12e348-2980-4fc4-8853-bef99d58981f.png)
![Screenshot from 2021-10-18 16-58-28](https://user-images.githubusercontent.com/3050060/137757282-534a0e1b-3016-49ba-b3ac-e45bdb9035cb.png)

r? ``@jsha``
2021-10-20 04:35:15 +09:00
Tomasz Miąsko
c97cf7fed7 Reject closures in patterns 2021-10-19 20:45:43 +02:00
Wesley Wiser
5929cf0d67
Update src/test/codegen/debug-vtable.rs
Co-authored-by: r00ster <r00ster91@protonmail.com>
2021-10-19 11:36:21 -04:00
Michael Woerister
bf39d86e0f Erase late-bound regions before computing vtable debuginfo name. 2021-10-19 13:57:35 +02:00
bors
d45ed7502a Auto merge of #90040 - nbdd0121:issue-90038, r=oli-obk
Fix wrong niche calculation when 2+ niches are placed at the start

When the niche is at the start, existing code incorrectly uses 1 instead of count for subtraction.

Fix #90038

`@rustbot` label: T-compiler
2021-10-19 08:13:35 +00:00
Gary Guo
7dbd5bb0bd Fix issue 90038 2021-10-19 06:43:33 +01:00
Matthias Krüger
c3cfa58157
Rollup merge of #89997 - cameron1024:const-str-as-bytes-ice, r=JohnTitor
Add test for issue #84957 - `str.as_bytes()` in a `const` expression

Hi, this PR adds a test for issue #84957 . I'm quite new to rustc so let me know if there's anything else that needs doing 😄

Closes #84957
2021-10-19 05:40:54 +02:00
Matthias Krüger
a0724d72b0
Rollup merge of #89988 - tmiasko:unpromote-const-drop, r=oli-obk
Do not promote values with const drop that need to be dropped

Changes from #88558 allowed using `~const Drop` in constants by
introducing a new `NeedsNonConstDrop` qualif.

The new qualif was also used for promotion purposes, and allowed
promotion to happen for values that needs to be dropped but which
do have a const drop impl.

Since for promoted the drop implementation is never executed,
this lead to observable change in behaviour. For example:

```rust

struct Panic();

impl const Drop for Panic {
    fn drop(&mut self) {
        panic!();
    }
}

fn main() {
    let _ = &Panic();
}
```

Restore the use of `NeedsDrop` qualif during promotion to avoid the issue.
2021-10-19 05:40:54 +02:00
Matthias Krüger
8c8835d277
Rollup merge of #89956 - JohnTitor:suggest-case-insensitive-match-names, r=estebank
Suggest a case insensitive match name regardless of levenshtein distance

Fixes #86170

Currently, `find_best_match_for_name` only returns a case insensitive match name depending on a Levenshtein distance. It's a bit unfortunate that that hides some suggestions for typos like `Bar` -> `BAR`. That idea is from https://github.com/rust-lang/rust/pull/46347#discussion_r153701834, but I think it still makes some sense to show a candidate when we find a case insensitive match name as it's more like a typo.
Skipped the `candidate != lookup` check because the current (i.e, `levenshtein_match`) returns the exact same `Symbol` anyway but it doesn't seem to confuse anything on UI tests.

r? ``@estebank``
2021-10-19 05:40:53 +02:00
Matthias Krüger
0d990a3dbd
Rollup merge of #89867 - Urgau:fix-double-definition, r=GuillaumeGomez
Fix macro_rules! duplication when reexported in the same module

This can append if within the same module a `#[macro_export] macro_rules!`
is declared but also a reexport of itself producing two export of the same
macro in the same module. In that case we only want to document it once.

Before:
```
Module {
    is_crate: true,
    items: [
        Id("0:4"),   // pub use crate::repro as repro2;
        Id("0:3"),   // macro_rules! repro
        Id("0:3"),   // duplicate, same as above
    ],
}
```

After:
```
Module {
    is_crate: true,
    items: [
        Id("0:4"),   // pub use crate::repro as repro2;
        Id("0:3"),   // macro_rules! repro
    ],
}
```

Fixes https://github.com/rust-lang/rust/issues/89852
2021-10-19 05:40:51 +02:00
Tomasz Miąsko
7581bae996 Fix const qualification when executed after promotion
The const qualification was so far performed before the promotion and
the implementation assumed that it will never encounter a promoted.

With `const_precise_live_drops` feature, checking for live drops is
delayed until after drop elaboration, which in turn runs after
promotion. so the assumption is no longer true. When evaluating
`NeedsNonConstDrop` it is now possible to encounter promoteds.

Use type base qualification for the promoted. It is a sound
approximation in general, and in the specific case of promoteds and
`NeedsNonConstDrop` it is precise.
2021-10-19 00:00:00 +00:00
Tyson Nottingham
aefbd40140 Add test for debug logging during incremental compilation
Debug logging during incremental compilation had been broken for some
time, until #89343 fixed it (among other things). Add a test so this is
less likely to break without being noticed. This test is nearly a copy
of the `src/test/ui/rustc-rust-log.rs` test, but tests debug logging in
the incremental compliation code paths.
2021-10-18 16:28:10 -07:00
Tyson Nottingham
93f80bff94 Remove comment saying that we don't build debug rustc in CI, since we do 2021-10-18 16:28:09 -07:00
bors
ec724ac075 Auto merge of #89229 - oli-obk:i_love_inferctxt, r=jackh726
Remove redundant member-constraint check

impl trait will, for each lifetime in the hidden type, register a "member constraint" that says the lifetime must be equal or outlive one of the lifetimes of the impl trait. These member constraints will be solved by borrowck

But, as you can see in the big red block of removed code, there was an ad-hoc check for member constraints happening at the site where they get registered. This check had some minor effects on diagnostics, but will fall down on its feet with my big type alias impl trait refactor. So we removed it and I pulled the removal out into a (hopefully) reviewable PR that works on master directly.
2021-10-18 23:02:53 +00:00
Tomasz Miąsko
915a581bcb Do not promote values with const drop that need to be dropped
Changes from #88558 allowed using `~const Drop` in constants by
introducing a new `NeedsNonConstDrop` qualif.

The new qualif was also used for promotion purposes, and allowed
promotion to happen for values that needs to be dropped but which
do have a const drop impl.

Since for promoted the drop implementation is never executed,
this lead to observable change in behaviour. For example:

```rust

struct Panic();

impl const Drop for Panic {
    fn drop(&mut self) {
        panic!();
    }
}

fn main() {
    let _ = &Panic();
}
```

Restore the use of `NeedsDrop` qualif during promotion to avoid the issue.
2021-10-18 21:56:57 +02:00
bors
bd41e09da3 Auto merge of #89124 - cjgillot:owner-info, r=michaelwoerister
Index and hash HIR as part of lowering

Part of https://github.com/rust-lang/rust/pull/88186
~Based on https://github.com/rust-lang/rust/pull/88880 (see merge commit).~

Once HIR is lowered, it is later indexed by the `index_hir` query and hashed for `crate_hash`. This PR moves those post-processing steps to lowering itself. As a side objective, the HIR crate data structure is refactored as an `IndexVec<LocalDefId, Option<OwnerInfo<'hir>>>` where `OwnerInfo` stores all the relevant information for an HIR owner.

r? `@michaelwoerister`
cc `@petrochenkov`
2021-10-18 19:53:05 +00:00
Aaron Hill
02e4d0b3b5
Make all proc-macro back-compat lints deny-by-default
The affected crates have had plenty of time to update.
By keeping these as lints rather than making them hard errors,
we ensure that downstream crates will still be able to compile,
even if they transitive depend on broken versions of the affected
crates.

This should hopefully discourage anyone from writing any
new code which relies on the backwards-compatibility behavior.
2021-10-18 13:17:05 -05:00
Yuki Okushi
101a81b807
Add a regression test for #89935 2021-10-19 02:43:54 +09:00
Yuki Okushi
e2453dc2ff
Revert "Rollup merge of #86011 - tlyu:correct-sized-bound-spans, r=estebank"
This reverts commit 36a1076d24, reversing
changes made to e1e9319d93.
2021-10-19 02:33:38 +09:00
jackh726
cacc3ee801 Normalize obligations for closure confirmation 2021-10-18 12:35:42 -04:00
Oli Scherer
b02f2982e7 Remove regionck member constraint handling and leave it to mir borrowck 2021-10-18 15:50:56 +00:00
Guillaume Gomez
77c29294be Add test to ensure that the docblock elements left margin is as expected 2021-10-18 16:50:31 +02:00
jackh726
347d503333 Add a couple tests for normalize under binder issues 2021-10-18 10:46:59 -04:00
Guillaume Gomez
20c286e268 Add GUI overflow tests for constant and typedef 2021-10-18 16:15:09 +02:00
jackh726
f9e14af7f0 Don't just check params 2021-10-18 10:11:57 -04:00
Guillaume Gomez
8b7a2dd462 * Remove left margin on items declaration at the top of their documentation page
* Rename "type-decl" into "item-decl" to reflect the change of usage
2021-10-18 15:06:38 +02:00
cameron
f8b2f91c48 add test for issue 84957 2021-10-18 08:41:18 +01:00
Matthias Krüger
cd72393566
Rollup merge of #89987 - pierwill:fix-85526-docs-hidden-assoc, r=GuillaumeGomez
Check implementing type for `#[doc(hidden)]`

Closes #85526.
2021-10-18 08:13:28 +02:00
Matthias Krüger
5898c5d88e
Rollup merge of #89974 - est31:let_else_if_error, r=nagisa
Nicer error message if the user attempts to do let...else if

Gives a nice "conditional `else if` is not supported for `let...else`" error when encountering a `let...else if` pattern, as suggested in the [let...else tracking issue](https://github.com/rust-lang/rust/issues/87335#issuecomment-944846205).
2021-10-18 08:13:27 +02:00
Matthias Krüger
b356a04c9a
Rollup merge of #89965 - JohnTitor:fix-let-else-ice-with-ref-mut, r=petrochenkov
Fix ICE with `let...else` and `ref mut`

Fixes #89960, opened for review.
I'm not satisfied with the current diagnostics, any ideas?
2021-10-18 08:13:26 +02:00
pierwill
d39a1bec81 Check implementing type for #[doc(hidden)]
Closes #85526.
2021-10-17 16:37:44 -05:00
est31
856541963c Nicer error message if the user attempts to do let...else if 2021-10-17 22:56:29 +02:00
Matthias Krüger
1ee7c2940e
Rollup merge of #89975 - JohnTitor:gats-tests-85921, r=jackh726
Add a regression test for #85921

Closes #85921
r? `@jackh726`
2021-10-17 18:18:59 +02:00
Matthias Krüger
e0e2b3cc43
Rollup merge of #89963 - r00ster91:parenthesisparentheses, r=nagisa
Some "parenthesis" and "parentheses" fixes

"Parenthesis" is the singular (e.g. one `(` or one `)`) and "parentheses" is the plural (multiple `(` or `)`s) and this is not hard to mix up so here are some fixes for that.

Inspired by #89958
2021-10-17 18:18:59 +02:00
Matthias Krüger
0f1ba8d8c7
Rollup merge of #89946 - JohnTitor:fix-89686, r=petrochenkov
Fix an ICE with TAITs and Future

Fixes #89686
2021-10-17 18:18:58 +02:00
Matthias Krüger
59dc2187ad
Rollup merge of #89738 - eddyb:extern-crate-recursion, r=nagisa
ty::pretty: prevent infinite recursion for `extern crate` paths.

Fixes #55779, fixes #87932.

This fix is based on `@estebank's` idea in https://github.com/rust-lang/rust/issues/55779#issuecomment-614758510 - but instead of trying to get `try_print_visible_def_path_recur`'s cycle detection to work in this case, this PR "just" disables the "visible path" feature when printing the path to an `extern crate`, so that the old recursion chain of `try_print_visible_def_path -> print_def_path -> try_print_visible_def_path`, is now impossible.

Both tests have been confirmed to crash `rustc` because of a stack overflow, without the fix.
2021-10-17 18:18:55 +02:00
Camille GILLOT
70aeced757 Ignore wasm32 in test. 2021-10-17 16:35:04 +02:00
Camille GILLOT
2fa9b11804 Normalize MIR with RevealAll before optimizations. 2021-10-17 14:57:57 +02:00
bors
6f53ddfa74 Auto merge of #89514 - davidtwco:polymorphize-shims-and-predicates, r=lcnr
polymorphization: shims and predicates

Supersedes #75737 and #75414. This pull request includes up some changes to polymorphization which hadn't landed previously and gets stage2 bootstrapping and the test suite passing when polymorphization is enabled. There are still issues with `type_id` and polymorphization to investigate but this should get polymorphization in a reasonable state to work on.

- #75737 and #75414 both worked but were blocked on having the rest of the test suite pass (with polymorphization enabled) with and without the PRs. It makes more sense to just land these so that the changes are in.
- #75737's changes remove the restriction of `InstanceDef::Item` on polymorphization, so that shims can now be polymorphized. This won't have much of an effect until polymorphization's analysis is more advanced, but it doesn't hurt.
- #75414's changes remove all logic which marks parameters as used based on their presence in predicates - given #75675, this will enable more polymorphization and avoid the symbol clashes that predicate logic previously sidestepped.
- Polymorphization now explicitly checks (and skips) foreign items, this is necessary for stage2 bootstrapping to work when polymorphization is enabled.
- The conditional determining the emission of a note adding context to a post-monomorphization error has been modified. Polymorphization results in `optimized_mir` running for shims during collection where that wouldn't happen previously, some errors are emitted during `optimized_mir` and these were considered post-monomorphization errors with the existing logic (more errors and shims have a `DefId` coming from the std crate, not the local crate), adding a note that resulted in tests failing. It isn't particularly feasible to change where polymorphization runs or prevent it from using `optimized_mir`, so it seemed more reasonable to not change the conditional.
- `characteristic_def_id_of_type` was being invoked during partitioning for self types of impl blocks which had projections that depended on the value of unused generic parameters of a function - this caused a ICE in a debuginfo test. If partitioning is enabled and the instance needs substitution then this is skipped. That test still fails for me locally, but not with an ICE, but it fails in a fresh checkout too, so 🤷‍♂️.

r? `@lcnr`
2021-10-17 12:33:12 +00:00
r00ster91
3c1d55422a Some "parenthesis" and "parentheses" fixes 2021-10-17 12:04:01 +02:00
Yuki Okushi
6bcf0e471b
Add a regression test for #85921 2021-10-17 16:09:49 +09:00
jackh726
c2da21063f Edit GATs tests to apply lint 2021-10-16 19:04:39 -04:00
jackh726
e391796d47 Better error 2021-10-16 19:04:39 -04:00
jackh726
82148cdc66 Change outlives clause checking algorithm 2021-10-16 19:04:39 -04:00
jackh726
a8c44d344b Some cleanup 2021-10-16 19:04:39 -04:00
jackh726
0bc340f756 Error initial pass 2021-10-16 19:04:39 -04:00
Yuki Okushi
c393f33d35
Rollup merge of #89907 - GuillaumeGomez:correctly-emit-errors, r=camelid
Remove FIXME since there is nothing to be fixed

Resolves #88593.

The errors are deduplicated when displayed to users. They only appear
multiple times in UI tests.

cc ``@jyn514``
r? ``@camelid``
2021-10-17 07:52:19 +09:00
Yuki Okushi
bf7c32a447
Fix ICE with let...else and ref mut 2021-10-17 07:12:22 +09:00
Guillaume Gomez
7bad85e815 Remove FIXME since there is nothing to be fixed.
The errors are deduplicated when displayed to users. They only appear
multiple times in UI tests.
2021-10-16 22:15:06 +02:00
Yuki Okushi
d4cc8774d5
Suggest a case insensitive match name regardless of levenshtein distance 2021-10-17 04:51:22 +09:00
bors
4e89811b46 Auto merge of #89860 - camsteffen:macro-semi, r=petrochenkov
Remove trailing semicolon from macro call span

Macro call site spans are now less surprising/more consistent since they no longer contain a semicolon after the macro call.

The downside is that we need to do a little guesswork to get the semicolon in diagnostics. But this should not be noticeable since it is rare for the semicolon to not immediately follow the macro call.
2021-10-16 18:20:20 +00:00
Yuki Okushi
f001e8c519
Fix an ICE with TAITs and Future 2021-10-16 18:30:37 +09:00
Matthias Krüger
4fa5d6e5f8
Rollup merge of #89918 - JohnTitor:gats-tests, r=jackh726
Add some GATs related regression tests

Closes #88287, closes #88405
2021-10-16 08:02:26 +02:00
Matthias Krüger
e8efe0931a
Rollup merge of #89914 - jackh726:gat_genericboundfailure, r=estebank
Emit impl difference error for GenericBoundFailure too

Fixes #86787

r? ````@estebank````
2021-10-16 08:02:24 +02:00
Matthias Krüger
27a7ced29f
Rollup merge of #89912 - davidtwco:issue-89280-split-lines-multiple-lines, r=oli-obk
emitter: current substitution can be multi-line

Fixes #89280.

In `splice_lines`, there is some arithmetic to compute the required alignment such that future substitutions in a suggestion are aligned correctly. However, this assumed that the current substitution's span was only on a single line. In circumstances where this was not true, it could result in a arithmetic overflow when the substitution's end column was less than the substitution's start column.

r? ````@oli-obk````
2021-10-16 08:02:24 +02:00
Matthias Krüger
e56b5ee716
Rollup merge of #89902 - rusticstuff:outline-atomics-linux-only, r=workingjubilee
Restrict the aarch64 outline atomics test to Linux

The test was introduced in #83655, which enables the `outline-atomics` feature for aarch64-unknown-linux-* but not for any other aarch64 targets. The test did not check for Linux causing test failures on aarch64-apple-darwin.

r? `@workingjubilee`
2021-10-16 08:02:22 +02:00
Matthias Krüger
9ae0804859
Rollup merge of #89509 - jhpratt:stabilize-const_unreachable_unchecked, r=oli-obk
Stabilize `unreachable_unchecked` as `const fn`

Closes #53188

This PR stabilizes `core::hint::unreachable_unchecked` as `const fn`. MIRI is able to detect when this method is called. Stabilization was delayed until `const_panic` was stabilized so as to avoid users calling this method in its place (thus resulting in runtime UB). With #89508, that is no longer an issue.

````@rustbot```` label +A-const-eval +A-const-fn +T-lang +S-blocked

(not sure why it's T-lang, but that's what the tracking issue is)
2021-10-16 08:02:20 +02:00
bors
c1026539bd Auto merge of #84096 - m-ou-se:windows-bcrypt-random, r=dtolnay
Use BCryptGenRandom instead of RtlGenRandom on Windows.

This removes usage of RtlGenRandom on Windows, in favour of BCryptGenRandom.

BCryptGenRandom isn't available on XP, but we dropped XP support a while ago.
2021-10-15 19:03:57 +00:00
Niko Matsakis
094a9c743e simplify constrain_opaque_types 2021-10-15 17:50:33 +00:00
Yuki Okushi
4333091625
Update E0637 description to mention & w/o an explicit lifetime name 2021-10-16 02:49:58 +09:00
Yuki Okushi
a51798a27b
Add some GATs related regression tests 2021-10-16 01:38:49 +09:00
jackh726
c4f9eb1e5a Emit impl difference error for GenericBoundFailure too 2021-10-15 11:41:39 -04:00
David Wood
d2dc0f3b0f emitter: current substitution can be multi-line
In `splice_lines`, there is some arithmetic to compute the required
alignment such that future substitutions in a suggestion are aligned
correctly. However, this assumed that the current substitution's span
was only on a single line. In circumstances where this was not true, it
could result in a arithmetic overflow when the substitution's end
column was less than the substitution's start column.

Signed-off-by: David Wood <david.wood@huawei.com>
2021-10-15 15:30:43 +00:00
Loïc BRANSTETT
db5b64a484 Rework the equivalent test to work with sidebar-items.js 2021-10-15 16:54:31 +02:00
Cameron Steffen
a697aa63d6 Use more lowered spans in for loop 2021-10-15 08:04:51 -05:00
Cameron Steffen
bd1a1e4f0d Don't mark for loop head span with desugaring 2021-10-15 08:04:50 -05:00
Mara Bos
acee39e5c5 Add missing bcrypt.lib to make-fulldeps Makefile. 2021-10-15 13:25:39 +02:00
Loïc BRANSTETT
e259cc46a6 Add equivalent test in src/test/rustdoc 2021-10-15 12:56:47 +02:00
lcnr
80fe0bb76e add a rustc::query_stability lint 2021-10-15 10:58:18 +02:00
Cameron Steffen
90f4521cfd Bless tests 2021-10-15 02:36:58 -05:00
bors
72d66064e7 Auto merge of #89903 - matthiaskrgr:rollup-s0c69xl, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #86011 (move implicit `Sized` predicate to end of list)
 - #89821 (Add a strange test for `unsafe_code` lint.)
 - #89859 (add dedicated error variant for writing the discriminant of an uninhabited enum variant)
 - #89870 (Suggest Box::pin when Pin::new is used instead)
 - #89880 (Use non-checking TLS relocation in aarch64 asm! sym test.)
 - #89885 (add long explanation for E0183)
 - #89894 (Remove unused dependencies from rustc_const_eval)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-15 05:59:49 +00:00
Matthias Krüger
e3099e7d8c
Rollup merge of #89885 - cameron1024:long-explanation-E0183, r=GuillaumeGomez
add long explanation for E0183

Addresses #61137
2021-10-15 07:44:49 +02:00
Matthias Krüger
f0555cefae
Rollup merge of #89880 - adamgemmell:dev/nc-relocation, r=Amanieu
Use non-checking TLS relocation in aarch64 asm! sym test.

The checking variant ensures that the offset required is not larger than 12 bits - hence we wouldn't ever need the upper 12 bits.

It's unlikely to ever fail in this small test but this is technically correct.

This was noticed incidentally when we found that LLD doesn't support the `tprel_lo12` relocation, even though LLVM can apparently generate it when using `-mtls-size=12`.
2021-10-15 07:44:48 +02:00
Matthias Krüger
e2c28ad1e7
Rollup merge of #89870 - tmandry:box-pin, r=estebank
Suggest Box::pin when Pin::new is used instead

This fixes an incorrect diagnostic.

**Based on #89390**; only the last commit is specific to this PR. "Ignore whitespace changes" also helps here.
2021-10-15 07:44:47 +02:00
Matthias Krüger
b74ae0487b
Rollup merge of #89821 - crlf0710:unsafe_code_lint_test, r=Mark-Simulacrum
Add a strange test for `unsafe_code` lint.

The current behavior is a little surprising to me. I'm not sure whether people would change it, but at least let me document the current behavior with a test.

I learnt about this from the [totally-speedy-transmute](https://docs.rs/totally-speedy-transmute) crate.

cc #10599 the original implementation pr.
2021-10-15 07:44:45 +02:00
Matthias Krüger
36a1076d24
Rollup merge of #86011 - tlyu:correct-sized-bound-spans, r=estebank
move implicit `Sized` predicate to end of list

In `Bounds::predicates()`, move the implicit `Sized` predicate to the
end of the generated list. This means that if there is an explicit
`Sized` bound, it will be checked first, and any resulting
diagnostics will have a more useful span.

Fixes #85998, at least partially. ~~Based on #85979, but only the last 2 commits are new for this pull request.~~ (edit: rebased) A full fix would need to deal with where-clauses, and that seems difficult. Basically, predicates are being collected in multiple stages, and there are two places where implicit `Sized` predicates can be inserted: once for generic parameters, and once for where-clauses. I think this insertion is happening too early, and we should actually do it only at points where we collect all of the relevant trait bounds for a type parameter.

I could use some help interpreting the changes to the stderr output. It looks like reordering the predicates changed some diagnostics that don't obviously have anything to do with `Sized` bounds. Possibly some error reporting code is making assumptions about ordering of predicates? The diagnostics for src/test/ui/derives/derives-span-Hash-*.rs seem to have improved, no longer pointing at the type parameter identifier, but src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.rs became less verbose for some reason.

I also ran into an instance of #84970 while working on this, but I kind of expected that could happen, because I'm reordering predicates. I can open a separate issue on that if it would be helpful.

``@estebank`` this seems likely to conflict (slightly?) with your work on #85947; how would you like to resolve that?
2021-10-15 07:44:44 +02:00
Hans Kratz
2a1fbb86eb test fix: aarch64 atomics are only outlined on Linux. 2021-10-15 06:19:08 +02:00
bors
313e71a253 Auto merge of #89884 - Mark-Simulacrum:revert-enum-discr, r=wesleywiser
Revert enum discriminants

Reverts stabilization of arbitrary enum discriminants per https://github.com/rust-lang/rust/issues/88621#issuecomment-929482371.

Reopens #60553.
2021-10-15 02:55:58 +00:00
Charles Lew
c76c620e4e Add a test for unsafe_code lint. 2021-10-15 01:21:05 +08:00
cameron1024
cca39148f3 add long explanation for E0183 2021-10-14 17:44:04 +01:00
bors
e1e9319d93 Auto merge of #89882 - matthiaskrgr:rollup-1dh7pz8, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #89390 (Fix incorrect Box::pin suggestion)
 - #89433 (Fix ctrl-c causing reads of stdin to return empty on Windows.)
 - #89823 (Switch order of terms to prevent overflow)
 - #89865 (Allow static linking LLVM with ThinLTO)
 - #89873 (Add missing word to `FromStr` trait documentation)
 - #89878 (Fix missing remaining compiler specific cfg information)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-14 16:23:10 +00:00
Mark Rousskov
8485e6fdec Revert "Stabilize arbitrary_enum_discriminant"
This reverts commit 7a62f29f31.
2021-10-14 10:57:56 -04:00
Matthias Krüger
f9c9774aea
Rollup merge of #89390 - tmandry:issue-72117, r=estebank
Fix incorrect Box::pin suggestion

The suggestion checked if `Pin<Box<T>>` could be coeerced to the expected
type, but did not check predicates created by the coercion. We now
look for predicates that definitely cannot be satisfied before giving
the suggestion.

The suggestion is still marked MaybeIncorrect because we allow predicates that
are still ambiguous and can't be proven.

Fixes #72117.
2021-10-14 16:06:43 +02:00
bors
0a56eb11fa Auto merge of #88698 - Noble-Mushtak:master, r=nikomatsakis,oli-obk
Add check that live_region is live in sanitize_promoted

This pull request fixes #88434 by adding a check in `sanitize_promoted` to ensure that only regions which are actually live are added to the `liveness_constraints` of the `BorrowCheckContext`.

To implement this change, I needed to add a method to `LivenessValues` which gets the elements contained by a region:

    /// Returns an iterator of all the elements contained by the region `r`
    crate fn get_elements(&self, row: N) -> impl Iterator<Item = Location> + '_

Then, inside `sanitize_promoted`, we check whether the iterator returned by this method is non-empty to ensure that the region is actually live at at least one location before adding that region to the `liveness_constraints` of the `BorrowCheckContext`.

This is my first pull request to the Rust repo, so any feedback on how I can improve this pull request or if there is a better way to fix this issue would be very appreciated.
2021-10-14 13:21:46 +00:00
Adam Gemmell
af5b146324 Use non-checking TLS relocation in aarch64 asm! sym test.
The checking variant ensures that the offset required is not larger than
12 bits - hence we wouldn't ever need the upper 12 bits.
2021-10-14 12:27:19 +01:00
bors
c34ac8747c Auto merge of #89247 - fee1-dead:const-eval-select, r=oli-obk
Add `const_eval_select` intrinsic

Adds an intrinsic that calls a given function when evaluated at compiler time, but generates a call to another function when called at runtime.

See https://github.com/rust-lang/const-eval/issues/7 for previous discussion.

r? `@oli-obk.`
2021-10-14 10:06:30 +00:00
Deadbeef
11fac09ead
fix codegen test 2021-10-14 07:35:35 +00:00
Deadbeef
26b78ccd31
Fix const stability 2021-10-14 07:07:34 +00:00
Deadbeef
6770dbd4b5
Avoid tupling at the callee 2021-10-14 06:18:53 +00:00
bors
7807a694c2 Auto merge of #89815 - GuillaumeGomez:associated-consts-sidebar, r=notriddle
Associated consts sidebar

Fixes #89354.

A screenshot with `f32`:

![Screenshot from 2021-10-12 15-07-57](https://user-images.githubusercontent.com/3050060/136962078-5faf7b87-7ea5-4d7a-99a4-b2afd77b78e2.png)
2021-10-14 02:24:52 +00:00
Tyler Mandry
d18502d6b3 Suggest Box::pin when Pin::new is used instead 2021-10-14 01:06:25 +00:00
Loïc BRANSTETT
e252274fb1 Add regression test for #89852 2021-10-14 02:12:18 +02:00
bors
8c852bc15a Auto merge of #89858 - matthiaskrgr:rollup-evsnr2e, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #89347 (suggestion for typoed crate or module)
 - #89670 (Improve `std:🧵:available_parallelism` docs)
 - #89757 (Use shallow clones for submodules)
 - #89759 (Assemble the compiler when running `x.py build`)
 - #89846 (Add `riscv32imc-esp-espidf` to 1.56 changelog)
 - #89853 (Update the 1.56.0 release header for consistency)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-13 23:27:57 +00:00
Tyler Mandry
156c9222f5 Move misplaced comment 2021-10-13 23:26:00 +00:00
Tyler Mandry
485ae9f2c0 Always check predicates in can_coerce
This only changed two tests and I consider both changes an improvement.
2021-10-13 23:26:00 +00:00
Tyler Mandry
5c14433c00 Fix incorrect Box::pin suggestion
The suggestion checked if Pin<Box<T>> could be coeerced to the expected
type, but did not check predicates created by the coercion. We now
look for predicates that definitely cannot be satisfied before giving
the suggestion.

The suggestion is marked MaybeIncorrect because we allow predicates that
are still ambiguous and can't be proven.
2021-10-13 23:26:00 +00:00
Matthias Krüger
efac68b93c
Rollup merge of #89347 - TaKO8Ki:crate-or-module-typo, r=estebank
suggestion for typoed crate or module

Previously, the compiler didn't suggest similarly named crates or modules. This pull request adds a suggestion for typoed crates or modules.

#76208

before:

```
error[E0433]: failed to resolve: use of undeclared type or module `chono`
 --> src/main.rs:2:5
  |
2 | use chono::prelude::*;
  |     ^^^^^ use of undeclared type or module `chono`
```

after:

```
error[E0433]: failed to resolve: use of undeclared type or module `chono`
 --> src/main.rs:2:5
  |
2 | use chono::prelude::*;
  |     ^^^^^
  |     |
  |     use of undeclared crate or module `chono`
  |     help: a similar crate or module exists: `chrono`
```
2021-10-13 22:51:00 +02:00
bors
dfc5add915 Auto merge of #89555 - oli-obk:nll_member_constraint_diag, r=estebank
Remove textual span from diagnostic string

This is an unnecessary repetition, as the diagnostic prints the span anyway in the source path right below the message.

I further removed the identification of the node, as that does not give any new information in any of the cases that are changed in tests.

EDIT: also inserted a suggestion that other diagnostics were already emitting
2021-10-13 20:36:10 +00:00
bors
eeb16a2a89 Auto merge of #89822 - tmiasko:overflap-duplicates, r=cjgillot
Deduplicate regions ids before merging them

The merging code does not expect to see any duplicates.

Fixes #89820.

r? `@cjgillot`
2021-10-13 16:42:53 +00:00
bors
81117ff930 Auto merge of #89847 - JohnTitor:rollup-xfymeo4, r=JohnTitor
Rollup of 12 pull requests

Successful merges:

 - #89768 (add some more testcases)
 - #89777 (Edit explanation of test for nested type ascriptions)
 - #89781 (Add missing words in `Infallible` docs)
 - #89782 (Improve CJK font in rustdoc)
 - #89794 (Add #[must_use] to to_value conversions)
 - #89814 (Fix uppercase/lowercase error)
 - #89816 (Fix invalid rules in .gitignore)
 - #89817 (Add #[inline] to int log10 functions.)
 - #89818 (Use Option::map_or instead of open coding it)
 - #89828 (Fix config.toml overflow-checks options)
 - #89840 (fix the stage0 tools config file path in `config.toml.example`)
 - #89845 (Add davidtwco to the `.mailmap`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-13 13:41:48 +00:00
Yuki Okushi
cd5fe938e7
Rollup merge of #89777 - pierwill:fix-88233, r=Mark-Simulacrum
Edit explanation of test for nested type ascriptions

Fixes typo ("an ascribing") and removes extra.

Closes #88233.
2021-10-13 21:55:10 +09:00
Yuki Okushi
0caa6164a3
Rollup merge of #89768 - hellow554:tests, r=Mark-Simulacrum
add some more testcases

resolves #52893
resolves #68295
resolves #87750
resolves #88071

All these issues have been fixed according to glacier. Just adding a test so it can be closed.

Can anybody tell me why the github keywords do not work? 🤔
Please edit this post if you can fix it.
2021-10-13 21:55:10 +09:00
Oli Scherer
ab7721d694 Bless nll tests 2021-10-13 10:53:44 +00:00
Oli Scherer
888ba509ea Re-use logic for adding a suggestion when a lifetime bound is missing on an impl trait 2021-10-13 10:53:44 +00:00
Oli Scherer
be399635a2 Remove explicit -Zborrowck=mir which does not affect test anymore 2021-10-13 10:53:44 +00:00
Oli Scherer
56e79e6ce2 Remove a feature attribute for an accepted feature 2021-10-13 10:53:44 +00:00
Oli Scherer
d435101537 Use a label instead of a note for member constraint errors 2021-10-13 10:53:44 +00:00
Oli Scherer
15f93473f1 Remove textual span from diagnostic string 2021-10-13 10:53:44 +00:00
bors
5728bd64b4 Auto merge of #89587 - camelid:all-candidates, r=petrochenkov
Include rmeta candidates in "multiple matching crates" error

Only dylib and rlib candidates were included in the error. I think the
reason is that at the time this error was originally implemented, rmeta
crate sources were represented different from dylib and rlib sources.
I wrote up more detailed analysis in [this comment][1].

The new version of the code is also a bit easier to read and should be
more robust to future changes since it uses `CrateSources::paths()`.

I also changed the code to sort the candidates to make the output deterministic;
added full stderr tests for the error; and added a long error code explanation.

[1]: https://github.com/rust-lang/rust/pull/88675#issuecomment-935282436

cc `@Mark-Simulacrum` `@jyn514`
2021-10-13 10:38:12 +00:00
Takayuki Maeda
f819e6d59c suggestion for typoed crate or module
avoid suggesting the same name

sort candidates

fix a message

use `opt_def_id` instead of `def_id`

move `find_similarly_named_module_or_crate` to rustc_resolve/src/diagnostics.rs
2021-10-13 12:17:02 +09:00
Tomasz Miąsko
8aaf4ab59a Deduplicate regions ids before merging them
The merging code does not expect to see any duplicates.
2021-10-13 00:00:00 +00:00
bors
d7c97a02d1 Auto merge of #89105 - DevinR528:reachable-fix, r=Nadrieril
Fix: non_exhaustive_omitted_patterns by filtering unstable and doc hidden variants

Fixes: #89042

Now that #86809 has been merged there are cases (std::io::ErrorKind) where unstable feature gated variants were included in warning/error messages when the feature was not turned on. This filters those variants out of the return of `SplitWildcard::new`.

Variants marked `doc(hidden)` are filtered out of the witnesses list in `Usefulness::apply_constructor`.

Probably worth a perf run 🤷 since this area can be sensitive.
2021-10-12 20:54:15 +00:00
Dominik Stolz
a400f1058e Bless tests 2021-10-12 22:47:34 +02:00
Noah Lev
bf2d2e5597 Work around different filenames for DLLs 2021-10-12 13:31:21 -07:00
Noah Lev
cc6a09009d Add long explanation for E0464
The test is copied from `src/test/ui/crate-loading/crateresolve1.rs` and
its auxiliary tests. I added it to the `compile_fail` code example check
exemption list since it's hard if not impossible to reproduce this error
in a standalone code example.
2021-10-12 13:10:12 -07:00
Noah Lev
2e56b6f98e Include rmeta candidates in "multiple matching crates" error
Only dylib and rlib candidates were included in the error. I think the
reason is that at the time this error was originally implemented, rmeta
crate sources were represented different from dylib and rlib sources.
I wrote up more detailed analysis in [this comment][1].

The new version of the code is also a bit easier to read and should be
more robust to future changes since it uses `CrateSources::paths()`.

[1]: https://github.com/rust-lang/rust/pull/88675#issuecomment-935282436
2021-10-12 13:10:11 -07:00
Noah Lev
ad49cb6e0c Add test for showing rmeta candidates in error 2021-10-12 13:10:11 -07:00
Noah Lev
642a43a9cd Test crate loading error stderr
And remove E0464 from test-exemption list, since it now has a full test.
2021-10-12 13:10:10 -07:00
Dominik Stolz
59b36bcfb5 Add UI test for the variance of types appearing in consts 2021-10-12 21:50:44 +02:00
Guillaume Gomez
51a993f4a6 Add test for associated constants in the sidebar 2021-10-12 15:07:11 +02:00
Devin Ragotzy
2a042d6105 Filter unstable and doc hidden variants in usefulness checking
Add test cases for unstable variants
Add test cases for doc hidden variants
Move is_doc_hidden to method on TyCtxt
Add unstable variants test to reachable-patterns ui test
Rename reachable-patterns -> omitted-patterns
2021-10-12 08:22:25 -04:00
bors
9475e609b8 Auto merge of #89770 - jkugelman:must-use-from-and-into, r=joshtriplett
Add #[must_use] to From::from and Into::into

Risk of churn: **High**
Magic 8-Ball says: **Outlook not so good**

I figured I'd put this out there. If we don't do it now maybe we save it for a rainy day.

Parent issue: #89692

r? `@joshtriplett`
2021-10-12 09:43:37 +00:00
Marcel Hellwig
0767ed31f3 add some more testcases 2021-10-12 08:56:05 +02:00
Deadbeef
5387b6542f
Add const_eval_select intrinsic 2021-10-12 05:42:23 +00:00
bors
97e3b30285 Auto merge of #89791 - matthiaskrgr:rollup-1lhxh5b, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #89471 (Use Ancestory to check default fn in const impl instead of comparing idents)
 - #89643 (Fix inherent impl overlap check.)
 - #89651 (Add `Poll::ready` and revert stabilization of `task::ready!`)
 - #89675 (Re-use TypeChecker instead of passing around some of its fields )
 - #89710 (Add long explanation for error E0482)
 - #89756 (Greatly reduce amount of debuginfo compiled for bootstrap itself)
 - #89760 (Remove hack ignoring unused attributes for stage 0 std)
 - #89772 (Fix function-names test for GDB 10.1)
 - #89785 (Fix ICE when compiling nightly std/rustc on beta compiler)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-12 00:20:34 +00:00
John Kugelman
f9692b5619 Add #[must_use] to From::from and Into::into 2021-10-11 18:10:30 -04:00
Matthias Krüger
603da7e83f
Rollup merge of #89772 - michaelwoerister:fix-function-names-test-gdb, r=Mark-Simulacrum
Fix function-names test for GDB 10.1

This PR updates the test output in `src/test/debuginfo/function-names.rs` for GDB 10.1.

This should fix issue https://github.com/rust-lang/rust/issues/89750 -- but not the underlying problem of CI ignoring tests if not viable debugger happens to be present.
2021-10-11 23:45:52 +02:00
Matthias Krüger
412301b26a
Rollup merge of #89471 - nbdd0121:const3, r=fee1-dead
Use Ancestory to check default fn in const impl instead of comparing idents

Fixes https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Const.20trait.20impl.20inside.20macro
2021-10-11 23:45:46 +02:00
bors
7cc8c44871 Auto merge of #89648 - nbdd0121:issue-89606, r=nikomatsakis
Ignore type of projections for upvar capturing

Fix #89606

Ignore type of projections for upvar capturing. Originally HashMap is used, and the hash/eq implementation of Place takes the type of projections into account. These types may differ by lifetime which causes #89606 to ICE.

I originally considered erasing regions but `place.ty()` is used when creating upvar tuple type, more than just serving as a key type, so I switched to a linear comparison with custom eq (`compare_place_ignore_ty`) instead.

r? `@wesleywiser`

`@rustbot` label +T-compiler
2021-10-11 21:39:11 +00:00
pierwill
e71d17b9b4 Edit explanation of test for nested type ascriptions
Closes #88233
2021-10-11 12:56:55 -05:00
Gary Guo
0a03f8c78b Split impl-with-default-fn test into a pass test and a fail test 2021-10-11 18:20:20 +01:00
bors
5b210643eb Auto merge of #83908 - Flying-Toast:master, r=davidtwco
Add enum_intrinsics_non_enums lint

There is a clippy lint to prevent calling [`mem::discriminant`](https://doc.rust-lang.org/std/mem/fn.discriminant.html) with a non-enum type. I think the lint is worthy of being included in rustc, given that `discriminant::<T>()` where `T` is a non-enum has an unspecified return value, and there are no valid use cases where you'd actually want this.

I've also made the lint check [variant_count](https://doc.rust-lang.org/core/mem/fn.variant_count.html) (#73662).

closes #83899
2021-10-11 17:12:14 +00:00
Michael Woerister
6531cd8cba Fix function-names test for GDB 10.1 2021-10-11 17:20:45 +02:00
Guillaume Gomez
d7c9693401
Rollup merge of #89726 - jkugelman:must-use-alloc-constructors, r=joshtriplett
Add #[must_use] to alloc constructors

Added `#[must_use]`. to the various forms of `new`, `pin`, and `with_capacity` in the `alloc` crate. No extra explanations given as I couldn't think of anything useful to add.

I figure this deserves extra scrutiny compared to the other PRs I've done so far. In particular:

* The 4 `pin`/`pin_in` methods I touched. Are there legitimate use cases for pinning and not using the result? Pinning's a difficult concept I'm not very comfortable with.
* `Box`'s constructors. Do people ever create boxes just for the side effects... allocating or zeroing out memory?

Parent issue: #89692

r? ``@joshtriplett``
2021-10-11 14:11:42 +02:00
Flying-Toast
59b186d99a
Add enum_intrinsics_non_enums lint 2021-10-11 09:46:27 +02:00
bors
9a757817c3 Auto merge of #89597 - michaelwoerister:improve-vtable-debuginfo, r=wesleywiser
Create more accurate debuginfo for vtables.

Before this PR all vtables would have the same name (`"vtable"`) in debuginfo. Now they get an unambiguous name that identifies the implementing type and the trait that is being implemented.

This is only one of several possible improvements:
- This PR describes vtables as arrays of `*const u8` pointers. It would nice to describe them as structs where function pointer is represented by a field with a name indicative of the method it maps to. However, this requires coming up with a naming scheme that avoids clashes between methods with the same name (which is possible if the vtable contains multiple traits).
- The PR does not update the debuginfo we generate for the vtable-pointer field in a fat `dyn` pointer. Right now there does not seem to be an easy way of getting ahold of a vtable-layout without also knowing the concrete self-type of a trait object.

r? `@wesleywiser`
2021-10-11 04:31:47 +00:00
bors
1ddd4e6d7e Auto merge of #89752 - matthiaskrgr:rollup-v4fgmwg, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #89579 (Add regression test for issue 80108)
 - #89632 (Fix docblock code display on mobile)
 - #89691 (Move `DebuggerCommands` and `check_debugger_output` to a separate module)
 - #89707 (Apply clippy suggestions for std)
 - #89722 (Fix spelling: Cannonical -> Canonical)
 - #89736 (Remove unused CSS rule)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-11 01:06:26 +00:00
Matthias Krüger
3fa897df26
Rollup merge of #89632 - GuillaumeGomez:fix-docblock-code, r=jsha
Fix docblock code display on mobile

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

Before:

![Screenshot from 2021-10-07 12-01-37](https://user-images.githubusercontent.com/3050060/136363624-72bedddd-b45e-48a0-89b4-6563612f8677.png)

After:

![Screenshot from 2021-10-07 20-17-21](https://user-images.githubusercontent.com/3050060/136440704-fa9ffa68-8e94-46a7-b556-c41aa5153750.png)

r? `@jsha`
2021-10-11 00:34:37 +02:00
Matthias Krüger
2bfbf97762
Rollup merge of #89579 - workingjubilee:regression-test-80108, r=Mark-Simulacrum
Add regression test for issue 80108

Closes #80108
2021-10-11 00:34:37 +02:00
bors
3bf55753c6 Auto merge of #89541 - workingjubilee:abbrev-shufvec-t, r=Mark-Simulacrum
Cleanup src/test/ui/{simd,simd-intrinsic}

Initial motivation was to simplify a huge macro expansion using a tuple, since we can just use an array in `#[repr(simd)]` now for the same result. But also, several tests were going unnoticed during development of SIMD intrinsics because people kept looking in the wrong directory, and many are basically run-pass vs. build-fail versions of the same tests, so let's keep them close together and simplify their names, so they're easier to sift through.
2021-10-10 22:25:49 +00:00
Jubilee Young
7fb6e1aa61 Add regression test for issue 80108 2021-10-10 14:09:55 -07:00