Commit Graph

256724 Commits

Author SHA1 Message Date
Raoul Strackx 9b2e41a218 Pass function for `Thread` as `Send` to `Thread::imp` 2024-06-04 08:45:48 +02:00
Nicholas Nethercote 6b47c5e24d Remove out-of-date comment.
Exhaustiveness and usefulness checking are now in
`rustc_pattern_analysis`.
2024-06-04 15:18:35 +10:00
Nicholas Nethercote 4798c20d31 Streamline `nested` calls.
`TyCtxt` impls `PpAnn` in `compiler/rustc_middle/src/hir/map/mod.rs`. We
can call that impl, which then calls the one on `intravisit::Map`,
instead of calling the one on `intravisit::Map` directly, avoiding a
cast and extra references.
2024-06-04 15:08:08 +10:00
bors 27529d5c25 Auto merge of #125525 - joboet:tls_accessor, r=cuviper
Make TLS accessors closures that return pointers

The current TLS macros generate a function that returns an `Option<&'static T>`. This is both risky as we lie about lifetimes, and necessitates that those functions are `unsafe`. By returning a `*const T` instead, the accessor function do not have safety requirements any longer and can be made closures without hassle. This PR does exactly that!

For native TLS, the closure approach makes it trivial to select the right accessor function at compile-time, which could result in a slight speed-up (I have the hope that the accessors are now simple enough for the MIR-inliner to kick in).
2024-06-04 05:03:52 +00:00
bohan f67a0eb2b7 resolve: mark it undetermined if single import is not has any bindings 2024-06-04 12:40:41 +08:00
David Carlier fd648a3c76 std::unix::fs::get_path: using fcntl codepath for netbsd instead.
on netbsd, procfs is not as central as on linux/solaris thus
can be perfectly not mounted.
Thus using fcntl with F_GETPATH, the kernel deals with MAXPATHLEN
internally too.
2024-06-04 04:36:48 +00:00
Nicholas Nethercote d2ea692e2d Explain why `tests/ui-fulldeps/` is unformatted. 2024-06-04 14:15:45 +10:00
Nicholas Nethercote 758d49e5c8 Explain why `tests/ui/` is unformatted. 2024-06-04 14:15:45 +10:00
Nicholas Nethercote 1be65925d7 Explain why `tests/rustdoc-ui/` is unformatted. 2024-06-04 14:15:44 +10:00
Nicholas Nethercote 50185807d7 rustfmt `tests/rustdoc-js-std/`.
This is trivial, because the directory contains no `.rs` files.
2024-06-04 14:15:29 +10:00
Nicholas Nethercote 9f16362ab4 rustfmt `tests/rustdoc-json/`. 2024-06-04 14:15:19 +10:00
Nicholas Nethercote c6fb703c05 rustfmt `tests/rustdoc-js/`. 2024-06-04 14:15:06 +10:00
Nicholas Nethercote 98d65d62c5 Explain why `tests/rustdoc-gui/` is unformatted. 2024-06-04 14:14:35 +10:00
Lokathor f4b060e452 Add more ABI test cases. 2024-06-03 23:56:15 -04:00
Zalathar c57a1d1baa coverage: Remove hole-carving code from the main span refiner
Now that hole spans are handled by a separate earlier pass, this code never
sees hole spans, and therefore doesn't need to deal with them.
2024-06-04 13:51:08 +10:00
Zalathar 6d1557f268 coverage: Use hole spans to carve up coverage spans into separate buckets
This performs the same task as the hole-carving code in the main span refiner,
but in a separate earlier pass.
2024-06-04 13:51:08 +10:00
Zalathar 464dee24ff coverage: Build up initial spans by appending to a vector
This is less elegant than returning an iterator, but more flexible.
2024-06-04 13:11:45 +10:00
Zalathar 9c931c01f7 coverage: Return a nested vector from initial span extraction
This will allow the span extractor to produce multiple separate buckets,
instead of just one flat list of spans.
2024-06-04 13:11:45 +10:00
Zalathar df96cba432 Add `Span::trim_end`
This is the counterpart of `Span::trim_start`.
2024-06-04 13:11:45 +10:00
Zalathar e609c9b254 Add unit tests for `Span::trim_start` 2024-06-04 13:11:45 +10:00
bors 90d6255d82 Auto merge of #125380 - compiler-errors:wc-obj-safety, r=oli-obk
Make `WHERE_CLAUSES_OBJECT_SAFETY` a regular object safety violation

#### The issue

