Commit graph

160417 commits

Author SHA1 Message Date
inquisitivecrystal
486585242e Do not resolve blocks in foreign functions 2022-01-05 15:22:22 -08:00
bors
8baeddfe8f Auto merge of #92437 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`
2021-12-31 00:07:29 +00:00
bors
a09f775e5a Auto merge of #92426 - calebcartwright:sync-rustfmt-subtree, r=calebcartwright
Sync rustfmt subtree

r? `@ghost`

Mostly refactoring and a few minor lint fixes, along with a couple small bug fixes
2021-12-30 20:53:39 +00:00
bors
b60e32c828 Auto merge of #92434 - matthiaskrgr:rollup-m8wuq0v, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #91519 (ast: Avoid aborts on fatal errors thrown from mutable AST visitor)
 - #92414 (Fix spacing of pretty printed const item without body)
 - #92423 (Add UI test for #92292)
 - #92427 (Use `UnsafeCell::get_mut()` in `core::lazy::OnceCell::get_mut()`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-30 14:52:50 +00:00
flip1995
4bb6fde5f9
Merge commit '0eff589afc83e21a03a168497bbab6b4dfbb4ef6' into clippyup 2021-12-30 15:10:43 +01:00
bors
0eff589afc Auto merge of #8196 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2021-12-30 13:22:47 +00:00
flip1995
b0f9894491
Bump nightly version -> 2021-12-30 2021-12-30 14:18:01 +01:00
flip1995
e45842e360
Merge remote-tracking branch 'upstream/master' into rustup 2021-12-30 14:17:53 +01:00
Matthias Krüger
c10fe04484
Rollup merge of #92427 - ChayimFriedman2:patch-1, r=kennytm
Use `UnsafeCell::get_mut()` in `core::lazy::OnceCell::get_mut()`

This removes one unnecessary `unsafe` block.
2021-12-30 13:12:36 +01:00
Matthias Krüger
a23ef617b3
Rollup merge of #92423 - weirane:ui-92292, r=fee1-dead
Add UI test for #92292

Closes #92292
2021-12-30 13:12:35 +01:00
Matthias Krüger
e810487b4d
Rollup merge of #92414 - dtolnay:constnoexpr, r=oli-obk
Fix spacing of pretty printed const item without body

Follow-up to #92238 fixing one of the FIXMEs.

```rust
macro_rules! repro {
    ($item:item) => {
        stringify!($item)
    };
}

fn main() {
    println!("{}", repro!(extern "C" { static S: i32; }));
}
```

Before: `extern "C" { static S: i32 ; }`
After: `extern "C" { static S: i32; }`
2021-12-30 13:12:34 +01:00
Matthias Krüger
b9f7197ab3
Rollup merge of #91519 - petrochenkov:cratexp2, r=Aaron1011
ast: Avoid aborts on fatal errors thrown from mutable AST visitor

Set the node to some dummy value and rethrow the error instead.

When using the old aborting `visit_clobber` in `InvocationCollector::visit_crate` the next tests abort due to fatal errors:
```
ui\modules\path-invalid-form.rs
ui\modules\path-macro.rs
ui\modules\path-no-file-name.rs
ui\parser\issues\issue-5806.rs
ui\parser\mod_file_with_path_attr.rs
```

Follow up to https://github.com/rust-lang/rust/pull/91313.
2021-12-30 13:12:33 +01:00
bors
f8d4ee7c7a Auto merge of #89336 - Aaron1011:variance-struct-diag, r=cjgillot
Refactor variance diagnostics to work with more types

Instead of special-casing mutable pointers/references, we
now support general generic types (currently, we handle
`ty::Ref`, `ty::RawPtr`, and `ty::Adt`)

When a `ty::Adt` is involved, we show an additional note
explaining which of the type's generic parameters is
invariant (e.g. the `T` in `Cell<T>`). Currently, we don't
explain *why* a particular generic parameter ends up becoming
invariant. In the general case, this could require printing
a long 'backtrace' of types, so doing this would be
more suitable for a follow-up PR.

We still only handle the case where our variance switches
to `ty::Invariant`.
2021-12-30 11:34:24 +00:00
bors
65d8785f0a Auto merge of #92377 - compiler-errors:rustdoc-lifetimes, r=camelid,jyn514
remove in_band_lifetimes from librustdoc

