Commit Graph

12188 Commits

Author SHA1 Message Date
Dylan DPC
1c82fac3f7
Rollup merge of #95560 - lcnr:obligation-cause, r=oli-obk
convert more `DefId`s to `LocalDefId`
2022-04-02 03:34:27 +02:00
Dylan DPC
1e43cf46bd
Rollup merge of #95559 - lcnr:inferctxt-typeck, r=oli-obk
small type system refactoring
2022-04-02 03:34:26 +02:00
Dylan DPC
556c7411cc
Rollup merge of #95544 - jam1garner:improve-naked-noreturn-diagnostic, r=tmiasko
Add error message suggestion for missing noreturn in naked function

I had to google the syntax for inline asm's `noreturn` option when I got this error earlier today, so I figured I'd save others the trouble and add the syntax/fix as a suggestion in the error.
2022-04-02 03:34:23 +02:00
Dylan DPC
46a4754df0
Rollup merge of #95430 - ChrisDenton:disable-tls-i686-msvc, r=nagisa
Disable #[thread_local] support on i686-pc-windows-msvc

Fixes #95429
2022-04-02 03:34:22 +02:00
Dylan DPC
be7c363182
Rollup merge of #95373 - RalfJung:invalid_value, r=davidtwco
invalid_value lint: detect invalid initialization of arrays
2022-04-02 03:34:21 +02:00
Dylan DPC
d7a24003d8
Rollup merge of #95354 - dtolnay:rustc_const_stable, r=lcnr
Handle rustc_const_stable attribute in library feature collector

The library feature collector in [compiler/rustc_passes/src/lib_features.rs](551b4fa395/compiler/rustc_passes/src/lib_features.rs) has only been looking at `#[stable(…)]`, `#[unstable(…)]`, and `#[rustc_const_unstable(…)]` attributes, while ignoring `#[rustc_const_stable(…)]`. The consequences of this were:

- When any const feature got stabilized (changing one or more `rustc_const_unstable` to `rustc_const_stable`), users who had previously enabled that unstable feature using `#![feature(…)]` would get told "unknown feature", rather than rustc's nicer "the feature … has been stable since … and no longer requires an attribute to enable".

    This can be seen in the way that https://github.com/rust-lang/rust/pull/93957#issuecomment-1079794660 failed after rebase:

    ```console
    error[E0635]: unknown feature `const_ptr_offset`
      --> $DIR/offset_from_ub.rs:1:35
       |
    LL | #![feature(const_ptr_offset_from, const_ptr_offset)]
       |                                   ^^^^^^^^^^^^^^^^
    ```

- We weren't enforcing that a particular feature is either stable everywhere or unstable everywhere, and that a feature that has been stabilized has the same stabilization version everywhere, both of which we enforce for the other stability attributes.

This PR updates the library feature collector to handle `rustc_const_stable`, and fixes places in the standard library and test suite where `rustc_const_stable` was being used in a way that does not meet the rules for a stability attribute.
2022-04-02 03:34:21 +02:00
bors
eb82facb16 Auto merge of #94883 - cjgillot:flat-metadata, r=oli-obk
Encode even more metadata through tables instead of EntryKind

This should move us closer to getting rid of `EntryKind`.
2022-04-01 21:16:41 +00:00
bors
297a8018b5 Auto merge of #95552 - matthiaskrgr:rollup-bxminn9, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #95032 (Clean up, categorize and sort unstable features in std.)
 - #95260 (Better suggestions for `Fn`-family trait selection errors)
 - #95293 (suggest wrapping single-expr blocks in square brackets)
 - #95344 (Make `impl Debug for rustdoc::clean::Item` easier to read)
 - #95388 (interpret: make isize::MAX the limit for dynamic value sizes)
 - #95530 (rustdoc: do not show primitives and keywords as private)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-01 17:19:15 +00:00
jam1garner
f793b696c8 Reword purpose description of noreturn in naked function 2022-04-01 11:28:45 -04:00
Ralf Jung
af24588a06 invalid_value lint: detect invalid initialization of arrays 2022-04-01 09:59:11 -04:00
lcnr
8eacf6078f update comment 2022-04-01 13:47:01 +02:00
lcnr
796b828371 convert more DefIds to LocalDefId 2022-04-01 13:38:43 +02:00
lcnr
389c83b474 remove unused incorrect EqUnifyValue impl 2022-04-01 12:57:24 +02:00
lcnr
c2b5a7ea52 remove unify_key::replace_if_possible 2022-04-01 12:41:46 +02:00
lcnr
18fae7b2e5 update comments 2022-04-01 12:41:46 +02:00
Matthias Krüger
f37bca4d7c
Rollup merge of #95531 - petrochenkov:metacount, r=nnethercote
expand: Do not count metavar declarations on RHS of `macro_rules`

