Commit graph

125671 commits

Author SHA1 Message Date
Tyler Mandry
8a33c98d52
Rollup merge of #75223 - Aaron1011:feature/session-track-caller, r=eddyb
Add #[track_caller] to `Session::delay_span_bug`

This forwards the caller span to `Handler::delay_span_bug`
2020-08-16 14:59:29 -07:00
Tyler Mandry
76b2fce98b
Rollup merge of #75177 - JohnTitor:broken-mir-test, r=eddyb
Add regression test for issue-66768

Fixes #66768

This is fixed by #70452 (in particular, https://github.com/rust-lang/rust/pull/70452/files#diff-53aef089a36a8e2ed07627fc8915fe63R1763) and I'm not sure it's worth to add this test (i.e. the tests in #70452 are enough), so r? @eddyb to confirm it.
2020-08-16 14:59:27 -07:00
Tyler Mandry
54c74345b4
Rollup merge of #74399 - mark-i-m:ty-err-4, r=eddyb
Move DelaySpanBugEmitted to ty::context

This makes it even hard to abuse.

r? @eddyb

cc @LeSeulArtichaut as this will probably conflict with your PR :/
2020-08-16 14:59:25 -07:00
Tyler Mandry
3ef2244b41
Rollup merge of #74346 - eddyb:reachable-defs, r=nikomatsakis
Use LocalDefId instead of HirId for reachable_set elements.

The only `HirId`s being tracked there that don't have matching `DefId`s are local variables, and that's an accident from #44316 (where I preserved the old behavior, even if nothing relied on reachability tracking local variables).
2020-08-16 14:59:23 -07:00
Tyler Mandry
c518347579
Rollup merge of #74314 - eddyb:closure-substs-direct, r=nikomatsakis
rustc_typeck: construct {Closure,Generator}Substs more directly.

We've previously not had a way to create `{Closure,Generator}Substs` other than instantiating all generics as inference variables and unifying the inference types (extracted using the regular `{Closure,Generator}Substs` accessors), with the actual types.

With this PR, those hacks, and assumptions about the order of closure/generator-specific components, are replaced with a simple API where the base `Substs` are combined with the additional information into a `{Closure,Generator}Substs`.
This might also be faster than relying inference, although probably not by much.

r? @nikomatsakis cc #53488 @blitzerr
2020-08-16 14:59:21 -07:00
Tyler Mandry
8eba138d5b
Rollup merge of #74204 - ayazhafiz:i/74120, r=eddyb
Don't visit foreign function bodies when lowering ast to hir

Previously the existence of bodies inside a foreign function block would
cause a panic in the hir `NodeCollector` during its collection of crate
bodies to compute a crate hash:

e59b08e62e/src/librustc_middle/hir/map/collector.rs (L154-L158)

The collector walks the hir tree and creates a map of hir nodes, then
attaching bodies in the crate to their owner in the map. For a code like

```rust
extern "C" {
    fn f() {
        fn g() {}
    }
}
```

The crate bodies include the body of the function `g`. But foreign
functions cannot have bodies, and while the parser AST permits a foreign
function to have a body, the hir doesn't. This means that the body of
`f` is not present in the hir, and so neither is `g`. So when the
`NodeCollector` finishes the walking the hir, it has no record of `g`,
cannot find an owner for the body of `g` it sees in the crate bodies,
and blows up.

Why do the crate bodies include the body of `g`? The AST walker has a
need a for walking function bodies, and FFIs share the same AST node as
functions in other contexts.

There are at least two options to fix this:

- Don't unwrap the map entry for an hir node in the `NodeCollector`
- Modifier the ast->hir lowering visitor to ignore foreign function
  blocks

I don't think the first is preferrable, since we want to know when we
can't find a body for an hir node that we thought had one (dropping this
information may lead to an invalid hash). So this commit implements the
second option.

Closes #74120
2020-08-16 14:59:20 -07:00
Mark Rousskov
ccfd438aa6 Fix fortanix build 2020-08-16 16:34:39 -04:00
Jan Riemer
56daf63d10
docs: add derive for struct
Code blocks in doc comments are compiled and run, so we show `Copy` works in this example.

