Commit graph

158776 commits

Author SHA1 Message Date
Dylan MacKenzie fca642c1c3 Add pass for simple phase change 2021-12-02 17:31:38 -08:00
Dylan MacKenzie fd18b45e11 Update passes with new interface 2021-12-02 17:31:38 -08:00
Dylan MacKenzie c1a501b131 Implement a pass manager 2021-12-02 17:31:38 -08:00
Dylan MacKenzie a0de6346de Move instrument coverage config getters to Options 2021-12-02 17:12:59 -08:00
Dylan MacKenzie 386b1c5f57 Move mir_opt_level getter into Options 2021-12-02 17:12:58 -08:00
bors ff23ad3179 Auto merge of #91469 - matthiaskrgr:rollup-xom3j55, r=matthiaskrgr
Rollup of 12 pull requests

Successful merges:

 - #89954 (Fix legacy_const_generic doc arguments display)
 - #91321 (Handle placeholder regions in NLL type outlive constraints)
 - #91329 (Fix incorrect usage of `EvaluatedToOk` when evaluating `TypeOutlives`)
 - #91364 (Improve error message for incorrect field accesses through raw pointers)
 - #91387 (Clarify and tidy up explanation of E0038)
 - #91410 (Move `#![feature(const_precise_live_drops)]` checks earlier in the pipeline)
 - #91435 (Improve diagnostic for missing half of binary operator in `if` condition)
 - #91444 (disable tests in Miri that take too long)
 - #91457 (Add additional test from rust issue number 91068)
 - #91460 (Document how `last_os_error` should be used)
 - #91464 (Document file path case sensitivity)
 - #91466 (Improve the comments in `Symbol::interner`.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-02 21:58:48 +00:00
Matthias Krüger f7afd461c7
Rollup merge of #91466 - nnethercote:Symbol-interner-comments, r=Mark-Simulacrum
Improve the comments in `Symbol::interner`.

r? `@Mark-Simulacrum`
2021-12-02 22:16:19 +01:00
Matthias Krüger 6e5f4c2f1b
Rollup merge of #91464 - ChrisDenton:doc-path-case-sensitivity, r=joshtriplett
Document file path case sensitivity

This describes the current behaviour of the standard library's pure path methods.

Fixes #66260.
2021-12-02 22:16:18 +01:00
Matthias Krüger 2ec0f841b4
Rollup merge of #91460 - ChrisDenton:doc-last-os-error, r=joshtriplett
Document how `last_os_error` should be used

It should be made clear that the state of the last OS error could change if another function call is made before the call to `Error::last_os_error()`.

Fixes: #53155
2021-12-02 22:16:16 +01:00
Matthias Krüger d5fc7cf2c4
Rollup merge of #91457 - steffahn:additional_test_from_91068, r=jackh726
Add additional test from rust issue number 91068

see rust-lang/rust#91068

r? ``@jackh726``
2021-12-02 22:16:15 +01:00
Matthias Krüger fbfa003016
Rollup merge of #91444 - RalfJung:miri-tests, r=dtolnay
disable tests in Miri that take too long

Comparing slices of length `usize::MAX` diverges in Miri. In fact these tests even diverge in rustc unless `-O` is passed. I tried this code to check that:
```rust
#![feature(slice_take)]

const EMPTY_MAX: &'static [()] = &[(); usize::MAX];

fn main() {
    let mut slice: &[_] = &[(); usize::MAX];
    println!("1");
    assert_eq!(Some(&[] as _), slice.take(usize::MAX..));
    println!("2");
    let remaining: &[_] = EMPTY_MAX;
    println!("3");
    assert_eq!(remaining, slice);
    println!("4");
}
```
So, disable these tests in Miri for now.
2021-12-02 22:16:14 +01:00
Matthias Krüger dbb9e224af
Rollup merge of #91435 - FabianWolff:issue-91421-if-then, r=lcnr
Improve diagnostic for missing half of binary operator in `if` condition

