]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoreplace if-let and while-let with `if let` and `while let`
Takayuki Maeda [Wed, 17 Feb 2021 10:26:38 +0000 (19:26 +0900)]
replace if-let and while-let with `if let` and `while let`

3 years agoEnable the tests on Arm Linux too
bjorn3 [Wed, 17 Feb 2021 09:01:29 +0000 (10:01 +0100)]
Enable the tests on Arm Linux too

3 years agoRemove redundant rustc_data_structures path component
est31 [Wed, 17 Feb 2021 08:30:08 +0000 (09:30 +0100)]
Remove redundant rustc_data_structures path component

3 years agomake suggest setup help messages better
Henry Boisdequin [Wed, 17 Feb 2021 06:56:02 +0000 (12:26 +0530)]
make suggest setup help messages better

3 years agoAuto merge of #82197 - tmiasko:try-get-cached, r=cjgillot
bors [Wed, 17 Feb 2021 04:07:35 +0000 (04:07 +0000)]
Auto merge of #82197 - tmiasko:try-get-cached, r=cjgillot

Inline try_get_cached

3 years agorustdoc: treat edition 2021 as unstable
Eric Huss [Wed, 17 Feb 2021 03:17:01 +0000 (19:17 -0800)]
rustdoc: treat edition 2021 as unstable

3 years agoMake `Clean` take &mut DocContext
Joshua Nelson [Fri, 12 Feb 2021 06:59:20 +0000 (01:59 -0500)]
Make `Clean` take &mut DocContext

- Take `FnMut` in `rustc_trait_selection::find_auto_trait_generics`
- Take `&mut DocContext` in most of `clean`
- Collect the iterator in auto_trait_impls instead of iterating lazily; the lifetimes were really bad.
- Changes `fn sess` to properly return a borrow with the lifetime of `'tcx`, not the mutable borrow.

3 years agoTake `&mut DocContext` in passes
Joshua Nelson [Fri, 12 Feb 2021 06:11:32 +0000 (01:11 -0500)]
Take `&mut DocContext` in passes

This should hopefully allow for less interior mutability.

3 years agoUpdate books
Eric Huss [Wed, 17 Feb 2021 01:19:28 +0000 (17:19 -0800)]
Update books

3 years agoAdd riscv32 and riscv64 musl to supported platform targets
Khem Raj [Wed, 17 Feb 2021 00:44:39 +0000 (16:44 -0800)]
Add riscv32 and riscv64 musl to supported platform targets

Signed-off-by: Khem Raj <raj.khem@gmail.com>
3 years agoadd specs for riscv32/riscv64 musl targets
Khem Raj [Wed, 17 Feb 2021 00:18:53 +0000 (16:18 -0800)]
add specs for riscv32/riscv64 musl targets

Signed-off-by: Khem Raj <raj.khem@gmail.com>
3 years agoMove some tests to more reasonable directories
Caio [Wed, 17 Feb 2021 00:22:21 +0000 (21:22 -0300)]
Move some tests to more reasonable directories

3 years agoEnsure debug_assert! tests get run
Teddy Katz [Wed, 17 Feb 2021 00:05:30 +0000 (19:05 -0500)]
Ensure debug_assert! tests get run

3 years agoUse -Ccodegen-units=1 to make issue-23458 test deterministic
Tomasz Miąsko [Wed, 17 Feb 2021 00:00:00 +0000 (00:00 +0000)]
Use -Ccodegen-units=1 to make issue-23458 test deterministic

The test case fails with either one error or two errors.
Use a single code generation unit to avoid nondeterminism.

3 years agoReduce size of InterpErrorInfo to 8 bytes
Tomasz Miąsko [Sun, 14 Feb 2021 00:00:00 +0000 (00:00 +0000)]
Reduce size of InterpErrorInfo to 8 bytes

3 years ago./x.py fmt
Tomasz Miąsko [Mon, 15 Feb 2021 00:00:00 +0000 (00:00 +0000)]
./x.py fmt

3 years agoPass MPlaceTy by reference not value
Tomasz Miąsko [Mon, 15 Feb 2021 00:00:00 +0000 (00:00 +0000)]
Pass MPlaceTy by reference not value

