Commit graph

135645 commits

Author SHA1 Message Date
Yuki Okushi 7008911080 FIx ICE on wf check for foreign fns 2020-12-31 11:25:53 +09:00
bors 507bff92fa Auto merge of #80510 - JohnTitor:rollup-gow7y0l, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #80185 (Fix ICE when pointing at multi bytes character)
 - #80260 (slightly more typed interface to panic implementation)
 - #80311 (Improvements to NatVis support)
 - #80337 (Use `desc` as a doc-comment for queries if there are no doc comments)
 - #80381 (Revert "Cleanup markdown span handling")
 - #80492 (remove empty wraps, don't return Results from from infallible functions)
 - #80509 (where possible, pass slices instead of &Vec or &String (clippy::ptr_arg))

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-12-30 15:30:56 +00:00
Yuki Okushi 41fa0dba27
Rollup merge of #80509 - matthiaskrgr:ptr_arg, r=varkor
where possible, pass slices instead of &Vec or &String (clippy::ptr_arg)
2020-12-30 22:49:26 +09:00
Yuki Okushi 07083739fb
Rollup merge of #80492 - matthiaskrgr:tasty_wraps, r=varkor
remove empty wraps, don't return Results from from infallible functions

This makes code easier to understand because it is more obvious when a function actually can't fail (return Err or None)

Make functions that only ever return Some(x), return x directly
Remove return type from functions that return Option<(), Err> but would only ever return Ok(()).

Found with `clippy::unnecessary_wraps`
2020-12-30 22:49:24 +09:00
Yuki Okushi 7494aef979
Rollup merge of #80381 - rust-lang:revert-80244-spans, r=GuillaumeGomez
Revert "Cleanup markdown span handling"

Reverts rust-lang/rust#80244. This caused a diagnostic regression, originally it was:

```
warning: unresolved link to `std::process::Comman`
 --> link.rs:3:10
  |
3 | //! [a]: std::process::Comman
  |          ^^^^^^^^^^^^^^^^^^^^ no item named `Comman` in module `process`
  |
  = note: `#[warn(broken_intra_doc_links)]` on by default
```
but after that PR rustdoc now displays
```
warning: unresolved link to `std::process::Comman`
 --> link.rs:1:14
  |
1 | //! Links to [a] [link][a]
  |              ^^^ no item named `Comman` in module `process`
  |
  = note: `#[warn(broken_intra_doc_links)]` on by default