Fixes #91421. I've also changed it so that it doesn't consume the `else` token in the error case, because it will try to consume it again afterwards, leading to this incorrect error message (where the `else` reported as missing is actually there):
```
error: expected one of `.`, `;`, `?`, `else`, or an operator, found `{`
 --> src/main.rs:4:12
  |
4 |     } else { 4 };
  |            ^ expected one of `.`, `;`, `?`, `else`, or an operator
```

r? `@lcnr`
2021-12-02 22:16:13 +01:00
Matthias Krüger 39641319ad
Rollup merge of #91410 - ecstatic-morse:const-precise-live-drops-take-2, r=oli-obk
Move `#![feature(const_precise_live_drops)]` checks earlier in the pipeline

Should mitigate the issues found during MCP on #73255.

Once this is done, we should clean up the queries a bit, since I think `mir_drops_elaborated_and_const_checked` can be merged back into `mir_promoted`.

Fixes #90770.

cc ``@rust-lang/wg-const-eval``
r? ``@nikomatsakis`` (since they reviewed #71824)
2021-12-02 22:16:13 +01:00
Matthias Krüger b269213b35
Rollup merge of #91387 - graydon:E0038-clarification, r=wesleywiser
Clarify and tidy up explanation of E0038

I ran into E0038 (specifically the `Self:Sized` constraint on object-safety) the other day and it seemed to me that the explanations I found floating around the internet were a bit .. wrong. Like they didn't make sense. And then I went and checked the official explanation here and it didn't make sense either.

As far as I can tell (reading through the history of the RFCs), two totally different aspects of object-safety have got tangled up in much of the writing on the subject:
  - Object-safety related to "not even theoretically possible" issues. This includes things like "methods that take or return Self by value", which obviously will never work for an unsized type in a world with fixed-size stack frames (and it'd be an opaque type anyways, which, ugh). This sort of thing was originally decided method-by-method, with non-object-safe methods stripped from objects; but in [RFC 0255](https://rust-lang.github.io/rfcs/0255-object-safety.html) this sort of per-impossible-method reasoning was made into a per-trait safety property (with the escape hatch left in where users could mark methods `where Self:Sized` to have them stripped before the trait's object safety is considered).
  - Object-safety related to "totally possible but ergonomically a little awkward" issues. Specifically in a trait with `Trait:Sized`, there's no a priori reason why this constraint makes the trait impossible to make into an object -- imagine it had nothing but harmless `&self`-taking methods. No problem! Who cares if the Trait requires its implementing types to be sized? As far as I can tell reading the history here, in both RFC 0255 and then later in [RFC 0546](https://rust-lang.github.io/rfcs/0546-Self-not-sized-by-default.html) it seems that the motivation for making `Trait:Sized` be non-object-safe has _nothing to do_ with the impossibility of making objects out of such types, and everything to do with enabling "[a trait object SomeTrait to implement the trait SomeTrait](https://rust-lang.github.io/rfcs/0546-Self-not-sized-by-default.html#motivation)". That is, since `dyn Trait` is unsized, if `Trait:Sized` then you can never have the automatic (and reasonable) ergonomic implicit `impl Trait for dyn Trait`. And the authors of that RFC really wanted that automatic implicit implementation of `Trait` for `dyn Trait`. So they just defined `Trait:Sized` as non-object safe -- no `dyn Trait` can ever exist that the compiler can't synthesize such an impl for. Well enough!

However, I noticed in my reading-and-reconstruction that lots of documentation on the internet, including forum and Q&A site answers and (most worrying) the compiler explanation all kinda grasp at something like the first ("not theoretically possible") explanation, and fail to mention the second ("just an ergonomic constraint") explanation. So I figured I'd clean up the docs to clarify, maybe confuse the next person less (unless of course I'm misreading the history here and misunderstanding motives -- please let me know if so!)

While here I also did some cleanups:

  - Rewrote the preamble, trying to help the user get a little better oriented (I found the existing preamble a bit scattered).
  - Modernized notation (using `dyn Trait`)
  - Changed the section headings to all be written with the same logical sense: to all be written as "conditions that violate object safety" rather than a mix of that and the negated form "conditions that must not happen in order to ensure object safety".

I think there's a fair bit more to clean up in this doc -- the later sections get a bit rambly and I suspect there should be a completely separated-out section covering the `where Self:Sized` escape hatch for instructing the compiler to "do the old thing" and strip methods off traits when turning them into objects (it's a bit buried as a digression in the individual sub-error sections). But I did what I had time for now.
2021-12-02 22:16:12 +01:00
Matthias Krüger 7483211ed5
Rollup merge of #91364 - FabianWolff:issue-91210-ptr-field, r=oli-obk
Improve error message for incorrect field accesses through raw pointers

