Commit graph

152868 commits

Author SHA1 Message Date
Oli Scherer
20371b94f6 Immediately register new opaque types in the global list.
Previously each opaque type instantiation would create new inference vars, even for the same opaque type/substs combination. Now there is a global map in InferCtxt that gets filled whenever we encounter an opaque type.
2021-08-06 10:39:08 +00:00
Oli Scherer
816b9fc2d1 Remove Option only used as its Some variant 2021-08-06 10:27:37 +00:00
Oli Scherer
c091b5c84c Remove a useless feature gateing
With the planned lazy TAIT system, this will not really make sense anymore anyway.
2021-08-06 10:25:18 +00:00
Oli Scherer
a30b548919 Split fold_opaque_ty 2021-08-06 10:23:11 +00:00
Oli Scherer
34182804e8 Move some code around in preparation of splitting a function 2021-08-06 10:21:01 +00:00
Oli Scherer
14021feea9 Remove a field that is computed later anyway 2021-08-06 10:18:31 +00:00
Oli Scherer
d99805982b Move opaque type cache into InferCtxt 2021-08-06 10:12:31 +00:00
Jakub Beránek
d0d4947775
Add hint for unresolved associated trait items if the trait has a single item 2021-08-06 11:31:52 +02:00
David Carlier
5501eba645 current_exe haiku code path simplification all of these part of libc 2021-08-06 10:11:49 +01:00
bors
1f94abcda6 Auto merge of #87808 - JohnTitor:rollup-qqp79xs, r=JohnTitor
Rollup of 9 pull requests

Successful merges:

 - #87561 (thread set_name haiku implementation.)
 - #87715 (Add long error explanation for E0625)
 - #87727 (explicit_generic_args_with_impl_trait: fix min expected number of generics)
 - #87742 (Validate FFI-safety warnings on naked functions)
 - #87756 (Add back -Zno-profiler-runtime)
 - #87759 (Re-use std::sealed::Sealed in os/linux/process.)
 - #87760 (Promote `aarch64-apple-ios-sim` to Tier 2)
 - #87770 (permit drop impls with generic constants in where clauses)
 - #87780 (alloc: Use intra doc links for the reserve function)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-08-06 05:02:35 +00:00
Max Fan
89a8ba46b8 Fix typo in the ptr documentation 2021-08-05 22:50:56 -04:00
Yuki Okushi
b98c388352
Rollup merge of #87780 - est31:intra_doc_links, r=jyn514
alloc: Use intra doc links for the reserve function

The sentence exists to highlight the existence of a
performance footgun of repeated calls of the
reserve_exact function.
2021-08-06 11:21:36 +09:00
Yuki Okushi
8bad35095b
Rollup merge of #87770 - BoxyUwU:cec-drop-impl, r=lcnr
permit drop impls with generic constants in where clauses

Fixes #79248

`==` is not sufficient to check for equality between unevaluated consts which causes the above issue because the const in `[(); N - 1]:` on the impl and the const in `[(); N - 1]:` on the struct def are not seen as equal. Any predicate that can contain an unevaluated const cant use `==` here as it will cause us to incorrectly emit an error.

I dont know much about chalk but it seems like we ought to be relating the `TypeWellFormedFromEnv` instead of `==` as it contains a `Ty` so I added that too...

r? ``````@lcnr``````
2021-08-06 11:21:35 +09:00
Yuki Okushi
41076a8ac9
Rollup merge of #87760 - badboy:promote-ios-sim-target, r=Mark-Simulacrum
Promote `aarch64-apple-ios-sim` to Tier 2

As per https://github.com/rust-lang/compiler-team/issues/428 this target becomes Tier 2.

---

I tested that the latest nightly has the target and I'm already building my project with that on CI and locally.
2021-08-06 11:21:34 +09:00
Yuki Okushi
13f9a4c309
Rollup merge of #87759 - m-ou-se:linux-process-sealed, r=jyn514
Re-use std::sealed::Sealed in os/linux/process.

This uses `std::sealed::Sealed` in `std::os::linux::process` instead of defining new `Sealed` traits there.
2021-08-06 11:21:33 +09:00
Yuki Okushi
5a36cdb9d2
Rollup merge of #87756 - Amanieu:no_profiler_runtime, r=jackh726
Add back -Zno-profiler-runtime

This was removed by #85284 in favor of `-Zprofiler-runtime=<name>`.However the suggested `-Zprofiler-runtime=None` doesn't work because`None` is treated as a crate name.
2021-08-06 11:21:32 +09:00
Yuki Okushi
71ad503fd9
Rollup merge of #87742 - npmccallum:naked_ffi, r=Amanieu
Validate FFI-safety warnings on naked functions

Test that FFI-safety warnings don't get accidentally dropped on naked
functions. The big picture is that if you implement a naked function
with the Rust ABI you'll get a warning. Further, if you implement a
naked function with a standardized ABI, but use non-FFI-safe types you
will still get a warning.

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

cc ``````@joshtriplett`````` ``````@Amanieu`````` ``````@haraldh``````
2021-08-06 11:21:31 +09:00
Yuki Okushi
5b43960687
Rollup merge of #87727 - SkiFire13:fix-87718, r=jackh726
explicit_generic_args_with_impl_trait: fix min expected number of generics

