]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoAuto merge of #82058 - gilescope:to_digit_speedup, r=lcnr
bors [Tue, 16 Feb 2021 08:38:11 +0000 (08:38 +0000)]
Auto merge of #82058 - gilescope:to_digit_speedup, r=lcnr

no need to check assertion on fast path as will always hold.

V small change. Easy to review though!

3 years agoAuto merge of #81734 - richkadel:fixfordash, r=pnkfelix
bors [Tue, 16 Feb 2021 05:45:10 +0000 (05:45 +0000)]
Auto merge of #81734 - richkadel:fixfordash, r=pnkfelix

Ensures `make` tests run under /bin/dash (if available), like CI, and fixes a Makefile

Note: This cherrypicks #81688 (`@pnkfelix)`

Updates `tools.mk` to explicitly require `SHELL := /bin/dash`, since CI uses `dash` but other environments (including developer local machines) may default to `bash`.

Replaces bash-specific shell command in one Makefile with a dash-compatible alternative, and re-enables the affected Makefile test.

Removes apparently redundant definition of `UNAME`.

Also see: [zulip discussion thread](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/how.20to.20run.2Fbless.20src.2Ftest.2Frun-make-fulldeps.2Fcoverage.20.3F)

r? `@pnkfelix`

FYI: `@wesleywiser` `@tmandry`

3 years agoAuto merge of #82153 - jonas-schievink:rollup-ls5r943, r=jonas-schievink
bors [Tue, 16 Feb 2021 02:14:13 +0000 (02:14 +0000)]
Auto merge of #82153 - jonas-schievink:rollup-ls5r943, r=jonas-schievink

Rollup of 19 pull requests

Successful merges:

 - #81503 (Suggest to create a new `const` item if the `fn` in the array is a `const fn`)
 - #81897 (Add match pattern diagnostics regression test)
 - #81975 (Seal the CommandExt, OsStrExt and OsStringExt traits)
 - #82009 (const_generics: Dont evaluate array length const when handling errors)
 - #82060 (Fix typos in BTreeSet::{first, last} docs)
 - #82061 (CTFE validation: catch ReadPointerAsBytes and better error)
 - #82063 (Fixed minor typo in catch_unwind docs)
 - #82067 (const_generics: Fix incorrect ty::ParamEnv::empty() usage)
 - #82077 (Edit `rustc_arena::DropArena` docs)
 - #82096 (Fix a typo)
 - #82106 (Remove unnecessary `Option` in `default_doc`)
 - #82107 (expand: Some cleanup)
 - #82118 (Add missing env!-decl variant)
 - #82119 (Fix typo in link to CreateSymbolicLinkW documentation.)
 - #82120 (Stabilize Arguments::as_str)
 - #82129 (Remove redundant bool_to_option feature gate)
 - #82133 (Update link for extern prelude.)
 - #82141 (32-bit ARM: Emit `lr` instead of `r14` when specified as an `asm!` output register.)
 - #82147 (:arrow_up: rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoRollup merge of #82147 - lnicola:rust-analyzer-2021-02-15, r=jonas-schievink
Jonas Schievink [Mon, 15 Feb 2021 15:07:12 +0000 (16:07 +0100)]
Rollup merge of #82147 - lnicola:rust-analyzer-2021-02-15, r=jonas-schievink

:arrow_up: rust-analyzer

3 years agoRollup merge of #82141 - jrvanwhy:issue-82052, r=sanxiyn
Jonas Schievink [Mon, 15 Feb 2021 15:07:11 +0000 (16:07 +0100)]
Rollup merge of #82141 - jrvanwhy:issue-82052, r=sanxiyn

32-bit ARM: Emit `lr` instead of `r14` when specified as an `asm!` output register.

On 32-bit ARM platforms, the register `r14` has the alias `lr`. When used as an output register in `asm!`, rustc canonicalizes the name to `r14`. LLVM only knows the register by the name `lr`, and rejects it. This changes rustc's LLVM code generation to output `lr` instead.

closes #82052

r? ``@nagisa``

3 years agoRollup merge of #82133 - ehuss:extern-prelude-link, r=jyn514
Jonas Schievink [Mon, 15 Feb 2021 15:07:10 +0000 (16:07 +0100)]
Rollup merge of #82133 - ehuss:extern-prelude-link, r=jyn514

Update link for extern prelude.

There was some reorganization in the reference as part of https://github.com/rust-lang/reference/pull/937.

3 years agoRollup merge of #82129 - est31:master, r=jyn514
Jonas Schievink [Mon, 15 Feb 2021 15:07:09 +0000 (16:07 +0100)]
Rollup merge of #82129 - est31:master, r=jyn514

Remove redundant bool_to_option feature gate

3 years agoRollup merge of #82120 - sfackler:arguments-as-str, r=dtolnay
Jonas Schievink [Mon, 15 Feb 2021 15:07:08 +0000 (16:07 +0100)]
Rollup merge of #82120 - sfackler:arguments-as-str, r=dtolnay

Stabilize Arguments::as_str

Closes #74442

3 years agoRollup merge of #82119 - m-ou-se:typo, r=dtolnay
Jonas Schievink [Mon, 15 Feb 2021 15:07:06 +0000 (16:07 +0100)]
Rollup merge of #82119 - m-ou-se:typo, r=dtolnay

Fix typo in link to CreateSymbolicLinkW documentation.

3 years agoRollup merge of #82118 - lukaslueg:env_decl, r=m-ou-se
Jonas Schievink [Mon, 15 Feb 2021 15:07:05 +0000 (16:07 +0100)]
Rollup merge of #82118 - lukaslueg:env_decl, r=m-ou-se

Add missing env!-decl variant

Resolves #82117

