Commit Graph

143407 Commits

Author SHA1 Message Date
Andy Wang
37dbe868c9
Split span_to_string into span_to_diagnostic/embeddable_string 2021-05-11 00:04:12 +01:00
LeSeulArtichaut
804ab9f78e Remove an invalid #[doc(inline)] 2021-05-11 00:03:44 +02:00
Aaron Hill
a4c0793551 Show nicer error when an 'unstable fingerprints' error occurs 2021-05-10 17:43:51 -04:00
bors
79e50bf779 Auto merge of #84677 - CDirkx:pal, r=Mark-Simulacrum
Fix `tidy` platform-specific code check

I noticed new platform-specific code was introduced outside of `std::sys` ([example](https://github.com/rust-lang/rust/blob/master/library/std/src/thread/available_concurrency.rs)), which should have been checked against by `tidy`. Apparently there are 2 problems with the current check implementation:

- It ignores everything after encountering "mod tests", which is often at the very top of a file.
- There was a bug where when checking the byte immediately before a found string, the first byte of the file was checked instead.

I fixed the bug and made excluding tests a bit more robust by instead adding the following rules:
- Files with a path containing either `tests` or `benches` are excluded.
- A `cfg(...)` containing `test` is excluded.

(Tests are excluded because almost all tests have something like `#[cfg(not(target_os = "emscripten"))]` somewhere.)

The fixed check found some more cases of platform-specific code; for now I have explicitly excluded them and added a FIXME stating that the platform-specific code must be moved to `sys`.
2021-05-10 21:32:13 +00:00
bors
6fd7a6dc0f Auto merge of #85156 - GuillaumeGomez:rollup-8u4h34g, r=GuillaumeGomez
Rollup of 4 pull requests

Successful merges:

 - #84465 (rustdoc: Implement `is_primitive` in terms of `primitive_type()`)
 - #85118 (Use an SVG image for clipboard instead of unicode character)
 - #85148 (Fix source code line number display and make it clickable again)
 - #85152 (Adjust target search algorithm for rustlib path)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-10 18:28:24 +00:00
Guillaume Gomez
6ec1de7d4f
Rollup merge of #85152 - nagisa:target-search-rustlib, r=Mark-Simulacrum
Adjust target search algorithm for rustlib path

With this the concerns expressed in #83800 should be addressed.

r? `@Mark-Simulacrum`
2021-05-10 20:05:27 +02:00
Guillaume Gomez
3962541dcb
Rollup merge of #85148 - GuillaumeGomez:source-code-line-number, r=jsha
Fix source code line number display and make it clickable again

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

I used the same logic we're using for other codeblocks: putting the line number `<span>`s into the `example-wrap` directly and then add `display: inline-flex` on `example-wrap`.

r? `@jsha`
2021-05-10 20:05:26 +02:00
Guillaume Gomez
c7e7de4021
Rollup merge of #85118 - GuillaumeGomez:clipboard-svg, r=Nemo157
Use an SVG image for clipboard instead of unicode character

Linked to https://github.com/rust-lang/docs.rs/pull/1394.

cc `@jsha`
r? `@Nemo157`
2021-05-10 20:05:25 +02:00
Guillaume Gomez
205a0d3a27
Rollup merge of #84465 - jyn514:primitive, r=GuillaumeGomez
rustdoc: Implement `is_primitive` in terms of `primitive_type()`

Previously, they disagreed about what types were primitives.

r? `@GuillaumeGomez`
2021-05-10 20:05:24 +02:00
LeSeulArtichaut
6e8d0dbe11 Add documentation 2021-05-10 18:38:09 +02:00
Simonas Kazlauskas
b7c5599d22 Adjust target search algorithm for rustlib path
With this the concerns expressed in #83800 should be addressed.
2021-05-10 19:15:19 +03:00
Fabian Wolff
98728c2b35 Implement changes suggested by tmiasko and davidtwco 2021-05-10 17:47:50 +02:00
bors
266f452118 Auto merge of #85150 - Dylan-DPC:rollup-q26gbx3, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #85050 (Fix suggestions for missing return type lifetime specifiers)
 - #85075 (Improve "panic message is not a string literal" warning)
 - #85096 (Make unchecked_{add,sub,mul} inherent methods unstably const)
 - #85112 (ensure failing promoteds in const/static bodies are handled correctly)
 - #85146 (Provide io::Seek::rewind)
 - #85147 (⬆️ rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-10 15:08:08 +00:00
Guillaume Gomez
7450f70ae2 Use an SVG image for clipboard instead of unicode character 2021-05-10 16:26:16 +02:00
Dylan DPC
e76340191e
Rollup merge of #85147 - lnicola:rust-analyzer-2021-05-10, r=jonas-schievink
⬆️ rust-analyzer
2021-05-10 16:15:06 +02:00
Dylan DPC
c5e612ce6b
Rollup merge of #85146 - ijackson:seek-rewind, r=m-ou-se
Provide io::Seek::rewind

Using `Seek::seek` is slightly clumsy because of the need to write (or import) `std::io::SeekFrom` to get at `SeekStart`.  C already has `rewind` (although with broken error handling); we should have it too.

I'm motivated to do this because I've just found myself copy-pasting my 5-line extension trait between projects.

That the example ends up using `OpenOptions` makes this look like a niche use case, but it is very common to rewind temporary files.  `tempfile` isn't available for use in this example or it would have looked shorter and more natural.

If this gets a positive reception I will open a tracking issue and update the feature gate.
2021-05-10 16:15:05 +02:00
Dylan DPC
ae8a438034
Rollup merge of #85112 - RalfJung:promoted-errors, r=oli-obk
ensure failing promoteds in const/static bodies are handled correctly

`const`/`static` bodies are the one case where we still promote code that might fail to evaluate. Ensure that this is handled correctly; in particular, it must not fail compilation.

`src/test/ui/consts/const-eval/erroneous-const.rs` ensures that when a non-promoted fails to evaluate, we *do* show an error.

r? `@oli-obk`
2021-05-10 16:15:03 +02:00
Dylan DPC
7107c89970
Rollup merge of #85096 - clarfonthey:const_unchecked, r=oli-obk
Make unchecked_{add,sub,mul} inherent methods unstably const

The intrinsics are marked as being stably const (even though they're not stable by nature of being intrinsics), but the currently-unstable inherent versions are not marked as const. This fixes this inconsistency. Split out of #85017,

r? `@oli-obk`
2021-05-10 16:15:02 +02:00
Dylan DPC
37c603864e
Rollup merge of #85075 - ptrojahn:panic_warning, r=jackh726
Improve "panic message is not a string literal" warning

This warning always referenced panic! even in case of an
assert. Related to #84656
2021-05-10 16:15:01 +02:00
Dylan DPC
0740015d59
Rollup merge of #85050 - FabianWolff:issue-84592, r=jackh726
Fix suggestions for missing return type lifetime specifiers

This pull request aims to fix #84592. The issue is that the current code seems to assume that there is only a single relevant span pointing to the missing lifetime, and only looks at the first one:
e5f83d24ae/compiler/rustc_resolve/src/late/lifetimes.rs (L2959)

This is incorrect, though, and leads to incorrect error messages and invalid suggestions. For instance, the example from #84592:
```rust
struct TwoLifetimes<'x, 'y> {
    x: &'x (),
    y: &'y (),
}

fn two_lifetimes_needed(a: &(), b: &()) -> TwoLifetimes<'_, '_> {
    TwoLifetimes { x: &(), y: &() }
}
```
currently leads to:
```
error[E0106]: missing lifetime specifiers
 --> src/main.rs:6:57
  |
6 | fn two_lifetimes_needed(a: &(), b: &()) -> TwoLifetimes<'_, '_> {
  |                            ---     ---                  ^^ expected 2 lifetime parameters
  |
  = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `a` or `b`
help: consider introducing a named lifetime parameter
  |
6 | fn two_lifetimes_needed<'a>(a: &'a (), b: &'a ()) -> TwoLifetimes<'_<'a, 'a>, '_> {
  |                        ^^^^    ^^^^^^     ^^^^^^                  ^^^^^^^^^^
```
There are two problems:
- The error message is wrong. There is only _one_ lifetime parameter expected at the location pointed to by the error message (and another one at a separate location).
- The suggestion is incorrect and will not lead to correct code.

With the changes in this PR, I get the following output:
```
error[E0106]: missing lifetime specifiers
 --> p.rs:6:57
  |
6 | fn two_lifetimes_needed(a: &(), b: &()) -> TwoLifetimes<'_, '_> {
  |                            ---     ---                  ^^  ^^ expected named lifetime parameter
  |                                                         |
  |                                                         expected named lifetime parameter
  |
  = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `a` or `b`
help: consider introducing a named lifetime parameter
  |
6 | fn two_lifetimes_needed<'a>(a: &'a (), b: &'a ()) -> TwoLifetimes<'a, 'a> {
  |                        ^^^^    ^^^^^^     ^^^^^^                  ^^  ^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0106`.
```
Mainly, I changed `add_missing_lifetime_specifiers_label()` to receive a _vector_ of spans (and counts) instead of just one, and adjusted its body accordingly.
2021-05-10 16:15:00 +02:00
Fabian Wolff
2448c7698e More minor fixes suggested by @jackh726 2021-05-10 15:02:15 +02:00
Ian Jackson
7ae852e349 io::Seek: Set tracking issue
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-10 13:55:31 +01:00
Ian Jackson
3113b6bd69
Fix typo in doc
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-05-10 13:50:56 +01:00
Ralf Jung
1f17fc23b6 update perf version used for PGO 2021-05-10 14:39:28 +02:00
bors
544d124b81 Auto merge of #85079 - petrochenkov:sessclean, r=davidtwco
rustc_session: Move more option building code from the `options!` macro

The moved code doesn't need to be generated by a macro, it can use a regular (generic) function and type aliases instead.

(The refactoring is salvaged from a branch with different now abandoned work.)
2021-05-10 12:26:46 +00:00
Guillaume Gomez
4e3fb6858a Add test for source code clickable line number 2021-05-10 14:12:00 +02:00
Guillaume Gomez
09150f8193 Fix line number not being clickable on source pages 2021-05-10 14:11:42 +02:00
Laurențiu Nicola
debf987421 ⬆️ rust-analyzer 2021-05-10 15:11:01 +03:00
Ian Jackson
c3ca148ac0 io::Seek: Provide rewind()
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-10 13:03:49 +01:00
Ian Jackson
74e0e45f3c io::Seek: Mention that seeking can fail due to buffer flush fail
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-10 12:57:19 +01:00
Vadim Petrochenkov
273e0a2a05 rustc_session: Use Iterator::find instead of manual search 2021-05-10 14:52:31 +03:00
Vadim Petrochenkov
9d18d4df0e rustc_session: Move more option building code from the options! macro 2021-05-10 14:41:45 +03:00
shirshak55
0778e8dcb8 change k to key and v to v in std::env mod 2021-05-10 19:31:09 +08:00
Deadbeef
5068cbc901
Document Rc::from 2021-05-10 18:46:13 +08:00
bors
1b30245ea1 Auto merge of #85053 - camsteffen:duplicate-lint, r=davidtwco
Fix duplicate unknown lint errors

Fixes rust-lang/rust-clippy#6602
2021-05-10 09:45:28 +00:00
Guillaume Gomez
08519959c7 Update documentation for SharedContext::maybe_collapsed_doc_value 2021-05-10 10:49:44 +02:00
bors
2fb1dee14b Auto merge of #85104 - hi-rustin:rustin-patch-typo, r=jonas-schievink
Fix typo
2021-05-10 07:15:23 +00:00
bors
00f2bf40d6 Auto merge of #85074 - GuillaumeGomez:end-toggle-migration, r=jsha
Migrate top doc and non-exhaustive toggles to details tag

Fixes #83332.

r? `@jsha`
2021-05-10 04:05:55 +00:00
hamidreza kalbasi
8f5585ac00 remove big match 2021-05-10 05:53:42 +04:30
bors
d29289c509 Auto merge of #84507 - crlf0710:codegen_nonlocal_main_wrapper, r=nagisa
Add primary marker on codegen unit and generate main wrapper on primary codegen.

This is the codegen part of changes extracted from #84062.

This add a marker called `primary` on each codegen units, where exactly one codegen unit will be `primary = true` at a time. This specific codegen unit will take charge of generating `main` wrapper when `main` is imported from a foreign crate after the implementation of RFC 1260.

cc #28937

I'm not sure who should i ask for review for codegen changes, so feel free to reassign.
r? `@nagisa`
2021-05-10 00:42:31 +00:00
hamidreza kalbasi
48f5f01e8b move logic to a function 2021-05-10 03:31:31 +04:30
Guillaume Gomez
3837c1ce33 Update rustdoc test 2021-05-10 00:09:57 +02:00
Guillaume Gomez
4edcf61479 End toggle migration 2021-05-10 00:09:57 +02:00
bors
c55c26cb36 Auto merge of #83800 - xobs:impl-16351-nightly, r=nagisa
Add default search path to `Target::search()`

The function `Target::search()` accepts a target triple and returns a `Target` struct defining the requested target.

There is a `// FIXME 16351: add a sane default search path?` comment that indicates it is desirable to include some sort of default. This was raised in https://github.com/rust-lang/rust/issues/16351 which was closed without any resolution.

https://github.com/rust-lang/rust/pull/31117 was proposed, however that has platform-specific logic that is unsuitable for systems without `/etc/`.

This patch implements the suggestion raised in https://github.com/rust-lang/rust/issues/16351#issuecomment-180878193 where a `target.json` file may be placed in `$(rustc --print sysroot)/lib/rustlib/<target-triple>/target.json`. This allows shipping a toolchain distribution as a single file that gets extracted to the sysroot.
2021-05-09 22:01:26 +00:00
ltdk
e6b12c8e4f Fix Step feature flag, make tidy lint more useful to find things like this 2021-05-09 17:15:54 -04:00
Fabian Wolff
3c0c3874fc Implement @jackh726's suggestions 2021-05-09 22:35:18 +02:00
ltdk
380bbe8d47 Make unchecked_{add,sub,mul} inherent methods unstably const 2021-05-09 16:29:40 -04:00
bors
ca82264ec7 Auto merge of #85065 - Mark-Simulacrum:preds-no-alloc, r=jackh726
Avoid predecessors having Drop impls

Should be a simple win - but let's make sure with perf.
2021-05-09 19:01:05 +00:00
Joshua Nelson
506031fc78 Remove outdated FIXME for download-rustc 2021-05-09 12:24:59 -04:00
bors
7a2f446889 Auto merge of #83894 - nikic:newpm, r=nagisa
Improve support for NewPM

This adds various missing bits of support for NewPM and allows us to successfully run stage 2 tests with NewPM enabled.

This does not yet enable NewPM by default, as there are still known issue on LLVM 12 (such as a weak fat LTO pipeline). The plan is to make the switch after we update to LLVM 13.
2021-05-09 16:19:21 +00:00