Commit graph

6109 commits

Author SHA1 Message Date
bors
1a462831ad Auto merge of #86385 - JohnTitor:use-attrvec, r=davidtwco
Use `AttrVec` for `Arm`, `FieldDef`, and `Variant`

Uses `AttrVec` for `Arm`, `FieldDef`, and `Variant`, i.e., where the size of the vector can be empty often.
Skips `Crate` and `Item` because I think they may have the attributes on common cases and need more work outside of `rustc_ast` (e.g. rustc_expand needs a lot of tweaks). But if it's reasonable to change, I'm happy to do so.

Fixes #77662
2021-06-18 02:00:18 +00:00
bors
a6bc43ea84 Auto merge of #86417 - m-ou-se:rollup-vo2y1rz, r=m-ou-se
Rollup of 6 pull requests

Successful merges:

 - #85925 (Linear interpolation)
 - #86202 (Specialize `io::Bytes::size_hint` for more types)
 - #86357 (Rely on libc for correct integer types in os/unix/net/ancillary.rs.)
 - #86388 (Make `s` pre-interned)
 - #86401 (Fix ICE when using `#[doc(keyword = "...")]` on non-items)
 - #86405 (Add incr-comp note for 1.53.0 relnotes)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-06-17 23:30:08 +00:00
Mara Bos
0274401f93
Rollup merge of #86401 - FabianWolff:issue-83512, r=LeSeulArtichaut
Fix ICE when using `#[doc(keyword = "...")]` on non-items

This pull request fixes #83512. The code for checking attributes calls `expect_item()` when it shouldn't, thus causing an ICE. I have implemented a proper check for the node kind, so that an error is reported instead of the ICE.
2021-06-17 23:41:02 +02:00
Mara Bos
3d7437fa21
Rollup merge of #86388 - JohnTitor:static-symbol-s, r=LeSeulArtichaut
Make `s` pre-interned

Now we should be able to pre-intern `s` as the test `ui/lint/rfc-2457-non-ascii-idents/lint-confusable-idents.rs` no longer fails.
2021-06-17 23:41:01 +02:00
bors
149f4836dd Auto merge of #86392 - JohnTitor:use-partition-point, r=petrochenkov
Prefer `partition_point` to look up assoc items