Co-authored-by: Poliorcetics <poliorcetics@users.noreply.github.com>
2020-08-16 22:25:59 +02:00
Jan Riemer
9061da2e14
add empty line above code block
Co-authored-by: Poliorcetics <poliorcetics@users.noreply.github.com>
2020-08-16 22:15:59 +02:00
Simon Vandel Sillesen
293756c93d Implement 'considered equal' for statements, so that for example _0 = _1 and discriminant(_0) = discriminant(0) are considered equal if 0 is a fieldless variant of an enum 2020-08-16 22:04:58 +02:00
Mateusz Mikuła
1627ba1964 Use more compatible out-implib style 2020-08-16 21:56:36 +02:00
mark
e1cd1853c8 move DelaySpanBugEmitted to ty::context 2020-08-16 14:25:51 -05:00
Jan Riemer
dce864454c add back emojis that have been removed accidentally
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-16 20:48:44 +02:00
bors
9b4db695b0 Auto merge of #73176 - LeSeulArtichaut:tyctxtat-err, r=eddyb
Add `TyCtxtAt::{ty_error, ty_error_with_message}`

~~Only e2d957d was added, the rest comes from #70551.~~
I was unsure where to put the implementation for those methods, please tell me if there is a better place for it.

Closes #72619, ~~blocked on #70551~~.

r? @eddyb cc @mark-i-m, maybe this should be part of #70551? If so feel free to cherry-pick or ask me to file a PR against your fork.
2020-08-16 18:48:26 +00:00
Eduard-Mihai Burtescu
5d44d5456f rustc_typeck: construct {Closure,Generator}Substs more directly. 2020-08-16 21:34:40 +03:00
Simonas Kazlauskas
5d22b18bf2 Improve codegen of align_offset when stride == 1
Previously checking for `pmoda == 0` would get LLVM to generate branchy
code, when, for `stride = 1` the offset can be computed without such a
branch by doing effectively a `-p % a`.

For well-known (constant) alignments, with the new ordering of these
conditionals, we end up generating 2 to 3 cheap instructions on x86_64:

    movq    %rdi, %rax
    negl    %eax
    andl    $7, %eax

instead of 5+ as previously.

For unknown alignments the new code also generates just 3 instructions:

    negq    %rdi
    leaq    -1(%rsi), %rax
    andq    %rdi, %rax
2020-08-16 21:31:48 +03:00
Simonas Kazlauskas
e7271da69a Improve align_offset at opt-level <= 1
At opt-level <= 1, the methods such as `wrapping_mul` are not being
inlined, causing significant bloating and slowdowns of the
implementation at these optimisation levels.

With use of these intrinsics, the codegen of this function at
-Copt_level=1 is the same as it is at -Copt_level=3.
2020-08-16 21:31:48 +03:00
Jan Riemer
43dec0e171
rephrase: struct -> type
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-16 20:17:28 +02:00
Eduard-Mihai Burtescu
8b86b28f50 Use LocalDefId instead of HirId for reachable_set elements. 2020-08-16 21:04:28 +03:00
Jan Riemer
a876b3d8aa
docs(marker/copy): provide example for &T being Copy
In the current documentation about the `Copy` marker trait, there is a section
with examples of structs that can implement `Copy`. Currently there is no example for
showing that shared references (`&T`) are also `Copy`.
It is worth to have a dedicated example for `&T` being `Copy`, because shared
references are an integral part of the language and it being `Copy` is not as
intuitive as other types that share this behaviour like `i32` or `bool`.

The example picks up on the previous non-`Copy` struct and shows that
structs can be `Copy`, even when they hold a shared reference to a non-`Copy` type.
2020-08-16 20:03:34 +02:00
Prabakaran Kumaresshan
0a96e089ba Switch to intra-doc links in /sys/windows/ext/{ffi,fs,process}.rs 2020-08-16 22:28:45 +05:30
bors
009551f758 Auto merge of #75472 - Mark-Simulacrum:mangling-config, r=eddyb
Add option to use the new symbol mangling in rustc/std

I don't know if this causes problems in some cases -- maybe it should be on by default for at least rustc. I've never encountered problems with it other than tools not supporting it, though.

cc @nnethercote
r? @eddyb
2020-08-16 16:58:13 +00:00
Mark Rousskov
172e67e487 Adjust installation place for compiler docs
This avoids conflicts when installing with rustup; rustup does not currently
support overlapping installations.
2020-08-16 11:42:43 -04:00
Ralf Jung
20aea20592 miri engine: add option to use force_int for alignment check 2020-08-16 17:36:46 +02:00
David Wood
dde93c9ba6
rustdoc: clean QPath::LangItem
This commit adds support for cleaning `QPath::LangItem` and
`hir::GenericBound::LangItemTrait` in rustdoc. `QPath::LangItem`
does not require lowering, and `hir::GenericBound::LangItemTrait`
is lowered to a `GenericBound::TraitBound`.

