Commit graph

152576 commits

Author SHA1 Message Date
Guillaume Gomez
1a48d1a4de Add documentation and FIXME 2021-08-05 23:08:29 +02:00
Guillaume Gomez
b336f2801c Fix invalid generation of HTML in highlight 2021-08-05 23:08:29 +02:00
Guillaume Gomez
ef0d909f26 formatting 2021-08-05 23:08:29 +02:00
Guillaume Gomez
f233a70567 Use rustdoc Span in LinkFromSrc directly 2021-08-05 23:08:29 +02:00
Guillaume Gomez
dffc9c0a79 Move extra arguments for highlight URL generation into a new ContextInfo struct for better readability 2021-08-05 23:08:28 +02:00
Guillaume Gomez
e8869cb7a7 Wrap the span_map tuple index into a type called "LightSpan" 2021-08-05 23:08:28 +02:00
Guillaume Gomez
c5c927dfda Improve code readability 2021-08-05 23:08:28 +02:00
Guillaume Gomez
38444f61bb * Rename Span::from_rustc_span to Span::new
* Rename Span::wrap to Span::wrap_raw
* Improve documentation for Span::wrap_raw
2021-08-05 23:08:28 +02:00
Guillaume Gomez
2a3b71ae33 * Rename 'move_span' into 'local_span_to_global_span'
* Add documentation on new arguments/functions
2021-08-05 23:08:28 +02:00
Guillaume Gomez
b5c27b49d0 Underline source code links on hover 2021-08-05 23:08:28 +02:00
Guillaume Gomez
89bdc33781 Update rustdoc tests 2021-08-05 23:08:28 +02:00
Guillaume Gomez
1abb7faddb Generate links for modules as well 2021-08-05 23:08:28 +02:00
Guillaume Gomez
71763a52ff Add test for source code pages URLs 2021-08-05 23:08:28 +02:00
Guillaume Gomez
b689cedc0e Generate links for methods as well 2021-08-05 23:08:28 +02:00
Guillaume Gomez
83dcd30ee0 Ensure that --generate-link-to-definition is only used with HTML output and is unstable 2021-08-05 23:08:28 +02:00
Guillaume Gomez
2104bf27d4 Add an option for the source code link generation 2021-08-05 23:08:28 +02:00
Guillaume Gomez
023231a709 Add links on source types to go to definition 2021-08-05 23:08:27 +02:00
bors
2f07ae408f Auto merge of #87768 - rust-lang:core-features-cleanup, r=dtolnay
Core features cleanup

This sorts and categorizes the `#![features]` in `core` and removes unused ones.

This is part of #87766

The following feature attributes were unnecessary and are removed:

```diff
// Library features:
-#![feature(bool_to_option)]
-#![feature(char_indices_offset)]
-#![feature(pin_deref_mut)]
-#![feature(str_split_as_str)]
-#![feature(str_split_inclusive_as_str)]

// Language features:
-#![feature(arbitrary_self_types)]
-#![feature(custom_inner_attributes)]
-#![feature(nll)]
```
2021-08-05 17:45:43 +00:00
bors
61a941b8ba Auto merge of #87737 - LeSeulArtichaut:unsafeck-less-freeze, r=oli-obk
Only compute `is_freeze` for layout-constrained ADTs

Places are usually shallow and quick to visit. By contrast, computing `is_freeze` can be much costlier, involving inference and trait solving. Making sure to call `is_freeze` only when necessary should be beneficial for performance in most cases.

