Commit graph

6148 commits

Author SHA1 Message Date
bors
d789de67dc Auto merge of #85775 - adamrk:warn-unused-target-fields, r=nagisa
Emit warnings for unused fields in custom targets.

Add a warning which lists any fields in a custom target `json` file that aren't used. Currently unrecognized fields are ignored so, for example, a typo in the `json` will silently produce a target which isn't the one intended.
2021-06-21 06:56:51 +00:00
bors
3824017f8e Auto merge of #86166 - tmiasko:no-alloca-for-zsts, r=nagisa
Do not emit alloca for ZST locals with multiple assignments

This extends 35566bfd7d to additionally stop emitting unnecessary allocas for zero sized locals that are assigned multiple times.

When rebuilding the standard library with `-Zbuild-std` this reduces the number of locals that require an allocation from 62315 to 61767.
2021-06-21 04:03:51 +00:00
Yuki Okushi
8b9e138ecd
Rollup merge of #86491 - petrochenkov:derefact, r=Aaron1011
expand: Move some more derive logic to rustc_builtin_macros

And cleanup some `unwrap`s in `cfg_eval`.

Refactorings extracted from https://github.com/rust-lang/rust/pull/83354 and https://github.com/rust-lang/rust/pull/86057.
r? ``@Aaron1011``
2021-06-21 09:42:19 +09:00
Yuki Okushi
e5ecded392
Rollup merge of #86484 - fee1-dead:builtin-macro-recursion, r=petrochenkov
Do not set depth to 0 in fully_expand_fragment

Fixes #84632.
2021-06-21 09:42:18 +09:00
Yuki Okushi
1a1909a8a6
Rollup merge of #83739 - JohnTitor:issue-75889, r=estebank
Account for bad placeholder errors on consts/statics with trait objects

Fixes #75889
r? ``@estebank``
2021-06-21 09:42:12 +09:00
bors
e82b65026d Auto merge of #85538 - r00ster91:iterrepeat, r=Mark-Simulacrum
Replace some `std::iter::repeat` with `str::repeat`

I noticed that there were some instances where `std::iter::repeat` would be used to repeat a string or a char to take a specific count of it and then collect it into a `String` when `str::repeat` is actually much faster and better for that.

See also: https://github.com/rust-lang/rust-clippy/issues/7260.
2021-06-20 20:07:13 +00:00
Deadbeef
37d0d2705d
Do not set depth to 0 in fully_expand_fragment 2021-06-21 02:05:37 +08:00
Vadim Petrochenkov
d9fd5eaae8 cfg_eval: Replace multiple unwraps with a single unwrap 2021-06-20 18:54:45 +03:00
Vadim Petrochenkov
3f0729f378 expand: Move some more derive logic to rustc_builtin_macros 2021-06-20 18:48:42 +03:00
bors
2e940ac5e9 Auto merge of #86250 - RalfJung:intrinsic_operation_unsafety, r=oli-obk
fix intrinsic_operation_unsafety comment
2021-06-20 14:01:26 +00:00
bors
150fad30ea Auto merge of #86460 - JohnTitor:use-static-in-pattern-err, r=oli-obk
Refactor `PatternError` structure

Now we emit the `StaticInPattern` error precisely.
Fixes #68395
r? `@oli-obk`
2021-06-19 19:46:02 +00:00
bors
29cd70d407 Auto merge of #86437 - nikomatsakis:tait-docs, r=oli-obk
add various coments to explain how the TAIT code works

r? `@oli-obk`
2021-06-19 12:41:10 +00:00
bors
39260f6d49 Auto merge of #86426 - hi-rustin:rustin-patch-lint-warn, r=Aaron1011
Lint for unused borrows as part of UNUSED_MUST_USE

close https://github.com/rust-lang/rust/issues/76264

base on https://github.com/rust-lang/rust/pull/76894

r? `@RalfJung`
2021-06-19 08:41:58 +00:00
bors
9cf05f3614 Auto merge of #86378 - Smittyvb:thir-walker-pat, r=LeSeulArtichaut
Add pattern walking support to THIR walker

Suggested in https://github.com/rust-lang/rust/pull/85263#issuecomment-861906730, this splits off the support for pattern walking in THIR from #85263. This has no observable effect on THIR unsafety checking, since it is not currently possible to trigger unsafety from the THIR checker using the additional patterns or constants that are now walked. THIR patterns are walked in source code order.