Signed-off-by: David Wood <david@davidtw.co>
2020-08-16 15:42:30 +01:00
David Wood
8367af469b
resolve: support GenericBound::LangItemTrait
This commit modifies name resolution to ensure that new scopes are
introduced from lang-item generic bounds.

Co-authored-by: Matthew Jasper <mjjasper1@gmail.com>
Signed-off-by: David Wood <david@davidtw.co>
2020-08-16 15:42:29 +01:00
David Wood
664ecf1085
hir: simplify is_range_literal
This commit simplifies `is_range_literal` by checking for
`QPath::LangItem` containing range-related lang items, rather than using
a heuristic.

Co-authored-by: Matthew Jasper <mjjasper1@gmail.com>
Signed-off-by: David Wood <david@davidtw.co>
2020-08-16 15:42:27 +01:00
David Wood
1e2f350d92
save_analysis: support QPath::LangItem
This commit implements support for `QPath::LangItem` and
`GenericBound::LangItemTrait` in save analysis.

Signed-off-by: David Wood <david@davidtw.co>
2020-08-16 15:42:26 +01:00
David Wood
762137e212
hir: introduce QPath::LangItem
This commit introduces `QPath::LangItem` to the HIR and uses it in AST
lowering instead of constructing a `hir::Path` from a slice of symbols.

