Commit Graph

11498 Commits

Author SHA1 Message Date
xFrednet
43dc430f52
Test expect with forbid and fix doc errors (RFC-2383)
* Add test to expect and the forbid a lint (RFC 2383)
2022-03-02 17:46:09 +01:00
xFrednet
aa2a0a83d9
Expect each lint in attribute individually (RFC-2383) 2022-03-02 17:46:09 +01:00
xFrednet
a9bf9eaef5
Add UI tests for the expect attribute (RFC-2383)
* Add UI tests with macros for the `expect` attribute (RFC-2383)
* Addressed review comments - mostly UI test updates (RFC-2383)
* Documented lint level attribute on macro not working bug (RFC-2383)
  See `rust#87391`
2022-03-02 17:46:08 +01:00
xFrednet
33a5945069
Make LintExpectationId stable between compilation sessions (RFC-2383) 2022-03-02 17:46:08 +01:00
xFrednet
44cb8fa482
Check lint expectations and emit lint if unfulfilled (RFC-2383) 2022-03-02 17:46:07 +01:00
xFrednet
2ca9037b61
Set LintExpectationId in level and collect fulfilled ones (RFC-2383)
* Collect lint expectations and set expectation ID in level (RFC-2383)
* Collect IDs of fulfilled lint expectations from diagnostics (RFC 2383)
2022-03-02 17:46:07 +01:00
xFrednet
f467a58b7b
Added unfulfilled_lint_expectations lint for (RFC-2383) 2022-03-02 17:46:06 +01:00
xFrednet
9fef3d9e0a
Added Expect lint level and attribute (RFC-2383)
* Also added the `LintExpectationId` which will be used in future commits
2022-03-02 17:46:05 +01:00
bors
c42d846add Auto merge of #94229 - erikdesjardins:rem2, r=nikic
Remove LLVM attribute removal

This was necessary before, because `declare_raw_fn` would always apply
the default optimization attributes to every declared function.
Then `attributes::from_fn_attrs` would have to remove the default
attributes in the case of, e.g. `#[optimize(speed)]` in a `-Os` build.
(see [`src/test/codegen/optimize-attr-1.rs`](03a8cc7df1/src/test/codegen/optimize-attr-1.rs (L33)))