Fixes #91210.
2021-12-02 22:16:11 +01:00
Matthias Krüger fd6e66f423
Rollup merge of #91329 - Aaron1011:modulo-regions-test, r=jackh726
Fix incorrect usage of `EvaluatedToOk` when evaluating `TypeOutlives`

A global predicate is not guarnatenteed to outlive all regions.
If the predicate involves late-bound regions, then it may fail
to outlive other regions (e.g. `for<'b> &'b bool: 'static` does not
hold)

We now only produce `EvaluatedToOk` when a global predicate has no
late-bound regions - in that case, the ony region that can be present
in the type is 'static
2021-12-02 22:16:10 +01:00
Matthias Krüger b56e3d955a
Rollup merge of #91321 - matthewjasper:constaint-placeholders, r=jackh726
Handle placeholder regions in NLL type outlive constraints

Closes #76168
2021-12-02 22:16:09 +01:00
Matthias Krüger 444635df25
Rollup merge of #89954 - GuillaumeGomez:legacy-const-generic-doc, r=Amanieu
Fix legacy_const_generic doc arguments display

Fixes https://github.com/rust-lang/rust/issues/83167.

cc ``@Amanieu``
2021-12-02 22:16:08 +01:00
Nicholas Nethercote 66153d76e2 Improve the comments in Symbol::interner. 2021-12-03 07:12:31 +11:00
Chris Denton d8832425fc
Document file path case sensitivity 2021-12-02 19:48:10 +00:00
bors acbe4443cc Auto merge of #91318 - eggyal:reduce-boilerplate-around-infallible-folders, r=jackh726
Reduce boilerplate around infallible folders

Further to https://github.com/rust-lang/rust/pull/91230#issuecomment-981059666

r? `@jackh726`
2021-12-02 19:12:00 +00:00
Chris Denton 6df44a389c
Document how last_os_error should be used 2021-12-02 17:53:57 +00:00
Jack Huey b77ed83ee2
Change to check-pass 2021-12-02 12:11:31 -05:00
Frank Steffahn 51875e3d5a Add additional test from rust issue number 91068 2021-12-02 17:46:57 +01:00
Alan Egerton cf683e644f
Rename TypeFolderFallible to FallibleTypeFolder 2021-12-02 16:14:18 +00:00
eggyal d79e17daf0
Update compiler/rustc_middle/src/ty/fold.rs
Co-authored-by: lcnr <rust@lcnr.de>
2021-12-02 16:14:16 +00:00
Alan Egerton bfc434b6d0
Reduce boilerplate around infallible folders 2021-12-02 16:14:16 +00:00
Alan Egerton db7295fa96
Remove no-longer used IdFunctor::map_id 2021-12-02 15:45:40 +00:00
bors e5038e2099 Auto merge of #91455 - matthiaskrgr:rollup-gix2hy6, r=matthiaskrgr
Rollup of 4 iffy pull requests

Successful merges:

 - #89234 (Disallow non-c-like but "fieldless" ADTs from being casted to integer if they use arbitrary enum discriminant)
 - #91045 (Issue 90702 fix: Stop treating some crate loading failures as fatal errors)
 - #91394 (Bump stage0 compiler)
 - #91411 (Enable svh tests on msvc)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-02 14:53:20 +00:00