This might be better for performance, but is also much cleaner as the
previous approach is fragile. In addition, it resolves a bug (#61019)
where an extern crate imported as "std" would result in the paths
created during AST lowering being resolved incorrectly (or not at all).

Co-authored-by: Matthew Jasper <mjjasper1@gmail.com>
Signed-off-by: David Wood <david@davidtw.co>
2020-08-16 15:42:25 +01:00
David Wood
7dee5f824d
hir: introduce lang items for AST lowering
This commit adds new lang items which will be used in AST lowering once
`QPath::LangItem` is introduced.

Co-authored-by: Matthew Jasper <mjjasper1@gmail.com>
Signed-off-by: David Wood <david@davidtw.co>
2020-08-16 15:42:23 +01:00
David Wood
734441c1ae
tests: add test for #61019's current behaviour
This commit adds a test for #61019 where a extern crate is imported as
`std` which results in name resolution to fail due to the uses of `std`
types introduced from lowering.

Signed-off-by: David Wood <david@davidtw.co>
2020-08-16 15:42:22 +01:00
David Wood
764dc3dc2f
lang_items: add support for lang items on variants
This commit adds support for lang items (`#[lang = "..."]` attributes)
on enum variants.

Signed-off-by: David Wood <david@davidtw.co>
2020-08-16 15:42:20 +01:00
bors
7a4fb355c6 Auto merge of #75567 - poliorcetics:intra-links-std-net, r=jyn514
Move to intra doc links in std::net

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc

The links for `true` and `false` had to stay else `rustdoc` complained, it is intended ?
2020-08-16 13:15:52 +00:00
Alexis Bourget
5fc187cd97 Fix a link, improve method resolution 2020-08-16 14:41:12 +02:00
bors
97ba0c7171 Auto merge of #75536 - estebank:e0255-suggestion, r=varkor
Tweak output of E0225

When encountering multiple non-auto trait bounds suggest creating a new
trait and explain what auto-traits are.

_Inspired by https://fasterthanli.me/articles/frustrated-its-not-you-its-rust_
2020-08-16 11:16:44 +00:00
bors
de32266a17 Auto merge of #75565 - nixphix:docs/vxworks-ext, r=jyn514
Switch to intra-doc links in std/src/sys/vxworks/ext/{fs,process}.rs

Partial fix for #75080

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc

r? @jyn514
2020-08-16 08:45:52 +00:00
bors
243c725c24 Auto merge of #75561 - kornelski:stringcol, r=Dylan-DPC
Doc: String isn't a collection

On forums one user was confused by this text, interpreting it as saying that `String` is a `Vec<char>` literally, rather than figuratively for the purpose of collect. I've reworded that paragraph.
2020-08-16 06:26:38 +00:00
bors
9d38dc22e5 Auto merge of #75553 - denisvasilik:intra-doc-links-convert, r=jyn514
Move to intra-doc links for /library/core/src/char/convert.rs

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc
2020-08-16 04:31:05 +00:00
bors
86bccb684d Auto merge of #75541 - camelid:intra-doc-links-for-core-option, r=jyn514
Switch to intra-doc links in `core::option`

Part of #75080.

I didn't change some of the links since they link into `std` and you can't link from `core` to `std` (#74481).

Also, at least one other link can't be switched to an intra-doc link because it's not supported yet (#74489).
2020-08-16 02:39:21 +00:00
bors
f032cba02e Auto merge of #75575 - marmeladema:only-measure-drop-ast, r=eddyb
Only measure time spent dropping the AST

r? @eddyb
2020-08-15 23:55:56 +00:00
marmeladema
a1dfa0f230 Only measure time spent dropping the AST 2020-08-16 00:21:14 +01:00
bors
9b88e0a866 Auto merge of #75514 - gdhuper:gdhuper/replace_log_with_tracing, r=davidtwco
Replaced `log` with `tracing`

## Description

Replaced `log` with `tracing` in the following crates:
- [x] librustc_ast
- [x] librustc_driver
- [x]  librustc_errors
- [x] librustc_expand
- [x]  librustc_hir
- [x]  librustc_incremental
- [x]  librustc_infer
- [x]  librustc_interface
- [x]  librustc_lint
- [x]  librustc_metadata
- [x]  librustc_middle
- [x]  librustc_mir
- [x]  librustc_mir_build
- [x]  librustc_parse
- [x]  librustc_passes
- [x]  librustc_privacy
- [x]  librustc_query_system
- [x]  librustc_resolve
- [x]  librustc_save_analysis
- [x] librustc_session
- [x] librustc_span
- [x] librustc_symbol_mangling
- [x] librustc_target
- [x] librustc_trait_selection
- [x] librustc_traits
- [x] librustc_ty
- [x] librustc_typeck
- [x] compiletest

Fixes: #74747

## Checklist:
- [x] Code compiles / builds
- [x] run tidy
- [x] Cleanup any clippy warnings
- [x] Update/add docs
2020-08-15 22:00:06 +00:00
Tomasz Miąsko
8de63eb964 Bump minor version of emsdk to 1.38.47
Release Notes:

```
v1.38.47: 10/02/2019
--------------------
 - Add support for FETCH API in WASM backend. This doesn't support FETCH in the
   main thread (`USE_FETCH_WORKER=0` is enforced). #9490
 - Redefine errno values to be consistent with wasi. This will let us avoid
   needing to convert the values back and forth as we use more wasi APIs.
   This is an ABI change, which should not be noticeable from user code
   unless you use errno defines (like EAGAIN) *and* keep around binaries
   compiled with an older version that you link against. In that case, you
   should rebuild them. See #9545.
 - Removed build option `-s ONLY_MY_CODE` as we now have much better solutions
   for that, like building to a wasm object file or using `STANDALONE_WASM`
   etc. (see
   https://github.com/emscripten-core/emscripten/wiki/WebAssembly-Standalone).
 - Emscripten now supports the config file (.emscripten) being placed in the
   emscripten directory rather that the current user's home directory.
   See #9543
```
2020-08-15 22:29:21 +02:00
Gurpreet Singh
d2753f91b5 replaced log with tracing 2020-08-15 13:03:11 -07:00
bors
3f3250500f Auto merge of #75246 - pickfire:patch-5, r=Amanieu
Add more examples to Path ends_with

We faced a footgun when using ends_with to check extension,
showing an example could prevent that.

2c155e50b2
2020-08-15 19:51:44 +00:00
bors
f9d17312c9 Auto merge of #75560 - Mark-Simulacrum:rustc-docs, r=matthiaskrgr
Add rustc-docs as a component

Previously it was listed as a package but wasn't available in the component
lists in rustup, so wasn't actually installable.

rustc-docs is also only present for x86_64-unknown-linux-gnu. Eventually it'll
also be shipped for aarch64-gnu with current CI configuration, but that builder
isn't quite up and running yet.

We probably want to ship compiler docs for other platforms as well, though, but
this commit doesn't enable that quite yet. A future PR may do so by adding
--enable-compiler-docs to the relevant builders (but it would also need to
decide the set of builders which we'd ship on).

r? @matthiaskrgr
2020-08-15 18:01:06 +00:00
Denis Vasilik
14b50ede7d Link to primitive instead of module 2020-08-15 19:27:34 +02:00
Alexis Bourget
15cad1c465 Move to intra doc links in std::net 2020-08-15 19:17:19 +02:00
Kornel Lesiński
d5cb5eb08b Doc: String isn't a collection 2020-08-15 17:55:10 +01:00
Camelid
8227b3b0b2
Remove unnecessary intra-doc link
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-15 09:52:35 -07:00