See [this comparison](https://perf.rust-lang.org/compare.html?start=81f08a4763e7537b92506fa5a597e6bf774d20cc&end=56a58d347b1c7dd0c2984b8fc3930c408e26fbc2&stat=instructions%3Au) from #87710.

r? `@oli-obk`
2021-08-05 14:45:09 +00:00
Mara Bos
cdf83c030a Make rustfmt happy. 2021-08-05 12:55:35 +02:00
Mara Bos
1b318a2b49 Remove unnecessary #[unstable] from internal macro.
After this change, all library #![feature]s enabled in core are for
const fns.
2021-08-05 12:55:35 +02:00
Mara Bos
9decf6365d Remove unused langauge #![feature]s from core. 2021-08-05 12:55:35 +02:00
Mara Bos
37d402eadd Remove unused library #![feature]s from core. 2021-08-05 12:55:35 +02:00
Mara Bos
25d0c58e0a Sort and categorize lint and feature attributes in core. 2021-08-05 12:55:33 +02:00
bors
e21e1d6a41 Auto merge of #87740 - npmccallum:naked_args, r=Amanieu
Disable unused variable lint for naked functions

In most calling conventions, accessing function parameters may require
stack access. However, naked functions have no assembly prelude to set
up stack access.  This is why naked functions may only contain a single
`asm!()` block. All parameter access is done inside the `asm!()` block,
so we cannot validate the liveness of the input parameters. Therefore,
we should disable the lint for naked functions.

rust-lang/rfcs#2774
rust-lang/rfcs#2972

`@joshtriplett` `@Amanieu` `@haraldh`
2021-08-05 10:35:21 +00:00
bors
2ddb65c322 Auto merge of #87532 - tlyu:bootstrap-rev-list, r=jyn514
bootstrap.py: use `git rev-list` for robustness

Use `git rev-list` instead of `git log` to be more robust against
UI changes in git. Also, use the full email address for bors,
because `--author` uses a substring match.

Based on #87513, but is separate because it's less minimal and may require additional manual testing.

~Open questions:~
* ~Should the `merge_base` search also use `--first-parent`?~
* ~Do we exclude non-merge commits from bors? There are a few, and I'm not sure what they have in common. Some of them look like squashes, and some look like they're in rollup branches.~

r? `@jyn514`
`@rustbot` label +A-rustbuild +C-cleanup
2021-08-05 07:33:20 +00:00
bors
d4ad1cfc63 Auto merge of #87641 - HackAttack:expand-unknown-option-message, r=wesleywiser
Allow more "unknown argument" strings from linker

Some toolchains emit slightly different errors, e.g.

    ppc-vle-gcc: error: unrecognized option '-no-pie'
2021-08-05 00:11:05 +00:00
bors
25b7648496 Auto merge of #86155 - alexcrichton:abort-on-unwind, r=nikomatsakis
rustc: Fill out remaining parts of C-unwind ABI

This commit intends to fill out some of the remaining pieces of the
C-unwind ABI. This has a number of other changes with it though to move
this design space forward a bit. Notably contained within here is:

* On `panic=unwind`, the `extern "C"` ABI is now considered as "may
  unwind". This fixes a longstanding soundness issue where if you
  `panic!()` in an `extern "C"` function defined in Rust that's actually
  UB because the LLVM representation for the function has the `nounwind`
  attribute, but then you unwind.

* Whether or not a function unwinds now mainly considers the ABI of the
  function instead of first checking the panic strategy. This fixes a
  miscompile of `extern "C-unwind"` with `panic=abort` because that ABI
  can still unwind.

* The aborting stub for non-unwinding ABIs with `panic=unwind` has been
  reimplemented. Previously this was done as a small tweak during MIR
  generation, but this has been moved to a separate and dedicated MIR
  pass. This new pass will, for appropriate functions and function
  calls, insert a `cleanup` landing pad for any function call that may
  unwind within a function that is itself not allowed to unwind. Note
  that this subtly changes some behavior from before where previously on
  an unwind which was caught-to-abort it would run active destructors in
  the function, and now it simply immediately aborts the process.

* The `#[unwind]` attribute has been removed and all users in tests and
  such are now using `C-unwind` and `#![feature(c_unwind)]`.

I think this is largely the last piece of the RFC to implement.
Unfortunately I believe this is still not stabilizable as-is because
activating the feature gate changes the behavior of the existing `extern
"C"` ABI in a way that has no replacement. My thinking for how to enable
this is that we add support for the `C-unwind` ABI on stable Rust first,
and then after it hits stable we change the behavior of the `C` ABI.
That way anyone straddling stable/beta/nightly can switch to `C-unwind`
safely.
2021-08-04 21:09:53 +00:00
Nathaniel McCallum
9c0147c02d Disable unused variable lint for naked functions
In most calling conventions, accessing function parameters may require
stack access. However, naked functions have no assembly prelude to set
up stack access.  This is why naked functions may only contain a single
`asm!()` block. All parameter access is done inside the `asm!()` block,
so we cannot validate the liveness of the input parameters. Therefore,
we should disable the lint for naked functions.

rust-lang/rfcs#2774
rust-lang/rfcs#2972
2021-08-04 15:30:10 -04:00
Nathaniel McCallum
7ac0cb0ec1 Add test for naked function unused variables lint
This test proves that naked functions are treated the same as regular
functions regarding unused function parameters. We will change this
behavior in the next patch.
2021-08-04 15:29:09 -04:00
bors
d54fbb9855 Auto merge of #87695 - tmiasko:gep-opaque-pointers, r=nagisa
Prepare GEP building for opaque pointers
2021-08-04 18:22:29 +00:00
bors
6fe0886723 Auto merge of #87736 - the8472:inline-advance-by, r=Mark-Simulacrum
#[inline] slice::Iter::advance_by

https://github.com/rust-lang/rust/pull/87387#issuecomment-891942661 was marked as a regression. One of the methods in the PR was missing an inline annotation unlike all the other methods on slice iterators.

Let's see if that makes a difference.
2021-08-04 15:39:20 +00:00
Alex Crichton
bb68c66c40 Fix assertions in coverage-reports test
Update some `C-unwind` bits and then
2021-08-04 07:47:09 -07:00
Tomasz Miąsko
8e0df32ad6 Replace LLVMConstInBoundsGEP with LLVMConstInBoundsGEP2*
A custom reimplementation of LLVMConstInBoundsGEP2 is used, since the
LLVM contains a declaration of LLVMConstInBoundsGEP2 but not the
implementation.
2021-08-04 15:51:30 +02:00
Tomasz Miąsko
77e5e17231 Prepare inbounds_gep for opaque pointers
Implement inbounds_gep using LLVMBuildInBoundsGEP2 which takes an
explicit type argument instead of deriving it from a pointer type.
2021-08-04 15:51:30 +02:00
Tomasz Miąsko
4013e094f5 Prepare gep for opaque pointers
Implement gep using LLVMBuildGEP2 which takes an explicit type argument
instead of deriving it from a pointer type.
2021-08-04 15:51:30 +02:00
Tomasz Miąsko
838042aa4e Prepare struct_gep for opaque pointers
Imlement struct_gep using LLVMBuildStructGEP2 which takes an explicit
type argument instead of deriving it from a pointer type.
2021-08-04 15:51:30 +02:00
bors
7f3dc04644 Auto merge of #87150 - rusticstuff:simplify_wrapping_neg, r=m-ou-se
Make wrapping_neg() use wrapping_sub(), #[inline(always)]

This is a follow-up change to the fix for #75598. It simplifies the implementation of wrapping_neg() for all integer types by just calling 0.wrapping_sub(self) and always inlines it. This leads to much less assembly code being emitted for opt-level≤1 and thus much better performance for debug-compiled code.

Background is [this discussion on the internals forum](https://internals.rust-lang.org/t/why-does-rust-generate-10x-as-much-unoptimized-assembly-as-gcc/14930).
2021-08-04 12:58:31 +00:00
bors
87d713ff2b Auto merge of #86197 - FabianWolff:trailing-whitespace, r=JohnTitor
Remove unnecessary trailing whitespace from error messages

Some error messages currently contain unnecessary trailing whitespace. There are some legitimate reasons for having trailing whitespace in the output, such as for uniform indentation of possibly-empty input lines, but the whitespace I have addressed here occurs in a line used only for spacing, and I see no reason why that should have trailing whitespace (spacing lines inserted in other places also don't have trailing whitespace).

I have also removed a superfluous call to `buffer.putc()`, which has no effect because the same character is already placed there by `draw_col_separator()`.

Use `git diff --ignore-space-at-eol` to see my changes; otherwise the diff is quite large due to the whitespace removed from expected outputs in `src/test/ui/`.
2021-08-04 09:58:16 +00:00
Fabian Wolff
f8372f876c Remove trailing whitespace from error messages 2021-08-04 10:48:30 +02:00
bors
49ca3d9796 Auto merge of #87026 - FabianWolff:issue-86948, r=estebank
Allow labeled loops as value expressions for `break`

Fixes #86948. This is currently allowed:
```rust
return 'label: loop { break 'label 42; };
break ('label: loop { break 'label 42; });
break 1 + 'label: loop { break 'label 42; };
break 'outer 'inner: loop { break 'inner 42; };
```
But not this:
```rust
break 'label: loop { break 'label 42; };
```
I have fixed this, so that the above now parses as an unlabeled break with a labeled loop as its value expression.
2021-08-04 07:17:25 +00:00
bors
71ff9b41e9 Auto merge of #87712 - est31:line-column-1-based, r=petrochenkov
Proc macro spans: make columns 1 based

This makes proc macro spans consistent with the `column!()` macro as well as `std::panic::Location`, as both are 1-based.

https://github.com/rust-lang/rust/issues/54725#issuecomment-497246753
2021-08-04 04:27:35 +00:00
bors
bb744e1e9f Auto merge of #87568 - petrochenkov:localevel, r=cjgillot
rustc: Replace `HirId`s with `LocalDefId`s in `AccessLevels` tables

and passes using those tables - primarily privacy checking, stability checking and dead code checking.

All these passes work with definitions rather than with arbitrary HIR nodes.
r? `@cjgillot`
cc `@lambinoo` (#87487)
2021-08-04 02:04:04 +00:00
bors
2b8de6f212 Auto merge of #87746 - JohnTitor:rollup-zaapqgl, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #81797 (Add `core::stream::from_iter`)
 - #87267 (Remove space after negative sign in Literal to_string)
 - #87663 (Rustdoc accessibility: use an icon for the [-]/[+] controls)
 - #87720 (don't use .into() to convert types to identical types (clippy::useless_conversion))
 - #87723 (Use .contains instead of manual reimplementation.)
 - #87729 (Remove the aarch64 `crypto` target_feature)
 - #87731 (Update cargo)
 - #87734 (Test dropping union fields more)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-08-03 23:07:07 +00:00
Yuki Okushi
7c5588edf5
Rollup merge of #87734 - Smittyvb:more-union-tests, r=LeSeulArtichaut
Test dropping union fields more

Now that #87403 is merged, a few more tests can be added for reads/writes to dropping union fields.

r? ``@LeSeulArtichaut``
2021-08-04 08:05:58 +09:00
Yuki Okushi
1666c26d90
Rollup merge of #87731 - ehuss:update-cargo, r=ehuss
Update cargo

11 commits in d21c22870e58499d6c31f1bef3bf1255eb021666..cc17afbb0067b1f57d8882640f63b2168d5b7624
2021-07-26 20:23:21 +0000 to 2021-08-02 20:28:08 +0000
- Stabilize the rust-version field (rust-lang/cargo#9732)
- Remove nbsp characters. (rust-lang/cargo#9751)
- Update unstable documentation TOC. (rust-lang/cargo#9750)
- Some minor updates for package/publish package selection. (rust-lang/cargo#9749)
- Bump to 0.57.0, update changelog (rust-lang/cargo#9748)
- Stabilize `[env]` sections (rust-lang/cargo#9411)
- doc: Clarify [doc].browser docs, document PathAndArgs better (rust-lang/cargo#9747)
- Bump cargo-util version. (rust-lang/cargo#9745)
- Make clippy happy (rust-lang/cargo#9736)
- Fix typo in features doc (rust-lang/cargo#9737)
- doc test supports silent output (rust-lang/cargo#9730)
2021-08-04 08:05:57 +09:00
Yuki Okushi
519c5a24e1
Rollup merge of #87729 - adamgemmell:dev/deprecate-crypto, r=Amanieu
Remove the aarch64 `crypto` target_feature

The subfeatures `aes` or `sha2` should be used instead.

This can't yet be done for ARM targets as some LLVM intrinsics still require `crypto`.

Also update the runtime feature detection tests in `library/std` to mirror the updates in `stdarch`. This also helps https://github.com/rust-lang/rust/issues/86941

r? ``@Amanieu``
2021-08-04 08:05:56 +09:00
Yuki Okushi
af8c99a235
Rollup merge of #87723 - frogtd:patch-3, r=JohnTitor
Use .contains instead of manual reimplementation.

It's also significantly easier to read.
2021-08-04 08:05:55 +09:00
Yuki Okushi
917c047c33
Rollup merge of #87720 - matthiaskrgr:clippy_into, r=jyn514
don't use .into() to convert types to identical types (clippy::useless_conversion)

Example:
let _x: String = String::from("hello world").into();
2021-08-04 08:05:54 +09:00
Yuki Okushi
75e14873b8
Rollup merge of #87663 - GuillaumeGomez:rustdoc-brace-minus-brace, r=notriddle
Rustdoc accessibility: use an icon for the [-]/[+] controls

This is a reopening of #87207 with improvement for the way of generating the `background-image` CSS property.

I quote from the original PR:

> This way, we can show the plus and minus buttons on screens, while voice
> control will read off actual words "Collapse" and "Expand" instead of reading
> "open brace minus close brace" and "open brace plus close brace".

Part of #87059

r? ``@notriddle``
2021-08-04 08:05:53 +09:00