Commit Graph

149837 Commits

Author SHA1 Message Date
LingMan
07dbd4d398 Use try_into instead of asserting manually 2021-06-07 01:27:40 +02:00
Guillaume Gomez
487200b438
Rollup merge of #86077 - FabianWolff:issue-86061, r=GuillaumeGomez
Fix corrected example in E0759.md

This pull request fixes #86061, which was probably caused by a copy-paste error, where the supposedly corrected code example was also marked with `compile_fail`. Thus, the fact that the "correct" example actually _isn't_ correct was not caught by the doc-tests. This pull request removes the incorrect `compile_fail` annotation and fixes the example.

r? ``@GuillaumeGomez``
2021-06-07 01:06:55 +02:00
Guillaume Gomez
d7d2548eb0
Rollup merge of #86058 - fee1-dead:E0121-improvements, r=jackh726
Remove `_`  from E0121 diagnostic suggestions

Fixes #86021.
2021-06-07 01:06:54 +02:00
Guillaume Gomez
00a704f182
Rollup merge of #86040 - GuillaumeGomez:search-result-display-height, r=jsha
Fix display for search results

This fixes unwanted margin and font-weight coming from `.method`. Before:

![Screenshot from 2021-06-05 23-03-34](https://user-images.githubusercontent.com/3050060/120905486-9e46f380-c652-11eb-8008-6db6e0517ba3.png)

after:

![Screenshot from 2021-06-05 23-05-02](https://user-images.githubusercontent.com/3050060/120905489-9edf8a00-c652-11eb-817d-f676f6ab7303.png)

r? ``@jsha``
2021-06-07 01:06:53 +02:00
Guillaume Gomez
1bef90fb25
Rollup merge of #86010 - FabianWolff:ICE-parser, r=varkor
Fix two ICEs in the parser

This pull request fixes #84104 and fixes #84148. The latter is caused by an invalid `assert_ne!()` in the parser, which I have simply removed because the error is then caught in another part of the parser.

#84104 is somewhat more subtle and has to do with a suggestion to remove extraneous `<` characters; for instance:
```rust
fn main() {
    foo::<Ty<<<i32>();
}
```
currently leads to
```
error: unmatched angle brackets
 --> unmatched-langle.rs:2:10
  |
2 |     foo::<Ty<<<i32>();
  |          ^^^ help: remove extra angle brackets
```
which is obviously wrong and stems from the fact that the code for issuing the above suggestion does not consider the possibility that there might be other tokens in between the opening angle brackets. In #84104, this has led to a span being generated that ends in the middle of a multi-byte character (because the code issuing the suggestion thought that it was only skipping over `<`, which are single-byte), causing an ICE.
2021-06-07 01:06:52 +02:00
Guillaume Gomez
a3c76f6d98
Rollup merge of #85965 - tmiasko:a, r=nagisa
Remove dead code from `LocalAnalyzer`
2021-06-07 01:06:51 +02:00
Guillaume Gomez
b71bc91192
Rollup merge of #85912 - LingMan:iter_any, r=nagisa
Use `Iterator::any` and `filter_map` instead of open-coding them

``@rustbot`` modify labels +C-cleanup +T-compiler
2021-06-07 01:06:50 +02:00
Guillaume Gomez
83664bd16b
Rollup merge of #84940 - jyn514:ninja, r=Mark-Simulacrum
Don't run sanity checks for `x.py setup`

These requirements change as soon as the command finishes running, and
`setup` doesn't build anything, so the check doesn't make sense.

Previously, `x.py setup` would give hard errors if `ninja` and `cmake`
were not installed, even if the new profile didn't require them.

Fixes https://github.com/rust-lang/rust/issues/84938.
2021-06-07 01:06:49 +02:00
Guillaume Gomez
85fec06617
Rollup merge of #83433 - jyn514:cfg-bootstrap-macro, r=Mark-Simulacrum
Pass --cfg=bootstrap for proc macros built by stage0

Cargo has a bug where it ignores RUSTFLAGS when building proc macro
crates (https://github.com/rust-lang/cargo/issues/4423).
However, sometimes rustc_macro needs to have conditional
compilation when there are breaking changes to the `libproc_macro` API
(see for example #83363). Previously, this wasn't possible, because the
crate couldn't tell the difference between stage 0 and stage 1.

Another alternative is to unconditionally build rustc_macros with the
master libstd instead of the beta one (i.e. use `--sysroot
stage0-sysroot`), but that led to strange and maddening errors:

```
error[E0460]: found possibly newer version of crate `std` which `synstructure` depends on
 --> compiler/rustc_macros/src/lib.rs:5:5
  |
5 | use synstructure::decl_derive;
  |     ^^^^^^^^^^^^
  |
  = note: perhaps that crate needs to be recompiled?
  = note: the following crate versions were found:
          crate `std`: /home/joshua/rustc2/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-b3602c301b71cc3d.rmeta
          crate `synstructure`: /home/joshua/rustc2/build/x86_64-unknown-linux-gnu/stage0-rustc/release/deps/libsynstructure-74ee66863479e972.rmeta
error[E0460]: found possibly newer version of crate `std` which `proc_macro2` depends on
  --> /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/tracing-attributes-0.1.13/src/lib.rs:90:5
   |
90 | use proc_macro2::TokenStream;
   |     ^^^^^^^^^^^
   |
   = note: perhaps that crate needs to be recompiled?
   = note: the following crate versions were found:
           crate `std`: /home/joshua/rustc2/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-b3602c301b71cc3d.rmeta
           crate `proc_macro2`: /home/joshua/rustc2/build/x86_64-unknown-linux-gnu/stage0-rustc/release/deps/libproc_macro2-a83c1f01610c129e.rlib
```

r? `@Mark-Simulacrum` cc `@jhpratt`
2021-06-07 01:06:48 +02:00
Guillaume Gomez
45973621bc Add test to check that font-weight is correctly set on type page 2021-06-07 00:06:32 +02:00
Guillaume Gomez
570ba09cbe Fix invalid weight for type pages 2021-06-06 23:06:01 +02:00
Fabian Wolff
31eee595cf Fix corrected example in E0759.md 2021-06-06 22:54:00 +02:00
Reagan McFarland
eb3fd6d208 Default panic message should print Box<dyn Any>
Prior to this patch, the default panic message (resulting from calling
`panic_any(42);` for example), would print the following error message:

```
thread 'main' panicked at 'Box<Any>', ...
```

However, this should be `Box<dyn Any>` instead.
2021-06-06 16:21:47 -04:00
bors
35fff69d04 Auto merge of #85343 - Aaron1011:variance-diag, r=estebank
Add variance-related information to lifetime error messages

This PR adds a basic framework for displaying variance-related information in error messages. For example:

```
error: lifetime may not live long enough
  --> $DIR/type-check-pointer-comparisons.rs:12:5
   |
LL | fn compare_mut<'a, 'b>(x: *mut &'a i32, y: *mut &'b i32) {
   |                --  -- lifetime `'b` defined here
   |                |
   |                lifetime `'a` defined here
LL |     x == y;
   |     ^ requires that `'a` must outlive `'b`
   |
   = help: consider adding the following bound: `'a: 'b`
   = note: requirement occurs because of a mutable pointer to &i32
   = note: mutable pointers are invariant over their type parameter
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
```

The last three lines are new.

This is accomplished by adding a new struct `VarianceDiagInfo`, and passing it along through the various relation methods. When relating types that change the variance (e.g. `&mut T` or `*mut T`), we pass a more specific `VarianceDiagInfo` storing information about the cause of the variance change. When an error, we use the `VarianceDiagInfo` to add additional information to the error message.

This PR doesn't change any variance-related computation or behavior - only diagnostic messages. Therefore, the implementation is quite incomplete - more detailed error messages can be filled in in subsequent PRs.

Limitations:
* We only attempt to deal with invariance - since it's at the bottom of the 'variance lattice', our variance will never change again after it becomes invariant. Handling contravariance would be trickier, since we can change between contravariance and covariance multiple times (e.g. `fn(fn(&'static u8))`). Since contravariance (AFAIK) is only used for function arguments, we can probably get away without a very fancy message for cases involving contravariance.
* `VarianceDiagInfo` currently only handles mutable pointers/references. However, user-defined types (structs, enums, and unions) have the variance of their type parameters inferred, so it would be good to eventually display information about that. We'll want to try to find a balance between displaying too much and too little information about how the variance was inferred.
* The improved error messages are only displayed when `#![feature(nll)]` / `-Z borrowck=mir` is enabled.  If issue https://github.com/rust-lang/rust/issues/58781 is not resolved relatively soon, then we might want to duplicate some of this logic in the 'current' (non-NLL) region/outlives handling code.
2021-06-06 19:12:05 +00:00
Aaron Hill
fad2242ff7
Add variance-related information to lifetime error messages 2021-06-06 12:37:42 -05:00
bors
5b638c1d37 Auto merge of #85086 - petrochenkov:linkord2, r=nagisa
linker: Reorder linker arguments

- Split arguments into order-independent and order-dependent, to define more precisely what (pre-,post-,late-,)link-args mean.
- Add some comments.
2021-06-06 16:41:36 +00:00
Vadim Petrochenkov
3eab280567 linker: Re-apply Solaris fixes for -z ignore 2021-06-06 17:48:18 +03:00
Vadim Petrochenkov
5275bf1c1d linker: Restore the old order of linking native libraries 2021-06-06 17:30:32 +03:00
Vadim Petrochenkov
b7994f9e7e linker: Reorder linker arguments
- Combine all native library arguments together, to simplify potential support for library deduplication and similar things
- Split arguments into order-independent and order-dependent, to define more precisely what (pre,post,late)-link-args mean
2021-06-06 17:30:30 +03:00
Vadim Petrochenkov
dca3acb6c2 linker: Inline fn link_local_crate_native_libs_and_dependent_crate_libs 2021-06-06 17:29:13 +03:00
bors
86b0bafbf1 Auto merge of #84995 - petrochenkov:tcollect, r=Aaron1011
parser: Ensure that all nonterminals have tokens after parsing

`parse_nonterminal` should always result in something with tokens.

This requirement wasn't satisfied in two cases:
- `stmt` nonterminal with expression statements (e.g. `0`, or `{}`, or `path + 1`) because `fn parse_stmt_without_recovery` forgot to propagate `force_collect` in some cases.
- `expr` nonterminal with expressions with built-in attributes (e.g. `#[allow(warnings)] 0`) due to an incorrect optimization in `fn parse_expr_force_collect`, it assumed that all expressions starting with `#` have their tokens collected during parsing, but that's not true if all the attributes on that expression are built-in and inert.

(Discovered when trying to implement eager `cfg` expansion for all attributes https://github.com/rust-lang/rust/pull/83824#issuecomment-817317170.)

r? `@Aaron1011`
2021-06-06 14:00:43 +00:00
Tamir Duberstein
977903bb11
String::remove_matches O(n^2) -> O(n)
Copy only non-matching bytes.
2021-06-06 08:06:56 -04:00
Tamir Duberstein
38013e708e
Use iter::from_fn in String::remove_matches 2021-06-06 08:06:03 -04:00
bors
f57d5ba3c9 Auto merge of #86054 - JohnTitor:rollup-j40z7sm, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #85436 (Avoid cloning cache key)
 - #85772 (Preserve metadata w/ Solaris-like linkers.)
 - #85920 (Tweak wasm_base target spec to indicate linker is not GNU and update linker inferring logic for wasm-ld.)
 - #85930 (Update standard library for IntoIterator implementation of arrays )
 - #85972 (Rustdoc html fixes)
 - #86028 (Drop an `if let` that will always succeed)
 - #86043 (don't clone attrs)
 - #86047 (Don't fire `invalid_doc_attributes` on `extern crate` items)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-06-06 11:31:16 +00:00
Vadim Petrochenkov
cbdfa1edca parser: Ensure that all nonterminals have tokens after parsing 2021-06-06 14:21:12 +03:00
Yuki Okushi
19433c44bd
Rollup merge of #86047 - jyn514:doc-attrs, r=petrochenkov
Don't fire `invalid_doc_attributes` on `extern crate` items

Fixes https://github.com/rust-lang/rust/issues/86046.
2021-06-06 19:11:24 +09:00
Yuki Okushi
2f0a8556a9
Rollup merge of #86043 - klensy:attr-clone, r=jyn514
don't clone attrs
2021-06-06 19:11:23 +09:00
Yuki Okushi
1886123b7d
Rollup merge of #86028 - LingMan:dupe_empty_check, r=jyn514
Drop an `if let` that will always succeed

We've already checked that `proj_base == []` in the line above and renaming
`place_local` to `local` doesn't gain us anything.

``@rustbot`` modify labels +C-cleanup +T-compiler
2021-06-06 19:11:22 +09:00
Yuki Okushi
302f3dcf90
Rollup merge of #85972 - GuillaumeGomez:rustdoc-html-fixes, r=jsha
Rustdoc html fixes

#84480 latest update allowed me to fix the remaining issues. The last one is coming from `pulldown-cmark` so I'll send them a fix soon.

r? ``@jsha``
2021-06-06 19:11:21 +09:00
Yuki Okushi
f923f73b9a
Rollup merge of #85930 - mominul:array_into_iter, r=m-ou-se
Update standard library for IntoIterator implementation of arrays

This PR partially resolves issue #84513 of updating the standard library part.

I haven't found any remaining doctest examples which are using iterators over e.g. &i32 instead of just i32 in the standard library. Can anyone point me to them if there's remaining any?

Thanks!

r? ```@m-ou-se```
2021-06-06 19:11:19 +09:00
Yuki Okushi
679a1d1ac1
Rollup merge of #85920 - luqmana:wasm-linker-tweaks, r=petrochenkov
Tweak wasm_base target spec to indicate linker is not GNU and update linker inferring logic for wasm-ld.

Reported via [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/wasi.20linker.20unknown.20argument.3A.20--as-needed): we try passing `--as-needed` to the linker if it's GNU ld which `wasm-ld` is not. Usually this isn't an issue for wasm as we would use the WasmLd linker driver but because the linker in question (`wasm32-unknown-wasi-wasm-ld`) ended with `-ld` our linker inferring [logic](f64503eb55/compiler/rustc_codegen_ssa/src/back/link.rs (L957-L1040)) used the `GccLinker` implementations. (UPD: The linker inferring logic actually didn't apply in this case because the linker is actually invoked through gcc in the reported issue. But it's still worth updating the logic I think.)

This change then has 2 parts:
1. Update wasm_base target spec to indicate `linker_is_gnu: false` plus a few additions of `target.is_like_wasm` to handle flags `wasm-ld` does in fact support.
2. Improve the linker detection logic to properly determine the correct flavor of wasm linker we're using when we can.

We need to add the new `target.is_like_wasm` branches to handle the case where the "linker" used could be something like clang which would then under the hood call wasm-ld.
2021-06-06 19:11:18 +09:00
Yuki Okushi
d69cd46761
Rollup merge of #85772 - luqmana:ignored-metadata, r=petrochenkov
Preserve metadata w/ Solaris-like linkers.

#84468 moved the `-zignore` linker flag from the `gc_sections` method to `add_as_needed` which is more accurate but Solaris-style linkers will also end up removing an unreferenced ELF sections [1]. This had the unfortunate side effect of causing the `.rustc` section (which has the metada) to be removed which could cause issues when trying to link against the resulting crates or use proc macros.

Since the `-zignore` is positional, we fix this by moving the metadata objects to before the flag.

[1] Specifically a section is considered unreferenced if:
* The section is allocatable
* No other sections bind to (relocate) to this section
* The section provides no global symbols

https://docs.oracle.com/cd/E19683-01/817-3677/6mj8mbtbs/index.html#chapter4-19
2021-06-06 19:11:17 +09:00
Yuki Okushi
b3bcf4af74
Rollup merge of #85436 - tamird:save-clone, r=estebank
Avoid cloning cache key

r? `@estebank`
2021-06-06 19:11:16 +09:00
bors
3740ba2a7d Auto merge of #84863 - ABouttefeux:libtest, r=m-ou-se
Show test type during prints

Test output can sometimes be confusing. For example doctest with the no_run argument are displayed the same way than test that are run.

During #83857 I got the feedback that test output can be confusing.

For the moment test output is
```
test $DIR/test-type.rs - f (line 12) ... ignored
test $DIR/test-type.rs - f (line 15) ... ok
test $DIR/test-type.rs - f (line 21) ... ok
test $DIR/test-type.rs - f (line 6) ... ok
```

I propose to change output by indicating the test type as
```
test $DIR/test-type.rs - f (line 12) ... ignored
test $DIR/test-type.rs - f (line 15) - compile ... ok
test $DIR/test-type.rs - f (line 21) - compile fail ... ok
test $DIR/test-type.rs - f (line 6) ... ok
```
by indicating the test type after the test name (and in the case of doctest after the function name and line) and before the "...".

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

Note: this is a proof of concept, the implementation is probably not optimal as the properties added in `TestDesc` are only use in the display and does not represent actual change of behavior, maybe `TestType::DocTest` could have fields
2021-06-06 09:13:59 +00:00
Luqman Aden
a26f00357f Unify duplicate linker_and_flavor methods in rustc_codegen_{cranelift,ssa}. 2021-06-05 21:59:41 -07:00
Joshua Nelson
1cdc81bdc1 Don't pass -Z unstable-options by default for UI tests
- Pass it explicitly where appropriate
- Update stderr files and warnings; it turns that unstable-options has
  far-reaching effects on diagnostics.
2021-06-06 00:44:54 -04:00
bors
9a576175cc Auto merge of #84171 - ricobbe:raw-dylib-via-llvm, r=petrochenkov
Partial support for raw-dylib linkage

First cut of functionality for issue #58713: add support for `#[link(kind = "raw-dylib")]` on `extern` blocks in lib crates compiled to .rlib files.  Does not yet support `#[link_name]` attributes on functions, or the `#[link_ordinal]` attribute, or `#[link(kind = "raw-dylib")]` on `extern` blocks in bin crates; I intend to publish subsequent PRs to fill those gaps.  It's also not yet clear whether this works for functions in `extern "stdcall"` blocks; I also intend to investigate that shortly and make any necessary changes as a follow-on PR.

This implementation calls out to an LLVM function to construct the actual `.idata` sections as temporary `.lib` files on disk and then links those into the generated .rlib.
2021-06-06 03:59:17 +00:00
erer1243
67f4f3baec Updated code examples and wording 2021-06-05 23:44:21 -04:00
Joshua Nelson
b8ebf4431e Don't fire invalid_doc_attributes on extern crate items 2021-06-05 21:18:20 -04:00
bors
f434217aab Auto merge of #79608 - alessandrod:bpf, r=nagisa
BPF target support

This adds `bpfel-unknown-none` and `bpfeb-unknown-none`, two new no_std targets that generate little and big endian BPF. The approach taken is very similar to the cuda target, where `TargetOptions::obj_is_bitcode` is enabled and code generation is done by the linker.

I added the targets to `dist-various-2`. There are [some tests](https://github.com/alessandrod/bpf-linker/tree/main/tests/assembly) in bpf-linker and I'm planning to add more. Those are currently not ran as part of rust CI.
2021-06-06 01:02:32 +00:00
Guillaume Gomez
e078e56112 Fix invalid ID value in all.html file 2021-06-05 23:14:12 +02:00
Guillaume Gomez
8c9200d045 Add missing backslash in HTML layout string 2021-06-05 23:14:10 +02:00
Guillaume Gomez
e1180f521f Escape <meta> content attribute value 2021-06-05 23:13:11 +02:00
bors
6c2dd251bb Auto merge of #86002 - cjgillot:expn_that_defined, r=petrochenkov
Always go through the expn_that_defined query.
2021-06-05 21:10:01 +00:00
Guillaume Gomez
c01bd560e2 Fix display for search results 2021-06-05 23:03:54 +02:00
bors
ac3e680193 Auto merge of #86032 - GuillaumeGomez:rollup-y3ij27b, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #83646 (Add a map method to Bound)
 - #85501 (Fix `deny(invalid_doc_attributes)`)
 - #85503 (rustdoc: add tooltips to some buttons)
 - #85710 (Document `From` impls in path.rs)
 - #85760 (Possible errors when accessing file metadata are platform specific)
 - #85974 (td align attribute)
 - #86014 (msp430 linker does not accept -znoexecstack. Set linker_is_gnu to fal…)

Failed merges:

 - #85972 (Rustdoc html fixes)

r? `@ghost`
`@rustbot` modify labels: rollup
2021-06-05 18:41:36 +00:00
Camille Gillot
3f32738628
Update compiler/rustc_middle/src/query/mod.rs 2021-06-05 20:40:58 +02:00
Guillaume Gomez
16504f6253
Rollup merge of #86014 - cr1901:msp430-link, r=jonas-schievink
msp430 linker does not accept -znoexecstack. Set linker_is_gnu to fal…

…se as workaround for now.

Tested locally and works. Closes #85948.
2021-06-05 19:41:45 +02:00
Guillaume Gomez
9c7ebc15a6
Rollup merge of #85974 - GuillaumeGomez:td-align, r=jsha
td align attribute

This is a follow-up of #85972. I have put this one on its own because it changes the display:

![Screenshot from 2021-06-03 21-49-11](https://user-images.githubusercontent.com/3050060/120703622-d533d280-c4b5-11eb-9519-ea1131a40bee.png)

Without align:

![Screenshot from 2021-06-03 21-49-15](https://user-images.githubusercontent.com/3050060/120703623-d5cc6900-c4b5-11eb-95f9-878d3915c7fb.png)

I also opened an issue about it: raphlinus/pulldown-cmark#533. However, I'm not sure if this is the right course of action... Should we instead ignore the warning?

r? ``@jsha``
2021-06-05 19:41:44 +02:00
Guillaume Gomez
114aff58fd
Rollup merge of #85760 - ChrisDenton:path-doc-platform-specific, r=m-ou-se
Possible errors when accessing file metadata are platform specific

In particular the `is_dir`, `is_file` and `exists` functions suggests that querying a file requires querying the directory. On Windows this is not normally true.

r? `@m-ou-se`
2021-06-05 19:41:43 +02:00