3 years agoRollup merge of #82107 - petrochenkov:minexpclean, r=Aaron1011
Jonas Schievink [Mon, 15 Feb 2021 15:07:04 +0000 (16:07 +0100)]
Rollup merge of #82107 - petrochenkov:minexpclean, r=Aaron1011

expand: Some cleanup

See individual commits for details.

r? ``@Aaron1011``

3 years agoRollup merge of #82106 - jyn514:cleanup-bootstrap, r=Mark-Simulacrum
Jonas Schievink [Mon, 15 Feb 2021 15:07:02 +0000 (16:07 +0100)]
Rollup merge of #82106 - jyn514:cleanup-bootstrap, r=Mark-Simulacrum

Remove unnecessary `Option` in `default_doc`

Previously, there were two different ways to encode the same info: `None` or
`Some(&[])`. Now there is only one way, `&[]`.

3 years agoRollup merge of #82096 - TaKO8Ki:fix-typo, r=GuillaumeGomez
Jonas Schievink [Mon, 15 Feb 2021 15:07:01 +0000 (16:07 +0100)]
Rollup merge of #82096 - TaKO8Ki:fix-typo, r=GuillaumeGomez

Fix a typo

This pull request fixes a typo.

3 years agoRollup merge of #82077 - pierwill:edit-droparena, r=lcnr
Jonas Schievink [Mon, 15 Feb 2021 15:07:00 +0000 (16:07 +0100)]
Rollup merge of #82077 - pierwill:edit-droparena, r=lcnr

Edit `rustc_arena::DropArena` docs

- Add a "Safety" section, edit formatting for clarity
- Add missing punctuation in code comments

3 years agoRollup merge of #82067 - BoxyUwU:hahaicantthinkofabadpun, r=oli-obk
Jonas Schievink [Mon, 15 Feb 2021 15:06:59 +0000 (16:06 +0100)]
Rollup merge of #82067 - BoxyUwU:hahaicantthinkofabadpun, r=oli-obk

const_generics: Fix incorrect ty::ParamEnv::empty() usage

Fixes #80561

Not sure if I should keep the `debug!(..)`s or not but its the second time I've needed them so they sure seem useful lol

cc ``@lcnr``
r? ``@oli-obk``

3 years agoRollup merge of #82063 - NULLx76:fix-minor-typo, r=jonas-schievink
Jonas Schievink [Mon, 15 Feb 2021 15:06:58 +0000 (16:06 +0100)]
Rollup merge of #82063 - NULLx76:fix-minor-typo, r=jonas-schievink

Fixed minor typo in catch_unwind docs

Changed "a an exception" to "an exception" inside of the `std::panic::catch_unwind` docs.

3 years agoRollup merge of #82061 - RalfJung:ctfe-read-pointer-as-bytes, r=oli-obk
Jonas Schievink [Mon, 15 Feb 2021 15:06:57 +0000 (16:06 +0100)]
Rollup merge of #82061 - RalfJung:ctfe-read-pointer-as-bytes, r=oli-obk

CTFE validation: catch ReadPointerAsBytes and better error

r? ``@oli-obk``
Fixes https://github.com/rust-lang/rust/issues/79690
Cc https://github.com/rust-lang/miri/issues/1706

3 years agoRollup merge of #82060 - taiki-e:typo, r=m-ou-se
Jonas Schievink [Mon, 15 Feb 2021 15:06:56 +0000 (16:06 +0100)]
Rollup merge of #82060 - taiki-e:typo, r=m-ou-se

Fix typos in BTreeSet::{first, last} docs

map -> set

3 years agoRollup merge of #82009 - BoxyUwU:idontknooow, r=varkor
Jonas Schievink [Mon, 15 Feb 2021 15:06:55 +0000 (16:06 +0100)]
Rollup merge of #82009 - BoxyUwU:idontknooow, r=varkor

const_generics: Dont evaluate array length const when handling errors

Fixes #79518
Fixes #78246

cc ````@lcnr````

This was ICE'ing because we dont pass in the correct ``ParamEnv`` which meant that there was no ``Self: Foo`` predicate to make ``Self::Assoc`` well formed which caused an ICE when trying to normalize ``Self::Assoc`` in the mir interpreter

r? ````@varkor````

3 years agoRollup merge of #81975 - Amanieu:seal2, r=m-ou-se
Jonas Schievink [Mon, 15 Feb 2021 15:06:54 +0000 (16:06 +0100)]
Rollup merge of #81975 - Amanieu:seal2, r=m-ou-se

Seal the CommandExt, OsStrExt and OsStringExt traits