In #50781, we have known about unsound `where` clauses in function arguments:

```rust
trait Impossible {}

trait Foo {
    fn impossible(&self)
    where
        Self: Impossible;
}

impl Foo for &() {
    fn impossible(&self)
    where
        Self: Impossible,
    {}
}

// `where` clause satisfied for the object, meaning that the function now *looks* callable.
impl Impossible for dyn Foo {}

fn main() {
    let x: &dyn Foo = &&();
    x.impossible();
}
```

... which currently segfaults at runtime because we try to call a method in the vtable that doesn't exist. :(

#### What did u change

This PR removes the `WHERE_CLAUSES_OBJECT_SAFETY` lint and instead makes it a regular object safety violation. I choose to make this into a hard error immediately rather than a `deny` because of the time that has passed since this lint was authored, and the single (1) regression (see below).

That means that it's OK to mention `where Self: Trait` where clauses in your trait, but making such a trait into a `dyn Trait` object will report an object safety violation just like `where Self: Sized`, etc.

```rust
trait Impossible {}

trait Foo {
    fn impossible(&self)
    where
        Self: Impossible; // <~ This definition is valid, just not object-safe.
}

impl Foo for &() {
    fn impossible(&self)
    where
        Self: Impossible,
    {}
}

fn main() {
    let x: &dyn Foo = &&(); // <~ THIS is where we emit an error.
}
```

#### Regressions

From a recent crater run, there's only one crate that relies on this behavior: https://github.com/rust-lang/rust/pull/124305#issuecomment-2122381740. The crate looks unmaintained and there seems to be no dependents.

#### Further

We may later choose to relax this (e.g. when the where clause is implied by the supertraits of the trait or something), but this is not something I propose to do in this FCP.

For example, given:

```
trait Tr {
  fn f(&self) where Self: Blanket;
}

impl<T: ?Sized> Blanket for T {}
```

Proving that some placeholder `S` implements `S: Blanket` would be sufficient to prove that the same (blanket) impl applies for both `Concerete: Blanket` and `dyn Trait: Blanket`.

Repeating here that I don't think we need to implement this behavior right now.

----

r? lcnr
2024-06-04 02:34:20 +00:00
Sergi-Ferrez b7a8f1f225 Include trailing commas in functions 2024-06-04 02:47:06 +02:00
Michael Goulet 273b990554 Align Term methods with GenericArg methods 2024-06-03 20:36:27 -04:00
Michael Goulet e9957b922a Stop passing empty args to check_expr_path 2024-06-03 20:29:10 -04:00
Michael Goulet 8f08625443 Remove a bunch of redundant args from report_method_error 2024-06-03 20:29:09 -04:00
bors 1689a5a531 Auto merge of #122597 - pacak:master, r=bjorn3
Show files produced by `--emit foo` in json artifact notifications

Right now it is possible to ask `rustc` to save some intermediate representation into one or more files with `--emit=foo`, but figuring out what exactly was produced is difficult. This pull request adds information about `llvm_ir` and `asm` intermediate files into notifications produced by `--json=artifacts`.

Related discussion: https://internals.rust-lang.org/t/easier-access-to-files-generated-by-emit-foo/20477

Motivation - `cargo-show-asm` parses those intermediate files and presents them in a user friendly way, but right now I have to apply some dirty hacks. Hacks make behavior confusing: https://github.com/hintron/computer-enhance/issues/35

This pull request introduces a new behavior: now `rustc` will emit a new artifact notification for every artifact type user asked to `--emit`, for example for `--emit asm` those will include all the `.s` files.