r? `@camelid`

closes #92368
2021-12-30 08:26:07 +00:00
Chayim Refael Friedman
e86ecdf9fe
Use UnsafeCell::get_mut() in core::lazy::OnceCell::get_mut()
This removes one unnecessary `unsafe` block.
2021-12-30 05:04:44 +02:00
bors
1b3a5f29dd Auto merge of #91125 - eskarn:llvm-passes-plugin-support, r=nagisa
Allow loading LLVM plugins with both legacy and new pass manager

Opening a draft PR to get feedback and start discussion on this feature. There is already a codegen option `passes` which allow giving a list of LLVM pass names, however we currently can't use a LLVM pass plugin (as described here : https://llvm.org/docs/WritingAnLLVMPass.html), the only available passes are the LLVM built-in ones.

The proposed modification would be to add another codegen option `pass-plugins`, which can be set with a list of paths to shared library files. These libraries are loaded using the LLVM function `PassPlugin::Load`, which calls the expected symbol `lvmGetPassPluginInfo`, and register the pipeline parsing and optimization callbacks.

An example usage with a single plugin and 3 passes would look like this in the `.cargo/config`:

```toml
rustflags = [
    "-C", "pass-plugins=/tmp/libLLVMPassPlugin",
    "-C", "passes=pass1 pass2 pass3",
]
```
This would give the same functionality as the opt LLVM tool directly integrated in rust build system.

Additionally, we can also not specify the `passes` option, and use a plugin which inserts passes in the optimization pipeline, as one could do using clang.
2021-12-30 02:53:09 +00:00
Caleb Cartwright
521fdcbe4d Merge commit '4a053f206fd6799a25823c307f7d7f9d897be118' into sync-rustfmt-subtree 2021-12-29 20:49:39 -06:00
Wang Ruochen
12b59b4027
Add UI test for #92292
Closes #92292
2021-12-29 16:06:26 -08:00
Aaron Hill
b15cb29a4a
Refactor variance diagnostics to work with more types
Instead of special-casing mutable pointers/references, we
now support general generic types (currently, we handle
`ty::Ref`, `ty::RawPtr`, and `ty::Adt`)

When a `ty::Adt` is involved, we show an additional note
explaining which of the type's generic parameters is
invariant (e.g. the `T` in `Cell<T>`). Currently, we don't
explain *why* a particular generic parameter ends up becoming
invariant. In the general case, this could require printing
a long 'backtrace' of types, so doing this would be
more suitable for a follow-up PR.

We still only handle the case where our variance switches
to `ty::Invariant`.
2021-12-29 18:53:40 -05:00
David Lattimore
4a053f206f Do not flatten match arm block with leading attributes
This is a backport of #4124.

Fixes #4109
2021-12-29 17:43:58 -06:00
bors
d331cb710f Auto merge of #88354 - Jmc18134:hint-space-pauth-opt, r=nagisa
Add codegen option for branch protection and pointer authentication on AArch64

The branch-protection codegen option enables the use of hint-space pointer
authentication code for AArch64 targets.
2021-12-29 22:35:11 +00:00
David Tolnay
b62163515a
Move equal sign back into head ibox 2021-12-29 12:26:50 -08:00
David Tolnay
b7df49895c
Fix spacing of pretty printed const item without body 2021-12-29 12:26:50 -08:00
bors
78fd0f633f Auto merge of #92244 - petrochenkov:alltraits, r=cjgillot
rustc_metadata: Encode list of all crate's traits into metadata

While working on https://github.com/rust-lang/rust/pull/88679 I noticed that rustdoc is casually doing something quite expensive, something that is used only for error reporting in rustc - collecting all traits from all crates in the dependency tree.

This PR trades some minor extra time spent by metadata encoder in rustc for major gains for rustdoc (and for rustc runs with errors, which execute the `all_traits` query for better diagnostics).
2021-12-29 19:22:33 +00:00
bors
df96fb166f Auto merge of #92309 - ehuss:remove-check_lines, r=Mark-Simulacrum
compiletest: Remove some vestigial code