A crater run (https://github.com/rust-lang/rust/pull/81213#issuecomment-767651811) has shown that this does not break any existing code.

This also unblocks #77728.

Based on #81213.

r? ````@m-ou-se````
cc ````@lygstate````

3 years agoRollup merge of #81897 - vandenheuvel:match_exhaustive_diagnostics_regression_test...
Jonas Schievink [Mon, 15 Feb 2021 15:06:53 +0000 (16:06 +0100)]
Rollup merge of #81897 - vandenheuvel:match_exhaustive_diagnostics_regression_test, r=Mark-Simulacrum

Add match pattern diagnostics regression test

Closes #72377 by adding a regression test.

This test case fails on stable but now works on beta and nightly. It *should* have worked already for years, the crucial point whether it is mentioned that some uncovered patterns are not explicitly mentioned.

3 years agoRollup merge of #81503 - henryboisdequin:fix-const-fn-arr-err-msg, r=estebank
Jonas Schievink [Mon, 15 Feb 2021 15:06:47 +0000 (16:06 +0100)]
Rollup merge of #81503 - henryboisdequin:fix-const-fn-arr-err-msg, r=estebank

Suggest to create a new `const` item if the `fn` in the array is a `const fn`

Fixes #73734. If the `fn` in the array repeat expression is a `const fn`, suggest creating a new `const` item. On nightly, suggest creating an inline `const` block. This PR also removes the `suggest_const_in_array_repeat_expressions` as it is no longer necessary.

Example:

```rust
fn main() {
    // Should not compile but hint to create a new const item (stable) or an inline const block (nightly)
    let strings: [String; 5] = [String::new(); 5];
    println!("{:?}", strings);
}

```

Gives this error:

```
error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied
 --> $DIR/const-fn-in-vec.rs:3:32
  |
2 |     let strings: [String; 5] = [String::new(); 5];
  |                             ^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `String`
  |
  = note: the `Copy` trait is required because the repeated element will be copied
```

With this change, this is the error message:

```
error[E0277]: the trait bound `String: Copy` is not satisfied
  --> $DIR/const-fn-in-vec.rs:3:32
   |
LL |     let strings: [String; 5] = [String::new(); 5];
   |                                ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
   |
   = help: moving the function call to a new `const` item will resolve the error
```

3 years ago:arrow_up: rust-analyzer
Laurențiu Nicola [Mon, 15 Feb 2021 12:58:36 +0000 (14:58 +0200)]
:arrow_up: rust-analyzer

3 years agoAuto merge of #81855 - cjgillot:ensure-cache, r=oli-obk
bors [Mon, 15 Feb 2021 12:11:59 +0000 (12:11 +0000)]
Auto merge of #81855 - cjgillot:ensure-cache, r=oli-obk

Check the result cache before the DepGraph when ensuring queries

Split out of https://github.com/rust-lang/rust/pull/70951

Calling `ensure` on already forced queries is a common operation.
Looking at the results cache first is faster than checking the DepGraph for a green node.

3 years ago32-bit ARM: Emit `lr` instead of `r14` when specified as an `asm!` output register.
Johnathan Van Why [Mon, 15 Feb 2021 06:05:33 +0000 (22:05 -0800)]
32-bit ARM: Emit `lr` instead of `r14` when specified as an `asm!` output register.

On 32-bit ARM platforms, the register `r14` has the alias `lr`. When used as an output register in `asm!`, rustc canonicalizes the name to `r14`. LLVM only knows the register by the name `lr`, and rejects it. This changes rustc's LLVM code generation to output `lr` instead.

3 years agoUpdate link for extern prelude.
Eric Huss [Mon, 15 Feb 2021 03:38:40 +0000 (19:38 -0800)]
Update link for extern prelude.

3 years agoRemove redundant bool_to_option feature gate
est31 [Mon, 15 Feb 2021 02:55:52 +0000 (03:55 +0100)]
Remove redundant bool_to_option feature gate

3 years agoStabilize Arguments::as_str
Steven Fackler [Sun, 14 Feb 2021 22:47:08 +0000 (17:47 -0500)]
Stabilize Arguments::as_str

Closes #74442

3 years agoUpdate library/core/src/macros/mod.rs
lukaslueg [Sun, 14 Feb 2021 22:33:43 +0000 (23:33 +0100)]
Update library/core/src/macros/mod.rs

Co-authored-by: Joshua Nelson <joshua@yottadb.com>
3 years agoAuto merge of #82103 - Dylan-DPC:rollup-5wv8rid, r=Dylan-DPC
bors [Sun, 14 Feb 2021 22:26:21 +0000 (22:26 +0000)]
Auto merge of #82103 - Dylan-DPC:rollup-5wv8rid, r=Dylan-DPC

Rollup of 11 pull requests

Successful merges:

 - #80523 (#[doc(inline)] sym_generated)
 - #80920 (Visit more targets when validating attributes)
 - #81720 (Updated smallvec version due to RUSTSEC-2021-0003)
 - #81891 ([rustdoc-json] Make `header` a vec of modifiers, and FunctionPointer consistent)
 - #81912 (Implement the precise analysis pass for lint `disjoint_capture_drop_reorder`)
 - #81914 (Fixing bad suggestion for `_` in `const` type when a function #81885)
 - #81919 (BTreeMap: fix internal comments)
 - #81927 (Add a regression test for #32498)
 - #81965 (Fix MIR pretty printer for non-local DefIds)
 - #82029 (Use debug log level for developer oriented logs)
 - #82056 (fix ice (#82032))

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoFix typo in link to CreateSymbolicLinkW documentation.
Mara Bos [Sun, 14 Feb 2021 22:16:45 +0000 (23:16 +0100)]
Fix typo in link to CreateSymbolicLinkW documentation.

3 years agoAdd missing env!-decl variant
Lukas Lueg [Sun, 14 Feb 2021 21:39:47 +0000 (22:39 +0100)]
Add missing env!-decl variant

Resolves #82117

3 years agoexpand: Remove redundant calls to configure
Vadim Petrochenkov [Sun, 14 Feb 2021 16:47:00 +0000 (19:47 +0300)]
expand: Remove redundant calls to configure

Starting from https://github.com/rust-lang/rust/pull/63468 cfg attributes on variants, fields, fn params etc. are processed together with other attributes (via `configure!`).

3 years agoexpand: Remove obsolete `ExpansionConfig::keep_macs`
Vadim Petrochenkov [Sun, 14 Feb 2021 16:43:54 +0000 (19:43 +0300)]
expand: Remove obsolete `ExpansionConfig::keep_macs`

Maybe it was used before the introduction of placeholders, but now it has no effect.

3 years agorustc_span: Remove obsolete `allow_internal_unstable_backcompat_hack`
Vadim Petrochenkov [Sun, 14 Feb 2021 15:56:21 +0000 (18:56 +0300)]
rustc_span: Remove obsolete `allow_internal_unstable_backcompat_hack`

3 years agoRemove unnecessary `Option` in `default_doc`
Joshua Nelson [Sun, 14 Feb 2021 16:31:35 +0000 (11:31 -0500)]
Remove unnecessary `Option` in `default_doc`

Previously, there two different ways to encode the same info: `None` or
`Some(&[])`. Now there is only one way, `&[]`.

3 years agoRollup merge of #82056 - b-naber:mut_for_loop_bug, r=oli-obk
Dylan DPC [Sun, 14 Feb 2021 15:54:53 +0000 (16:54 +0100)]
Rollup merge of #82056 - b-naber:mut_for_loop_bug, r=oli-obk

fix ice (#82032)

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

3 years agoRollup merge of #82029 - tmiasko:debug, r=matthewjasper
Dylan DPC [Sun, 14 Feb 2021 15:54:52 +0000 (16:54 +0100)]
Rollup merge of #82029 - tmiasko:debug, r=matthewjasper

Use debug log level for developer oriented logs

The information logged here is of limited general interest, while at the
same times makes it impractical to simply enable logging and share the
resulting logs due to the amount of the output produced.

Reduce log level from info to debug for developer oriented information.

For example, when building cargo, this reduces the amount of logs
generated by `RUSTC_LOG=info cargo build` from 265 MB to 79 MB.

Continuation of changes from 81350.

3 years agoRollup merge of #81965 - osa1:issue81200, r=oli-obk
Dylan DPC [Sun, 14 Feb 2021 15:54:51 +0000 (16:54 +0100)]
Rollup merge of #81965 - osa1:issue81200, r=oli-obk

Fix MIR pretty printer for non-local DefIds

Tries to fix #81200 -- the reproducer in the issue is not fixed yet.
Submitting PR to get feedback.

r? oli-obk

3 years agoRollup merge of #81927 - vandenheuvel:issue_32498, r=Mark-Simulacrum
Dylan DPC [Sun, 14 Feb 2021 15:54:50 +0000 (16:54 +0100)]
Rollup merge of #81927 - vandenheuvel:issue_32498, r=Mark-Simulacrum

Add a regression test for #32498

[This](https://github.com/rust-lang/rust/issues/32498#issuecomment-613626968) test mentioned at issue #32498 now passes. This PR adds this regression test.

3 years agoRollup merge of #81919 - ssomers:btree_cleanup_comments, r=Mark-Simulacrum
Dylan DPC [Sun, 14 Feb 2021 15:54:49 +0000 (16:54 +0100)]
Rollup merge of #81919 - ssomers:btree_cleanup_comments, r=Mark-Simulacrum

BTreeMap: fix internal comments

Salvaged from #81372

r? `@Mark-Simulacrum`

3 years agoRollup merge of #81914 - kper:fixing-81885, r=estebank
Dylan DPC [Sun, 14 Feb 2021 15:54:47 +0000 (16:54 +0100)]
Rollup merge of #81914 - kper:fixing-81885, r=estebank

Fixing bad suggestion for `_` in `const` type when a function #81885

Closes #81885

```
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
  --> $DIR/typeck_type_placeholder_item_help.rs:13:22
   |
LL | const TEST4: fn() -> _ = 42;
   |                      ^
   |                      |
   |                      not allowed in type signatures
   |                      help: use type parameters instead: `T`
```

Do not show the suggestion `help: use type parameters instead: T` when `fn`

3 years agoRollup merge of #81912 - sexxi-goose:Migrations2_review, r=nikomatsakis
Dylan DPC [Sun, 14 Feb 2021 15:54:46 +0000 (16:54 +0100)]
Rollup merge of #81912 - sexxi-goose:Migrations2_review, r=nikomatsakis

Implement the precise analysis pass for lint `disjoint_capture_drop_reorder`

The precision pass for the lint prevents the lint from triggering for a variable (that was previously entirely captured by the closure) if all paths that need Drop starting at root variable have been captured by the closure.

r? `@nikomatsakis`

3 years agoRollup merge of #81891 - CraftSpider:fn-header, r=jyn514
Dylan DPC [Sun, 14 Feb 2021 15:54:45 +0000 (16:54 +0100)]
Rollup merge of #81891 - CraftSpider:fn-header, r=jyn514

[rustdoc-json] Make `header` a vec of modifiers, and FunctionPointer consistent

Bumps version number and adds tests, this is a breaking change. I can split this into two (`is_unsafe` -> `header` and `header: Vec<Modifiers>`) if desired.

Rationale: Modifiers are individual notes on a function, it makes more sense for them to be a list of an independent enum over a String which is inconsistently exposing the HIR representation (prefix_str vs custom literals).
Function pointers currently only support `unsafe`, but there has been talk on and off about allowing them to also support `const`, and this makes handling their modifiers consistent with handling those of a function, allowing better shared code.

`@rustbot` modify labels: +A-rustdoc-json +T-rustdoc
CC: `@HeroicKatora`
r? `@jyn514`

3 years agoRollup merge of #81720 - klensy:smallvec-update, r=Mark-Simulacrum
Dylan DPC [Sun, 14 Feb 2021 15:54:44 +0000 (16:54 +0100)]
Rollup merge of #81720 - klensy:smallvec-update, r=Mark-Simulacrum

Updated smallvec version due to RUSTSEC-2021-0003

Hi.

Updated Cargo.toml's for smallvec due to RUSTSEC-2021-0003 and Cargo.toml in separate commit.

Affected function `SmallVec::insert_many` looks like don't was used directly in rust, but can be somewhere in deps.

There should be some mechanism to not to do this kind of things manually, like dependabot. Actually, dependabot supports rust and can check security articles (at least that noted in description).

3 years agoRollup merge of #80920 - rylev:check_attr-refactor, r=davidtwco
Dylan DPC [Sun, 14 Feb 2021 15:54:42 +0000 (16:54 +0100)]
Rollup merge of #80920 - rylev:check_attr-refactor, r=davidtwco

Visit more targets when validating attributes

This begins to address #80048, allowing for additional validation of attributes.

There are more refactorings that can be done, though I think they should be tackled in additional PRs:
* ICE when a builtin attribute is encountered that is not checked
* Move some of the attr checking done `ast_validation` into `rustc_passes`
  * note that this requires a bit of additional refactoring, especially of extern items which currently parse attributes (and thus are a part of the AST) but do not possess attributes in their HIR representation.
* Rename `Target` to `AttributeTarget`
* Refactor attribute validation completely to go through `Visitor::visit_attribute`.
  * This would require at a minimum passing `Target` into this method which might be too big of a refactoring to be worth it.
  * It's also likely not possible to do all the validation this way as some validation requires knowing what other attributes a target has.

r? `@davidtwco`

3 years agoRollup merge of #80523 - LeSeulArtichaut:inline-sym, r=jyn514
Dylan DPC [Sun, 14 Feb 2021 15:54:35 +0000 (16:54 +0100)]
Rollup merge of #80523 - LeSeulArtichaut:inline-sym, r=jyn514

#[doc(inline)] sym_generated

Manually doc-inlines `rustc_span::sym_generated` into `sym`.
Previously the docs would not get inlined, causing the symbols to be undocumented as `sym_generated` is private.

r? `@jyn514`

3 years agobumped smallvec deps
klensy [Sun, 14 Feb 2021 14:37:30 +0000 (17:37 +0300)]
bumped smallvec deps

3 years agoAuto merge of #81286 - Aaron1011:collect-tokens-attrs, r=petrochenkov
bors [Sun, 14 Feb 2021 15:00:52 +0000 (15:00 +0000)]
Auto merge of #81286 - Aaron1011:collect-tokens-attrs, r=petrochenkov

Require passing an `AttrWrapper` to `collect_tokens_trailing_token`

This is a pure refactoring split out from #80689.
It represents the most invasive part of that PR, requiring changes in
every caller of `parse_outer_attributes`

In order to eagerly expand `#[cfg]` attributes while preserving the
original `TokenStream`, we need to know the range of tokens that
corresponds to every attribute target. This is accomplished by making
`parse_outer_attributes` return an opaque `AttrWrapper` struct. An
`AttrWrapper` must be converted to a plain `AttrVec` by passing it to
`collect_tokens_trailing_token`. This makes it difficult to accidentally
construct an AST node with attributes without calling `collect_tokens_trailing_token`,
since AST nodes store an `AttrVec`, not an `AttrWrapper`.

As a result, we now call `collect_tokens_trailing_token` for attribute
targets which only support inert attributes, such as generic arguments
and struct fields. Currently, the constructed `LazyTokenStream` is
simply discarded. Future PRs will record the token range corresponding
to the attribute target, allowing those tokens to be removed from an
enclosing `collect_tokens_trailing_token` call if necessary.

3 years agofix typo
Takayuki Maeda [Sun, 14 Feb 2021 12:18:17 +0000 (21:18 +0900)]
fix typo

3 years agoparam_env debugs are instrumental to rustc's success
Ellen [Sun, 14 Feb 2021 11:18:40 +0000 (11:18 +0000)]
param_env debugs are instrumental to rustc's success

3 years agoAuto merge of #81956 - ssomers:btree_post_75200, r=Mark-Simulacrum
bors [Sun, 14 Feb 2021 04:53:24 +0000 (04:53 +0000)]
Auto merge of #81956 - ssomers:btree_post_75200, r=Mark-Simulacrum

BTree: remove outdated traces of coercions

The introduction of `marker::ValMut` (#75200) meant iterators no longer see mutable keys but their code still pretends it does. And settle on the majority style `Some(unsafe {…})` over `unsafe { Some(…) }`.

r? `@Mark-Simulacrum`

3 years agoupdate message
Henry Boisdequin [Sun, 14 Feb 2021 04:38:37 +0000 (10:08 +0530)]
update message

3 years agoEdit `rustc_arena::DropArena` docs
pierwill [Sat, 13 Feb 2021 23:18:42 +0000 (15:18 -0800)]
Edit `rustc_arena::DropArena` docs

- Add a "Safety" section, edit formatting for clarity
- Add missing punctuation in code comments

3 years agoAuto merge of #81238 - RalfJung:copy-intrinsics, r=m-ou-se
bors [Sat, 13 Feb 2021 20:30:07 +0000 (20:30 +0000)]
Auto merge of #81238 - RalfJung:copy-intrinsics, r=m-ou-se

directly expose copy and copy_nonoverlapping intrinsics

This effectively un-does https://github.com/rust-lang/rust/pull/57997. That should help with `ptr::read` codegen in debug builds (and any other of these low-level functions that bottoms out at `copy`/`copy_nonoverlapping`), where the wrapper function will not get inlined. See the discussion in https://github.com/rust-lang/rust/pull/80290 and https://github.com/rust-lang/rust/issues/81163.

Cc `@bjorn3` `@therealprof`

3 years agoCheck query cache before calling into the query engine.
Camille GILLOT [Sat, 6 Feb 2021 13:52:04 +0000 (14:52 +0100)]
Check query cache before calling into the query engine.

3 years agoDrop the cache lock earlier.
Camille GILLOT [Sat, 6 Feb 2021 13:04:20 +0000 (14:04 +0100)]
Drop the cache lock earlier.

3 years agoSeparate the query cache from the query state.
Camille GILLOT [Sat, 6 Feb 2021 12:49:08 +0000 (13:49 +0100)]
Separate the query cache from the query state.

3 years agoReturn a Result for query cache.
Camille GILLOT [Fri, 23 Oct 2020 20:34:32 +0000 (22:34 +0200)]
Return a Result for query cache.

3 years agoIntroduce query_storage.
Camille GILLOT [Tue, 19 Jan 2021 19:02:05 +0000 (20:02 +0100)]
Introduce query_storage.

3 years agoIntroduce query_stored module.
Camille GILLOT [Sun, 17 Jan 2021 13:57:07 +0000 (14:57 +0100)]
Introduce query_stored module.

3 years agoMerge {get,ensure}_query.
Camille GILLOT [Wed, 18 Nov 2020 15:53:39 +0000 (16:53 +0100)]
Merge {get,ensure}_query.

3 years agoa wild test has appeared uwu
Ellen [Sat, 13 Feb 2021 18:27:39 +0000 (18:27 +0000)]
a wild test has appeared uwu

3 years agoyeet ya fixme into the void
Ellen [Sat, 13 Feb 2021 18:11:43 +0000 (18:11 +0000)]
yeet ya fixme into the void

3 years agodebug!("paramenv={}paramenv={}paramenv={}paramenv={}")
Ellen [Sat, 13 Feb 2021 19:08:31 +0000 (19:08 +0000)]
debug!("paramenv={}paramenv={}paramenv={}paramenv={}")

3 years agoAddress review comments
Aaron Hill [Sat, 13 Feb 2021 17:42:43 +0000 (12:42 -0500)]
Address review comments

3 years agoFix clippy's path to the copy intrinsics.
Mara Bos [Sat, 13 Feb 2021 17:58:54 +0000 (18:58 +0100)]
Fix clippy's path to the copy intrinsics.

3 years agoAuto merge of #81494 - cuviper:btree-node-init, r=Mark-Simulacrum
bors [Sat, 13 Feb 2021 17:29:22 +0000 (17:29 +0000)]
Auto merge of #81494 - cuviper:btree-node-init, r=Mark-Simulacrum

Initialize BTree nodes directly in the heap

We can avoid any stack-local nodes entirely by using `Box::new_uninit`, and since the nodes are mostly `MaybeUninit` fields, we only need a couple of actual writes before `assume_init`. This should help with the stack overflows in #81444, and may also improve performance in general.

r? `@Mark-Simulacrum`
cc `@ssomers`

3 years agoFix MIR pretty printer for non-local DefIds
Ömer Sinan Ağacan [Wed, 10 Feb 2021 14:32:45 +0000 (17:32 +0300)]
Fix MIR pretty printer for non-local DefIds

3 years agoRequire passing an `AttrWrapper` to `collect_tokens_trailing_token`
Aaron Hill [Fri, 22 Jan 2021 18:28:08 +0000 (13:28 -0500)]
Require passing an `AttrWrapper` to `collect_tokens_trailing_token`

This is a pure refactoring split out from #80689.
It represents the most invasive part of that PR, requiring changes in
every caller of `parse_outer_attributes`

In order to eagerly expand `#[cfg]` attributes while preserving the
original `TokenStream`, we need to know the range of tokens that
corresponds to every attribute target. This is accomplished by making
`parse_outer_attributes` return an opaque `AttrWrapper` struct. An
`AttrWrapper` must be converted to a plain `AttrVec` by passing it to
`collect_tokens_trailing_token`. This makes it difficult to accidentally
construct an AST node with attributes without calling `collect_tokens_trailing_token`,
since AST nodes store an `AttrVec`, not an `AttrWrapper`.

As a result, we now call `collect_tokens_trailing_token` for attribute
targets which only support inert attributes, such as generic arguments
and struct fields. Currently, the constructed `LazyTokenStream` is
simply discarded. Future PRs will record the token range corresponding
to the attribute target, allowing those tokens to be removed from an
enclosing `collect_tokens_trailing_token` call if necessary.

3 years agoFixed minor typo in catch_unwind docs
Victor Roest [Sat, 13 Feb 2021 15:59:06 +0000 (16:59 +0100)]
Fixed minor typo in catch_unwind docs

Changed 'a an exception' to 'an exception'

3 years agoHeat up the ICE-y error reporting
Ellen [Sat, 13 Feb 2021 14:42:30 +0000 (14:42 +0000)]
Heat up the ICE-y error reporting

rest in peace match bool <3

3 years agoCTFE validation: catch ReadPointerAsBytes and better error
Ralf Jung [Sat, 13 Feb 2021 13:58:31 +0000 (14:58 +0100)]
CTFE validation: catch ReadPointerAsBytes and better error

3 years agoFix typos in BTreeSet::{first, last} docs
Taiki Endo [Sat, 13 Feb 2021 13:49:46 +0000 (22:49 +0900)]
Fix typos in BTreeSet::{first, last} docs

3 years agoAuto merge of #81666 - hyd-dev:miri-windows-test-fail, r=Mark-Simulacrum
bors [Sat, 13 Feb 2021 13:47:02 +0000 (13:47 +0000)]
Auto merge of #81666 - hyd-dev:miri-windows-test-fail, r=Mark-Simulacrum

Don't release Miri if its tests only failed on Windows

Extends #66053 to Windows, so the released Miri won't be broken if its tests only fail on Windows.

Relevant Zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/269128-miri/topic/Miri.20is.20still.20available.20in.20rustup.20today.3F

3 years agoAdd match pattern diagnostics regression test
Bram van den Heuvel [Mon, 8 Feb 2021 20:43:52 +0000 (21:43 +0100)]
Add match pattern diagnostics regression test

3 years agono need to check assertion on fast path.
Giles Cope [Sat, 13 Feb 2021 12:25:56 +0000 (12:25 +0000)]
no need to check assertion on fast path.

3 years agoadd test
b-naber [Sat, 13 Feb 2021 11:12:57 +0000 (12:12 +0100)]
add test

3 years agoAuto merge of #81854 - the8472:specialize-clone-slice, r=Mark-Simulacrum
bors [Sat, 13 Feb 2021 10:55:19 +0000 (10:55 +0000)]
Auto merge of #81854 - the8472:specialize-clone-slice, r=Mark-Simulacrum

specialize slice::clone_from_slice() for T: Copy

3 years agofix 82032
b-naber [Sat, 13 Feb 2021 10:47:44 +0000 (11:47 +0100)]
fix 82032

3 years agoDisabled SHELL=dash on Windows due to invalid path backslash handling
Rich Kadel [Sat, 13 Feb 2021 08:14:50 +0000 (00:14 -0800)]
Disabled SHELL=dash on Windows due to invalid path backslash handling

Calling an executable via full path with Windows backslashes fails in
dash.

3 years agoAuto merge of #82053 - JohnTitor:rollup-ymi9q0g, r=JohnTitor
bors [Sat, 13 Feb 2021 07:58:44 +0000 (07:58 +0000)]
Auto merge of #82053 - JohnTitor:rollup-ymi9q0g, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #81811 (Fix doc test for Vec::retain(), now passes clippy::eval_order_dependence)
 - #81900 (Organize trait test files)
 - #81995 (Fix suggestion to introduce explicit lifetime)
 - #82031 (Drop an unnecessary intermediate variable)
 - #82033 (Refactor `get_word_attr` to return only `Option`)
 - #82040 (Add test to prevent src link regression)
 - #82041 (Add docs for shared_from_slice From impls)
 - #82050 (Added tests to drain an empty vec)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoRollup merge of #82050 - hbina:fix/added-test-to-drain-empty-vec, r=dtolnay
Yuki Okushi [Sat, 13 Feb 2021 07:36:52 +0000 (16:36 +0900)]
Rollup merge of #82050 - hbina:fix/added-test-to-drain-empty-vec, r=dtolnay

Added tests to drain an empty vec

Discovered this kind of issue in an unrelated library.
The author copied the tests from here and AFAIK, there are no tests for this particular case.

https://github.com/LeonineKing1199/minivec/pull/19

Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com>
3 years agoRollup merge of #82041 - notriddle:shared-from-slice-docs, r=m-ou-se
Yuki Okushi [Sat, 13 Feb 2021 07:36:51 +0000 (16:36 +0900)]
Rollup merge of #82041 - notriddle:shared-from-slice-docs, r=m-ou-se

Add docs for shared_from_slice From impls

The advantage of making these docs is mostly in pointing out that these
functions all make new allocations and copy/clone/move the source into them.

These docs are on the function, and not the `impl` block, to avoid showing
the "[+] show undocumented items" button.

CC #51430

3 years agoRollup merge of #82040 - GuillaumeGomez:ensure-src-link, r=CraftSpider
Yuki Okushi [Sat, 13 Feb 2021 07:36:49 +0000 (16:36 +0900)]
Rollup merge of #82040 - GuillaumeGomez:ensure-src-link, r=CraftSpider

Add test to prevent src link regression

Fixes #80502.

This PR is simply about adding a test to prevent a regression.

cc `@bugadani` `@CraftSpider`
r? `@camelid`

3 years agoRollup merge of #82033 - magurotuna:issue82016, r=jyn514
Yuki Okushi [Sat, 13 Feb 2021 07:36:48 +0000 (16:36 +0900)]
Rollup merge of #82033 - magurotuna:issue82016, r=jyn514

Refactor `get_word_attr` to return only `Option`

This commit removes `bool` from the return type of `NestedAttributesExt::get_word_attr` so it will return only `Option<ast::NestedMetaItem>` for less redundancy.

Closes #82016

r? `@jyn514`

3 years agoRollup merge of #82031 - LingMan:unneeded_var, r=varkor
Yuki Okushi [Sat, 13 Feb 2021 07:36:47 +0000 (16:36 +0900)]
Rollup merge of #82031 - LingMan:unneeded_var, r=varkor

Drop an unnecessary intermediate variable

Neither does it shorten the code nor does it provide a helpful name.

`@rustbot` modify labels +C-cleanup +T-compiler

r? `@varkor`

3 years agoRollup merge of #81995 - 0yoyoyo:fix-issue-81650-explicit-lifetime-error, r=estebank
Yuki Okushi [Sat, 13 Feb 2021 07:36:46 +0000 (16:36 +0900)]
Rollup merge of #81995 - 0yoyoyo:fix-issue-81650-explicit-lifetime-error, r=estebank

Fix suggestion to introduce explicit lifetime

Addresses #81650

Error message after fix:

```
error[E0311]: the parameter type `T` may not live long enough
  --> src/main.rs:25:11
   |
24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) {
   |              -- help: consider adding an explicit lifetime bound...: `T: 'a +`
25 |     scope.spawn(move |_| {
   |           ^^^^^
   |
note: the parameter type `T` must be valid for the anonymous lifetime #2 defined on the function body at 24:1...
  --> src/main.rs:24:1
   |
24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...so that the type `[closure@src/main.rs:25:17: 27:6]` will meet its required lifetime bounds
  --> src/main.rs:25:11
   |
25 |     scope.spawn(move |_| {
   |           ^^^^^
```

3 years agoRollup merge of #81900 - vandenheuvel:organize_trait_tests, r=Mark-Simulacrum
Yuki Okushi [Sat, 13 Feb 2021 07:36:45 +0000 (16:36 +0900)]
Rollup merge of #81900 - vandenheuvel:organize_trait_tests, r=Mark-Simulacrum

Organize trait test files

Organizes trait tests in folders where reasonable and removes name redundancies.

3 years agoRollup merge of #81811 - schteve:fix_vec_retain_doc_test, r=m-ou-se
Yuki Okushi [Sat, 13 Feb 2021 07:36:40 +0000 (16:36 +0900)]
Rollup merge of #81811 - schteve:fix_vec_retain_doc_test, r=m-ou-se

Fix doc test for Vec::retain(), now passes clippy::eval_order_dependence

Doc test for Vec::retain() works correctly but is flagged by clippy::eval_order_dependence. Fix avoids the issue by using an iterator instead of an index.

3 years agoModifiers -> Qualifiers
Rune Tynan [Sat, 13 Feb 2021 04:24:09 +0000 (23:24 -0500)]
Modifiers -> Qualifiers

3 years agoAdded tests to drain an empty vec
Hanif Bin Ariffin [Sat, 13 Feb 2021 03:18:36 +0000 (11:18 +0800)]
Added tests to drain an empty vec

Discovered this kind of issue in an unrelated library.
The author copied the tests from here and AFAIK, there are no tests for this particular case.

Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com>
3 years agoAuto merge of #82045 - Dylan-DPC:rollup-244l0sb, r=Dylan-DPC
bors [Sat, 13 Feb 2021 02:46:57 +0000 (02:46 +0000)]
Auto merge of #82045 - Dylan-DPC:rollup-244l0sb, r=Dylan-DPC

Rollup of 10 pull requests

Successful merges:

 - #79775 (Fix injected errors when running doctests on a crate named after a keyword)
 - #81012 (Stabilize the partition_point feature)
 - #81479 (Allow casting mut array ref to mut ptr)
 - #81506 (HWAddressSanitizer support)
 - #81741 (Increment `self.index` before calling `Iterator::self.a.__iterator_ge…)
 - #81850 (use RWlock when accessing os::env)
 - #81911 (GAT/const_generics: Allow with_opt_const_param to return GAT param def_id)
 - #82022 (Push a `char` instead of a `str` with len one into a String)
 - #82023 (Remove unnecessary lint allow attrs on example)
 - #82030 (Use `Iterator::all` instead of open-coding it)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoUse debug log level for developer oriented logs
Tomasz Miąsko [Sat, 13 Feb 2021 00:00:00 +0000 (00:00 +0000)]
Use debug log level for developer oriented logs

The information logged here is of limited general interest, while at the
same times makes it impractical to simply enable logging and share the
resulting logs due to the amount of the output produced.

Reduce log level from info to debug for developer oriented information.

For example, when building cargo, this reduces the amount of logs
generated by `RUSTC_LOG=info cargo build` from 265 MB to 79 MB.

Continuation of changes from 81350.

3 years agoRollup merge of #82030 - LingMan:init_directly, r=varkor
Dylan DPC [Fri, 12 Feb 2021 21:53:38 +0000 (22:53 +0100)]
Rollup merge of #82030 - LingMan:init_directly, r=varkor

Use `Iterator::all` instead of open-coding it

Shorter code and by initializing to the final value directly, the variable
doesn't need to be mut.

3 years agoRollup merge of #82023 - MikailBag:boxed-docs-unallow, r=jyn514
Dylan DPC [Fri, 12 Feb 2021 21:53:37 +0000 (22:53 +0100)]
Rollup merge of #82023 - MikailBag:boxed-docs-unallow, r=jyn514

Remove unnecessary lint allow attrs on example

It seems they are not needed anymore.

3 years agoRollup merge of #82022 - LingMan:single_char, r=jonas-schievink
Dylan DPC [Fri, 12 Feb 2021 21:53:36 +0000 (22:53 +0100)]
Rollup merge of #82022 - LingMan:single_char, r=jonas-schievink

Push a `char` instead of a `str` with len one into a String

``@rustbot`` modify labels +C-cleanup +T-compiler

3 years agoRollup merge of #81911 - BoxyUwU:constgenericgaticefix, r=nikomatsakis
Dylan DPC [Fri, 12 Feb 2021 21:53:34 +0000 (22:53 +0100)]
Rollup merge of #81911 - BoxyUwU:constgenericgaticefix, r=nikomatsakis

GAT/const_generics: Allow with_opt_const_param to return GAT param def_id

Fixes #75415
Fixes #79666
cc ```@lcnr```

I've absolutely no idea who to r?  for this...

3 years agoRollup merge of #81850 - the8472:env-rwlock, r=m-ou-se
Dylan DPC [Fri, 12 Feb 2021 21:53:33 +0000 (22:53 +0100)]
Rollup merge of #81850 - the8472:env-rwlock, r=m-ou-se

use RWlock when accessing os::env

Multiple threads modifying the current process environment is fairly uncommon. Optimize for the more common read case.

r? ````@m-ou-se````

3 years agoRollup merge of #81741 - sdroege:zip-trusted-random-access-specialization-panic-safet...
Dylan DPC [Fri, 12 Feb 2021 21:53:32 +0000 (22:53 +0100)]
Rollup merge of #81741 - sdroege:zip-trusted-random-access-specialization-panic-safety, r=KodrAus

Increment `self.index` before calling `Iterator::self.a.__iterator_ge…

…`t_unchecked` in `Zip` `TrustedRandomAccess` specialization

Otherwise if `Iterator::self.a.__iterator_get_unchecked` panics the
index would not have been incremented yet and another call to
`Iterator::next` would read from the same index again, which is not
allowed according to the API contract of `TrustedRandomAccess` for
`!Clone`.

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