Most users won't notice this behavior, to be affected by it all of the following must hold:
- user must use `rustc` binary directly (when `cargo` invokes `rustc` - it consumes artifact notifications and doesn't emit anything)
- user must specify both `--emit xxx` and `--json artifacts`
- user must refuse to handle unknown artifact types
- user must disable incremental compilation (or deal with it better than cargo does, or use a workaround like `save-temps`) in order not to hit #88829 / #89149
2024-06-04 00:05:56 +00:00
Nicholas Nethercote e372bf8e33 Explain why `tests/rustdoc/` is unformatted. 2024-06-04 09:53:02 +10:00
Nicholas Nethercote a78e1202dd rustfmt `tests/run-pass-valgrind/`. 2024-06-04 09:53:02 +10:00
Nicholas Nethercote d161d06241 rustfmt `tests/run-make-fulldeps/`.
Note: I inserted blank lines between the items in
`pretty-expanded/input.rs` because it looked better that way.
2024-06-04 09:53:02 +10:00
Nicholas Nethercote 5875f3fff3 Explain why `tests/pretty/` is unformatted. 2024-06-04 09:53:02 +10:00
Weihang Lo 0a11dcfdf4
feat(opt-dist): new flag `--benchmark-cargo-config`
The flag propagates cargo configs to `rustc-perf --cargo-config`,
which is particularly useful when the environment is air-gapped,
and you want to use the default set of training crates vendored
in the rustc-src tarball.
2024-06-03 17:15:52 -04:00
bors 7c52d2db63 Auto merge of #125383 - Oneirical:bundle-them-up, r=jieyouxu
Rewrite `emit`, `mixing-formats` and `bare-outfile` `run-make` tests in `rmake.rs` format

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

try-job: x86_64-msvc
2024-06-03 18:35:54 +00:00
Julia Ryan 832b8b8688
Update fuchsia maintainers 2024-06-03 10:27:10 -07:00
rustbot 47053d1621 Update books 2024-06-03 13:00:52 -04:00
Tim Kurdov 9436fbe00d
Fix typo in the docs of `HashMap::raw_entry_mut` 2024-06-03 17:35:58 +01:00
bors eb5e2449c5 Auto merge of #125864 - compiler-errors:opt-in-error-reporting, r=lcnr
Opt-in to `FulfillmentError` generation to avoid doing extra work in the new solver

In the new solver, we do additional trait solving in order to generate fulfillment errors, because all we have is the root obligation. This is problematic because there are many cases where we don't need the full error information, and instead are just calling `ObligationCtxt::select_all_or_error` to probe whether a predicate holds or not. This is also problematic because we use `ObligationCtxt`s within the error reporting machinery itself, and so we can definitely cause stack overflows:

a94483a5f2/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs (L75-L84)

So instead, make `TraitEngine` and `ObligationCtxt` generic over `E: FulfillmentErrorLike<'tcx>`, and introduce a new `ScrubbedTraitError` which only stores whether the failure was due to a "true error" or an ambiguity. Then, introduce `ObligationCtxt::new_with_diagnostics` for the callsites that actually inspect their `FulfillmentError`s.

r? `@lcnr`

Number-wise, there are:
```
     39 ObligationCtxt::new
     32 ObligationCtxt::new_with_diagnostics
      1 ObligationCtxt::new_generic
```
calls to each `ObligationCtxt` constructor, which suggests that there are indeed a lot of callsites that don't care about diagnostics.
2024-06-03 15:43:06 +00:00
Weihang Lo e9c4eb3cd3
chore: update src/tools/rustc-perf
This is needed for fixing the missing license issue.

See https://github.com/rust-lang/rust/pull/125465.
2024-06-03 11:38:23 -04:00
Michael Goulet a41c44f21c Nits and formatting 2024-06-03 10:02:08 -04:00
Michael Goulet 511f1cf7c8 check_is_object_safe -> is_object_safe 2024-06-03 09:49:30 -04:00
Michael Goulet de6b219803 Make WHERE_CLAUSES_OBJECT_SAFETY a regular object safety violation 2024-06-03 09:49:04 -04:00
Oli Scherer d498eb5937 Provide previous generic arguments to `provided_kind` 2024-06-03 13:48:54 +00:00
Oli Scherer 108a1e5f4b Always provide previous generic arguments 2024-06-03 13:45:36 +00:00
Oli Scherer 063b26af6b Explain some code duplication 2024-06-03 13:28:49 +00:00
Michael Goulet 1e72c7f536 Add cycle errors to ScrubbedTraitError to remove a couple more calls to new_with_diagnostics 2024-06-03 09:27:52 -04:00
Michael Goulet 27f5eccd1f Move FulfillmentErrorCode to rustc_trait_selection too 2024-06-03 09:27:52 -04:00
Michael Goulet 94a524ed11 Use ScrubbedTraitError in more places 2024-06-03 09:27:52 -04:00
Michael Goulet eb0a70a557 Opt-in diagnostics reporting to avoid doing extra work in the new solver 2024-06-03 09:27:52 -04:00
Michael Goulet 54b2b7d460 Make TraitEngines generic over error 2024-06-03 09:27:52 -04:00
Michael Goulet 084ccd2390 Remove unnecessary extension trait 2024-06-03 09:27:52 -04:00
Oli Scherer adb2ac0165 Mark all extraneous generic args as errors 2024-06-03 13:21:17 +00:00