Commit graph

7419 commits

Author SHA1 Message Date
bors
0035d9dcec Auto merge of #87050 - jyn514:no-doc-primitive, r=manishearth
Add future-incompat lint for `doc(primitive)`

## What is `doc(primitive)`?

`doc(primitive)` is an attribute recognized by rustdoc which adds documentation for the built-in primitive types, such as `usize` and `()`. It has been stable since Rust 1.0.

## Why change anything?

`doc(primitive)` is useless for anyone outside the standard library. Since rustdoc provides no way to combine the documentation on two different primitive items, you can only replace the docs, and since the standard library already provides extensive documentation there is no reason to do so.

While fixing rustdoc's handling of primitive items (https://github.com/rust-lang/rust/pull/87073) I discovered that even rustdoc's existing handling of primitive items was broken if you had more than two crates using it (it would pick randomly between them). That meant both:
- Keeping rustdoc's existing treatment was nigh-impossible, because it was random.
- doc(primitive) was even more useless than it would otherwise be.

The only use-case for this outside the standard library is for no-std libraries which want to link to primitives (https://github.com/rust-lang/rust/issues/73423) which is being fixed in https://github.com/rust-lang/rust/pull/87073.

https://github.com/rust-lang/rust/pull/87073 makes various breaking changes to `doc(primitive)` (breaking in the sense that they change the semantics, not in that they cause code to fail to compile). It's not possible to avoid these and still fix rustdoc's issues.

## What can we do about it?

As shown by the crater run (https://github.com/rust-lang/rust/pull/87050#issuecomment-886166706), no one is actually using doc(primitive), there wasn't a single true regression in the whole run. We can either:
1. Feature gate it completely, breaking anyone who crater missed. They can easily fix the breakage just by removing the attribute.
2. add it to the `INVALID_DOC_ATTRIBUTES` future-incompat lint, and at the same time make it a no-op unless you add a feature gate. That would mean rustdoc has to look at the features of dependent crates, because it needs to know where primitives are defined in order to link to them.
3. add it to `INVALID_DOC_ATTRIBUTES`, but still use it to determine where primitives come from
4. do nothing; the behavior will silently change in https://github.com/rust-lang/rust/pull/87073.

My preference is for 2, but I would also be happy with 1 or 3. I don't think we should silently change the behavior.

This PR currently implements 3.
2021-08-16 15:36:44 +00:00
Mara Bos
0a313250a4 Improve non_fmt_panics suggestion based on trait impls. 2021-08-16 17:25:35 +02:00
Deadbeef
ee85704c04
Skip assert ICE with default_method_body_is_const
functions marked with #[default_method_body_is_const] would
ICE when being const checked due to it not being a const function:
`tcx.is_const_fn_raw(did)` returns false. We should skip this assert
when it is marked with that attribute.
2021-08-16 12:04:01 +00:00
Mara Bos
111201d27c Use multi span suggestions for closure migrations. 2021-08-16 11:38:28 +02:00
bors
73d96b090b Auto merge of #88032 - hyd-dev:no-mangle-method, r=petrochenkov
Fix `reachable_set` for non-function items in non-library crates

I unintentionally changed `reachable_set` to ignore non-function items when `!self.any_library` in https://github.com/rust-lang/rust/pull/86492, which can lead to "undefined reference" errors in non-library (`cdylib`/`staticlib`/`bin`) crates, for example: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=6bb2c5065a9be7e40943d0541e161b5a

This PR restores the behavior of `reachable_set` for non-function items.

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

<details>
<summary>The modified test will fail with this output without the `reachable_set` change</summary>

```
---- [codegen] codegen/external-no-mangle-statics.rs#staticlib stdout ----

error in revision `staticlib`: verification with 'FileCheck' failed
status: exit status: 1
command: "/checkout/build/x86_64-unknown-linux-gnu/ci-llvm/bin/FileCheck" "--input-file" "/checkout/build/x86_64-unknown-linux-gnu/test/codegen/external-no-mangle-statics.staticlib/external-no-mangle-statics.ll" "/checkout/src/test/codegen/external-no-mangle-statics.rs" "--check-prefixes" "CHECK,NONMSVC,staticlib"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
/checkout/src/test/codegen/external-no-mangle-statics.rs:10:11: error: CHECK: expected string not found in input
// CHECK: `@A` = local_unnamed_addr constant
          ^
/checkout/build/x86_64-unknown-linux-gnu/test/codegen/external-no-mangle-statics.staticlib/external-no-mangle-statics.ll:1:1: note: scanning from here
; ModuleID = 'external_no_mangle_statics.b50529d3-cgu.0'
^
/checkout/build/x86_64-unknown-linux-gnu/test/codegen/external-no-mangle-statics.staticlib/external-no-mangle-statics.ll:1:6: note: possible intended match here
; ModuleID = 'external_no_mangle_statics.b50529d3-cgu.0'
     ^

Input file: /checkout/build/x86_64-unknown-linux-gnu/test/codegen/external-no-mangle-statics.staticlib/external-no-mangle-statics.ll
Check file: /checkout/src/test/codegen/external-no-mangle-statics.rs

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: ; ModuleID = 'external_no_mangle_statics.b50529d3-cgu.0'
check:10'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:10'1          ?                                                   possible intended match
            2: source_filename = "external_no_mangle_statics.b50529d3-cgu.0"
check:10'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            3: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
check:10'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            4: target triple = "x86_64-unknown-linux-gnu"
check:10'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            5:
check:10'0     ~
            6: !llvm.module.flags = !{!0, !1}
check:10'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            .
            .
            .
>>>>>>

------------------------------------------

failures:
    [codegen] codegen/external-no-mangle-statics.rs#staticlib
```
</details>
2021-08-16 09:38:18 +00:00
kit
13e2f807a1 Generate an iOS LLVM target with a specific version
Without the specific version, the mach-o header will be missing the
minimum supported operating system version. This is mandatory for
running Rust binaries on iOS devices.
2021-08-16 17:31:37 +10:00
Rémy Rakic
311578d7f4
fix typo in bound_region_errors.rs
Co-authored-by: matthewjasper <20113453+matthewjasper@users.noreply.github.com>
2021-08-16 09:07:42 +02:00
bors
92f3753b07 Auto merge of #84039 - jyn514:uplift-atomic-ordering, r=wesleywiser
Uplift the invalid_atomic_ordering lint from clippy to rustc

This is mostly just a rebase of https://github.com/rust-lang/rust/pull/79654; I've copy/pasted the text from that PR below.

r? `@lcnr` since you reviewed the last one, but feel free to reassign.

---

This is an implementation of https://github.com/rust-lang/compiler-team/issues/390.

As mentioned, in general this turns an unconditional runtime panic into a (compile time) lint failure. It has no false positives, and the only false negatives I'm aware of are if `Ordering` isn't specified directly and is comes from an argument/constant/whatever.

As a result of it having no false positives, and the alternative always being strictly wrong, it's on as deny by default. This seems right.

In the [zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Uplift.20the.20.60invalid_atomic_ordering.60.20lint.20from.20clippy/near/218483957) `@joshtriplett` suggested that lang team should FCP this before landing it. Perhaps libs team cares too?

---

Some notes on the code for reviewers / others below

## Changes from clippy

The code is changed from [the implementation in clippy](68cf94f6a6/clippy_lints/src/atomic_ordering.rs) in the following ways:

1. Uses `Symbols` and `rustc_diagnostic_item`s instead of string literals.
    - It's possible I should have just invoked Symbol::intern for some of these instead? Seems better to use symbol, but it did require adding several.
2. The functions are moved to static methods inside the lint struct, as a way to namespace them.
    - There's a lot of other code in that file — which I picked as the location for this lint because `@jyn514` told me that seemed reasonable.
3. Supports unstable AtomicU128/AtomicI128.
    - I did this because it was almost easier to support them than not — not supporting them would have (ideally) required finding a way not to give them a `rustc_diagnostic_item`, which would have complicated an already big macro.
    - These don't have tests since I wasn't sure if/how I should make tests conditional on whether or not the target has the atomic... This is to a certain extent an issue of 64bit atomics too, but 128-bit atomics are much less common. Regardless, the existing tests should be *more* than thorough enough here.
4. Minor changes like:
    - grammar tweaks ("loads cannot have `Release` **and** `AcqRel` ordering" => "loads cannot have `Release` **or** `AcqRel` ordering")
    - function renames (`match_ordering_def_path` => `matches_ordering_def_path`),
    - avoiding clippy-specific helper methods that don't exist in rustc_lint and didn't seem worth adding for this case (for example `cx.struct_span_lint` vs clippy's `span_lint_and_help` helper).

## Potential issues

(This is just about the code in this PR, not conceptual issues with the lint or anything)

1. I'm not sure if I should have used a diagnostic item for `Ordering` and its variants (I couldn't figure out how really, so if I should do this some pointers would be appreciated).
    - It seems possible that failing to do this might possibly mean there are more cases this lint would miss, but I don't really know how `match_def_path` works and if it has any pitfalls like that, so maybe not.

2. I *think* I deprecated the lint in clippy (CC `@flip1995` who asked to be notified about clippy changes in the future in [this comment](https://github.com/rust-lang/rust/pull/75671#issuecomment-718731659)) but I'm not sure if I need to do anything else there.
    - I'm kind of hoping CI will catch if I missed anything, since `x.py test src/tools/clippy` fails with a lot of errors with and without my changes (and is probably a nonsense command regardless). Running `cargo test` from src/tools/clippy also fails with unrelated errors that seem like refactorings that didnt update clippy? So, honestly no clue.

3. I wasn't sure if the description/example I gave good. Hopefully it is. The example is less thorough than the one from clippy here: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_atomic_ordering. Let me know if/how I should change it if it needs changing.

4. It pulls in the `if_chain` crate. This crate was already used in clippy, and seems like it's used elsewhere in rustc, but I'm willing to rewrite it to not use this if needed (I'd prefer not to, all things being equal).
2021-08-16 06:36:13 +00:00
Joshua Nelson
03df65497e feature gate doc(primitive) 2021-08-16 05:41:16 +00:00
Joshua Nelson
5522177db6 Only run expensive calculations if the method name is recognized 2021-08-16 03:55:27 +00:00
Thom Chiovoloni
402a9c9f5e Uplift the invalid_atomic_ordering lint from clippy to rustc
- Deprecate clippy::invalid_atomic_ordering
- Use rustc_diagnostic_item for the orderings in the invalid_atomic_ordering lint
- Reduce code duplication
- Give up on making enum variants diagnostic items and just look for
`Ordering` instead

  I ran into tons of trouble with this because apparently the change to
  store HIR attrs in a side table also gave the DefIds of the
  constructor instead of the variant itself. So I had to change
  `matches_ordering` to also check the grandparent of the defid as well.

- Rename `atomic_ordering_x` symbols to just the name of the variant
- Fix typos in checks - there were a few places that said "may not be
  Release" in the diagnostic but actually checked for SeqCst in the lint.
- Make constant items const
- Use fewer diagnostic items
- Only look at arguments after making sure the method matches

  This prevents an ICE when there aren't enough arguments.

- Ignore trait methods
- Only check Ctors instead of going through `qpath_res`

  The functions take values, so this couldn't ever be anything else.

- Add if_chain to allowed dependencies
- Fix grammar
- Remove unnecessary allow
2021-08-16 03:55:27 +00:00
Erik Desjardins
8e11199a15 Revert "Auto merge of #83417 - erikdesjardins:enableremovezsts, r=oli-obk"
This reverts commit 8007b506ac, reversing
changes made to e55c13e109.
2021-08-15 23:44:34 -04:00
bors
2a6fb9a4c0 Auto merge of #80357 - c410-f3r:new-hir-let, r=matthewjasper
Introduce `hir::ExprKind::Let` - Take 2

Builds on #68577 and depends on #79328.

cc #53667
2021-08-16 00:31:42 +00:00
Aaron Hill
179fd38bb5
Update rustc_codegen_cratelift for working_dir change 2021-08-15 15:17:37 -05:00
Aaron Hill
a895069c50
Include (potentially remapped) working dir in crate hash
Fixes #85019

A `SourceFile` created during compilation may have a relative
path (e.g. if rustc itself is invoked with a relative path).
When we write out crate metadata, we convert all relative paths
to absolute paths using the current working direction.

However, the working directory is not included in the crate hash.
This means that the crate metadata can change while the crate
hash remains the same. Among other problems, this can cause a
fingerprint mismatch ICE, since incremental compilation uses
the crate metadata hash to determine if a foreign query is green.

This commit moves the field holding the working directory from
`Session` to `Options`, including it as part of the crate hash.
2021-08-15 15:17:37 -05:00
Caio
6aa9937a76 Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
Matthew Jasper
2d9f2eae84 Use correct drop scopes for if expressions 2021-08-15 16:05:25 -03:00
bors
2d2bc94c8c Auto merge of #87982 - m-ou-se:non-fmt-panic-assert-str, r=cjgillot
Add automatic migration for assert!(.., string).

Fixes part of #87313.
2021-08-15 17:57:39 +00:00
Aaron Hill
d8c3a649a6
Remove HashStable impls for FileName and RealFileName
These impls were unused, and incorrectly hashed the local
(non-remapped) path for `RealFileName::Remapped` (which would
break reproducible builds if these impls were used).
2021-08-15 10:48:53 -05:00
Rémy Rakic
2cf4b87393 De-dupe NLL HRTB diagnostics' use of type_op_prove_predicate 2021-08-15 14:49:36 +02:00
bors
dfe5fd0902 Auto merge of #87975 - m-ou-se:unused-import-attributes, r=nagisa
Include attributes in removal span for unused imports.

Fixes https://github.com/rust-lang/rust/issues/87973
2021-08-15 07:40:53 +00:00
Rémy Rakic
a69c7cc0d5 don't derive Copy for RegionElement 2021-08-15 09:11:03 +02:00
Rémy Rakic
19dfea552a Slight cleanup 2021-08-15 09:11:03 +02:00
Rémy Rakic
5cf6edb4c5 Fix dyn trait warning 2021-08-15 09:11:02 +02:00
Matthew Jasper
d563a63788 Report nicer errors for HRTB NLL errors from queries 2021-08-15 09:11:01 +02:00
Matthew Jasper
0c388b0261 Report mismatched type errors for bound region errors in NLL 2021-08-15 09:11:00 +02:00
Matthew Jasper
5e6027c6bf Track causes for universes created during borrowck 2021-08-15 09:10:46 +02:00
Matthew Jasper
e271383c6b Simplify BoundUniversalRegionError 2021-08-15 08:44:37 +02:00
Matthew Jasper
4421dd17fa Return the canonicalized query from type ops 2021-08-15 08:44:36 +02:00
Matthew Jasper
842f0590db Show bound lifetimes when comparing types in diagnostics 2021-08-15 08:44:35 +02:00
Matthew Jasper
5d52c0e0c6 Remove unused Option from NllTypeRelatingDelegate 2021-08-15 08:44:35 +02:00
Roxane
9c32b5b3ba Only compute place if upvars can be resolved 2021-08-14 21:00:58 -04:00
bors
85109e257a Auto merge of #87581 - Amanieu:asm_clobber_abi, r=nagisa
Add support for clobber_abi to asm!

This PR adds the `clobber_abi` feature that was proposed in #81092.

Fixes #81092

cc `@rust-lang/wg-inline-asm`

r? `@nagisa`
2021-08-14 22:29:27 +00:00
Gary Guo
2969aece41 Fix dead code warning when inline const is used in pattern 2021-08-14 22:58:04 +01:00
bors
8007b506ac Auto merge of #83417 - erikdesjardins:enableremovezsts, r=oli-obk
Run RemoveZsts pass at mir-opt-level=1

per https://github.com/rust-lang/rust/pull/83177#issuecomment-803942217

This pass removes assignments to ZST places.

Perf (from https://github.com/rust-lang/rust/pull/83177#issuecomment-803442557): https://perf.rust-lang.org/compare.html?start=41b315a470d583f6446599984ff9ad3bd61012b2&end=bd5d1b96f0c64c9938feea831789e1b5bb2cd4a2

r? `@oli-obk`
2021-08-14 19:59:08 +00:00
hyd-dev
29b73ee5fa
Fix reachable_set for non-function items in non-library crates 2021-08-15 02:59:53 +08:00
bors
e55c13e109 Auto merge of #87324 - asquared31415:named-asm-labels, r=Amanieu
Lint against named asm labels

This adds a deny-by-default lint to prevent the use of named labels in inline `asm!`.  Without a solution to #81088 about whether the compiler should rewrite named labels or a special syntax for labels, a lint against them should prevent users from writing assembly that could break for internal compiler reasons, such as inlining or anything else that could change the number of actual inline assembly blocks emitted.

This does **not** resolve the issue with rewriting labels, that still needs a decision if the compiler should do any more work to try to make them work.
2021-08-14 17:33:38 +00:00
Deadbeef
f25d2bd53b
Assign FIXMEs to me and remove obsolete ones
Also fixed capitalization of documentation
2021-08-14 16:48:01 +00:00
bors
136eaa1b25 Auto merge of #87375 - fee1-dead:move-constness-to-traitpred, r=oli-obk
Try filtering out non-const impls when we expect const impls

**TL;DR**: Associated types on const impls are now bounded; we now disallow calling a const function with bounds when the specified type param only has a non-const impl.

r? `@oli-obk`
2021-08-14 12:06:34 +00:00
DC
df751d82c8 freebsd arm64 add supported sanitizers. 2021-08-14 10:37:07 +01:00
bors
99efc51dae Auto merge of #85020 - lrh2000:named-upvars, r=tmandry
Name the captured upvars for closures/generators in debuginfo

Previously, debuggers print closures as something like
```
y::main::closure-0 (0x7fffffffdd34)
```
The pointer actually references to an upvar. It is not very obvious, especially for beginners.

It's because upvars don't have names before, as they are packed into a tuple. This PR names the upvars, so we can expect to see something like
```
y::main::closure-0 {_captured_ref__b: 0x[...]}
```

r? `@tmandry`
Discussed at https://github.com/rust-lang/rust/pull/84752#issuecomment-831639489 .
2021-08-14 07:01:36 +00:00
Roxane
2e61659bd1 Update comment and fix fmt 2021-08-13 20:48:59 -04:00
bors
d0a10b2056 Auto merge of #87478 - jackh726:issue-84931, r=estebank
Point to where clause for GATs to add bound

Fixes #84931

r? `@estebank`
2021-08-13 22:28:01 +00:00
jackh726
22fc7d6e5a Point to where clause for GATs 2021-08-13 17:07:56 -04:00
bors
5a19ffe1c2 Auto merge of #86492 - hyd-dev:no-mangle-method, r=petrochenkov
Associated functions that contain extern indicator or have `#[rustc_std_internal_symbol]` are reachable

Previously these fails to link with ``undefined reference to `foo'``:

<details>
<summary>Example 1</summary>

```rs
struct AssocFn;

impl AssocFn {
    #[no_mangle]
    fn foo() {}
}

fn main() {
    extern "Rust" {
        fn foo();
    }
    unsafe { foo() }
}
```
([Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=f1244afcdd26e2a28445f6e82ca46b50))
</details>

<details>
<summary>Example 2</summary>

```rs
#![crate_name = "lib"]
#![crate_type = "lib"]

struct AssocFn;

impl AssocFn {
    #[no_mangle]
    fn foo() {}
}
```
```rs
extern crate lib;

fn main() {
    extern "Rust" {
        fn foo();
    }
    unsafe { foo() }
}
```
</details>

But I believe they should link successfully, because this works:
<details>

```rs
#[no_mangle]
fn foo() {}

fn main() {
    extern "Rust" {
        fn foo();
    }
    unsafe { foo() }
}
```
([Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=789b3f283ee6126f53939429103ed98d))
</details>

This PR fixes the problem, by adding associated functions that have "custom linkage" to `reachable_set`, just like normal functions.

I haven't tested whether #76211 and [Miri](https://github.com/rust-lang/miri/issues/1837) are fixed by this PR yet, but I'm submitting this anyway since this fixes the examples above.

I added a `run-pass` test that combines my two examples above, but I'm not sure if that's the right way to test this. Maybe I should add / modify an existing codegen test (`src/test/codegen/export-no-mangle.rs`?) instead?
2021-08-13 19:47:03 +00:00
bors
881aeab7b1 Auto merge of #87984 - m-ou-se:closure-lint-wording, r=Aaron1011
Closure lint wording

Some small changes to the wording of the closure migration lint.

r? `@Aaron1011`
2021-08-13 16:57:34 +00:00
Mara Bos
fa7bf885f8 Update closure migration diagnostic wording. 2021-08-13 16:21:59 +02:00
Guillaume Gomez
96c9dabd17
Rollup merge of #87969 - Aaron1011:revert-stmt-id, r=petrochenkov
Revert "Rollup merge of #87779 - Aaron1011:stmt-ast-id, r=petrochenkov"

Fixes #87877

This change interacts badly with `noop_flat_map_stmt`,
which synthesizes multiple statements with the same `NodeId`.

I'm working on a better fix that will still allow us to
remove this special case. For now, let's revert the change
to fix the ICE.

This reverts commit a4262cc984, reversing
changes made to 8ee962f88e.
2021-08-13 15:29:12 +02:00
Guillaume Gomez
717f9e3769
Rollup merge of #87795 - estebank:erase-lifetimes-in-suggestion, r=oli-obk
Avoid ICE caused by suggestion

When suggesting dereferencing something that can be iterable in a `for`
loop, erase lifetimes and use a fresh `ty::ParamEnv` to avoid 'region
constraints already solved' panic.

Fix #87657, fix #87709, fix #87651.
2021-08-13 15:29:10 +02:00
Mara Bos
8fedb31649 Use is_diagnostic_item instead of get_diagnostic_item. 2021-08-13 12:21:31 +02:00
Mara Bos
b4f448a7ea non_fmt_panic: machine app. suggestion for assert with string msg. 2021-08-13 11:50:32 +02:00
Deadbeef
2931a9df2f
make check less conservative and add explanation 2021-08-13 09:28:52 +00:00
Deadbeef
1fa712d0ba
Make assoc types work with ?const opt=out 2021-08-13 09:28:52 +00:00
Deadbeef
869daad8fc
Fix tests 2021-08-13 09:28:51 +00:00
Deadbeef
6b6ad781f8
Fix call-generic-method-nonconst test 2021-08-13 09:28:51 +00:00
Deadbeef
7106f8d8ee
Don't transform predicates in Inherited 2021-08-13 09:28:51 +00:00
Deadbeef
c6d0a20f7b
handle the case when container is not impl 2021-08-13 09:28:50 +00:00
Deadbeef
bcf0e2f528
Fix assoc-type test 2021-08-13 09:28:50 +00:00
Deadbeef
01bb3710b5
Pass constness to SelectionContext 2021-08-13 09:28:50 +00:00
Deadbeef
a00f2bcf5c
Try to fix problem 2021-08-13 09:28:50 +00:00
Deadbeef
779eef2dae
Relate impl 2021-08-13 09:28:50 +00:00
Deadbeef
3bab45d2ac
Make selection and evaluation caches use constness 2021-08-13 09:28:49 +00:00
Deadbeef
36ace4c0ad
fmt 2021-08-13 09:28:49 +00:00
Deadbeef
7e6db83b14
Inherited use constness and assoc change predicate 2021-08-13 09:28:40 +00:00
Deadbeef
d356cd10f7
fmt 2021-08-13 09:26:34 +00:00
Deadbeef
4c8b6a20a9
Filter non-const impls when we expect a const one 2021-08-13 09:26:33 +00:00
Deadbeef
32390a0df6
move Constness into TraitPredicate 2021-08-13 09:26:33 +00:00
bors
2fc3c69e54 Auto merge of #87956 - m-ou-se:closure-migration-macro-body, r=Aaron1011
Fix closure migration suggestion when the body is a macro.

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

Before:
```
warning: changes to closure capture in Rust 2021 will affect drop order
 --> src/main.rs:5:13
  |
5 |     let _ = || panic!(a.0);
  |             ^^^^^^^^^^---^
  |                       |
  |                       in Rust 2018, closure captures all of `a`, but in Rust 2021, it only captures `a.0`
6 | }
  | - in Rust 2018, `a` would be dropped here, but in Rust 2021, only `a.0` would be dropped here alongside the closure
  |

help: add a dummy let to cause `a` to be fully captured
  |
20~     ($msg:expr $(,)?) => ({ let _ = &a;
21+         $crate::rt::begin_panic($msg)
22~     }),
  |
```

After:
```
warning: changes to closure capture in Rust 2021 will affect drop order
 --> src/main.rs:5:13
  |
5 |     let _ = || panic!(a.0);
  |             ^^^^^^^^^^---^
  |                       |
  |                       in Rust 2018, closure captures all of `a`, but in Rust 2021, it only captures `a.0`
6 | }
  | - in Rust 2018, `a` would be dropped here, but in Rust 2021, only `a.0` would be dropped here alongside the closure
  |
help: add a dummy let to cause `a` to be fully captured
  |
5 |     let _ = || { let _ = &a; panic!(a.0) };
  |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
2021-08-13 08:31:26 +00:00
bors
13d6c5c90c Auto merge of #87927 - spastorino:use-def-id-typeckresults, r=oli-obk
Make concrete_opaque_types be FxHashSet<DefId>

r? `@oli-obk`

`@bors` rollup=always
2021-08-13 02:49:45 +00:00
Roxane
7d0afaec5a Add missing multi variant cases 2021-08-12 21:33:06 -04:00
bors
0fa3190394 Auto merge of #87916 - nbdd0121:black_box, r=nagisa
Implement `black_box` using intrinsic

Introduce `black_box` intrinsic, as suggested in https://github.com/rust-lang/rust/pull/87590#discussion_r680468700.

This is still codegenned as empty inline assembly for LLVM. For MIR interpretation and cranelift it's treated as identity.

cc `@Amanieu` as this is related to inline assembly
cc `@bjorn3` for rustc_codegen_cranelift changes
cc `@RalfJung` as this affects MIRI

r? `@nagisa` I suppose
2021-08-12 21:04:07 +00:00
Aaron Hill
77b02eed7b
Prevent double panic when handling incremental fingerprint mismatch
When an incremental fingerprint mismatch occurs, we debug-print
our `DepNode` and query result. Unfortunately, the debug printing
process may cause us to run additional queries, which can result
in a re-entrant fingerprint mismatch error.

To avoid a double panic, this commit adds a thread-local variable
to detect re-entrant calls.
2021-08-12 15:11:39 -05:00
Gary Guo
64e1b63b25 Forbid ! from being used in asm! output 2021-08-12 20:28:35 +01:00
Mara Bos
26c590d1b3 Improve fallback span for closure migration lint. 2021-08-12 20:35:54 +02:00
Mara Bos
cd7f960314 Improve comment in closure migration code. 2021-08-12 20:35:39 +02:00
Manish Goregaokar
2d27976b8b
Rollup merge of #87965 - m-ou-se:non-fmt-panic-external, r=estebank
Silence non_fmt_panic from external macros.

This stops the non_fmt_panic lint from triggering if a macro from another crate is entirely responsible. In those cases there's nothing that the current crate can/should do.

See also https://github.com/rust-lang/rust/issues/87621#issuecomment-890311054
2021-08-12 10:04:16 -07:00
Manish Goregaokar
0c4e37ad5c
Rollup merge of #87953 - m-ou-se:closure-migration-multiline-formatting, r=petrochenkov
Improve formatting of closure capture migration suggestion for multi-line closures.

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

Before:
```
help: add a dummy let to cause `a` to be fully captured
  |
5 ~     let _ = || { let _ = &a;
6 +         dbg!(a.0);
7 ~     };
  |
```

After:
```
help: add a dummy let to cause `a` to be fully captured
  |
5 ~     let _ = || {
6 +         let _ = &a;
7 +         dbg!(a.0);
8 ~     };
  |
```
2021-08-12 10:04:15 -07:00
Manish Goregaokar
692833a28f
Rollup merge of #87922 - Manishearth:c-enum-target-spec, r=nagisa,eddyb
Add c_enum_min_bits target spec field, use for arm-none and thumb-none targets

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

<s>Haven't tested this yet, still playing around.</s>

This seems to fix the issue.
2021-08-12 10:04:14 -07:00
Manish Goregaokar
df23264f80
Rollup merge of #87916 - nbdd0121:black_box, r=nagisa
Implement `black_box` using intrinsic

Introduce `black_box` intrinsic, as suggested in https://github.com/rust-lang/rust/pull/87590#discussion_r680468700.

This is still codegenned as empty inline assembly for LLVM. For MIR interpretation and cranelift it's treated as identity.

cc `@Amanieu` as this is related to inline assembly
cc `@bjorn3` for rustc_codegen_cranelift changes
cc `@RalfJung` as this affects MIRI

r? `@nagisa` I suppose
2021-08-12 10:04:07 -07:00
Manish Goregaokar
4c0e424461 Apply c_enum_min_bits = 8 to (arm|thumb)-none- platforms 2021-08-12 09:44:16 -07:00
Manish Goregaokar
fd116c806a Add c_enum_min_bits to target spec 2021-08-12 09:44:16 -07:00
Mara Bos
f1860d1901 Include attributes in removal span for unused imports. 2021-08-12 17:35:52 +02:00
Gary Guo
1fb1643129 Implement black_box using intrinsic
The new implementation allows some `memcpy`s to be optimized away,
so the uninit value in ui/sanitize/memory.rs is constructed directly
onto the return place. Therefore the sanitizer now says that the
value is allocated by `main` rather than `random`.
2021-08-12 16:16:57 +01:00
hyd-dev
db138485b1
Adjust check_no_mangle and check_export_name to warn/error on #[no_mangle]/#[export_name] on trait methods 2021-08-12 22:02:22 +08:00
bors
4498e300e4 Auto merge of #87963 - GuillaumeGomez:rollup-e54sbez, r=GuillaumeGomez
Rollup of 4 pull requests

Successful merges:

 - #87819 (Use a more accurate span on assoc types WF checks)
 - #87863 (Fix Windows Command::env("PATH"))
 - #87885 (Link to edition guide instead of issues for 2021 lints.)
 - #87941 (Fix/improve rustdoc-js tool)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-08-12 13:24:29 +00:00
Aaron Hill
cfc3fee952
Revert "Rollup merge of #87779 - Aaron1011:stmt-ast-id, r=petrochenkov"
Fixes #87877

This change interacts badly with `noop_flat_map_stmt`,
which synthesizes multiple statements with the same `NodeId`.

I'm working on a better fix that will still allow us to
remove this special case. For now, let's revert the change
to fix the ICE.

This reverts commit a4262cc984, reversing
changes made to 8ee962f88e.
2021-08-12 08:24:22 -05:00
Mara Bos
079bf755a3 Detect fake spans in non_fmt_panic lint. 2021-08-12 14:56:41 +02:00
Mara Bos
a6da55c70e Silence non_fmt_panic from external macros. 2021-08-12 14:33:30 +02:00
Amanieu d'Antras
3fd463a5ca Add support for clobber_abi to asm! 2021-08-12 12:43:11 +01:00
Amanieu d'Antras
2f4612260d Mark RISC-V vector state as clobbered in inline assembly 2021-08-12 12:42:58 +01:00
Amanieu d'Antras
e9fb7bada1 Fix error message typo for pure asm without outputs 2021-08-12 12:42:58 +01:00
Guillaume Gomez
3d733f6785
Rollup merge of #87885 - m-ou-se:edition-guide-links, r=rylev
Link to edition guide instead of issues for 2021 lints.

This changes the 2021 lints to not link to github issues, but to the edition guide instead.

Fixes  #86996
2021-08-12 13:25:07 +02:00
Guillaume Gomez
0b950d3255
Rollup merge of #87819 - estebank:assoc-type-span, r=jackh726
Use a more accurate span on assoc types WF checks

Before
```
error[E0275]: overflow evaluating the requirement `<FooStruct as Foo>::A == _`
  --> $DIR/issue-21946.rs:8:5
   |
LL |     type A = <FooStruct as Foo>::A;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
after
```
error[E0275]: overflow evaluating the requirement `<FooStruct as Foo>::A == _`
  --> $DIR/issue-21946.rs:8:14
   |
LL |     type A = <FooStruct as Foo>::A;
   |              ^^^^^^^^^^^^^^^^^^^^^
```
2021-08-12 13:25:05 +02:00
bors
6bed1f0bc3 Auto merge of #87666 - ivmarkov:master, r=Amanieu
STD support for the ESP-IDF framework

Dear all,

This PR is implementing libStd support for the [ESP-IDF](https://github.com/espressif/esp-idf) newlib-based framework, which is the open source SDK provided by Espressif for their MCU family (esp32, esp32s2, esp32c3 and all other forthcoming ones).

Note that this PR has a [sibling PR](https://github.com/rust-lang/libc/pull/2310) against the libc crate, which implements proper declarations for all ESP-IDF APIs which are necessary for libStd support.

# Implementation approach

The ESP-IDF framework - despite being bare metal - offers a relatively complete POSIX API based on newlib. `pthread`, BSD sockets, file descriptors, and even a small file-system VFS layer. Perhaps the only significant exception is the lack of support for processes, which is to be expected of course on bare metal.

Therefore, the libStd support is implemented as a set of (hopefully small) changes to the `sys/unix` family of modules, in the form of conditional-compilation branches based either on `target_os = "espidf"` or in a couple of cases - based on `target_env = "newlib"` (the latter was already there actually and is not part of this patch).

The PR also contains two new targets:
- `riscv32imc-esp-espidf`
- `riscv32imac-esp-espidf`

... which are essentially copies of `riscv32imc-unknown-none-elf` and `riscv32imac-unknown-none-elf`, but enriched with proper `linker`, `linker_flavor`, `families`, `os`, `env` etc. specifications so that (a) the proper conditional compilation branches in libStd are selected when compiling with these targets and (b) the correct linker is used.

Since support for atomics is a precondition for libStd, the `riscv32imc-esp-espidf` target additionally is configured in such a way, so as to emit libcalls to the `__sync*` & `__atomic*` GCC functions, which are already implemented in the ESP-IDF framework. If this modification is not acceptable, we can also live with only the `riscv32imac-esp-espidf` target as well.  While the RiscV chips of Espressif lack native atomics support, the relevant instructions are transparently emulated in the ESP-IDF framework using invalid instruction trap. This modification was implemented specifically with Rust support in mind.

# Target maintainers

In case this PR eventually gets merged, you can list myself as a Target Maintainer.

More importantly, Espressif (the chip vendor) is now actively involved and [embracing](https://github.com/espressif/rust-esp32-example/blob/main/docs/rust-on-xtensa.md) all [Rust-related efforts](https://github.com/esp-rs) which were originally a community effort. In light of that, I suppose `@MabezDev` - who initiated the Rust-on-Espressif efforts back in time and who now works for Espressif won't object to being listed as a maintainer as well.

**EDIT:** I was hinted (thanks, `@Urgau)` that answering the Tier 3 policy explicitly might be helpful. Answers below.

# Tier 3 Target Policy - answers

> A proposed target or target-specific patch that substantially changes code shared with other targets (not just target-specific code) must be reviewed and approved by the appropriate team for that shared code before acceptance.

Hopefully, the changes introduced by the ESP-IDF libStd support are rather on the small side. They are completely contained within the `sys/unix` set of modules (that is, aside from the obviously necessary one-liners in the `unwind` crate and in `build.rs`).

> A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)

`@ivmarkov`
`@MabezDev`

> Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.

The two introduced targets follow as much as possible the naming conventions of the other targets. I.e. taking the bare-metal `riscv32imac_unknown_none_elf` as a base:
* The name of the new target was derived by replacing `none` with `espidf` to designate the `target_os`.
* `_elf` was removed, as the non-bare metal targets seem not to have it
* `-newlib` was deliberately NOT added at the end, as I believe the chance of having two simultaneously active separate targets for the ESP-IDF framework with different C libraries (say, newlib vs musl) is way too small
* Finally, we replaced the middle `unknown` with `esp` which is kind of the name of the whole chipset MCU family (and abbreviation from Espressif which is too long). It will stay `esp` for all RiscV32-based MCUs of the company, as they all use the riscv32imc instruction set. By necessity however (disambiguation), it will be `esp32` or `esp32s2` or `esp32s3` for the Xtensa-based MCUs as all of these have their own variation of the Xtensa architecture. (The Xtensa targets are not part of this PR, even though they would use 1:1 the same LibStd implementation provided here, as they depend on the upstreaming of the Xtensa architecture support in LLVM; this upstreaming this is currently in progress.)

There was also a preceding discussion on the topic [here](https://github.com/espressif/rust-esp32-example/issues/14).

> Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it.

We are explicitly putting an `-espidf` suffix to designate that the target is *specifically* for Rust + ESP-IDF

> Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.

Agreed.

> The target must not introduce license incompatibilities.

To the best of our knowledge, it doesn't.

> Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0).

MIT + Apache 2.0

> The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the tidy tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements.

Requirements are not changed for any other target.

> If the target supports building host tools (such as rustc or cargo), those host tools must not depend on proprietary (non-FOSS) libraries, other than ordinary runtime libraries supplied by the platform and commonly used by other binaries built for the target. For instance, rustc built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3.

The targets are for bare-metal environment which is not hosting build tools or a compiler.

> Targets should not require proprietary (non-FOSS) components to link a functional binary or library.

The linker used by the targets is the GCC linker from the GCC toolchain cross-compiled for riscv. GNU GPL.

> "onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are not limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users.
> Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.
> This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements.

Agreed.

> Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.

The targets implement libStd almost in its entirety, except for the missing support for process, as this is a bare metal platform. The process `sys\unix` module is currently stubbed to return "not implemented" errors.

> The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running tests (even if they do not pass), the documentation must explain how to run tests for the target, using emulation if possible or dedicated hardware if necessary.

Target does not (yet) support running tests. We would gladly provide all documentation how to build for the target (where?). It is currently hosted in this [README.md](https://github.com/ivmarkov/rust-esp32-std-hello) file, but will likely be moved to the [esp-rs](https://github.com/esp-rs) organization. Since the build for the target is driven by cargo and [all other tooling is downloaded automatically during the build](https://github.com/esp-rs/esp-idf-sys/blob/master/build.rs), there is no need for extensive documentation.

> Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via `@)` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.

Agreed.

> Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications.

Agreed.

> Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.

To the best of our knowledge, we believe we are not breaking any other target (be it tier 1, 2 or 3).

> In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target.

To the best of our knowledge, we have not introduced any unconditional use of a feature that affects any other target.

> If a tier 3 target stops meeting these requirements, or the target maintainers no longer have interest or time, or the target shows no signs of activity and has not built for some time, or removing the target would improve the quality of the Rust codebase, we may post a PR to remove it; any such PR will be CCed to the target maintainers (and potentially other people who have previously worked on the target), to check potential interest in improving the situation.

Agreed.
2021-08-12 10:33:14 +00:00
Esteban Küber
a0bf7d2cd3 Avoid ICE caused by suggestion
When suggesting dereferencing something that can be iterable in a `for`
loop, erase lifetimes and use a fresh `ty::ParamEnv` to avoid 'region
constraints already solved' panic.

Fix  #87657.
2021-08-12 10:24:01 +00:00
Esteban Kuber
3a515aec67 Use a more accurate span on assoc types WF checks 2021-08-12 10:02:36 +00:00
Mara Bos
945a4b18d9 Fix closure migration suggestion when the body is a macro. 2021-08-12 12:01:22 +02:00
Mara Bos
c3b4a1f9bf Improve formatting of closure capture migration suggestion. 2021-08-12 11:23:18 +02:00
hyd-dev
0bb2ea653e
Adjust #[no_mangle]-related checks and lints for impl items 2021-08-12 17:11:44 +08:00
hyd-dev
c84beefd83
Add associated functions that have custom linkage to reachable_set 2021-08-12 17:11:43 +08:00
bors
4e900176b6 Auto merge of #87948 - JohnTitor:rollup-efmgyl8, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #85835 (Implement Extend<(A, B)> for (Extend<A>, Extend<B>))
 - #87671 (Warn when an escaped newline skips multiple lines)
 - #87878 (⬆️ rust-analyzer)
 - #87903 (Reduce verbosity of tracing output of  RUSTC_LOG)
 - #87925 (Update books)
 - #87928 (Update cargo)
 - #87942 (set the executable bit on pre-commit.sh)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-08-12 07:28:15 +00:00
Yuki Okushi
4c632d9068
Rollup merge of #87903 - jackh726:logging-cleanup, r=oli-obk
Reduce verbosity of tracing output of  RUSTC_LOG

The current output is really hard to read, I find, for things like trait selection. I nearly always end up removing these calls locally.

r? ```@oli-obk``` since you originally authored this
2021-08-12 15:32:56 +09:00
Yuki Okushi
53a66acbd3
Rollup merge of #87671 - jesyspa:issue-87319-multiple-newlines, r=estebank
Warn when an escaped newline skips multiple lines

Resolves #87319
2021-08-12 15:32:54 +09:00
bors
eb2226b1f1 Auto merge of #85296 - bjorn3:plugin_cleanup, r=petrochenkov
Plugin interface cleanup

The first commit performs two uncontroversial cleanups. The second commit removes `#[plugin_registrar]` and instead requires you to export a `__rustc_plugin_registrar` function, this will require a change to servo's script_plugins (cc `@jdm)`
2021-08-12 04:30:41 +00:00
Santiago Pastorino
0aa0d59e51
Make concrete_opaque_types be FxHashSet<DefId> 2021-08-11 09:48:25 -03:00
Anton Golov
07aacf53c5 Renamed variable str -> tail for clarity 2021-08-11 13:57:28 +02:00
Esteban Küber
99f2977031 Modify structured suggestion output
* On suggestions that include deletions, use a diff inspired output format
* When suggesting addition, use `+` as underline
* Color highlight modified span
2021-08-11 09:46:24 +00:00
Anton Golov
a03fbfe2ff Warn when an escaped newline skips multiple lines 2021-08-11 11:35:08 +02:00
bors
d488de82f3 Auto merge of #87587 - oli-obk:lazy_tait, r=spastorino
Various refactorings of the TAIT infrastructure

Before this PR we used to store the opaque type knowledge outside the `InferCtxt`, so it got recomputed on every opaque type instantiation.

I also removed a feature gate check that makes no sense in the planned lazy TAIT resolution scheme

Each commit passes all tests, so this PR is best reviewed commit by commit.

r? `@spastorino`
2021-08-11 05:14:45 +00:00
bors
47b41b7788 Auto merge of #87254 - rusticstuff:rustc_codegen_llvm_dont_emit_zero_sized_padding, r=eddyb
LLVM codegen: Don't emit zero-sized padding for fields

Currently padding is emitted before fields of a struct and at the end of the struct regardless of the ABI. Even if no padding is required zero-sized padding fields are emitted. This is not useful and - more importantly - it make it impossible to generate the exact vector types that LLVM expects for certain ARM SIMD intrinsics. This change should unblock the implementation of many ARM intrinsics using the `unadjusted` ABI, see https://github.com/rust-lang/stdarch/issues/1143#issuecomment-827404092.

This is a proof of concept only because the field lookup now takes O(number of fields) time compared to O(1) before since it recalculates the mapping at every lookup. I would like to find out how big the performance impact actually is before implementing caching or restricting this behavior to the `unadjusted` ABI.

cc `@SparrowLii` `@bjorn3`

([Discussion on internals](https://internals.rust-lang.org/t/feature-request-add-a-way-in-rustc-for-generating-struct-type-llvm-ir-without-paddings/15007))
2021-08-11 01:36:23 +00:00
Yuki Okushi
4be63b2b5c
Rollup merge of #87895 - TheWastl:issue-87872, r=estebank
typeck: don't suggest inaccessible fields in struct literals and suggest ignoring inaccessible fields in struct patterns

Fixes #87872.

This PR adjusts the missing field diagnostic logic in typeck so that when any of the missing fields in a struct literal or pattern is inaccessible then the error is less confusing, even if some of the missing fields are accessible.

See also #76524.
2021-08-11 04:18:47 +09:00
Yuki Okushi
4d4915ae48
Rollup merge of #87889 - estebank:method-call-disambiguate, r=oli-obk
Use smaller spans when suggesting method call disambiguation

Use smaller spans when suggesting method call disambiguation.
2021-08-11 04:18:46 +09:00
Yuki Okushi
e72754dc59
Rollup merge of #87880 - pierwill:graph-duplicate-trait-bound, r=LeSeulArtichaut
Remove duplicate trait bounds in `rustc_data_structures::graph`

Remove duplicate trait bounds in `rustc_data_structures::graph`.
2021-08-11 04:18:44 +09:00
Yuki Okushi
6c92656624
Rollup merge of #87854 - BoxyUwU:var-None, r=oli-obk
correctly handle enum variants in `opt_const_param_of`

Fixes #87542

`opt_const_param_of` was returning `None` for args on an enum variant `Enum::Variant::<10>` because we called `generics_of` on the enum variant which has no generics.

r? `@oli-obk`
2021-08-11 04:18:39 +09:00
Yuki Okushi
bcef40e5fb
Rollup merge of #87811 - estebank:issue-87549, r=oli-obk
Do not ICE on HIR based WF check when involving lifetimes

Fix #87549.
2021-08-11 04:18:37 +09:00
Yuki Okushi
4442806626
Rollup merge of #87700 - kornelski:e530text, r=oli-obk
Expand explanation of E0530

The explanation didn't cover a puzzling case of enum variants missing fields.
2021-08-11 04:18:36 +09:00
Yuki Okushi
43b7cad3e5
Rollup merge of #87582 - tmiasko:symbol-printer, r=michaelwoerister
Implement `Printer` for `&mut SymbolPrinter`

to avoid passing `SymbolPrinter` by value.
2021-08-11 04:18:33 +09:00
TheWastl
cda6ecfc3d typeck: better diagnostics for missing inaccessible fields in struct literals/patterns
- typeck/expr: don't suggest adding fields in struct literals with inaccessible fields
- typeck/pat: suggest ignoring inaccessible fields in struct patterns
2021-08-10 16:18:37 +02:00
bjorn3
a501308ec1 Replace #[plugin_registrar] with exporting __rustc_plugin_registrar 2021-08-10 14:20:48 +02:00
Oli Scherer
93c4aa80b8 Don't collect into a Vec that is immediately being iterated on again. 2021-08-10 11:03:10 +00:00
ivmarkov
459eaa6bae STD support for the ESP-IDF framework 2021-08-10 12:09:00 +03:00
jackh726
62b8a5ef04 Reduce verbosity of RUSTC_LOG 2021-08-09 21:39:39 -04:00
Esteban Kuber
f3021b3561 Use smaller spans when suggesting method call disambiguation 2021-08-09 16:47:09 +00:00
Mara Bos
260f9b9e91 Link to edition guide instead of issues for 2021 lints. 2021-08-09 17:45:01 +02:00
Hans Kratz
02295f464a Test: Use smallvec directly instead of boxed. 2021-08-09 15:42:37 +00:00
pierwill
3e123e4150 Remove duplicate trait bounds in rustc_data_structures::graph 2021-08-09 08:52:04 -05:00
bors
ae90dcf020 Auto merge of #85357 - Andy-Python-Programmer:aarch64_uefi_target, r=petrochenkov
Add `aarch64-unknown-uefi` target

This pull request adds the `aarch64-unknown-uefi` target.
2021-08-09 13:16:51 +00:00
Hans Kratz
1d4972e0e9 Avoid unnecessary allocation. 2021-08-09 12:59:23 +00:00
Hans Kratz
c1d0f0a65c TEST: Use SmallVec<[u32; 4]> for field projection. 2021-08-09 12:25:33 +00:00
Hans Kratz
c627c0d88b Fix nits. 2021-08-09 12:08:18 +00:00
Esteban Küber
f93cbedade Do not ICE on HIR based WF check when involving lifetimes
Fix #87549.
2021-08-09 07:01:35 +00:00
unknown
44b81fb8fc
Add the aarch64-unknown-uefi target
* This commit adds the aarch64-unknown-uefi target and also adds it into
the supported targets list under the tier-3 target table.
* Uses the small code model by default

Signed-off-by: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
2021-08-09 16:49:04 +10:00
bors
7b52ad00cb Auto merge of #87619 - 12101111:fix-native_link_modifiers_bundle, r=petrochenkov
Fix feature gate checking of static-nobundle and native_link_modifiers

Feature native_link_modifiers_bundle don't need feature static-nobundle
to work.

Also check the feature gates when using native_link_modifiers from command line options. Current nighly compiler don't check those feature gate.

```
> touch lib.rs
> rustc +nightly lib.rs -L /usr/lib -l static:+bundle=dl --crate-type=rlib
> rustc +nightly lib.rs -L /usr/lib -l dylib:+as-needed=dl --crate-type=dylib -Ctarget-feature=-crt-static
> rustc +nightly lib.rs -L /usr/lib -l static:-bundle=dl --crate-type=rlib
error[E0658]: kind="static-nobundle" is unstable
  |
  = note: see issue #37403 <https://github.com/rust-lang/rust/issues/37403> for more information
  = help: add `#![feature(static_nobundle)]` to the crate attributes to enable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.

```

First found this in https://github.com/rust-lang/rust/pull/85600#discussion_r676612655
2021-08-09 03:59:30 +00:00
bors
d3928b183d Auto merge of #87465 - audunhalland:refactor_typeck_primary_body_of, r=eddyb
Simplify typeck/primary_body_of, fix comment to match return signature

Hi, new contributor here! I'm carefully reading through the various modules just to learn. I noticed this function, `primary_body_of`, which has gone through a couple of refactors over time, adding new `Option`s to its returned tuple. Observations:

1. the `fn`'s documentation was not all up to date with the the current return signature.
2. `FnHeader` and `FnDecl` are always both `Some` or `None`. So I figured it might just return a reference to the full `hir::FnSig`, for simplicity and more precise typing. It's a pure refactor.

I'm learning better by working with code than just reading it, so here goes! If you want to avoid pure refactor PRs that don't really fix anything, I can revert the code change to only update the comment instead.
2021-08-09 01:08:52 +00:00
bors
74a11c63f8 Auto merge of #87235 - poliorcetics:issue-87217-fn-quali-order, r=nagisa
Improve diagnostics for wrongly ordered keywords in function declaration

Fix #87217

`@rustbot` label A-diagnostics T-compiler
2021-08-08 22:28:01 +00:00
bors
442e627bee Auto merge of #87697 - GuillaumeGomez:add-e0784, r=nagisa
Assign E0784 error code for union expression errors
2021-08-08 16:40:14 +00:00
12101111
d935a14f4c
Fix feature gate checking of static-nobundle and native_link_modifiers 2021-08-08 21:46:40 +08:00
bors
c4c2986c49 Auto merge of #87815 - BoxyUwU:cec-generics-of-ice, r=eddyb
encode `generics_of` for fields and ty params

Fixes #87674
Fixes #87603

ICE was caused by calling `generics_of` on a `DefId` without any `generics_of` results. This was happening when we call `generics_of` on parent `DefId`s of an unevaluated const when we evaluate it.

r? `@lcnr`
2021-08-08 07:15:48 +00:00
bors
2d10c2a330 Auto merge of #87798 - durin42:llvm-14, r=nikic
PassWrapper: handle move of OptimizationLevel class out of PassBuilder

This is the first build break of the LLVM 14 cycle, and was caused by
https://reviews.llvm.org/D107025. Mercifully an easy fix.
2021-08-08 04:33:22 +00:00
bors
798446fe06 Auto merge of #87772 - npmccallum:naked_abi, r=Amanieu
Move naked function ABI check to its own lint

This check was previously categorized under the lint named
`UNSUPPORTED_NAKED_FUNCTIONS`. That lint is future incompatible and will
be turned into an error in a future release. However, as defined in the
Constrained Naked Functions RFC, this check should only be a warning.
This is because it is possible for a naked function to be implemented in
such a way that it does not break even the undefined ABI. For example, a
`jmp` to a `const`.

Therefore, this patch defines a new lint named
`UNDEFINED_NAKED_FUNCTION_ABI` which contains just this single check.
Unlike `UNSUPPORTED_NAKED_FUNCTIONS`, `UNDEFINED_NAKED_FUNCTION_ABI`
will not be converted to an error in the future.

rust-lang/rfcs#2774
rust-lang/rfcs#2972
2021-08-07 23:24:15 +00:00
bors
574d375680 Auto merge of #87743 - cuviper:opaque-calls, r=nikic
Prepare call/invoke for opaque pointers

Rather than relying on `getPointerElementType()` from LLVM function
pointers, we now pass the function type explicitly when building `call`
or `invoke` instructions.
2021-08-07 20:43:25 +00:00
Ellen
5f61271e38 fmt 2021-08-07 20:55:37 +01:00
Ellen
d777cb84e2 less opt in const param of 2021-08-07 18:44:36 +01:00
Erik Desjardins
585e4ae6e1 Run RemoveZsts at mir-opt-level=1
Effectively reverts commit 6960bc9696.
2021-08-07 11:20:46 -04:00
Nathaniel McCallum
4968537780 Fix naked function test run on non-x86_64 2021-08-07 11:17:03 -04:00
bors
996ff2e0a0 Auto merge of #87408 - kornelski:try_reserve_error, r=yaahc
Hide allocator details from TryReserveError

I think there's [no need for TryReserveError to carry detailed information](https://github.com/rust-lang/rust/issues/48043#issuecomment-825139280), but I wouldn't want that issue to delay stabilization of the `try_reserve` feature.

So I'm proposing to stabilize `try_reserve` with a `TryReserveError` as an opaque structure, and if needed, expose error details later.

This PR moves the `enum` to an unstable inner `TryReserveErrorKind` that lives under a separate feature flag. `TryReserveErrorKind` could possibly be left as an implementation detail forever, and the `TryReserveError` get methods such as `allocation_size() -> Option<usize>` or `layout() -> Option<Layout>` instead, or the details could be dropped completely to make try-reserve errors just a unit struct, and thus smaller and cheaper.
2021-08-07 01:26:15 +00:00
Augie Fackler
482f1901b0 PassWrapper: handle move of OptimizationLevel class out of PassBuilder
This is the first build break of the LLVM 14 cycle, and was caused by
https://reviews.llvm.org/D107025. Mercifully an easy fix.
2021-08-06 18:08:04 -04:00
Yuki Okushi
0de0b88fea
Rollup merge of #87816 - bjorn3:sync_cg_clif-2021-08-06, r=bjorn3
Sync rustc_codegen_cranelift

05677b6bd6 removes two assertions that should have been removed in https://github.com/rust-lang/rust/pull/87515. They are no longer correct and trigger while compiling the sysroot.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2021-08-07 01:46:37 +09:00
Yuki Okushi
a4262cc984
Rollup merge of #87779 - Aaron1011:stmt-ast-id, r=petrochenkov
Remove special case for statement `NodeId` assignment

We now let `noop_flat_map_stmt` assign `NodeId`s (via `visit_id`),
just as we do for other AST nodes.
2021-08-07 01:46:34 +09:00
Yuki Okushi
8ee962f88e
Rollup merge of #87775 - Kobzol:single-associated-item-hint, r=oli-obk
Add hint for unresolved associated trait items if the trait has a single item

This PR introduces a special-cased hint for unresolved trait items paths. It is shown if:
- the path was not resolved to any existing trait item
- and no existing trait item's name was reasonably close with regard to edit distance
- and the trait only has a single item in the corresponding namespace

I didn't know where I should put tests, therefore so far I just managed to bless two existing tests. I would be glad for hints where should tests for a hint like this be created, how should they be named (with reference to the original issue?) and what tests should I create (is it enough to test it just for types? or create separate tests also for functions and constants?).

It could also be turned into a machine applicable suggestion I suppose.

This is my first `rustc` PR, so please go easy on me :)

Fixes: https://github.com/rust-lang/rust/issues/87638
2021-08-07 01:46:33 +09:00