The `check_lines` header is no longer parsed as a header, but instead inside the debuginfo tests. I believe this was changed in #13726.
2021-12-29 16:07:22 +00:00
bors
2b67c30bfe Auto merge of #92397 - matthiaskrgr:rollup-xnfou17, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #92075 (rustdoc: Only special case struct fields for intra-doc links, not enum variants)
 - #92118 (Parse and suggest moving where clauses after equals for type aliases)
 - #92237 (Visit expressions in-order when resolving pattern bindings)
 - #92340 (rustdoc: Start cleaning up search index generation)
 - #92351 (Add long error explanation for E0227)
 - #92371 (Remove pretty printer space inside block with only outer attrs)
 - #92372 (Print space after formal generic params in fn type)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-29 12:07:33 +00:00
Matthias Krüger
949769cf3b
Rollup merge of #92372 - dtolnay:fntype, r=jackh726
Print space after formal generic params in fn type

Follow-up to #92238 fixing one of the FIXMEs.

```rust
macro_rules! repro {
    ($ty:ty) => {
        stringify!($ty)
    };
}

fn main() {
    println!("{}", repro!(for<'a> fn(&'a u8)));
}
```

Before:&ensp;`for<'a>fn(&'a u8)`
After:&ensp;`for<'a> fn(&'a u8)`

The pretty printer's `print_formal_generic_params` already prints formal generic params correctly with a space, we just need to call it when printing BareFn types instead of reimplementing the printing incorrectly without a space.

83b15bfe1c/compiler/rustc_ast_pretty/src/pprust/state.rs (L1394-L1400)
2021-12-29 10:17:13 +01:00
Matthias Krüger
5583010347
Rollup merge of #92371 - dtolnay:attrblock, r=oli-obk
Remove pretty printer space inside block with only outer attrs

Follow-up to #92238 fixing one of the FIXMEs.

```rust
macro_rules! repro {
    ($expr:expr) => {
        stringify!($expr)
    };
}

fn main() {
    println!("{}", repro!(#[attr] {}));
}
```

Before:&ensp;`#[attr] { }`
After:&ensp;`#[attr] {}`
2021-12-29 10:17:12 +01:00
Matthias Krüger
c82b2bc590
Rollup merge of #92351 - TmLev:master, r=GuillaumeGomez
Add long error explanation for E0227

Part of the #61137.
2021-12-29 10:17:11 +01:00
Matthias Krüger
0e4119488d
Rollup merge of #92340 - camelid:search-index-cleanup, r=GuillaumeGomez
rustdoc: Start cleaning up search index generation

I'm trying to simplify and clean up the code, partly to make #90779 easier.

r? `@GuillaumeGomez`
2021-12-29 10:17:11 +01:00
Matthias Krüger
f044c6c86c
Rollup merge of #92237 - compiler-errors:issue-92100, r=cjgillot
Visit expressions in-order when resolving pattern bindings

[edited:] Visit the pattern's sub-expressions before defining any bindings.

Otherwise, we might get into a case where a Lit/Range expression in a pattern has a qpath pointing to a Ident pattern that is defined after it, causing an ICE when lowering to HIR. I have a more detailed explanation in the issue linked.

Fixes #92100
2021-12-29 10:17:10 +01:00
Matthias Krüger
bee14712ab
Rollup merge of #92118 - jackh726:type-alias-position-error, r=petrochenkov
Parse and suggest moving where clauses after equals for type aliases

~Mostly the same as #90076, but doesn't make any syntax changes.~ Whether or not we want to land the syntax changes, we should  parse the invalid where clause position and suggest moving.

r? `@nikomatsakis`
cc `@petrochenkov` you might have thoughts on implementation
2021-12-29 10:17:08 +01:00
Matthias Krüger
e31314307f
Rollup merge of #92075 - jyn514:resolve-cleanup, r=camelid
rustdoc: Only special case struct fields for intra-doc links, not enum variants

Variants are already handled by `resolve_str_path_error`, rustdoc doesn't need to consider them separately. Thanks `@camelid` for catching this!

Eventually I'd like to fix the "combine this with `variant_field`" comment but that needs `resolve_field` to take a `ty_res` parameter to avoid it being super hacky (cc https://github.com/rust-lang/rust/issues/83761#issuecomment-813026026).

r? `@camelid`
2021-12-29 10:17:08 +01:00
bors
6211dd7250 Auto merge of #92254 - krasimirgg:gsgdt-up, r=Mark-Simulacrum
Bump `gsgdt` to 0.1.3

No functional changes intended.