However, every relevant callsite of `declare_raw_fn` (i.e. where we
actually generate code for the function, and not e.g. a call to an
intrinsic, where optimization attributes don't [?] matter)
calls `from_fn_attrs`, so we can remove the attribute setting
from `declare_raw_fn`, and rely on `from_fn_attrs` to apply the correct
attributes all at once.

r? `@ghost` (blocked on #94221)
`@rustbot` label S-blocked
2022-03-02 08:48:33 +00:00
bors
2a280de64f Auto merge of #94514 - matthiaskrgr:rollup-pdzn82h, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #94464 (Suggest adding a new lifetime parameter when two elided lifetimes should match up for traits and impls.)
 - #94476 (7 - Make more use of `let_chains`)
 - #94478 (Fix panic when handling intra doc links generated from macro)
 - #94482 (compiler: fix some typos)
 - #94490 (Update books)
 - #94496 (tests: accept llvm intrinsic in align-checking test)
 - #94498 (9 - Make more use of `let_chains`)
 - #94503 (Provide C FFI types via core::ffi, not just in std)
 - #94513 (update Miri)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-03-02 05:32:00 +00:00
Matthias Krüger
1ff654af39
Rollup merge of #94498 - c410-f3r:chega-ja-deu, r=Dylan-DPC
9 - Make more use of `let_chains`

Continuation of #94376.

cc #53667
2022-03-02 04:30:11 +01:00
Matthias Krüger
cd6e53d926
Rollup merge of #94482 - cuishuang:master, r=Dylan-DPC
compiler: fix some typos
2022-03-02 04:30:09 +01:00
Matthias Krüger
42596a71d6
Rollup merge of #94476 - c410-f3r:yet-more-let-chains, r=Dylan-DPC
7 - Make more use of `let_chains`

Continuation of #94376.

cc #53667
2022-03-02 04:30:06 +01:00
Matthias Krüger
2b72ecbb42
Rollup merge of #94464 - kckeiks:lifetime-elision-mismatch-hint-for-traits, r=estebank
Suggest adding a new lifetime parameter when two elided lifetimes should match up for traits and impls.

Suggest adding a new lifetime parameter when two elided lifetimes should match up for functions in traits and impls.

Issue #94462
2022-03-02 04:30:04 +01:00
bors
39a3b52767 Auto merge of #87402 - nagisa:nagisa/request-feature-requests-for-features, r=estebank
Direct users towards using Rust target feature names in CLI

This PR consists of a couple of changes on how we handle target features.

In particular there is a bug-fix wherein we avoid passing through features that aren't prefixed by `+` or `-` to LLVM. These appear to be causing LLVM to assert, which is pretty poor a behaviour (and also makes it pretty clear we expect feature names to be prefixed).

The other commit, I anticipate to be somewhat more controversial is outputting a warning when users specify a LLVM-specific, or otherwise unknown, feature name on the CLI. In those situations we request users to either replace it with a known Rust feature name (e.g. `bmi` -> `bmi1`) or file a feature request. I've a couple motivations for this: first of all, if users are specifying these features on the command line, I'm pretty confident there is also a need for these features to be usable via `#[cfg(target_feature)]` machinery.  And second, we're growing a fair number of backends recently and having ability to provide some sort of unified-ish interface in this place seems pretty useful to me.

Sponsored by: standard.ai
2022-03-02 03:03:22 +00:00
Caio
a7b4d667fe 9 - Make more use of let_chains
Continuation of #94376.

cc #53667
2022-03-01 18:34:35 -03:00
Fausto
270730f514 add suggestion to update trait if error is in impl 2022-03-01 13:00:02 -05:00
cuishuang
eb2b9441e7 compiler: fix some typos 2022-03-01 20:02:47 +08:00
bors
f0c4da4998 Auto merge of #94477 - matthiaskrgr:rollup-8h29qek, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #94359 (Fix inconsistent symbol mangling of integers constants with -Zverbose)
 - #94465 (6 - Make more use of `let_chains`)
 - #94470 (⬆️ rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-03-01 11:24:10 +00:00
Matthias Krüger
a0baf252b2
Rollup merge of #94465 - c410-f3r:more-let-chains, r=Dylan-DPC
6 - Make more use of `let_chains`

Continuation of #94376.

cc #53667
2022-03-01 12:00:44 +01:00
Matthias Krüger
c531b01e9d
Rollup merge of #94359 - tmiasko:legacy-verbose-const, r=petrochenkov
Fix inconsistent symbol mangling of integers constants with -Zverbose

The `PrettyPrinter` changes formatting of array size and integer
constants based on `-Zverbose`, so its implementation cannot be used in
legacy symbol mangling.

Example symbol demangling before changes:

```console
$ cat a.rs
pub struct A<T>(T);
impl A<[u8; 128]> { pub fn f() {} }
$ rustc --crate-type=lib a.rs -Zverbose=n && nm -C ./liba.rlib
00000000 T a::A<[u8; 128]>::f
$ rustc --crate-type=lib a.rs -Zverbose=y && nm -C ./liba.rlib
00000000 T a::A<[u8; Const { ty. usize, val. Value(Scalar(0x0000000000000080)) }]>::f
```
2022-03-01 12:00:43 +01:00
Caio
7aa5ea9a4a 7 - Make more use of let_chains
Continuation of #94376.

cc #53667
2022-03-01 07:43:12 -03:00
bors
4a56cbec59 Auto merge of #94402 - erikdesjardins:revert-coldland, r=nagisa
Revert "Auto merge of #92419 - erikdesjardins:coldland, r=nagisa"

Should fix (untested) #94390

Reopens #46515, #87055

r? `@ehuss`
2022-03-01 08:57:46 +00:00
bors
6e5a6ffb14 Auto merge of #94471 - matthiaskrgr:rollup-ffz65qt, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #94438 (Check method input expressions once)
 - #94459 (Update cargo)
 - #94470 (⬆️ rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-03-01 06:15:54 +00:00
Matthias Krüger
2353e835c5
Rollup merge of #94438 - compiler-errors:check-method-inputs-once, r=davidtwco
Check method input expressions once

If the user mistakenly forgets to wrap their method args in a tuple, then the compiler tries to check that  types within the tuple match the expression args. This means we call `check_expr` once within this diagnostic code, so when we check the expr once again in `demand_compatible`, we attempt to apply expr adjustments twice, leading to ICEs.

This PR attempts to fix this by skipping the expression type check in `demand_compatible` if we have detected an method arg mismatch at all.

This does lead to a single UI test regressing slightly, due to a diagnostic disappearing, though I don't know if it is generally meaningful to even raise an type error after noting that the argument count is incorrect in a function call, since the user might be providing (in-context) meaningless expressions to the wrong method.

I can adjust this to be a bit more targeted (to just skip checking exprs in `demand_compatible` in the tuple case) if this UI test regression is a problem.

fixes #94334
cc #94291

Also drive-by fixup of `.node_type(expr.hir_id)` to `.expr_ty(expr)`, since that method exists.
2022-03-01 06:22:32 +01:00
Dylan DPC
bf6954b2fc
Rollup merge of #94448 - c410-f3r:yet-more-let-chains, r=estebank
5 - Make more use of `let_chains`

Continuation of #94376.

cc #53667
2022-03-01 03:41:52 +01:00
Dylan DPC
daed86445d
Rollup merge of #93926 - PatchMixolydic:bugfix/must_use-on-exprs, r=cjgillot
Lint against more useless `#[must_use]` attributes

This expands the existing `#[must_use]` check in `unused_attributes` to lint against pretty much everything `#[must_use]` doesn't support.
Fixes #93906.
2022-03-01 03:41:49 +01:00
Dylan DPC
4bd40d67d8
Rollup merge of #91545 - compiler-errors:deref-suggestion-improvements, r=estebank
Generalize "remove `&`"  and "add `*`" suggestions to more than one deref

Suggest removing more than one `&` and `&mut`, along with suggesting adding more than one `*` (or a combination of the two).

r? `@estebank`
(since you're experienced with these types of suggestions, feel free to reassign)
2022-03-01 03:41:46 +01:00
Caio
fe94f78b9b 6 - Make more use of let_chains
Continuation of #94376.

cc #53667
2022-02-28 21:12:52 -03:00
Simonas Kazlauskas
df701a292c Querify global_backend_features
At the very least this serves to deduplicate the diagnostics that are
output about unknown target features provided via CLI.
2022-03-01 01:57:25 +02:00
Simonas Kazlauskas
c97c216efd Direct users towards using Rust feature names in CLI
If they are trying to use features rustc doesn't yet know about,
request a feature request.

Additionally, also warn against using feature names without leading `+`
or `-` signs.
2022-03-01 01:57:10 +02:00
bors
8d6f527530 Auto merge of #94299 - oli-obk:stable_hash_ty, r=michaelwoerister
Caching the stable hash of Ty within itself

Instead of computing stable hashes on types as needed, we compute it during interning.

This way we can, when a hash is requested, just hash that hash, which is significantly faster than traversing the type itself.

We only do this for incremental for now, as incremental is the only frequent user of stable hashing.

As a next step we can try out

* moving the hash and TypeFlags to Interner, so projections and regions get the same benefit (tho regions are not nested, so maybe that's not a good idea? Would be nice for dedup tho)
* start comparing types via their stable hash instead of their address?
2022-02-28 23:38:05 +00:00
Fausto
abcccc9143 Suggest adding a new lifetime parameter when two elided lifetimes should match up for traits and impls.
Issue #94462
2022-02-28 18:16:19 -05:00
Tomasz Miąsko
99a77798d3 Fix inconsistent symbol mangling of integers constants with -Zverbose
The `PrettyPrinter` changes formatting of array size and integer
constants based on `-Zverbose`, so its implementation cannot be used in
legacy symbol mangling.
2022-02-28 21:48:42 +01:00
Matthias Krüger
34657ccbe7
Rollup merge of #94449 - GuillaumeGomez:explanation-e0726, r=Urgau
Add long explanation for E0726

This is the cleaned up version of #87655 with the missing fixes.

Part of https://github.com/rust-lang/rust/issues/61137.

r? `@Urgau`
2022-02-28 20:05:18 +01:00
Matthias Krüger
5be38d2bb3
Rollup merge of #94445 - c410-f3r:more-let-chains, r=cjgillot
4 - Make more use of `let_chains`

Continuation of #94376.

cc #53667
2022-02-28 20:05:17 +01:00
Matthias Krüger
975a0e0141
Rollup merge of #94414 - DrMeepster:box_alloc_ice2, r=tmiasko
Fix ICE when using Box<T, A> with large A

A sequel to #94043 that fixes #81270 and #92054 (duplicate).
2022-02-28 20:05:15 +01:00
Matthias Krüger
934079180d
Rollup merge of #94248 - compiler-errors:fix-while-loop-bad-delay, r=petrochenkov
Fix ICE when passing block to while-loop condition

We were incorrectly delaying a bug when we passed _any_ block (that evaluated to `()`) to a while loop. This PR makes the check a bit more sophisticated.

We should only suppress the error here in cases that are equivalent to those we find in #93574 (i.e. only while loop conditions that have destructuring assignment expressions in them).

Fixes #93997
cc `@estebank` who added this code

I would not be opposed to removing the delay-bug altogether, and just emitting this error always. I much prefer duplicate errors over no errors.
2022-02-28 20:05:14 +01:00
Caio
d956c8b816 5 - Make more use of let_chains 2022-02-28 15:52:36 -03:00
Esteban Kuber
f42b4f595e Tweak diagnostics
* Recover from invalid `'label: ` before block.
* Make suggestion to enclose statements in a block multipart.
* Point at `match`, `while`, `loop` and `unsafe` keywords when failing
  to parse their expression.
* Do not suggest `{ ; }`.
* Do not suggest `|` when very unlikely to be what was wanted (in `let`
  statements).
2022-02-28 18:22:45 +00:00
Guillaume Gomez
911de7b98c Add explanation for E0726 2022-02-28 15:51:05 +01:00
bors
97cde9fe08 Auto merge of #94447 - matthiaskrgr:rollup-d8rj2xv, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #89793 (Add `slice::{from_ptr_range, from_mut_ptr_range} `)
 - #92642 (Update search location from a relative path to absolute)
 - #93389 (regression for issue 90847)
 - #93413 (Fix broken link from rustdoc docs to ayu theme)
 - #94365 (Fix MinGW target detection in raw-dylib)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-02-28 14:20:13 +00:00
Matthias Krüger
ea39f46cad
Rollup merge of #94365 - mati865:fix-mingw-detection-for-rawdylib, r=michaelwoerister
Fix MinGW target detection in raw-dylib

LLVM target doesn't have to be the same as Rust target so relying on it is wrong.

It was one of concerns in https://github.com/rust-lang/rust/pull/88801 that was not fixed in https://github.com/rust-lang/rust/pull/90782.
2022-02-28 12:57:48 +01:00
bors
edda7e959d Auto merge of #94216 - psumbera:sparc64-abi-fix2, r=nagisa
more complete sparc64 ABI fix for aggregates with floating point members

Previous fix didn't handle nested structures at all.
2022-02-28 11:54:17 +00:00
Caio
e3e902bb06 4 - Make more use of let_chains
Continuation of #94376.

cc #53667
2022-02-28 07:49:56 -03:00
bors
48132caac2 Auto merge of #94427 - cjgillot:inline-fresh-expn, r=oli-obk
Only create a single expansion for each inline integration.

The inlining integrator used to create one expansion for each span from the callee body.
This PR reverses the logic to create a single expansion for the whole call,
which is more consistent with how macro expansions work for macros.

This should remove the large memory regression in #91743.
2022-02-28 08:25:26 +00:00
bors
427cf81206 Auto merge of #94158 - erikdesjardins:more-more-noundef, r=nikic
Apply noundef metadata to loads of types that do not permit raw init

This matches the noundef attributes we apply on arguments/return types.

Fixes (partially) #74378.
2022-02-28 06:11:20 +00:00
Erik Desjardins
dce14cfacc Remove LLVM attribute removal
This was necessary before, because `declare_raw_fn` would always apply
the default optimization attributes to every declared function,
and then `attributes::from_fn_attrs` would have to remove the default
attributes in the case of, e.g. `#[optimize(speed)]` in a `-Os` build.

However, every relevant callsite of `declare_raw_fn` (i.e. where we
actually generate code for the function, and not e.g. a call to an
intrinsic, where optimization attributes don't [?] matter)
calls `from_fn_attrs`, so we can simply remove the attribute setting
from `declare_raw_fn`, and rely on `from_fn_attrs` to apply the correct
attributes all at once.
2022-02-28 00:02:11 -05:00
DrMeepster
d316aba04c expadn abi check + condese & fix tests 2022-02-27 20:25:16 -08:00
Erik Desjardins
851fcc7a54 Revert "Auto merge of #92419 - erikdesjardins:coldland, r=nagisa"
This reverts commit 4f49627c6f, reversing
changes made to 028c6f1454.
2022-02-27 23:11:03 -05:00