r? `@LeSeulArtichaut`
2021-06-19 05:44:11 +00:00
Yuki Okushi
e44e65e888
Assert is_associated_const when resolving 2021-06-19 13:55:24 +09:00
Yuki Okushi
bc243a7f55
Refactor PatternError structure 2021-06-19 11:47:15 +09:00
bors
9839f9c7ff Auto merge of #86456 - JohnTitor:rollup-jjzupny, r=JohnTitor
Rollup of 9 pull requests

Successful merges:

 - #86136 (Stabilize span_open() and span_close().)
 - #86359 (Use as_secs_f64 in JunitFormatter)
 - #86370 (Fix rustdoc stabilized versions layout)
 - #86397 (Alter std::cell::Cell::get_mut documentation)
 - #86407 (Use `map_or` instead of open-coding it)
 - #86425 (Update rustversion to 1.0.5)
 - #86440 (Update library tracking issue for libs-api rename.)
 - #86444 (Fix ICE with `#[repr(simd)]` on enum)
 - #86453 (stdlib: Fix typo in internal RefCell docs )

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-06-19 01:57:14 +00:00
Yuki Okushi
84d6c68822
Rollup merge of #86444 - FabianWolff:issue-83505, r=LeSeulArtichaut
Fix ICE with `#[repr(simd)]` on enum

This pull request fixes #83505. `#[repr(simd)]` may only be applied to structs, which correctly causes `E0517` for the example given in #83505, but the compiler attempts to recover from this error, which leads to an ICE later, when `.non_enum_variant()` is called on the `AdtDef`. I have added a check that prevents this from happening.
2021-06-19 10:14:14 +09:00
Yuki Okushi
b6e234c6cf
Rollup merge of #86407 - LingMan:map-or, r=LeSeulArtichaut
Use `map_or` instead of open-coding it

`@rustbot` modify labels +C-cleanup +T-compiler
2021-06-19 10:14:11 +09:00
bors
ec57c60c50 Auto merge of #86194 - RalfJung:const-ub-hard-error, r=oli-obk
make UB during CTFE a hard error

This is a next step for https://github.com/rust-lang/rust/issues/71800. `const_err` has been a future-incompatibility lint for 4 months now since https://github.com/rust-lang/rust/pull/80394 (and err-by-default for many years before that), so I think we could try making it a proper hard error at least in some situations.

I didn't yet adjust the tests, since I first want to gauge the fall-out via crater.
Cc `@rust-lang/wg-const-eval`
2021-06-18 23:17:40 +00:00
Niko Matsakis
831759a443 fix typos 2021-06-18 18:20:07 -04:00
Fabian Wolff
e7a1186c6d Fix ICE with #[repr(simd)] on enum 2021-06-18 21:39:53 +02:00
Niko Matsakis
f6adaedd9b add various coments to explain how the code works 2021-06-18 11:44:56 -04:00
bors
312b894cc1 Auto merge of #85421 - Smittyvb:rm_pushpop_unsafe, r=matthewjasper
Remove some last remants of {push,pop}_unsafe!

These macros have already been removed, but there was still some code handling these macros. That code is now removed.
2021-06-18 14:17:53 +00:00
Ralf Jung
3c08cf8e5e make UB during CTFE a hard error 2021-06-18 16:00:04 +02:00
hi-rustin
88abd7d81d Lint for unused borrows as part of UNUSED_MUST_USE 2021-06-18 15:09:40 +08:00
bors
ed33787335 Auto merge of #85284 - eggyal:custom-profiler-runtime, r=jackh726
Provide option for specifying the profiler runtime

Currently, if `-Zinstrument-coverage` is enabled, the target is linked
against the `library/profiler_builtins` crate (which pulls in LLVM's
compiler-rt runtime).

This option enables backends to specify an alternative runtime crate for
handling injected instrumentation calls.
2021-06-18 04:39:01 +00:00
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
Adam Bratschi-Kaye
88b01f1178 Emit warnings for unused fields in custom targets. 2021-06-17 21:48:02 +02: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
LingMan
382ba79380 Use map_or instead of open-coding it 2021-06-17 19:39:58 +02: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
Smitty
281dd6d6e0 Explicitly write out all fields 2021-06-17 10:17:35 -04:00
Smitty
1d5accabf1 simplify borrowing 2021-06-17 10:15:02 -04: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
Alan Egerton
872839eb49
Early return from inject_profiler_runtime 2021-06-17 12:11:40 +01: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