```
which IMO is much less clear.

cc `@bugadani,` thanks for catching this in https://github.com/rust-lang/rust/pull/77859.
r? `@GuillaumeGomez`
2020-12-30 22:49:23 +09:00
Yuki Okushi 18ac1ecac9
Rollup merge of #80337 - jyn514:add-query-desc, r=varkor
Use `desc` as a doc-comment for queries if there are no doc comments

This at least gives *some* idea of what the query does even if it's not very readable. Some examples:

![image](https://user-images.githubusercontent.com/23638587/103021399-13e15c00-4518-11eb-8121-940774ae2fd1.png)
![image](https://user-images.githubusercontent.com/23638587/103021448-222f7800-4518-11eb-8ee6-cc10795fdc22.png)
![image](https://user-images.githubusercontent.com/23638587/103021434-1d6ac400-4518-11eb-885b-59d00c57bc70.png)

I want to turn `{}` into either `_` or the stringified expr, but [I'm not sure how to do that](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Evaluate.20format.20string.20in.20proc-macro). In the meantime, this is better than having no docs at all.
2020-12-30 22:49:21 +09:00
Yuki Okushi 88b198b727
Rollup merge of #80311 - sivadeilra:natvis, r=petrochenkov
Improvements to NatVis support

NatVis files describe how to display types in some Windows debuggers,
such as Visual Studio, WinDbg, and VS Code.

This commit makes several improvements:

* Adds visualizers for Rc<T>, Weak<T>, and Arc<T>.

* Changes [size] to [len], for consistency with the Rust API.
  Visualizers often use [size] to mirror the size() method on C++ STL
  collections.

* Several visualizers used the PVOID and ULONG typedefs. These are part
  of the Windows API; they are not guaranteed to always be defined in a
  pure Rust DLL/EXE. I converted PVOID to `void*` and `ULONG` to
  `unsigned long`.

* Cosmetic change: Removed {} braces around the visualized display
  for `Option` types. They now display simply as `Some(value)` or
  `None`, which reflects what is written in source code.

* The visualizer for `alloc::string::String` makes assumptions about
  the layout of `String` (it casts `String*` to another type), rather
  than using symbolic expressions. This commit changes the visualizer
  so that it simply uses symbolic expressions to access the string
  data and string length.

* The visualizers for `str` and `String` now place the character data
  array under a synthetic `[chars]` node. When expanding a `String`
  node, users rarely want to see an array of characters. This just places
  them behind one expansion node / level.
2020-12-30 22:49:19 +09:00
Yuki Okushi 00741b8810
Rollup merge of #80260 - RalfJung:less-untyped-panics, r=m-ou-se
slightly more typed interface to panic implementation

The panic payload is currently being passed around as a `usize`. However, it actually is a pointer, and the involved types are available on all ends of this API, so I propose we use the proper pointer type to avoid some casts. Avoiding int-to-ptr casts also makes this code work with `miri -Zmiri-track-raw-pointers`.
2020-12-30 22:49:17 +09:00
Yuki Okushi 1caa5b00d5
Rollup merge of #80185 - JohnTitor:issue-80134, r=davidtwco
Fix ICE when pointing at multi bytes character

Fixes #80134

Seems this ICE was introduced by #73953, checking width of span to avoid ICE.
2020-12-30 22:49:16 +09:00
Yuki Okushi 4ae99cc843 Fix ICE when pointing at multi bytes character 2020-12-30 22:33:13 +09:00
bors bbcaed03bf Auto merge of #79684 - usbalbin:const_copy, r=oli-obk
Make copy[_nonoverlapping] const

Constifies
* `intrinsics::copy` and `intrinsics::copy_nonoverlapping`
* `ptr::read` and `ptr::read_unaligned`
  * `*const T::read` and `*const T::read_unaligned`
  * `*mut T::read` and `*mut T::read_unaligned`
* `MaybeUninit::assume_init_read`
2020-12-30 12:43:02 +00:00
Matthias Krüger e5ead5fc58 remove unused return types such as empty Results or Options that would always be Some(..)
remove unused return type of dropck::check_drop_obligations()
don't wrap return type in Option in get_macro_by_def_id() since we would always return Some(..)
remove redundant return type of back::write::optimize()
don't Option-wrap return type of compute_type_parameters() since we always return Some(..)
don't return empty Result in assemble_generator_candidates()
don't return empty Result in assemble_closure_candidates()
don't return empty result in assemble_fn_pointer_candidates()
don't return empty result in assemble_candidates_from_impls()
don't return empty result in assemble_candidates_from_auto_impls()
don't return emtpy result in assemble_candidates_for_trait_alias()
don't return empty result in assemble_builtin_bound_candidates()
don't return empty results in assemble_extension_candidates_for_traits_in_scope() and assemble_extension_candidates_for_trait()
remove redundant wrapping of return type of StripItem::strip() since it always returns Some(..)
remove unused return type of assemble_extension_candidates_for_all_traits()
2020-12-30 13:15:40 +01:00
Matthias Krüger bdc9291ed9 where possible, pass slices instead of &Vec or &String (clippy::ptr_arg) 2020-12-30 13:11:52 +01:00
bors d107a87d34 Auto merge of #80503 - JohnTitor:rollup-b26vglu, r=JohnTitor
Rollup of 13 pull requests

Successful merges:

 - #79812 (Lint on redundant trailing semicolon after item)
 - #80348 (remove redundant clones (clippy::redundant_clone))
 - #80358 (Edit rustc_span documentation)
 - #80457 (Add missing commas to `rustc_ast_pretty::pp` docs)
 - #80461 (Add llvm-libunwind change to bootstrap CHANGELOG)
 - #80464 (Use Option::map_or instead of open coding it)
 - #80465 (Fix typo in ffi-pure.md)
 - #80467 (More uses of the matches! macro)
 - #80469 (Fix small typo in time comment)
 - #80472 (Use sans-serif font for the "all items" page links)
 - #80477 (Make forget intrinsic safe)
 - #80482 (don't clone copy types)
 - #80487 (don't redundantly repeat field names)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-12-30 09:51:42 +00:00
Yuki Okushi 3812909919
Rollup merge of #80487 - matthiaskrgr:field_names, r=jyn514
don't redundantly repeat field names

r? `@Dylan-DPC`
2020-12-30 18:15:29 +09:00
Yuki Okushi 039b62e888
Rollup merge of #80482 - matthiaskrgr:cl0ne_on_copy, r=jyn514
don't clone copy types

r? `@Dylan-DPC`
2020-12-30 18:15:27 +09:00
Yuki Okushi 9576ee97d1
Rollup merge of #80477 - tmiasko:safe-forget, r=oli-obk
Make forget intrinsic safe
2020-12-30 18:15:25 +09:00
Yuki Okushi bdc215a8b9
Rollup merge of #80472 - GuillaumeGomez:sans-serif-for-all-items-page, r=Nemo157
Use sans-serif font for the "all items" page links

The "all items" pages' links aren't using a sans-serif font unlike the rest of equivalent items in the other module pages. ``@Nemo157`` reported me this issue so here is the fix!

r? ``@Nemo157``
2020-12-30 18:15:23 +09:00
Yuki Okushi c50800b772
Rollup merge of #80469 - BlackHoleFox:fix-time-typo, r=jonas-schievink
Fix small typo in time comment

I was reading through [this PR](https://github.com/rust-lang/rust/pull/77727/files) and noticed a [small typo](https://github.com/rust-lang/rust/pull/77727/files#diff-3183738c82f747fd92bb573712073aa384b16e14d154bf2df18f41077edc31cbR240) smuggled though. This just fixes that.
2020-12-30 18:15:21 +09:00
Yuki Okushi 231727d6e7
Rollup merge of #80467 - LingMan:more_matches, r=oli-obk
More uses of the matches! macro

`@rustbot` modify labels +C-cleanup +T-compiler
2020-12-30 18:15:20 +09:00
Yuki Okushi b050261a1a
Rollup merge of #80465 - eltociear:patch-3, r=jyn514
Fix typo in ffi-pure.md

accesing -> accessing
2020-12-30 18:15:18 +09:00
Yuki Okushi 30ddc91d41
Rollup merge of #80464 - LingMan:map_or, r=oli-obk
Use Option::map_or instead of open coding it

``@rustbot`` modify labels +C-cleanup +T-compiler
2020-12-30 18:15:16 +09:00
Yuki Okushi 7c57d51a9f
Rollup merge of #80461 - rust-lang:tmandry-patch-1, r=Mark-Simulacrum
Add llvm-libunwind change to bootstrap CHANGELOG

From #77703.

This doesn't need a `changelog-seen` version bump because the old values aren't accepted anymore, meaning anyone who was using this had to change it already.

r? ``@Mark-Simulacrum``
2020-12-30 18:15:14 +09:00
Yuki Okushi d8cabe1855
Rollup merge of #80457 - camelid:pretty-docs-commas, r=jonas-schievink
Add missing commas to `rustc_ast_pretty::pp` docs
2020-12-30 18:15:13 +09:00
Yuki Okushi 6064be7ced
Rollup merge of #80358 - pierwill:edit_rustc_span, r=lcnr
Edit rustc_span documentation

Various changes to the `rustc_span` docs, including the following:

- Additions to top-level docs
- Edits to the source_map module docs
- Edits to documentation for `Span` and `SpanData`
- Added intra-docs links
- Documentation for Levenshtein distances
- Fixed missing punctuation
2020-12-30 18:15:11 +09:00
Yuki Okushi a309468a8c
Rollup merge of #80348 - matthiaskrgr:less_clones, r=Dylan-DPC
remove redundant clones (clippy::redundant_clone)
2020-12-30 18:15:04 +09:00
Yuki Okushi 3fe423663b
Rollup merge of #79812 - Aaron1011:lint-item-trailing-semi, r=oli-obk
Lint on redundant trailing semicolon after item

We now lint on code like this:

```rust
fn main() {
    fn foo() {};
    struct Bar {};
}
```

Previously, this caused warnings in Cargo, so it was disabled.
2020-12-30 18:15:03 +09:00
bors b9c403be11 Auto merge of #79472 - Aaron1011:new-remove-pretty-print-hack, r=petrochenkov
Replace pretty-print/compare/retokenize hack with targeted workarounds

Based on https://github.com/rust-lang/rust/pull/78296
cc https://github.com/rust-lang/rust/issues/43081

The 'pretty-print/compare/retokenize' hack is used to try to avoid passing an outdated `TokenStream` to a proc-macro when the underlying AST is modified in some way (e.g. cfg-stripping before derives). Unfortunately, retokenizing throws away spans (including hygiene information), which causes issues of its own. Every improvement to the accuracy of the pretty-print/retokenize comparison has resulted in non-trivial ecosystem breakage due to hygiene changes. In extreme cases, users deliberately wrote unhygienic `macro_rules!` macros (likely because they did not realize that the compiler's behavior was a bug).

Additionaly, the comparison between the original and pretty-printed/retoknized token streams comes at a non-trivial runtime cost, as shown by https://github.com/rust-lang/rust/pull/79338

This PR removes the pretty-print/compare/retokenize logic from `nt_to_tokenstream`. We only discard the original `TokenStream` under two circumstances:
* Inner attributes are used (detected by examining the AST)
* `cfg`/`cfg_attr` processing modifies the AST. This is detected by making the visitor update a flag when it performs a modification, instead of trying to detect the modification after-the-fact. Note that a 'matching' `cfg` (e.g. `#[cfg(not(FALSE)]`) does not actually get removed from the AST, allowing us to preserve the original `TokenStream`.