3 years agoPass ImmTy by reference not value
Tomasz Miąsko [Mon, 15 Feb 2021 00:00:00 +0000 (00:00 +0000)]
Pass ImmTy by reference not value

3 years agoPass PlaceTy by reference not value
Tomasz Miąsko [Mon, 15 Feb 2021 00:00:00 +0000 (00:00 +0000)]
Pass PlaceTy by reference not value

3 years agoPass OpTy by reference not value
Tomasz Miąsko [Mon, 15 Feb 2021 00:00:00 +0000 (00:00 +0000)]
Pass OpTy by reference not value

3 years agoAdd size assertions for interpreter data structures
Tomasz Miąsko [Sun, 14 Feb 2021 00:00:00 +0000 (00:00 +0000)]
Add size assertions for interpreter data structures

3 years agoAuto merge of #81611 - cjgillot:meowner, r=estebank
bors [Tue, 16 Feb 2021 22:14:32 +0000 (22:14 +0000)]
Auto merge of #81611 - cjgillot:meowner, r=estebank

Only store a LocalDefId in some HIR nodes

Some HIR nodes are guaranteed to be HIR owners: Item, TraitItem, ImplItem, ForeignItem and MacroDef.
As a consequence, we do not need to store the `HirId`'s `local_id`, and we can directly store a `LocalDefId`.

This allows to avoid a bit of the dance with `tcx.hir().local_def_id` and `tcx.hir().local_def_id_to_hir_id` mappings.

3 years agoOptimize Iterator::is_sorted_by by using Iterator::all for internal iteration
Giacomo Stevanato [Tue, 16 Feb 2021 20:49:56 +0000 (21:49 +0100)]
Optimize Iterator::is_sorted_by by using Iterator::all for internal iteration

3 years agoAdd caveat to Path::display() about lossiness
Manish Goregaokar [Tue, 16 Feb 2021 19:45:46 +0000 (11:45 -0800)]
Add caveat to Path::display() about lossiness

3 years agoAuto merge of #82192 - GuillaumeGomez:rollup-gi1639b, r=GuillaumeGomez
bors [Tue, 16 Feb 2021 19:21:22 +0000 (19:21 +0000)]
Auto merge of #82192 - GuillaumeGomez:rollup-gi1639b, r=GuillaumeGomez

Rollup of 6 pull requests

Successful merges:

 - #82145 (Fix ES5 errors (IE11))
 - #82160 (Fix typo in rustc_infer::infer::UndoLog)
 - #82161 (Add long explanation for E0545)
 - #82163 (avoid full-slicing slices)
 - #82175 (validation: fix invalid-fn-ptr error message)
 - #82184 ([Minor] Update discriminant_value docs)

Failed merges:

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

3 years agoRemove ordering hint
kadmin [Tue, 16 Feb 2021 19:03:22 +0000 (19:03 +0000)]
Remove ordering hint

3 years agoRollup merge of #82184 - petertodd:2021-discriminant-value-doc, r=nagisa
Guillaume Gomez [Tue, 16 Feb 2021 18:21:21 +0000 (19:21 +0100)]
Rollup merge of #82184 - petertodd:2021-discriminant-value-doc, r=nagisa

[Minor] Update discriminant_value docs

Updated for new `DiscriminantKind` trait.

3 years agoRollup merge of #82175 - RalfJung:invalid-fn-ptr, r=oli-obk
Guillaume Gomez [Tue, 16 Feb 2021 18:21:21 +0000 (19:21 +0100)]
Rollup merge of #82175 - RalfJung:invalid-fn-ptr, r=oli-obk

validation: fix invalid-fn-ptr error message

https://github.com/rust-lang/rust/pull/82061 changed the code here to print an `ImmTy` instead of a `ScalarMaybeUninit`; that was an accident. So go back to printing a `ScalarMaybeUninit`.

r? ```@oli-obk```

3 years agoRollup merge of #82163 - matthiaskrgr:slice, r=jyn514
Guillaume Gomez [Tue, 16 Feb 2021 18:21:20 +0000 (19:21 +0100)]
Rollup merge of #82163 - matthiaskrgr:slice, r=jyn514

avoid full-slicing slices

If we already have a slice, there is no need to get another full-range slice from that, just use the original.
clippy::redundant_slicing