They are 0 by definition there.

Addresses https://github.com/rust-lang/rust/pull/95425#discussion_r837410476
r? ```@nnethercote```
2022-04-01 12:07:04 +02:00
Matthias Krüger
cdf178f776
Rollup merge of #95388 - RalfJung:rust-val-limit, r=oli-obk
interpret: make isize::MAX the limit for dynamic value sizes

We are currently enforcing `data_layout.obj_size_bound()` as the maximal dynamic size of a Rust value (including for `size_of_val_raw`), but that does not match the docs.

In particular, Miri currently falsely says that this code has UB:
```rust
#![feature(layout_for_ptr)]
fn main() {
    let size = isize::MAX as usize;
    // Creating a raw slice of size isize::MAX and asking for its size is okay.
    let s = std::ptr::slice_from_raw_parts(1usize as *const u8, size);
    assert_eq!(size, unsafe { std::mem::size_of_val_raw(s) });
}
```
2022-04-01 06:59:44 +02:00
Matthias Krüger
8f493fd46a
Rollup merge of #95293 - compiler-errors:braces, r=davidtwco
suggest wrapping single-expr blocks in square brackets

Suggests a fix in cases like:

```diff
- const A: [i32; 1] = { 1 };

+ const A: [i32; 1] = [ 1 ];
                      ^   ^
```

Also edit the message for the same suggestion in the parser (e.g. `{ 1, 2 }`).

Fixes #95289
2022-04-01 06:59:42 +02:00
Matthias Krüger
94b1960535
Rollup merge of #95260 - compiler-errors:fn, r=davidtwco
Better suggestions for `Fn`-family trait selection errors

1. Suppress suggestions to add `std::ops::Fn{,Mut,Once}` bounds when a type already implements `Fn{,Mut,Once}`
2. Add a note that points out that a type does in fact implement `Fn{,Mut,Once}`, but the arguments vary (either by number or by actual arguments)
3. Add a note that points out that a type does in fact implement `Fn{,Mut,Once}`, but not the right one (e.g. implements `FnMut`, but `Fn` is required).

Fixes #95147
2022-04-01 06:59:41 +02:00
jam1garner
b657cb5577 Add error message suggestion for missing noreturn in naked function 2022-03-31 18:34:20 -04:00
David Tolnay
5d30180634
Handle rustc_const_stable attribute in library feature collector 2022-03-31 12:34:46 -07:00
bors
0677edc86e Auto merge of #95526 - Dylan-DPC:rollup-0ikl5l5, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #91416 (Specialize infinite-type "insert some indirection" suggestion for Option)
 - #95384 (Update target_has_atomic documentation for stabilization)
 - #95517 (small rustc_borrowck cleanup)
 - #95520 (Fix typos in core::ptr docs)
 - #95523 (remove unused field from `infcx`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-03-31 17:45:26 +00:00
Camille GILLOT
15b2d1a97c Merge impl_constness and is_const_fn_raw. 2022-03-31 18:33:46 +02:00
Camille GILLOT
e62f483842 Create trait_def table. 2022-03-31 18:14:54 +02:00
Camille GILLOT
618138b923 Store fn constness in impl_constness. 2022-03-31 18:14:49 +02:00
Vadim Petrochenkov
9ab4f732cb expand: Do not count metavar declarations on RHS of macro_rules
They are 0 by definition there.
2022-03-31 19:09:40 +03:00
Camille GILLOT
f2bf484e3a Introduce repr_options table. 2022-03-31 17:56:32 +02:00
Dylan DPC
1074c814af
Rollup merge of #95523 - lcnr:yeet-unused-field, r=oli-obk
remove unused field from `infcx`

r? `@oli-obk` did we stop needing that for opaque types?
2022-03-31 17:29:56 +02:00
Dylan DPC
1f86789bb3
Rollup merge of #95517 - lcnr:rustc_borrowck-misc, r=jackh726
small rustc_borrowck cleanup

r? `@jackh726` because of the second commit, seems like that comment was missed in #91243
2022-03-31 17:29:54 +02:00
Dylan DPC
521c590c9f
Rollup merge of #91416 - compiler-errors:infinite-ty-option-box, r=estebank
Specialize infinite-type "insert some indirection" suggestion for Option