Since we now have `partition_point` (instead of `equal_range`), I think it's worth trying to use it instead of manually finding it.
`partition_point` uses `binary_search_by` internally (#85406) and its performance has been improved (#74024), so I guess this will make a performance difference.
2021-06-17 20:47:32 +00:00
bors
e062e5d34e Auto merge of #83572 - pkubaj:patch-1, r=nagisa
Add support for powerpc64le-unknown-freebsd
2021-06-17 18:06:44 +00:00
bors
4d3ce2e7da Auto merge of #86399 - JohnTitor:rollup-qlm2dvz, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #85663 (Document Arc::from)
 - #85802 (Rename IoSlice(Mut)::advance to advance_slice and add IoSlice(Mut)::advance)
 - #85970 (Remove methods under Implementors on trait pages)
 - #86340 (Use better error message for hard errors in CTFE)
 - #86343 (Do not emit invalid suggestions on multiple mutable borrow errors)
 - #86355 (Remove invalid suggestions for assoc consts on placeholder type error)
 - #86389 (Make `sum()` and `product()` documentation hyperlinks refer to `Iterator` methods.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-06-17 15:12:56 +00:00
Fabian Wolff
2cedd86b1c Fix ICE when using #[doc(keyword = "...")] on non-items 2021-06-17 16:45:26 +02:00
Yuki Okushi
aff7994740
Rollup merge of #86355 - JohnTitor:issue-82158, r=estebank
Remove invalid suggestions for assoc consts on placeholder type error

Fixes #82158
This also moves some tests to typeck.
r? ``@estebank``
2021-06-17 21:56:45 +09:00
Yuki Okushi
afe70ee440
Rollup merge of #86343 - JohnTitor:issue-85581, r=estebank
Do not emit invalid suggestions on multiple mutable borrow errors

Fixes #85581
2021-06-17 21:56:44 +09:00
Yuki Okushi
c062f3dddd
Rollup merge of #86340 - Smittyvb:ctfe-hard-error-message, r=RalfJung
Use better error message for hard errors in CTFE

I noticed this while working on #86255: currently the same message is used for hard errors and soft errors in CTFE. This changes the error messages to make hard errors use a message that indicates the reality of the situation correctly, since usage of the constant is never allowed when there was a hard error evaluating it. This doesn't affect the behaviour of these error messages, only the content.

This changes the error logic to check if the error should be hard or soft where it is generated, instead of where it is emitted, to allow this distinction in error messages.
2021-06-17 21:56:43 +09:00
bors
0ef2b4a29b Auto merge of #85755 - b-naber:unexpected_concrete_region, r=nikomatsakis
Replace parent substs of associated types with inference vars in borrow checker

Fixes https://github.com/rust-lang/rust/issues/83190
Fixes https://github.com/rust-lang/rust/issues/78450

When we normalize an associated type that refers to an opaque type, it can happen that the substs of the associated type do not occur in the projection (they are parent substs). We previously didn't replace those substs with inference vars, which left a concrete region after all regions should have already been replaced with inference vars and triggered a `delay_span_bug`. After we normalize the opaque type, we now try to replace any remaining concrete regions with inference vars.
2021-06-17 12:31:56 +00:00
Niko Matsakis
09eed2889a use to_region_vid in opaque type code
Normalization can pull in named regions from the parameter
environment. We need to be prepared for that in the opaque
types code.
2021-06-17 05:22:04 -04:00
bors
b17d9c1332 Auto merge of #85834 - cjgillot:save-sbi, r=michaelwoerister
Encode CrateNum using the StableCrateId for incr. comp.
2021-06-17 09:03:58 +00:00
bors
cb3c4ee718 Auto merge of #86164 - FabianWolff:issue-86053, r=davidtwco
Handle C-variadic arguments properly when reporting region errors

This pull request fixes #86053. The issue is that for a C-variadic function
```rust
#![feature(c_variadic)]
unsafe extern "C" fn foo(_: (), ...) {}
```
`foo`'s signature will contain only the first parameter (and have `c_variadic` set to `true`), whereas its body has a second argument (a `hir::Pat` for the `...`).

The code for reporting region errors iterates over the body's parameters and tries to fetch the corresponding parameter from the signature; this causes an out-of-bounds ICE for the `...` (though not in the example above, because there are no region errors to report).

I have simply restricted the iteration over the body parameters to exclude `...`, which is fine because `...` cannot cause a region error.
2021-06-17 06:34:12 +00:00
Yuki Okushi
c0efd2a15b
Prefer partition_point to look up assoc items 2021-06-17 11:40:37 +09:00
Yuki Okushi
34f38bf760
Make s pre-interned 2021-06-17 09:45:19 +09:00
Yuki Okushi
4f8e0ebcc5
Use AttrVec for Arm, FieldDef, and Variant 2021-06-17 08:04:54 +09:00
bors
444a85ac38 Auto merge of #86379 - JohnTitor:rollup-mkz9x36, r=JohnTitor
Rollup of 10 pull requests

Successful merges:

 - #85870 (Allow whitespace in dump_mir filter)
 - #86104 (Fix span calculation in format strings)
 - #86140 (Mention the `Borrow` guarantee on the `Hash` implementations for Arrays and `Vec`)
 - #86141 (Link reference in `dyn` keyword documentation)
 - #86260 (Open trait implementations' toggles by default.)
 - #86339 (Mention #79078 on compatibility notes of 1.52)
 - #86341 (Stop returning a value from `report_assert_as_lint`)
 - #86353 (Remove `projection_ty_from_predicates`)
 - #86361 (Add missing backslashes to prevent unwanted newlines in rustdoc HTML)
 - #86372 (Typo correction: s/is/its)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-06-16 22:48:31 +00:00
Smitty
044b3620e7 Move some hard error logic to InterpError 2021-06-16 18:23:34 -04:00
Yuki Okushi
05ba958fe8
Rollup merge of #86353 - JohnTitor:remove-projection_ty_from_predicates, r=oli-obk
Remove `projection_ty_from_predicates`

Fixes #86350
r? ``@oli-obk``
2021-06-17 05:54:59 +09:00
Yuki Okushi
36bf808aa1
Rollup merge of #86341 - LingMan:ret_val, r=davidtwco
Stop returning a value from `report_assert_as_lint`

This function only ever returns `None`. Make that explicity by not returning a value at all.

`@rustbot` modify labels +C-cleanup +T-compiler
2021-06-17 05:54:58 +09:00
Yuki Okushi
4ff55ecf04
Rollup merge of #86104 - FabianWolff:issue-86085, r=davidtwco
Fix span calculation in format strings

This pull request fixes #86085. The ICE described there is due to an error in the span calculation inside format strings, if the format string is the result of a macro invocation:
```rust
fn main() {
    format!(concat!("abc}"));
}
```
currently produces:
```
error: invalid format string: unmatched `}` found
 --> test.rs:2:17
  |
2 |     format!(concat!("abc}"));
  |                 ^ unmatched `}` in format string
```
which is obviously incorrect. This happens because the span of the entire `concat!()` is combined with the _relative_ location of the unmatched `` `}` `` in the _result_ of the macro invocation (i.e. 4).