3 years agoRollup merge of #82161 - jesusprubio:add-long-explanation-e0545, r=GuillaumeGomez
Guillaume Gomez [Tue, 16 Feb 2021 18:21:19 +0000 (19:21 +0100)]
Rollup merge of #82161 - jesusprubio:add-long-explanation-e0545, r=GuillaumeGomez

Add long explanation for E0545

Helps with #61137

3 years agoRollup merge of #82160 - pierwill:patch-2, r=lcnr
Guillaume Gomez [Tue, 16 Feb 2021 18:21:18 +0000 (19:21 +0100)]
Rollup merge of #82160 - pierwill:patch-2, r=lcnr

Fix typo in rustc_infer::infer::UndoLog

Also use double quotes.

3 years agoRollup merge of #82145 - GuillaumeGomez:es5-checks, r=Nemo157
Guillaume Gomez [Tue, 16 Feb 2021 18:21:14 +0000 (19:21 +0100)]
Rollup merge of #82145 - GuillaumeGomez:es5-checks, r=Nemo157

Fix ES5 errors (IE11)

rustdoc is supposed to run on IE11 but someone reported me that it wasn't. I just confirmed it by using `es-check` with the `es5` option like this:

```
$ es-check es5 src/librustdoc/html/static/*.js
```

The PR fixes those issues and add CI checks to prevent regressions.

`@Mark-Simulacrum:` I added checks in the CI, but not sure if it's the correct way to do it. Any help on that side would be very appreciated!

r? `@Nemo157`

3 years agoAuto merge of #82150 - RalfJung:miri, r=RalfJung
bors [Tue, 16 Feb 2021 16:22:56 +0000 (16:22 +0000)]
Auto merge of #82150 - RalfJung:miri, r=RalfJung

update Miri

This pulls in the recent cargo-miri fixes by `@hyd-dev.`
Cc `@rust-lang/miri` r? `@ghost`
Fixes https://github.com/rust-lang/rust/issues/82173

3 years agoReplace File::create and write_all with fs::write
est31 [Tue, 16 Feb 2021 07:09:07 +0000 (08:09 +0100)]
Replace File::create and write_all with fs::write

Also don't convert to u8 buffers and back
when we are only creating strings.

3 years ago[Minor] Update discriminant_value docs
Peter Todd [Tue, 16 Feb 2021 13:16:31 +0000 (08:16 -0500)]
[Minor] Update discriminant_value docs

3 years agoupdate Miri
Ralf Jung [Tue, 16 Feb 2021 10:17:42 +0000 (11:17 +0100)]
update Miri

3 years agoadd test
Ralf Jung [Tue, 16 Feb 2021 10:14:34 +0000 (11:14 +0100)]
add test

3 years agofix MIR fn-ptr pretty-printing
Ralf Jung [Tue, 16 Feb 2021 08:59:38 +0000 (09:59 +0100)]
fix MIR fn-ptr pretty-printing

3 years agovalidation: fix invalid-fn-ptr error message
Ralf Jung [Tue, 16 Feb 2021 08:57:21 +0000 (09:57 +0100)]
validation: fix invalid-fn-ptr error message

3 years agoIgnore Atomic*::fetch_{min,max} tests on ARM
bjorn3 [Tue, 16 Feb 2021 08:45:27 +0000 (09:45 +0100)]
Ignore Atomic*::fetch_{min,max} tests on ARM

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 agoDocument that `assert!` format arguments are evaluated lazily
Teddy Katz [Tue, 16 Feb 2021 02:06:00 +0000 (21:06 -0500)]
Document that `assert!` format arguments are evaluated lazily

It can be useful to do some computation in `assert!` format arguments, in order to get better error messages. For example:

```rust
assert!(
    some_condition,
    "The state is invalid. Details: {}",
    expensive_call_to_get_debugging_info(),
);
```

It seems like `assert!` only evaluates the format arguments if the assertion fails, which is useful but doesn't appear to be documented anywhere. This PR documents the behavior and adds some tests.

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 agoUpdate w/ comments
kadmin [Sun, 14 Feb 2021 04:35:18 +0000 (04:35 +0000)]
Update w/ comments

3 years agoUse iter::position in truncate_capture_for_move
Aman Arora [Sat, 13 Feb 2021 06:59:35 +0000 (01:59 -0500)]
Use iter::position in truncate_capture_for_move