Fixes #87718

The problem was that `synth_type_param_count` was already subtracted from `named_type_param_count`, so this ended up being subtracted again. This caused `expected_min` to overflow, and ultimately resulting in weird and wrong behaviour.

I've also added another test not present in the original issue but caused by the same bug.
2021-08-06 11:21:30 +09:00
Yuki Okushi
772db06e10
Rollup merge of #87715 - bhgomes:long-explanation-E0625, r=GuillaumeGomez
Add long error explanation for E0625

For #61137.
2021-08-06 11:21:29 +09:00
Yuki Okushi
4b068dd657
Rollup merge of #87561 - devnexen:haiku_thread_build_fix, r=yaahc
thread set_name haiku implementation.
2021-08-06 11:21:28 +09:00
bors
7129033b42 Auto merge of #87462 - ibraheemdev:tidy-file-length-ignore-comment, r=Mark-Simulacrum
Ignore comments in tidy-filelength

Ref https://github.com/rust-lang/rust/issues/60302#issuecomment-652402127
2021-08-06 02:07:01 +00:00
Hans Kratz
89a369ad2e Replace hard-coded field indexes with lookup on aarch64 non-macos.
The indexes into the VaListImpl struct used on aarch64 ABI (not macos/ios) are hard-coded which is brittle so we replace them with the usual lookup.

The varargs ffi is tested in ui/abi/variadic-ffi.rs on aarch64 Linux.
2021-08-05 22:40:32 +00:00
bors
e2f79572fb Auto merge of #84176 - GuillaumeGomez:src-to-definition, r=jyn514
Generate links to definition in rustdoc source code pages

## Description

This PR adds an option (disabled by default) to add links in the source code page on ident. So for for example:

```rust
mod other_module;
struct Foo;
fn bar() {}

fn x<T: other_module::Trait>(f: Foo, g: other_module::Whatever, t: &T) {
    let f: Foo = Foo;
    bar();
    f.some_method();
}
```

In the example (mostly in the `x` function), `other_module::Trait`, `Foo`, `other_module::Whatever`, `bar` and `some_method` are now links (and `other_module` at the top too).

In case there is a type coming from another crate, it'll link to its documentation page and not its definition (but you can then click on `[src]` so I guess it's fine).

Another important detail: I voluntarily didn't add links for primitive types. I think we can discuss about adding links on them or not in a later PR (adding the support for them would require only a few lines).

Here is a video summing up everything I wrote above:

https://user-images.githubusercontent.com/3050060/114622354-21307b00-9cae-11eb-834d-f6d8178a37bd.mp4

## Performance impact

So, on my computer, the performance remains more or less the same (which is quite surprising but that's a nice surprise). Here are the numbers:

Without the option:
 * core:  1m 21s
 * alloc: 26.78s
 * std: 27.30s
 * proc_macro: 4.50s

With source to definition links generation (I enabled by default the option):
 * core: 1m 25s
 * alloc: 25.76s
 * std: 27.07s
 * proc_macro: 4.66s

So no real change here (again, I'm very surprised by this fact).

For the size of the generated source files (only taking into account the `src` folder here since it's the only one impacted) by running `du -shc .` (when I am in the source folder).

Without the option: 11.939 MB
With the option: 12.611 MB

So not a big change here either. In all those docs, I ran `grep -nR '<a class=' . | wc -l` and got 43917. So there are quite a lot of links added. :)

cc `@rust-lang/rustdoc`
r? `@jyn514`
2021-08-05 22:13:32 +00:00
Guillaume Gomez
ba11dc7fdd Fix URL conflict for std type 2021-08-05 23:33:43 +02:00
Guillaume Gomez
dfe4fec783 Remove LightSpan and use Span directly 2021-08-05 23:08:29 +02:00
Guillaume Gomez
5cf300d695 Remove warnings/errors from compiler when using typeck_body in rustdoc span map builder 2021-08-05 23:08:29 +02:00
Guillaume Gomez
0799528db7 * Rename LightSpan::empty into LightSpan::dummy
* Add Classifier::new_light_span to wrap LightSpan::new_in_file constructor
2021-08-05 23:08:29 +02:00
Guillaume Gomez
fd69fa8670 Add missing root_path when generating links using href 2021-08-05 23:08:29 +02:00
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
The8472
1c21373b50 add Box::try_new_uninit_slice for symmetry 2021-08-05 21:21:52 +02:00
Josh Stone
a292390854 Only allow LLVM element_type on Array and Vector 2021-08-05 11:06:32 -07:00
Josh Stone
41f27d903a Remove the decl arg from FnAbi::llvm_type
We can apply the `c_variadic` fix all the time, rather than trying to
distinguish between declarations and any other use.
2021-08-05 10:58:55 -07:00
Josh Stone
183d79cc09 Prepare call/invoke for opaque pointers
Rather than relying on `getPointerElementType()` from LLVM function
pointers, we now pass the function type explicitly when building `call`
or `invoke` instructions.
2021-08-05 10:58:55 -07:00
The8472
55def120a4 replace Vec<u8> with Box<[u8]> 2021-08-05 19:52:08 +02:00