In #86085, this has led to a span that starts or ends in the middle of a multibyte character, but the root cause was the same. This pull request fixes the problem.
2021-06-17 05:54:52 +09:00
Yuki Okushi
7030efbb77
Rollup merge of #85870 - ptrojahn:mir_dump_whitespace, r=davidtwco
Allow whitespace in dump_mir filter

At least on my system this is necessary to get more complex filters with spaces like in https://rustc-dev-guide.rust-lang.org/mir/debugging.html working.
2021-06-17 05:54:46 +09:00
bors
a85f584aeb Auto merge of #86266 - LeSeulArtichaut:box-thir-adt, r=davidtwco
Box `thir::ExprKind::Adt` for performance

`Adt` is the biggest variant in the enum and probably isn't used very often compared to the other expr kinds, so boxing it should be beneficial for performance. We need a perf test to be sure.
2021-06-16 20:00:17 +00:00
bors
8daad743c4 Auto merge of #86332 - rylev:fix-ice-docalias, r=GuillaumeGomez
Fix ICE when doc aliases were put on function params

Fixes #86239

r? `@GuillaumeGomez`
2021-06-16 10:01:20 +00:00
Yuki Okushi
d828eadd7a
Remove invalid suggestions for assoc consts on placeholder type error 2021-06-16 18:57:53 +09:00
Yuki Okushi
280d19395d
Remove projection_ty_from_predicates 2021-06-16 16:33:03 +09:00
bors
2336406b38 Auto merge of #86291 - crlf0710:trait_vtbl_refactor, r=bjorn3
Refactor vtable codegen

This refactor the codegen of vtables of miri interpreter, llvm, cranelift codegen backends.

This is preparation for the implementation of trait upcasting feature. cc #65991

Note that aside from code reorganization, there's an internal behavior change here that now InstanceDef::Virtual's index now include the three metadata slots, and now the first method is with index 3.

cc  `@RalfJung` `@bjorn3`
2021-06-16 07:20:27 +00:00
Yuki Okushi
c8a8a23a31
Do not emit invalid suggestions on multiple mutable borrow errors 2021-06-16 09:47:37 +09:00
LingMan
e42d5eed31 Stop returning a value from report_assert_as_lint
This function only ever returns `None`. Make that explicity by not returning a value at all.
2021-06-16 01:55:05 +02:00
Smitty
4fe4ff95f6 Use better error message for hard errors in CTFE
Currently the same message is used for hard errors and soft errors. This
makes hard errors use a message that indicates the reality of the
situation correctly, since usage of the constant is never allowed when
there was a hard error evaluating it.
2021-06-15 19:16:10 -04:00
bors
607d6b00d4 Auto merge of #86321 - JohnTitor:rollup-q61c8q4, r=JohnTitor
Rollup of 10 pull requests

Successful merges:

 - #80269 (Explain non-dropped sender recv in docs)
 - #82179 (Add functions `Duration::try_from_secs_{f32, f64}`)
 - #85608 (Stabilize `ops::ControlFlow` (just the type))
 - #85792 (Refactor windows sockets impl methods)
 - #86220 (Improve maybe_uninit_extra docs)
 - #86277 (Remove must_use from ALLOWED_ATTRIBUTES)
 - #86285 (⬆️ rust-analyzer)
 - #86294 (Stabilize {std, core}::prelude::rust_*.)
 - #86306 (Add mailmap entries for myself)
 - #86314 (Remove trailing triple backticks in `mut_keyword` docs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-06-15 20:15:23 +00:00
Ryan Levick
5f74ba50bc Fix ICE when doc aliases were put on function params 2021-06-15 19:01:11 +02:00
bors
12d0849f9d Auto merge of #85154 - cjgillot:lessfn, r=bjorn3
Reduce amount of function pointers in query invocation.

r? `@ghost`
2021-06-15 14:52:58 +00:00
Yuki Okushi
5936ecc24f
Rollup merge of #85608 - scottmcm:stabilize-control-flow-enum-basics, r=m-ou-se
Stabilize `ops::ControlFlow` (just the type)

Tracking issue: https://github.com/rust-lang/rust/issues/75744 (which also tracks items *not* closed by this PR).