In all other cases, we preserve the original `TokenStream`.

This could use a bit of refactoring/renaming - opening for a Crater run.

r? `@ghost`
2020-12-30 07:04:49 +00:00
Joshua Nelson e67f9d3105 Use desc as a doc-comment if none exist yet
- Replace {} with the stringified expr

  Giant thank you to `@danielhenrymantilla` for figuring out how to make
  this work ❤️

- Note that this is just an approximation and it would be better to add
  a doc-comment
2020-12-29 21:13:06 -05:00
bors f3eead1c69 Auto merge of #80453 - petrochenkov:nocfail, r=Mark-Simulacrum
Remove `compile-fail` test suite

By moving all of its tests to `ui` test suite.
Now we have directives like `// dont-check-compiler-stderr` that allow to disable `.stderr` comparison for platform-dependent tests without introducing a whole new test suite.
2020-12-29 23:20:46 +00:00
Aaron Hill 6bef37c841
Remove unnecessary semicolon from Clippy test 2020-12-29 17:16:04 -05:00
Aaron Hill 4c4700d9e5
Remove unnecessary semicolon from Rustdoc-generated code 2020-12-29 16:30:02 -05:00
Aaron Hill 21ed141b94
Remove trailing semicolon in librustdoc 2020-12-29 16:30:02 -05:00
Aaron Hill c857cbeb06
Lint on redundant trailing semicolon after item
We now lint on code like this:

```rust
fn main() {
    fn foo() {};
    struct Bar {};
}
```

Previously, this caused warnings in Cargo, so it was disabled.
2020-12-29 16:30:02 -05:00
Matthias Krüger 0c3af22e08 don't redundantly repeat field names 2020-12-29 22:26:58 +01:00
Vadim Petrochenkov 4d2d0bad4e Remove compile-fail test suite 2020-12-29 23:39:56 +03:00
Matthias Krüger 17a8c1017f don't clone copy types 2020-12-29 19:40:03 +01:00
LingMan 7a41532ef9 More uses of the matches! macro 2020-12-29 17:18:52 +01:00
Guillaume Gomez 893c626d06 Use sans-serif font for the "all items" page links 2020-12-29 15:56:52 +01:00
Aaron Hill 530a629635
Remove pretty-print/reparse hack, and add derive-specific hack 2020-12-29 09:36:42 -05:00
bors 158f8d034b Auto merge of #80014 - jyn514:box-item-kind, r=nnethercote
[rustdoc] Box ItemKind to reduce the size of `Item`

This brings the size of `Item` from

```
[src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 536
```

to

```
[src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 136
```

This is an alternative to https://github.com/rust-lang/rust/pull/79967; I don't think it makes sense to make both changes.

Helps with #79103.
2020-12-29 10:41:01 +00:00
BlackHoleFox 5449a42a1c Fix small typo in time comment 2020-12-29 02:10:29 -06:00
bors e2a2592885 Auto merge of #79084 - simonvandel:instcombine-perf, r=oli-obk
Small perf changes for InstCombine
2020-12-29 06:21:18 +00:00
Joshua Nelson 5fce0dd787 Add static assertion for the size of ItemKind 2020-12-29 00:43:25 -05:00
Ikko Ashimine 02db77c2d1
Fix typo in ffi-pure.md
accesing -> accessing
2020-12-29 13:37:21 +09:00
LingMan 3dae414cb6 Use Option::map_or instead of open coding it 2020-12-29 04:27:37 +01:00
bors d75f48e04d Auto merge of #80449 - m-ou-se:rollup-kp2e5n8, r=m-ou-se
Rollup of 11 pull requests

Successful merges:

 - #80383 (clarify wrapping ptr arithmetic docs)
 - #80390 (BTreeMap: rename the area access methods)
 - #80393 (Add links to the source for the rustc and rustdoc books.)
 - #80398 (Use raw version of align_of in rc data_offset)
 - #80402 (Document `InferTy` & co.)
 - #80403 (fix: small typo error in chalk/mod.rs)
 - #80410 (rustdoc book: fix example)
 - #80419 (Add regression test for #80375)
 - #80430 (Add "length" as doc alias to len methods)
 - #80431 (Add "chr" as doc alias to char::from_u32)
 - #80448 (Fix stabilization version of deque_range feature.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-12-29 00:16:54 +00:00
Tomasz Miąsko 5718cc2f9b Make forget intrinsic safe 2020-12-29 00:00:00 +00:00
Tyler Mandry 8041ccff2c
Add llvm-libunwind change to bootstrap CHANGELOG
From #77703.
2020-12-28 15:57:53 -08:00
Camelid 8d5dc8c2f0
Add missing commas to rustc_ast_pretty::pp docs 2020-12-28 14:23:20 -08:00