The 0.1.2 -> 0.1.3 commit 3e1dcec539 renames `Node::new` to `Node::from_list`.
2021-12-29 09:00:27 +00:00
bors
b70cc6422c Auto merge of #92291 - AngelicosPhosphoros:typeid_inline_revert_92135, r=joshtriplett
Reverts #92135 because perf regression

Please, start a perf test for this.

r? `@joshtriplett` You approved original PR.
2021-12-29 05:53:19 +00:00
bors
8e05bb527c Auto merge of #92283 - vacuus:print-generic-bounds, r=camelid,GuillaumeGomez
rustdoc: Remove `String` allocation in iteration in `print_generic_bounds`

(I realized only after making the commit that maybe I shouldn't refer to iteration as looping, but it's close enough)

The string representation of a `clean::GenericBound` instance (evaluated [here](https://github.com/rust-lang/rust/blob/master/src/librustdoc/html/format.rs#L397)) is deterministic for a given `self` (the instance), `cx` and `f`, and since `cx` and `f` are constant (as far as I can tell) for a given invocation of `print_generic_bounds`, `self` is the determining factor. Therefore, using the data in `self` shouldn't differ in effect from using its string representation.

Given the totality of the function calls needed to evaluate the string representation as well as the actual allocation, at the very least, this shouldn't negatively affect performance.
2021-12-29 02:49:34 +00:00
Caleb Cartwright
f935f0cf89 feat: support parsing asm! args 2021-12-28 20:25:17 -06:00
Caleb Cartwright
50bbb43dab chore: bump toolchain 2021-12-28 20:25:17 -06:00
Michael Goulet
bc7968f961 remove in_band_lifetimes from librustdoc 2021-12-28 18:18:00 -08:00
bors
7ae5508426 Auto merge of #92269 - vacuus:clean-generics-print, r=camelid
rustdoc: Remove `collect` call in `clean::Generics::print`
2021-12-28 23:38:54 +00:00
bors
c1cd64b9c6 Auto merge of #8117 - hotate29:issue7320, r=camsteffen
update: ```Sugg::not()``` replacing the comparison operator. #7320

fixes #7320

changelog: ```needless_bool```: Changed to make a smart suggestion.
2021-12-28 22:15:53 +00:00
Noah Lev
908a9d4aad Add regression test for #59502
This issue was fixed using a hacky recursion "fuel" argument, but the
issue was never minimized nor was a regression test added. The
underlying bug is still unfixed, so this test should help with fixing it
and removing the `recurse` hack.
2021-12-28 14:09:20 -08:00
Noah Lev
09104adda4 Explain why struct fields are handled by assoc. item code 2021-12-28 14:05:15 -08:00
bors
16ef044e72 Auto merge of #8183 - alex-ozdemir:limit-ident, r=camsteffen
Limit the ``[`identity_op`]`` lint to integral operands.

changelog: limit ``[`identity_op`]`` to integral operands

In the ``[`identity_op`]`` lint, if the operands are non-integers, then the lint is likely
wrong.
2021-12-28 22:01:57 +00:00
Noah Lev
7d1ec64891 Remove unused parameter 2021-12-28 13:23:37 -08:00
David Tolnay
ad29c177f4
Print space after formal generic params in fn type 2021-12-28 12:56:55 -08:00
Joshua Nelson
636d6a3eec Only special case struct fields for intra-doc links, not enum variants
Variants are already handled by `resolve_str_path_error`, rustdoc doesn't need to consider them separately.
2021-12-28 12:49:32 -08:00
David Tolnay
cbccc4a597
Remove pretty printer space inside block with only outer attrs 2021-12-28 12:42:50 -08:00
Jack Huey
4391a11537 Parse and suggest moving where clauses after equals for type aliases 2021-12-28 14:20:15 -05:00
bors
a139949ead Auto merge of #8187 - ApamNapat:fix_7651, r=llogiq
Fixed issues with to_radians and to_degrees lints

fixes #7651

I fixed the original problem as described in the issue, but the bug remains for complex expressions (the commented out TC I added is an example). I would also love some feedback on how to cleanup my code and reduce duplication. I hope it's not a problem that the issue has been claimed by someone else - that was over two months ago.

changelog: ``[`suboptimal_flops`]`` no longer proposes broken code with `to_radians` and `to_degrees`
2021-12-28 17:11:40 +00:00