With the new `?` desugar implemented, [it's no longer possible to mix `Result` and `ControlFlow`](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=13feec97f5c96a9d791d97f7de2d49a6).  (At the time of making this PR, godbolt was still on the 2021-05-01 nightly, where you can see that [the mixing example compiled](https://rust.godbolt.org/z/13Ke54j16).)  That resolves the only blocker I know of, so I'd like to propose that `ControlFlow` be considered for stabilization.

Its basic existence was part of https://github.com/rust-lang/rfcs/pull/3058, where it got a bunch of positive comments (examples [1](https://github.com/rust-lang/rfcs/pull/3058#issuecomment-758277325) [2](https://github.com/rust-lang/rfcs/pull/3058#pullrequestreview-592106494) [3](https://github.com/rust-lang/rfcs/pull/3058#issuecomment-784444155) [4](https://github.com/rust-lang/rfcs/pull/3058#issuecomment-797031584)).  Its use in the compiler has been well received (https://github.com/rust-lang/rust/pull/78182#issuecomment-713695594), and there are ecosystem updates interested in using it (https://github.com/rust-itertools/itertools/issues/469#issuecomment-677729589, https://github.com/jonhoo/rust-imap/issues/194).

As this will need an FCP, picking a libs member manually:
r? `@m-ou-se`

## Stabilized APIs

```rust
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ControlFlow<B, C = ()> {
    /// Exit the operation without running subsequent phases.
    Break(B),
    /// Move on to the next phase of the operation as normal.
    Continue(C),
}
```

As well as using `?` on a `ControlFlow<B, _>` in a function returning `ControlFlow<B, _>`.  (Note, in particular, that there's no `From::from`-conversion on the `Break` value, the way there is for `Err`s.)

## Existing APIs *not* stabilized here

All the associated methods and constants: `break_value`, `is_continue`, `map_break`, [`CONTINUE`](https://doc.rust-lang.org/nightly/std/ops/enum.ControlFlow.html#associatedconstant.CONTINUE), etc.

Some of the existing methods in nightly seem reasonable, some seem like they should be removed, and some need more discussion to decide.  But none of them are *essential*, so [as in the RFC](https://rust-lang.github.io/rfcs/3058-try-trait-v2.html#methods-on-controlflow), they're all omitted from this PR.

They can be considered separately later, as further usage demonstrates which are important.
2021-06-15 17:40:08 +09:00
bors
6936ca8c99 Auto merge of #86311 - LeSeulArtichaut:cleanup-array-iter, r=jackh726
Use the now available implementation of `IntoIterator` for arrays
2021-06-15 07:46:48 +00:00
LeSeulArtichaut
e3ca81fd5a Use the now available implementation of IntoIterator for arrays 2021-06-14 23:40:09 +02:00
bors
539d7bd399 Auto merge of #86275 - lqd:ctfe-validation, r=RalfJung
Improve CTFE UB validation error messages

As mentioned in https://github.com/rust-lang/rust/pull/86245#discussion_r650494012 this PR slightly improves the formatting of validation errors, to move the path to the error prefix.

From:
`type validation failed: encountered invalid vtable: size is bigger than largest supported object at .0`

To:
`type validation failed at .0: encountered invalid vtable: size is bigger than largest supported object`.
2021-06-14 20:17:02 +00:00
Charles Lew
a86d3a7e45 Refactor to make interpreter and codegen backend neutral to vtable internal representation. 2021-06-15 01:59:00 +08:00
bors
304441960e Auto merge of #86117 - ehuss:force-warns-underscore, r=rylev
Fix force-warns to allow dashes.

The `--force-warns` flag was not allowing lint names with dashes, only supporting underscores.  This changes it to allow dashes to match the behavior of the A/W/D/F flags.
2021-06-14 17:21:28 +00:00
Rémy Rakic
5af1c72513 Adjust throw_validation_failure macro to shorten the use of with_no_trimmed_paths 2021-06-14 18:57:53 +02:00
Rémy Rakic
19fddc019f Improve documentation on UndefinedBehaviorInfo::ValidationFailure 2021-06-14 18:57:06 +02:00
Rémy Rakic
87ecf84c36 Improve CTFE validation error message 2021-06-13 22:40:42 +02:00
Shadlock0133
dab89b51ac
Fix typo with custom a custom -> with a custom 2021-06-13 21:21:45 +02:00
LeSeulArtichaut
5e802e5e97 Box ExprKind::Adt 2021-06-13 17:03:11 +02:00
bors
fb3ea63d9b Auto merge of #86245 - lqd:const-ub-align, r=RalfJung
Fix ICEs on invalid vtable size/alignment const UB errors

The invalid vtable size/alignment errors from `InterpCx::read_size_and_align_from_vtable` were "freeform const UB errors", causing ICEs when reaching validation. This PR turns them into const UB hard errors to catch them during validation and avoid that.

Fixes #86193

r? `@RalfJung`

(It seemed cleaner to have 2 variants but they can be merged into one variant with a message payload if you prefer that ?)
2021-06-13 12:08:59 +00:00
Rémy Rakic
cae1918b29 Turn incorrect vtable size/alignment errors into hard const-UB errors
They were "freeform const UB" error message, but could reach validation
and trigger ICEs there. We now catch them during validation to avoid
that.
2021-06-13 13:11:07 +02:00
bors
6cc5d5432a Auto merge of #86185 - klensy:ast-val, r=petrochenkov
simplify validate_generic_param_order
2021-06-13 09:36:12 +00:00
klensy
6a19867417 simplify validate_generic_param_order 2021-06-13 01:39:57 +03:00