Suggest `Option<Box<_>>` instead of `Box<Option<_>>` for infinitely-recursive members of a struct.

Not sure if I can get the span of the generic subty of the Option so I can make this a `+++`-style suggestion. The current output is a tiny bit less fancy looking than the original suggestion.

Should I limit the specialization to just `Option<Box<TheOuterStruct>>`? Because right now it applies to all `Option` members in the struct that are returned by `Representability::SelfRecursive`.

Fixes #91402

r? `@estebank`
(since you wrote the original suggestion and are definitely most familiar with it!)
2022-03-31 17:29:52 +02:00
bors
bd1a8692f6 Auto merge of #90204 - cjgillot:owner-pull, r=michaelwoerister
Make lowering pull-based

~Based on https://github.com/rust-lang/rust/pull/90451~
Part of https://github.com/rust-lang/rust/pull/88186

The current lowering code visits all the item-likes in the AST in order, and lowers them one by one.
This PR changes it to index the AST and then proceed to lowering on-demand. This is closer to the logic of query-based lowering.
2022-03-31 15:20:59 +00:00
lcnr
a5c68d747e remove unused field from infcx 2022-03-31 17:14:42 +02:00
Michael Goulet
c74f7a310f address comments, add test for shadowed Box type 2022-03-31 08:04:53 -07:00
Michael Goulet
de04c05dea Specialize suggestion for Option<T> 2022-03-31 08:04:53 -07:00
lcnr
89c66eb42d update comment 2022-03-31 15:41:52 +02:00
Ralf Jung
a417911c16 catch overflow in slice size computation 2022-03-31 08:57:45 -04:00
Ralf Jung
53c540a666 audit check_mul uses in interpret 2022-03-31 08:57:45 -04:00
Ralf Jung
a421cbbead interpret: make isize::MAX the limit for dynamic value sizes 2022-03-31 08:57:45 -04:00
bors
03314912f1 Auto merge of #95511 - Dylan-DPC:rollup-4n880fd, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #95445 (Don't build the full compiler before running unit tests)
 - #95470 (Fix last rustdoc-gui spurious test)
 - #95478 (Add note to the move size diagnostic)
 - #95495 (Remove unneeded `to_string` call)
 - #95505 (Fix library/std compilation on openbsd.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-03-31 12:55:13 +00:00
Camille GILLOT
6b099db18c Record item-likes in ItemLowerer. 2022-03-31 13:48:16 +02:00
Camille GILLOT
e5d482eeca Create a new LoweringContext for each item-like. 2022-03-31 13:47:56 +02:00
Camille GILLOT
6e4fb2038a Make lowering pull-based. 2022-03-31 13:47:22 +02:00
Camille GILLOT
41902f2859 Implement with_parent_item_lifetime_defs on ItemLowerer. 2022-03-31 13:47:02 +02:00
Camille GILLOT
dc8b6b4be4 Move lower_crate outside the LoweringContext. 2022-03-31 13:46:40 +02:00
Camille GILLOT
4b598d3f75 Stop emitting lints during lowering. 2022-03-31 13:46:06 +02:00
Camille GILLOT
c10a1cebe7 Store next_disambiguator in Definitions. 2022-03-31 13:34:54 +02:00
Camille GILLOT
b29fa94d22 Remove mutability in ResolverAstLowering. 2022-03-31 13:24:33 +02:00
Dylan DPC
4388ac58a2
Rollup merge of #95478 - InfRandomness:infrandomness/lint_largemove_note, r=compiler-errors
Add note to the move size diagnostic

context: https://github.com/rust-lang/rust/issues/83518
2022-03-31 13:09:53 +02:00
lcnr
d7cada1767 obligation cause: RepeatVec -> RepeatValueCopy 2022-03-31 12:51:46 +02:00
bors
df20355fa9 Auto merge of #95456 - RalfJung:size, r=oli-obk
allow large Size again

This basically reverts most of https://github.com/rust-lang/rust/pull/80042, and instead does the panic in `bits()` with a `#[cold]` function to make sure it does not get inlined.

https://github.com/rust-lang/rust/pull/80042 added a comment about an invariant ("The top 3 bits are ALWAYS zero") that is not actually enforced, and if it were enforced that would be a problem for https://github.com/rust-lang/rust/pull/95388. So I think we should not have that invariant, and I adjusted the code accordingly.

r? `@oli-obk` Cc `@sivadeilra`
2022-03-31 10:33:56 +00:00