Commit graph

154576 commits

Author SHA1 Message Date
Albin Hedman
92b57c0476
Updated for new const trait bounds syntax 2021-09-15 16:58:02 +02:00
Albin Hedman
3051bb9c81
Move tests to library/core/tests 2021-09-15 16:58:02 +02:00
Albin Hedman
aaf902bf8f
Add test for try operator with Option 2021-09-15 16:58:01 +02:00
Albin Hedman
a042705a7d
Constly impl TryV2 and Residual for Option 2021-09-15 16:58:00 +02:00
Albin Hedman
991b375d87
Add test for try operator on Result 2021-09-15 16:58:00 +02:00
Albin Hedman
88258c02a9
Constly impl TryV2 and FromResidual for Result 2021-09-15 16:57:59 +02:00
Albin Hedman
b85107ec71
Add tests for feature(const_identity_convert) 2021-09-15 16:57:59 +02:00
Albin Hedman
b82aaf4913
Constify identify conversions 2021-09-15 16:57:58 +02:00
bors
e846f9c44f Auto merge of #88619 - GuillaumeGomez:simplify-std-os-reexports, r=Amanieu
Remove `cfg(doc)` from std::os module reexports to fix rustdoc linking issues

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

I tested it based on https://github.com/rust-lang/rust/pull/88292.

Not sure if it's the best approach, but at least it makes thing a bit simpler.

cc `@jyn514`
2021-09-15 09:30:00 +00:00
bors
cdeba02ff7 Auto merge of #88558 - fee1-dead:const-drop, r=oli-obk
Const drop

The changes are pretty primitive at this point. But at least it works. ^-^

Problems with the current change that I can think of now:
 - [x] `~const Drop` shouldn't change anything in the non-const world.
 - [x] types that do not have drop glues shouldn't fail to satisfy `~const Drop` in const contexts. `struct S { a: u8, b: u16 }` This might not fail for `needs_non_const_drop`, but it will fail in `rustc_trait_selection`.
 - [x] The current change accepts types that have `const Drop` impls but have non-const `Drop` glue.

Fixes #88424.

Significant Changes:

- `~const Drop` is no longer treated as a normal trait bound. In non-const contexts, this bound has no effect, but in const contexts, this restricts the input type and all of its transitive fields to either a) have a `const Drop` impl or b) can be trivially dropped (i.e. no drop glue)
- `T: ~const Drop` will not be linted like `T: Drop`.
- Instead of recursing and iterating through the type in `rustc_mir::transform::check_consts`, we use the trait system to special case `~const Drop`. See [`rustc_trait_selection::...::candidate_assembly#assemble_const_drop_candidates`](https://github.com/fee1-dead/rust/blob/const-drop/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs#L817) and others.

Changes not related to `const Drop`ping and/or changes that are insignificant:

 - `Node.constness_for_typeck` no longer returns `hir::Constness::Const` for type aliases in traits. This was previously used to hack how we determine default bound constness for items. But because we now use an explicit opt-in, it is no longer needed.
 - Removed `is_const_impl_raw` query. We have `impl_constness`, and the only existing use of that query uses `HirId`, which means we can just operate it with hir.
 - `ty::Destructor` now has a field `constness`, which represents the constness of the destructor.

r? `@oli-obk`
2021-09-15 03:51:03 +00:00
bors
c3c0f80d60 Auto merge of #73314 - GuillaumeGomez:display-warnings, r=jyn514
Rename "--display-warnings" to "--display-doctest-warnings"

Fixes #41574.

cc `@ollie27`
r? `@kinnison`
2021-09-14 16:05:44 +00:00
Guillaume Gomez
b531a7f585 Add test for --display-doctest-warnings option 2021-09-14 10:49:57 +02:00
Guillaume Gomez
3a8fcff9b6 Rename --display-warnings to --display-doctest-warnings 2021-09-14 10:49:56 +02:00
bors
ec9a1bdc45 Auto merge of #88914 - GuillaumeGomez:rollup-h5svc6w, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #88033 (Add links for primitives in "jump to definition" feature)
 - #88722 (Make `UnsafeCell::get_mut` const)
 - #88851 (Fix duplicate bounds for const_trait_impl)
 - #88859 (interpreter PointerArithmetic: use new Size helper methods)
 - #88885 (Fix jump def background)
 - #88894 (Improve error message for missing trait in trait impl)
 - #88896 (Reduce possibility of flaky tests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-09-14 08:46:22 +00:00
bors
9f85cd6f2a Auto merge of #87794 - bonega:enum_niche_prefer_zero, r=nagisa
Enum should prefer discriminant zero for niche

Given an enum with unassigned zero-discriminant, rust should prefer it for niche selection.
Zero as discriminant for `Option<Enum>` makes it possible for LLVM to optimize resulting asm.

- Eliminate branch when expected value coincides.
- Use smaller instruction `test eax, eax` instead of `cmp eax, ?`
- Possible interaction with zeroed memory?

Example:
```rust

pub enum Size {
    One = 1,
    Two = 2,
    Three = 3,
}

pub fn handle(x: Option<Size>) -> u8 {
    match x {
        None => {0}
        Some(size) => {size as u8}
    }
}
```
In this case discriminant zero is available as a niche.

Above example on nightly:
```asm
 mov     eax, edi
 cmp     al, 4
 jne     .LBB0_2
 xor     eax, eax
.LBB0_2:
 ret
```

PR:
```asm
 mov     eax, edi
 ret
```

I created this PR because I had a performance regression when I tried to use an enum to represent legal grapheme byte-length for utf8.

Using an enum instead of `NonZeroU8` [here](d683304f5d/src/internal/decoder_incomplete.rs (L90))
resulted in a performance regression of about 5%.
I consider this to be a somewhat realistic benchmark.

Thanks to `@ogoffart` for pointing me in the right direction!

Edit: Updated description
2021-09-13 22:14:57 +00:00
Andreas Liljeqvist
4d66fbc4b9 enum niche allocation grows toward zero if possible 2021-09-13 21:55:14 +02:00
Guillaume Gomez
9a3b1cfeb0 Update permissions path for clippy lint 2021-09-13 21:27:53 +02:00
Guillaume Gomez
fb673bfdaa
Rollup merge of #88896 - GuillaumeGomez:flakyness, r=camelid
Reduce possibility of flaky tests

As asked in https://github.com/rust-lang/rust/pull/88885.

r? ``@camelid``
2021-09-13 21:20:43 +02:00
Guillaume Gomez
84d65fee0e
Rollup merge of #88894 - FabianWolff:issue-88818, r=estebank
Improve error message for missing trait in trait impl

Fixes #88818. For the following example:
```rust
struct S { }
impl for S { }
```
the current output is:
```
error: missing trait in a trait impl
 --> t1.rs:2:5
  |
2 | impl for S { }
  |     ^
```
With my changes, I get:
```
error: missing trait in a trait impl
 --> t1.rs:2:5
  |
2 | impl for S { }
  |     ^
  |
help: add a trait here
  |
2 | impl Trait for S { }
  |      +++++
help: for an inherent impl, drop this `for`
  |
2 - impl for S { }
2 + impl S { }
  |
```
2021-09-13 21:20:42 +02:00
Guillaume Gomez
f10fc2152b
Rollup merge of #88885 - GuillaumeGomez:fix-jump-def-background, r=camelid
Fix jump def background

Fixes #88870.

I somehow badly wrote the color in #88111.

r? ``@camelid``
2021-09-13 21:20:41 +02:00
Guillaume Gomez
c0e7f7edea
Rollup merge of #88859 - RalfJung:size-helpers, r=oli-obk
interpreter PointerArithmetic: use new Size helper methods
2021-09-13 21:20:40 +02:00
Guillaume Gomez
a9bc2ef894
Rollup merge of #88851 - fee1-dead:dup-bound, r=oli-obk
Fix duplicate bounds for const_trait_impl

Fixes #88383.

Compare the constness of the candidates before winnowing and removing a `~const` `BoundCandidate`.
2021-09-13 21:20:39 +02:00
Guillaume Gomez
5eb77838ea
Rollup merge of #88722 - WaffleLapkin:unsafe_cell_const_get_mut, r=dtolnay
Make `UnsafeCell::get_mut` const
2021-09-13 21:20:39 +02:00
Guillaume Gomez
b3bb7868f8
Rollup merge of #88033 - GuillaumeGomez:jump-to-def-primitive, r=jyn514
Add links for primitives in "jump to definition" feature

Follow-up of #84176.

I created a function `primitive_from_str` which is code that was originally in `collect_intra_doc_links::resolve_primitive` to prevent code duplication.

I also created the `primitive_link_url` function which is somewhat similar to `primitive_link` but too much different to merge both of them.

r? ``@jyn514``
2021-09-13 21:20:38 +02:00
Guillaume Gomez
7965a9f143 Move fortanix module position in std::os reexports for alpha sort 2021-09-13 21:00:28 +02:00
Guillaume Gomez
1c4873c81f Remove usage of cfg_if in std/src/os/mod.rs 2021-09-13 21:00:28 +02:00
Guillaume Gomez
8d879aa0f2 Simplify std::os module reexports to fix rustdoc linking issues 2021-09-13 21:00:28 +02:00
Guillaume Gomez
9e482c1add * Enable generate-link-to-def feature on a rustdoc GUI test
* Add test for jump-to-def links background color
2021-09-13 20:58:06 +02:00
bors
9bb77da74d Auto merge of #87915 - estebank:fancy-spans, r=oli-obk
Use smaller spans for some structured suggestions

Use more accurate suggestion spans for

* argument parse error
* fully qualified path
* missing code block type
* numeric casts
2021-09-13 16:31:12 +00:00
Guillaume Gomez
d73c0a3d69 Add test for primitive in "jump to definition" feature 2021-09-13 17:44:39 +02:00
Guillaume Gomez
8f3fd3d08c Add support for primitives in "jump to definition" feature 2021-09-13 17:41:43 +02:00
bors
b0ee4951f0 Auto merge of #88766 - ehuss:update-cargo, r=ehuss
Update cargo

6 commits in 18751dd3f238d94d384a7fe967abfac06cbfe0b9..e515c3277bf0681bfc79a9e763861bfe26bb05db
2021-09-01 14:26:00 +0000 to 2021-09-08 14:32:15 +0000
- Remove log output that may leak tokens (rust-lang/cargo#9873)
- rev = "refs/pull/𑑛/head" (rust-lang/cargo#9859)
- Update suggestion message on bad project name error (rust-lang/cargo#9877)
- clarify what goes into "*-sys" crates (rust-lang/cargo#9871)
- Improve error message when unable to initialize git index repo (rust-lang/cargo#9869)
- Use serde_json to generate cargo_vcs_info.json (rust-lang/cargo#9865)
2021-09-13 13:12:34 +00:00
bors
1cd17addad Auto merge of #88745 - hnj2:allow-trait-impl-missing-code, r=GuillaumeGomez
Allow missing code examples in trait impls.

Excludes Trait implementations from the items that need to have doc code examples when using the `rustdoc::missing_doc_code_examples` lint.

For details see #88741

fixes #88741

r? `@jyn514`
2021-09-13 09:41:22 +00:00
bors
61a1029143 Auto merge of #88529 - Meziu:master, r=nagisa
ARMv6K Nintendo 3DS Tier 3 target added

Addition of the target specifications to build .elf files for Nintendo 3DS (ARMv6K, Horizon). Requires devkitARM 3DS toolkit for system libraries and arm-none-eabi-gcc linker.
2021-09-13 05:48:03 +00:00
bors
c6f32f3750 Auto merge of #88517 - smoelius:without-patch-versions, r=flip1995
Update Clippy dependencies without patch versions

Trial run for https://github.com/rust-lang/rust-clippy/pull/7606
2021-09-13 02:45:18 +00:00
bors
96dee2825e Auto merge of #88839 - nbdd0121:alignof, r=nagisa
Introduce NullOp::AlignOf

This PR introduces `Rvalue::NullaryOp(NullOp::AlignOf, ty)`, which will be lowered from `align_of`, similar to `size_of` lowering to `Rvalue::NullaryOp(NullOp::SizeOf, ty)`.

The changes are originally part of #88700 but since it's not dependent on other changes and could have performance impact on its own, it's separated into its own PR.
2021-09-12 23:49:24 +00:00
Gary Guo
cdec87cafa Add mir opt test for min_align_of -> AlignOf lowering 2021-09-13 00:08:35 +01:00
Gary Guo
1c3409f333 Introduce NullOp::AlignOf 2021-09-13 00:08:35 +01:00
bors
51e514c0fb Auto merge of #88759 - Amanieu:panic_in_drop, r=nagisa,eddyb
Add -Z panic-in-drop={unwind,abort} command-line option

This PR changes `Drop` to abort if an unwinding panic attempts to escape it, making the process abort instead. This has several benefits:
- The current behavior when unwinding out of `Drop` is very unintuitive and easy to miss: unwinding continues, but the remaining drops in scope are simply leaked.
- A lot of unsafe code doesn't expect drops to unwind, which can lead to unsoundness:
  - https://github.com/servo/rust-smallvec/issues/14
  - https://github.com/bluss/arrayvec/issues/3
- There is a code size and compilation time cost to this: LLVM needs to generate extra landing pads out of all calls in a drop implementation. This can compound when functions are inlined since unwinding will then continue on to process drops in the callee, which can itself unwind, etc.
  - Initial measurements show a 3% size reduction and up to 10% compilation time reduction on some crates (`syn`).

One thing to note about `-Z panic-in-drop=abort` is that *all* crates must be built with this option for it to be sound since it makes the compiler assume that dropping `Box<dyn Any>` will never unwind.

cc https://github.com/rust-lang/lang-team/issues/97
2021-09-12 20:48:09 +00:00
Guillaume Gomez
cefa900a0f Reduce possibility of flaky tests 2021-09-12 22:44:37 +02:00
Fabian Wolff
3f0e695919 Improve error message for missing trait in trait impl 2021-09-12 22:05:52 +02:00
bors
d2dfb0eb8e Auto merge of #88811 - jackh726:issue-88446, r=nikomatsakis
Use a HashMap for UniverseInfo in mir borrowck

Fixes #88446

r? `@nikomatsakis`
2021-09-12 17:04:10 +00:00
Guillaume Gomez
6a2f500d87 Fix invalid background for jump-to-def links in source code pages 2021-09-12 16:34:47 +02:00
bors
c7dbe7a830 Auto merge of #88881 - Manishearth:rollup-alohfwx, r=Manishearth
Rollup of 7 pull requests

Successful merges:

 - #88336 ( Detect stricter constraints on gats where clauses in impls vs trait)
 - #88677 (rustc: Remove local variable IDs from `Export`s)
 - #88699 (Remove extra unshallow from cherry-pick checker)
 - #88709 (generic_const_exprs: use thir for abstract consts instead of mir)
 - #88711 (Rework DepthFirstSearch API)
 - #88810 (rustdoc: Cleanup `clean` part 1)
 - #88813 (explicitly link to external `ena` docs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-09-12 13:29:56 +00:00
Manish Goregaokar
146aee66b1
Rollup merge of #88813 - lcnr:ena-docs, r=jyn514
explicitly link to external `ena` docs

we currently do not link to the docs of `ena`: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/struct.InferCtxtInner.html#method.const_unification_table
2021-09-12 03:44:59 -07:00
Manish Goregaokar
b3af37ac7b
Rollup merge of #88810 - camelid:cleanup-pt1, r=jyn514
rustdoc: Cleanup `clean` part 1

Split out from #88379.

These commits are completely independent of each other, and each is a fairly
small change (the last few are new commits; they are not from #88379):

- Remove unnecessary `Cache.*_did` fields
- rustdoc: Get symbol for `TyParam` directly
- Create a valid `Res` in `external_path()`
- Remove unused `hir_id` parameter from `resolve_type`
- Fix redundant arguments in `external_path()`
- Remove unnecessary `is_trait` argument
- rustdoc: Cleanup a pattern match in `external_generic_args()`

r? ``@jyn514``
2021-09-12 03:44:58 -07:00
Manish Goregaokar
b87d0d0d94
Rollup merge of #88711 - Mark-Simulacrum:fix-dfs-bug, r=jackh726
Rework DepthFirstSearch API

This expands the API to be more flexible, allowing for more visitation patterns
on graphs. This will be useful to avoid extra datasets (and allocations) in
cases where the expanded DFS API is sufficient.

This also fixes a bug with the previous DFS constructor, which left the start
node not marked as visited (even though it was immediately returned).

Commit written by ```@nikomatsakis``` originally, cherry picked from several commits in work on never type stabilization, but stands alone.
2021-09-12 03:44:57 -07:00
Manish Goregaokar
f5ac5cadd3
Rollup merge of #88709 - BoxyUwU:thir-abstract-const, r=lcnr
generic_const_exprs: use thir for abstract consts instead of mir

Changes `AbstractConst` building to use `thir` instead of `mir` so that there's less chance of consts unifying when they shouldn't because lowering to mir dropped information (see `abstract-consts-as-cast-5.rs` test)

r? `@lcnr`
2021-09-12 03:44:56 -07:00
Manish Goregaokar
a8e3afe372
Rollup merge of #88699 - Mark-Simulacrum:fixes-cherry-picker, r=pietroalbini
Remove extra unshallow from cherry-pick checker

This is already done by 13db8440bb/src/ci/init_repo.sh (L32-L36) on the beta channel, and git throws an error if you attempt to unshallow an already non-shallow repository.

r? ```@pietroalbini```
2021-09-12 03:44:55 -07:00
Manish Goregaokar
bb5ca58d29
Rollup merge of #88677 - petrochenkov:exportid, r=davidtwco
rustc: Remove local variable IDs from `Export`s

Local variables can never be exported.
2021-09-12 03:44:53 -07:00