Matthias Krüger 822a058988
Rollup merge of #91411 - ChrisDenton:valid-paths, r=petrochenkov
Enable svh tests on msvc

These tests were ignored for msvc in #30778 because of additional notes that were being added for some reason. I'm fairly confident this has been fixed in the intervening years so lets try re-enabling these tests.

Fixes #31306
2021-12-02 15:52:04 +01:00
Matthias Krüger d96ce3ea8e
Rollup merge of #91394 - Mark-Simulacrum:bump-stage0, r=pietroalbini
Bump stage0 compiler

r? `@pietroalbini` (or anyone else)
2021-12-02 15:52:03 +01:00
Matthias Krüger 87ca333210
Rollup merge of #91045 - mjptree:issue-90702-fix, r=petrochenkov
Issue 90702 fix: Stop treating some crate loading failures as fatal errors

Surface mulitple `extern crate` resolution errors at a time.

This is achieved by creating a dummy crate, instead of aborting directly after the resolution error. The `ExternCrateError` has been added to allow propagating the resolution error from `rustc_metadata` crate to the `rustc_resolve` with a minimal public surface. The `import_extern_crate` function is a block that was factored out from `build_reduced_graph_for_item` for better organization. The only added functionality made to it where the added error handling in the `process_extern_crate` call. The remaining bits in this function are the same as before.

Resolves #90702

r? `@petrochenkov`
2021-12-02 15:52:01 +01:00
Matthias Krüger 0666a33a6b
Rollup merge of #89234 - nbdd0121:discr, r=jackh726
Disallow non-c-like but "fieldless" ADTs from being casted to integer if they use arbitrary enum discriminant

Code like

```rust
#[repr(u8)]
enum Enum {
    Foo /* = 0 */,
    Bar(),
    Baz{}
}

let x = Enum::Bar() as u8;
```

seems to be unintentionally allowed so we couldn't disallow them now ~~, but we could disallow them if arbitrary enum discriminant is used before 1.56 hits stable~~ (stabilization was reverted).

Related: #88621

`@rustbot` label +T-lang
2021-12-02 15:52:00 +01:00
bors 18bb8c61a9 Auto merge of #91354 - fee1-dead:const_env, r=spastorino
Cleanup: Eliminate ConstnessAnd

This is almost a behaviour-free change and purely a refactoring. "almost" because we appear to be using the wrong ParamEnv somewhere already, and this is now exposed by failing a test using the unstable `~const` feature.

We most definitely need to review all `without_const` and at some point should probably get rid of many of them by using `TraitPredicate` instead of `TraitRef`.

This is a continuation of https://github.com/rust-lang/rust/pull/90274.

r? `@oli-obk`

cc `@spastorino` `@ecstatic-morse`
2021-12-02 11:48:58 +00:00
Guillaume Gomez 5c75a4857e Add test for legacy-const-generic arguments 2021-12-02 11:27:01 +01:00
Guillaume Gomez bd8d7e4a45 Transform const generics if the function uses rustc_legacy_const_generics 2021-12-02 11:27:01 +01:00
bors d9baa36190 Auto merge of #91291 - GuillaumeGomez:const-deref-method, r=camelid
Fix const deref methods display

Fixes https://github.com/rust-lang/rust/issues/90855 (more information in the issue).

r? `@camelid`
2021-12-02 06:11:05 +00:00
Ralf Jung b11d88006c disable tests in Miri that take too long 2021-12-01 22:48:59 -05:00
bors a2b7b7891e Auto merge of #91003 - psumbera:sparc64-abi, r=nagisa
fix sparc64 ABI for aggregates with floating point members

Fixes #86163
2021-12-02 02:59:44 +00:00
bors 76938d64a4 Auto merge of #90446 - cjgillot:late-elided, r=jackh726
Lint elided lifetimes in path during lifetime resolution.

The lifetime elision lint is known to be brittle and can be redundant with later lifetime resolution errors. This PR aims to remove the redundancy by performing the lint after lifetime resolution.

