Commit Graph

655 Commits

Author SHA1 Message Date
Camille GILLOT
45ad22be8f Encode type in the main loop. 2022-08-30 19:04:04 +02:00
bors
a0d07093f8 Auto merge of #100812 - Nilstrieb:revert-let-chains-nightly, r=Mark-Simulacrum
Revert let_chains stabilization

This is the revert against master, the beta revert was already done in #100538.

Bumps the stage0 compiler which already has it reverted.
2022-08-30 05:48:22 +00:00
Nilstrieb
d1ef8180f9 Revert let_chains stabilization
This reverts commit 3266460749.

This is the revert against master, the beta revert was already done in #100538.
2022-08-29 19:34:11 +02:00
Dylan DPC
5555e13a6e
Rollup merge of #99821 - cjgillot:ast-lifetimes-2, r=compiler-errors
Remove separate indexing of early-bound regions

~Based on https://github.com/rust-lang/rust/pull/99728.~

This PR copies some modifications from https://github.com/rust-lang/rust/pull/97839 around object lifetime defaults.
These modifications allow to stop counting generic parameters during lifetime resolution, and rely on the indexing given by `rustc_typeck::collect`.
2022-08-29 16:49:39 +05:30
Daniel Paoliello
cc49c3e582 Implementation of import_name_type 2022-08-26 09:15:35 -07:00
bors
76531befc4 Auto merge of #100436 - jyn514:macro-query-system, r=cjgillot
try and simplify some things in the query system
2022-08-25 05:35:27 +00:00
Joshua Nelson
e188868014 get rid of another unnecessary lifetime macro argument 2022-08-23 21:52:29 -05:00
klensy
f6329485a8 rmeta/query cache: don't write string values of preinterned symbols 2022-08-20 15:39:21 +03:00
bors
468887ef91 Auto merge of #100209 - cjgillot:source-file-index, r=estebank
Lazily decode SourceFile from metadata

Currently, source files from foreign crates are decoded up-front from metadata.
Spans from those crates were matched with the corresponding source using binary search among those files.

This PR changes the strategy by matching spans to files during encoding. This allows to decode source files on-demand, instead of up-front. The on-disk format for spans becomes: `<tag> <position from start of file> <length> <file index> <crate (if foreign file)>`.
2022-08-19 15:31:25 +00:00
klensy
adba4691f6 cache strings while encoding/decoding to compiler artifacts 2022-08-15 17:56:37 +03:00
Mark Rousskov
154a09dd91 Adjust cfgs 2022-08-12 16:28:15 -04:00
Daniel Paoliello
fda5144ceb Add error if link_ordinal used without raw-dylib 2022-08-09 11:02:41 -07:00
Dylan DPC
1dc4858914
Rollup merge of #96478 - WaffleLapkin:rustc_default_body_unstable, r=Aaron1011
Implement `#[rustc_default_body_unstable]`

This PR implements a new stability attribute — `#[rustc_default_body_unstable]`.

`#[rustc_default_body_unstable]` controls the stability of default bodies in traits.
For example:
```rust
pub trait Trait {
    #[rustc_default_body_unstable(feature = "feat", isssue = "none")]
    fn item() {}
}
```
In order to implement `Trait` user needs to either
- implement `item` (even though it has a default implementation)
- enable `#![feature(feat)]`