3 years agoTreat read of COpy types via refs as not move in move-closure
Aman Arora [Fri, 12 Feb 2021 00:36:05 +0000 (19:36 -0500)]
Treat read of COpy types via refs as not move in move-closure

3 years agoHandle restricting closure origin
Aman Arora [Tue, 9 Feb 2021 04:31:26 +0000 (23:31 -0500)]
Handle restricting closure origin

3 years agoImplement reborrow for closure captures
Aman Arora [Thu, 4 Feb 2021 07:12:31 +0000 (02:12 -0500)]
Implement reborrow for closure captures

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 agoInline try_get_cached
Tomasz Miąsko [Tue, 16 Feb 2021 00:00:00 +0000 (00:00 +0000)]
Inline try_get_cached

3 years agoavoid full-slicing slices
Matthias Krüger [Mon, 15 Feb 2021 23:30:06 +0000 (00:30 +0100)]
avoid full-slicing slices

If we already have a slice, there is no need to get another full-range slice from that, just use the original.
clippy::redundant_slicing

3 years agoRemove HirItemLike.
Camille GILLOT [Mon, 1 Feb 2021 10:32:26 +0000 (11:32 +0100)]
Remove HirItemLike.

3 years agoTrait impls are Items, therefore HIR owners.
Camille GILLOT [Mon, 1 Feb 2021 10:12:49 +0000 (11:12 +0100)]
Trait impls are Items, therefore HIR owners.

3 years agoUse less HirId when referring to items.
Camille GILLOT [Sun, 31 Jan 2021 17:21:04 +0000 (18:21 +0100)]
Use less HirId when referring to items.

3 years agoOnly store a LocalDefId in hir::MacroDef.
Camille GILLOT [Sun, 31 Jan 2021 17:20:18 +0000 (18:20 +0100)]
Only store a LocalDefId in hir::MacroDef.

3 years agoIndex Modules using their LocalDefId.
Camille GILLOT [Sun, 31 Jan 2021 16:58:57 +0000 (17:58 +0100)]
Index Modules using their LocalDefId.

3 years agoFix E0657.
Camille GILLOT [Sun, 31 Jan 2021 10:01:49 +0000 (11:01 +0100)]
Fix E0657.

3 years agoOnly store a LocalDefId in hir::ForeignItem.
Camille GILLOT [Sun, 31 Jan 2021 23:33:38 +0000 (00:33 +0100)]
Only store a LocalDefId in hir::ForeignItem.

3 years agoOnly store a LocalDefId in hir::ImplItem.
Camille GILLOT [Sat, 30 Jan 2021 22:25:03 +0000 (23:25 +0100)]
Only store a LocalDefId in hir::ImplItem.

3 years agoOnly store a LocalDefId in hir::TraitItem.
Camille GILLOT [Sat, 30 Jan 2021 19:46:50 +0000 (20:46 +0100)]
Only store a LocalDefId in hir::TraitItem.

3 years agoOnly store a LocalDefId in hir::Item.
Camille GILLOT [Sat, 30 Jan 2021 16:47:51 +0000 (17:47 +0100)]
Only store a LocalDefId in hir::Item.

Items are guaranteed to be HIR owner.

3 years agoUse an ItemId inside mir::GlobalAsm.
Camille GILLOT [Sat, 30 Jan 2021 18:18:48 +0000 (19:18 +0100)]
Use an ItemId inside mir::GlobalAsm.

3 years agoUse ItemId as a strongly typed index.
Camille GILLOT [Sat, 30 Jan 2021 11:06:04 +0000 (12:06 +0100)]
Use ItemId as a strongly typed index.

3 years agoAdd assertions on HIR enum sizes.
Camille GILLOT [Fri, 29 Jan 2021 18:27:56 +0000 (19:27 +0100)]
Add assertions on HIR enum sizes.

3 years agoRemove useless Named trait.
Camille GILLOT [Sat, 30 Jan 2021 10:28:28 +0000 (11:28 +0100)]
Remove useless Named trait.

3 years agoAdd long explanation for E0545
Jesus Rubio [Mon, 15 Feb 2021 18:16:39 +0000 (19:16 +0100)]
Add long explanation for E0545