This PR proposes to carry the information that an elision should be linted against by using a special `LifetimeName`. I am not certain this is the best solution, but it is certainly the easiest.

Fixes https://github.com/rust-lang/rust/issues/60199
Fixes https://github.com/rust-lang/rust/issues/55768
Fixes https://github.com/rust-lang/rust/issues/63110
Fixes https://github.com/rust-lang/rust/issues/71957
2021-12-01 23:22:43 +00:00
Michael 2ca9333011 Improve suggestion for extern crate self error message 2021-12-01 21:59:54 +00:00
Fabian Wolff ba7374e517 Improve diagnostic for missing half of binary operator in if condition 2021-12-01 22:36:50 +01:00
Michael 62f4ce993e Stop treating extern crate loading failures as fatal errors 2021-12-01 21:04:13 +00:00
Michael 10b3a571d2 Factor out build reduced graph for extern crate 2021-12-01 21:04:12 +00:00
bors 48a5999fce Auto merge of #91433 - matthiaskrgr:rollup-118ql06, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #88502 (Add slice take methods)
 - #91313 (expand: Turn `ast::Crate` into a first class expansion target)
 - #91424 (Update LLVM with patches for better llvm-cov diagnostics)
 - #91425 (Include lint errors in error count for `-Ztreat-err-as-bug`)
 - #91430 (Add tests for `normalize-docs` overflow errors)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-01 20:14:07 +00:00
Gary Guo f7ef1c9f41 Disallow non-c-like but "fieldless" ADTs from being casted to integer...
... if they use arbitrary enum discriminant. Code like

```rust
enum Enum {
    Foo = 1,
    Bar(),
    Baz{}
}
```

seems to be unintentionally allowed so we couldn't disallow them now,
but we could disallow them if arbitrary enum discriminant is used before
1.56 hits stable.
2021-12-01 19:59:15 +00:00
Matthias Krüger 4ae75cfa2e
Rollup merge of #91430 - jyn514:normalize-fallible, r=jackh726
Add tests for `normalize-docs` overflow errors

`@b-naber` do you understand why using `try_normalize_erasing_regions` doesn't silence these cycle errors? Rustdoc isn't emitting them, rustc is aborting before returning an error, even though the function has `try_` in the name.

cc https://github.com/rust-lang/rust/issues/82692, https://github.com/rust-lang/rust/pull/91255
2021-12-01 20:57:48 +01:00
Matthias Krüger 4a6e8a9c93
Rollup merge of #91425 - jyn514:treat-lint-err-as-bug, r=oli-obk
Include lint errors in error count for `-Ztreat-err-as-bug`

This was a regression from https://github.com/rust-lang/rust/pull/87337;
the `panic_if_treat_err_as_bug` function only checked the number of hard
errors, not the number of lint errors.

r? `@oli-obk`
2021-12-01 20:57:47 +01:00
Matthias Krüger 5fb1886629
Rollup merge of #91424 - richkadel:llvm-patch-instrproferror, r=tmandry
Update LLVM with patches for better llvm-cov diagnostics

Cherry-picks
ee88b8d63e
and
126e7611c7

These patches to LLVM were added to help debug occasional errors that
cause coverage reporting to fail. Prior to this patch, the only messaging
was that the coverage data was malformed. Hopefully the improved
messaging will help identify the root cause of these errors, when they
arise, so we can make corrections to coverage output from Rust.

r? `@tmandry`
2021-12-01 20:57:46 +01:00
Matthias Krüger 519a842c50
Rollup merge of #91313 - petrochenkov:cratexp, r=Aaron1011
expand: Turn `ast::Crate` into a first class expansion target

And stop creating a fake `mod` item for the crate root when expanding a crate, thus addressing FIXMEs left in https://github.com/rust-lang/rust/pull/82238, and making a step towards a proper support for crate-level macro attributes (cc #54726).

I haven't added token collection support for the whole crate in this PR, maybe later.
r? `@Aaron1011`
2021-12-01 20:57:43 +01:00