This is useful in conjunction with [`#[rustc_must_implement_one_of]`](https://github.com/rust-lang/rust/pull/92164), we may want to relax requirements for a trait, for example allowing implementing either of `PartialEq::{eq, ne}`, but do so in a safe way — making implementation of only `PartialEq::ne` unstable.

r? `@Aaron1011`
cc `@nrc` (iirc you were interested in this wrt `read_buf`), `@danielhenrymantilla` (you were interested in the related `#[rustc_must_implement_one_of]`)
P.S. This is my first time working with stability attributes, so I'm not sure if I did everything right 😅
2022-08-09 17:34:50 +05:30
Camille GILLOT
0d41f9145c Remove unused parameter. 2022-08-08 21:12:04 +02:00
Camille GILLOT
bacb4db48c Only encode position from start of file. 2022-08-07 12:27:38 +02:00
Camille GILLOT
16ba778c12 Support parallel compiler. 2022-08-06 23:28:32 +02:00
Camille GILLOT
7c2d722fb0 Simplify encoding a bit. 2022-08-06 23:13:09 +02:00
Camille GILLOT
d74af405eb Remove unused cache. 2022-08-06 23:09:15 +02:00
Camille GILLOT
a09e9c99a4 Decode SourceFile out of order. 2022-08-06 23:08:10 +02:00
Camille GILLOT
f20ceb1c6f Encode index of SourceFile along with span. 2022-08-06 22:33:06 +02:00
Camille GILLOT
99e2d33315 Compute object_lifetime_default per parameter. 2022-08-03 18:42:04 +02:00
bors
21de280ccc Auto merge of #95884 - cjgillot:assoc-item, r=lcnr
Thin `AssocItem`

This PR removes a few fields from `AssocItem` that should be easily computed using other queries.
This simplifies some of the metadata decoding.
2022-08-01 21:43:35 +00:00
Camille GILLOT
957548183d Remove trait_of_item query. 2022-08-01 21:39:26 +02:00
Camille GILLOT
d7ea161b7e Remove DefId from AssocItemContainer. 2022-08-01 21:38:45 +02:00
Camille GILLOT
8ee4446ee5 Remove visibility from AssocItem. 2022-08-01 21:38:20 +02:00
Camille GILLOT
110f0656cb Store associated item defaultness in impl_defaultness. 2022-08-01 21:38:16 +02:00
bors
fe3342816a Auto merge of #99476 - dpaoliello:rawdylibvectorcall, r=michaelwoerister
Add tests for raw-dylib with vectorcall, and fix vectorcall code generation

* Adds tests for using `raw-dylib` (#58713) with `vectorcall`.
* Fixed code generation for `vectorcall` (parameters have to be marked with `InReg`, just like `fastcall`).
* Enabled running the `raw-dylib` `fastcall` tests when using MSVC (since I had to add support in the test for running MSVC-only tests since GCC doesn't support `vectorcall`).
2022-08-01 18:43:57 +00:00
Miguel Guarniz
16513d689e Rename local_did to def_id
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29 18:26:10 -04:00
Miguel Guarniz
25bdc8965e Change maybe_body_owned_by to take local def id
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29 18:25:58 -04:00
Yuki Okushi
645a88374a
Update mentions to rustc_metadata::rmeta::Lazy
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-07-27 20:09:46 +09:00
Yuki Okushi
3ca1c3100d
Rollup merge of #99698 - compiler-errors:no-doc-hidden, r=cjgillot
Prefer visibility map parents that are not `doc(hidden)` first

Far simpler approach to #98876.

This only fixes the case where the parent is `doc(hidden)`, not where the child is `doc(hidden)` since I don't know how to get the attrs on the import statement given a `ModChild`... I'll try to follow up with that, but this is a good first step.
2022-07-27 11:52:53 +09:00
Daniel Paoliello
722d67d5e7 Fix vectorcall 2022-07-26 14:11:37 -07:00
Maybe Waffle
177af47104 Implement #[rustc_default_body_unstable]
This attribute allows to mark default body of a trait function as
unstable. This means that implementing the trait without implementing
the function will require enabling unstable feature.

This is useful in conjunction with `#[rustc_must_implement_one_of]`,
we may want to relax requirements for a trait, for example allowing
implementing either of `PartialEq::{eq, ne}`, but do so in a safe way
-- making implementation of only `PartialEq::ne` unstable.
2022-07-26 15:38:03 +04:00
Michael Goulet
42a4419120 Do not prefer module parents which are doc(hidden) in visibility map 2022-07-24 21:27:03 +00:00
Pietro Albini
f1063c054d
remove new allocations from imported_source_files 2022-07-24 16:20:14 +02:00
Daniel Bevenius
db977ca37e Fix typo/grammar in locator.rs doc comment 2022-07-23 07:31:20 +02:00
David Wood
6246d66c6d passes: improved partial stabilization diagnostic
Improves the diagnostic when a feature attribute is specified
unnecessarily but the feature implies another (i.e. it was partially
stabilized) to refer to the implied feature.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-20 14:53:01 +01:00
Caio
3266460749 Stabilize let_chains 2022-07-16 20:17:58 -03:00
bors
1ba1fec234 Auto merge of #96544 - m-ysk:feature/issue-96358, r=cjgillot
Stop keeping metadata in memory before writing it to disk

Fixes #96358

I created this PR according with the instruction given in the issue except for the following points:

- While the issue says "Write metadata into the temporary file in `encode_and_write_metadata` even if `!need_metadata_file`", I could not do that. That is because though I tried to do that and run `x.py test`, I got a lot of test failures as follows.

<details>
<summary>List of failed tests</summary>
<pre>
<code>
failures:
    [ui] src/test/ui/json-multiple.rs
    [ui] src/test/ui/json-options.rs
    [ui] src/test/ui/rmeta/rmeta-rpass.rs
    [ui] src/test/ui/save-analysis/emit-notifications.rs
    [ui] src/test/ui/svh/changing-crates.rs
    [ui] src/test/ui/svh/svh-change-lit.rs
    [ui] src/test/ui/svh/svh-change-significant-cfg.rs
    [ui] src/test/ui/svh/svh-change-trait-bound.rs
    [ui] src/test/ui/svh/svh-change-type-arg.rs
    [ui] src/test/ui/svh/svh-change-type-ret.rs
    [ui] src/test/ui/svh/svh-change-type-static.rs
    [ui] src/test/ui/svh/svh-use-trait.rs

test result: FAILED. 12915 passed; 12 failed; 100 ignored; 0 measured; 0 filtered out; finished in 71.41s

Some tests failed in compiletest suite=ui mode=ui host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
Build completed unsuccessfully in 0:01:58
</code>
</pre>
</details>

- I could not resolve the extra tasks about `create_rmeta_file` and `create_compressed_metadata_file` for my lack of ability.
2022-07-14 21:50:14 +00:00
Dylan DPC
ecae3d74e2
Rollup merge of #99000 - JulianKnodt:allow_resolve_no_substs, r=lcnr
Move abstract const to middle

Moves AbstractConst (and all associated methods) to rustc middle for use in `rustc_infer`.
This allows for const resolution in infer to use abstract consts to walk consts and check if
they are resolvable.

This attempts to resolve the issue where `Foo<{ concrete const }, generic T>` is incorrectly marked as conflicting, and is independent from the other issue where nested abstract consts must be resolved.

r? `@lcnr`
2022-07-14 19:24:04 +05:30
Joshua Nelson
3c9765cff1 Rename debugging_opts to unstable_opts
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`).
Rename it to be more clear.
2022-07-13 17:47:06 -05:00
kadmin
e612e2603c Move abstract const to rustc_middle::ty 2022-07-12 02:21:31 +00:00
bors
1517f5de01 Auto merge of #99024 - matthiaskrgr:rollup-8ygpcpg, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #97917 (Implement ExitCodeExt for Windows)
 - #98844 (Reword comments and rename HIR visiting methods.)
 - #98979 (interpret: use AllocRange in UninitByteAccess)
 - #98986 (Fix missing word in comment)
 - #98994 (replace process exit with more detailed exit in src/bootstrap/*.rs)
 - #98995 (Add a test for #80471)
 - #99002 (suggest adding a derive for #[default] applied to variants)
 - #99004 (Add a test for #70408)
 - #99017 (Replace boolean argument for print_where_clause with an enum to make code more clear)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-07 20:55:34 +00:00
Camille GILLOT
111df9e6ed Reword comments and rename HIR visiting methods. 2022-07-07 16:01:43 +02:00
Camille GILLOT
43bb31b954 Allow to create definitions inside the query system. 2022-07-06 22:50:55 +02:00
bors
6a10920564 Auto merge of #97235 - nbdd0121:unwind, r=Amanieu
Fix FFI-unwind unsoundness with mixed panic mode

UB maybe introduced when an FFI exception happens in a `C-unwind` foreign function and it propagates through a crate compiled with `-C panic=unwind` into a crate compiled with `-C panic=abort` (#96926).

To prevent this unsoundness from happening, we will disallow a crate compiled with `-C panic=unwind` to be linked into `panic-abort` *if* it contains a call to `C-unwind` foreign function or function pointer. If no such call exists, then we continue to allow such mixed panic mode linking because it's sound (and stable). In fact we still need the ability to do mixed panic mode linking for std, because we only compile std once with `-C panic=unwind` and link it regardless panic strategy.

For libraries that wish to remain compile-once-and-linkable-to-both-panic-runtimes, a `ffi_unwind_calls` lint is added (gated under `c_unwind` feature gate) to flag any FFI unwind calls that will cause the linkable panic runtime be restricted.

In summary:
```rust
#![warn(ffi_unwind_calls)]

mod foo {
    #[no_mangle]
    pub extern "C-unwind" fn foo() {}
}

extern "C-unwind" {
    fn foo();
}

fn main() {
    // Call to Rust function is fine regardless ABI.
    foo::foo();
    // Call to foreign function, will cause the crate to be unlinkable to panic-abort if compiled with `-Cpanic=unwind`.
    unsafe { foo(); }
    //~^ WARNING call to foreign function with FFI-unwind ABI
    let ptr: extern "C-unwind" fn() = foo::foo;
    // Call to function pointer, will cause the crate to be unlinkable to panic-abort if compiled with `-Cpanic=unwind`.
    ptr();
    //~^ WARNING call to function pointer with FFI-unwind ABI
}
```

Fix #96926

`@rustbot` label: T-compiler F-c_unwind
2022-07-02 14:06:27 +00:00
Yoshiki Matsuda
7a5e773dc2 fall back on the blank path if out_filename is blank 2022-07-02 22:54:37 +09:00
Yoshiki Matsuda
a206121388 seek instead of opening a new file handle 2022-07-02 22:54:37 +09:00
Yoshiki Matsuda
ea0e0f4e13 avoid holding the temp_dir for empty metadata file 2022-07-02 22:54:37 +09:00
Yoshiki Matsuda
3e309350d2 add a comment about counting zero bytes 2022-07-02 22:54:37 +09:00