3 years agoSimplify pattern grammar by allowing nested leading vert
mark [Mon, 8 Feb 2021 02:40:33 +0000 (20:40 -0600)]
Simplify pattern grammar by allowing nested leading vert

Along the way, we also implement a handful of diagnostics improvements
and fixes, particularly with respect to the special handling of `||` in
place of `|` and when there are leading verts in function params, which
don't allow top-level or-patterns anyway.

3 years agoFix typo in rustc_infer::infer::UndoLog
pierwill [Mon, 15 Feb 2021 18:02:03 +0000 (10:02 -0800)]
Fix typo in rustc_infer::infer::UndoLog

Also use double quotes.

3 years agoname async generators something more human friendly in type error diagnostics
Gus Wynn [Fri, 29 Jan 2021 02:16:52 +0000 (18:16 -0800)]
name async generators something more human friendly in type error diagnostics

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 agoUse local path for already-imported function
Simon Sapin [Mon, 15 Feb 2021 13:25:22 +0000 (14:25 +0100)]
Use local path for already-imported function

This module has `use super::*;` at the top.

Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
3 years agoPointer metadata: add tracking issue number
Simon Sapin [Fri, 29 Jan 2021 13:38:48 +0000 (14:38 +0100)]
Pointer metadata: add tracking issue number

3 years agoAdd a ThinBox library as a libcore test for pointer metadata APIs
Simon Sapin [Mon, 18 Jan 2021 21:24:33 +0000 (22:24 +0100)]
Add a ThinBox library as a libcore test for pointer metadata APIs

3 years agoFix intra-doc link to raw pointer method
Simon Sapin [Mon, 18 Jan 2021 19:56:29 +0000 (20:56 +0100)]
Fix intra-doc link to raw pointer method

CC https://github.com/rust-lang/rust/pull/80181

3 years agoFix libcore unit tests in stage 0
Simon Sapin [Mon, 18 Jan 2021 19:45:34 +0000 (20:45 +0100)]
Fix libcore unit tests in stage 0

3 years agoMore doc-comments for pointer metadata APIs
Simon Sapin [Mon, 18 Jan 2021 18:45:32 +0000 (19:45 +0100)]
More doc-comments for pointer metadata APIs

3 years agoUse new pointer metadata API inside libcore instead of manual transmutes
Simon Sapin [Mon, 18 Jan 2021 16:18:13 +0000 (17:18 +0100)]
Use new pointer metadata API inside libcore instead of manual transmutes

3 years agoAdd `to_raw_parts` methods to `*const`, `*mut`, and `NonNull`
Simon Sapin [Mon, 18 Jan 2021 15:56:53 +0000 (16:56 +0100)]
Add `to_raw_parts` methods to `*const`, `*mut`, and `NonNull`

These are not named `into_` because they do not consume their receiver
since raw pointers are `Copy`.

3 years agoAdd `ptr::from_raw_parts`, `ptr::from_raw_parts_mut`, and `NonNull::from_raw_parts`
Simon Sapin [Mon, 18 Jan 2021 15:19:29 +0000 (16:19 +0100)]
Add `ptr::from_raw_parts`, `ptr::from_raw_parts_mut`, and `NonNull::from_raw_parts`

The use of module-level functions instead of associated functions
on `<*const T>` or `<*mut T>` follows the precedent of
`ptr::slice_from_raw_parts` and `ptr::slice_from_raw_parts_mut`.

3 years agoAdd `size_of`, `align_of`, and `layout` methods to `DynMetadata`
Simon Sapin [Wed, 13 Jan 2021 10:09:15 +0000 (11:09 +0100)]
Add `size_of`, `align_of`, and `layout` methods to `DynMetadata`

3 years agoParameterize `DynMetadata` over its `dyn SomeTrait` type
Simon Sapin [Tue, 29 Dec 2020 17:31:22 +0000 (18:31 +0100)]
Parameterize `DynMetadata` over its `dyn SomeTrait` type

3 years agoAdd `ptr::Pointee` trait (for all types) and `ptr::metadata` function
Simon Sapin [Mon, 19 Oct 2020 13:38:11 +0000 (15:38 +0200)]
Add `ptr::Pointee` trait (for all types) and `ptr::metadata` function

RFC: https://github.com/rust-lang/rfcs/pull/2580