]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agohermitkernel-target: Set OS to "none"
Martin Kröning [Fri, 29 Oct 2021 16:06:43 +0000 (18:06 +0200)]
hermitkernel-target: Set OS to "none"

For our kernel targets, we should not set OS, as the kernel runs bare
metal without a circular dependency on std.

This also prepares us for unifying with
https://github.com/rust-lang/rust/pull/89062. This patch requires
libhermit-rs to change a `cfg`s from `target_os = "hermit"` to `target_os
= "none"`.

I tested this patch locally.

2 years agoUpdate odht crate to 0.3.1 (big-endian bugfix)
Michael Woerister [Fri, 29 Oct 2021 16:05:15 +0000 (18:05 +0200)]
Update odht crate to 0.3.1 (big-endian bugfix)

2 years agoAuto merge of #90389 - camelid:rustdoc-rayon, r=jyn514
bors [Fri, 29 Oct 2021 15:31:37 +0000 (15:31 +0000)]
Auto merge of #90389 - camelid:rustdoc-rayon, r=jyn514

rustdoc: Switch to mainline rayon

The rustc fork of rayon integrates with Cargo's jobserver to limit the
amount of parallelism. However, rustdoc's use case is concurrent I/O,
which is not CPU-heavy, so it should be able to use mainline rayon.

See [this discussion][1] for more details.

[1]: https://github.com/rust-lang/rust/issues/90227#issuecomment-952468618

Note: I chose rayon 1.3.1 so that the rayon version used elsewhere in
the workspace does not change.

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

2 years agohermit: Implement Condvar::wait_timeout
Martin Kröning [Sat, 29 May 2021 20:16:10 +0000 (22:16 +0200)]
hermit: Implement Condvar::wait_timeout

2 years agoAdd a few query descriptions
Wesley Wiser [Fri, 29 Oct 2021 15:15:45 +0000 (11:15 -0400)]
Add a few query descriptions

2 years agoExplicitly skipping suggestions for 'Pin' as it does not implement the 'AsRef' trait
Yuval Dolev [Fri, 29 Oct 2021 12:43:33 +0000 (15:43 +0300)]
Explicitly skipping suggestions for 'Pin' as it does not implement the 'AsRef' trait

2 years agoSkip suggestions for the AsRef trait
Yuval Dolev [Wed, 27 Oct 2021 21:05:38 +0000 (00:05 +0300)]
Skip suggestions for the AsRef trait

2 years agoFix panic when documenting libproc-macro
Guillaume Gomez [Sat, 23 Oct 2021 21:26:29 +0000 (23:26 +0200)]
Fix panic when documenting libproc-macro

2 years agoDon't display "Methods from Deref<...>" if no method is display (the ones which don...
Guillaume Gomez [Sat, 23 Oct 2021 20:57:02 +0000 (22:57 +0200)]
Don't display "Methods from Deref<...>" if no method is display (the ones which don't have `self` argument)

2 years agoRemove the Rc wrapping of deref_id_map
Guillaume Gomez [Sat, 23 Oct 2021 20:18:33 +0000 (22:18 +0200)]
Remove the Rc wrapping of deref_id_map

2 years agoAdd tests for recursive deref
Guillaume Gomez [Fri, 22 Oct 2021 20:39:33 +0000 (22:39 +0200)]
Add tests for recursive deref

2 years agoAuto merge of #90373 - tmiasko:union-qualification, r=oli-obk
bors [Fri, 29 Oct 2021 12:21:09 +0000 (12:21 +0000)]
Auto merge of #90373 - tmiasko:union-qualification, r=oli-obk

Use type based qualification for unions

Union field access is currently qualified based on the qualification of
a value previously assigned to the union. At the same time, every union
access transmutes the content of the union, which might result in a
different qualification.

For example, consider constants A and B as defined below, under the
current rules neither contains interior mutability, since a value used
in the initial assignment did not contain `UnsafeCell` constructor.

```rust
#![feature(untagged_unions)]

union U { i: u32, c: std::cell::Cell<u32> }
const A: U = U { i: 0 };
const B: std::cell::Cell<u32> = unsafe { U { i: 0 }.c };
```

To avoid the issue, the changes here propose to consider the content of
a union as opaque and use type based qualification for union types.

Fixes #90268.

`@rust-lang/wg-const-eval`

2 years agoRecursively document Deref
Guillaume Gomez [Fri, 22 Oct 2021 19:45:06 +0000 (21:45 +0200)]
Recursively document Deref

2 years agoignore type flags insertion in default_anon_const_substs if error occurred
b-naber [Fri, 29 Oct 2021 11:14:44 +0000 (13:14 +0200)]
ignore type flags insertion in default_anon_const_substs if error occurred

2 years agoadd test
b-naber [Fri, 29 Oct 2021 10:38:28 +0000 (12:38 +0200)]
add test

2 years agodon't mutably borrow inner infcx in all of ConstInferUnifier::consts
b-naber [Fri, 29 Oct 2021 10:32:06 +0000 (12:32 +0200)]
don't mutably borrow inner infcx in all of ConstInferUnifier::consts

2 years agoAuto merge of #90214 - tmiasko:indirect-mutation-qualif, r=ecstatic-morse,oli-obk
bors [Fri, 29 Oct 2021 08:38:39 +0000 (08:38 +0000)]
Auto merge of #90214 - tmiasko:indirect-mutation-qualif, r=ecstatic-morse,oli-obk

Consider indirect mutation during const qualification dataflow

Previously a local would be qualified if either one of two separate data
flow computations indicated so. First determined if a local could
contain the qualif, but ignored any forms of indirect mutation. Second
determined if a local could be mutably borrowed (and so indirectly
mutated), but which in turn ignored the qualif.

The end result was incorrect because the effect of indirect mutation was
effectivelly ignored in the all but the final stage of computation.

In the new implementation the indirect mutation is directly incorporated
into the qualif data flow. The local variable becomes immediately
qualified once it is mutably borrowed and borrowed place type can
contain the qualif.

In general we will now reject additional programs, program that were
prevously unintentionally accepted.

There are also some cases which are now accepted but were previously
rejected, because previous implementation didn't consider whether
borrowed place could have the qualif under the consideration.

Fixes #90124.

r? `@ecstatic-morse`

2 years agoAuto merge of #90380 - Mark-Simulacrum:revert-89558-query-stable-lint, r=lcnr
bors [Fri, 29 Oct 2021 04:55:51 +0000 (04:55 +0000)]
Auto merge of #90380 - Mark-Simulacrum:revert-89558-query-stable-lint, r=lcnr

Revert "Add rustc lint, warning when iterating over hashmaps"

Fixes perf regressions introduced in https://github.com/rust-lang/rust/pull/90235 by temporarily reverting the relevant PR.

2 years agoAuto merge of #90363 - camelid:build-impl-perf, r=jyn514
bors [Fri, 29 Oct 2021 01:50:08 +0000 (01:50 +0000)]
Auto merge of #90363 - camelid:build-impl-perf, r=jyn514

Improve perf measurements of `build_extern_trait_impl`

Before, it was only measuring one callsite of `build_impl`, and it
incremented the call count even if `build_impl` returned early because
the `did` was already inlined.

Now, it measures all calls, minus calls that return early.

2 years agorustdoc: Remove a single-use macro
Noah Lev [Fri, 29 Oct 2021 01:39:32 +0000 (18:39 -0700)]
rustdoc: Remove a single-use macro

I think the new code is simpler and easier to understand.

2 years agoUpdate miri
Brennan Vincent [Fri, 29 Oct 2021 01:38:43 +0000 (21:38 -0400)]
Update miri

2 years agorustdoc: Switch to mainline rayon
Noah Lev [Fri, 29 Oct 2021 01:19:01 +0000 (18:19 -0700)]
rustdoc: Switch to mainline rayon

The rustc fork of rayon integrates with Cargo's jobserver to limit the
amount of parallelism. However, rustdoc's use case is concurrent I/O,
which is not CPU-heavy, so it should be able to use mainline rayon.

See this discussion [1] for more details.

[1]: https://github.com/rust-lang/rust/issues/90227#issuecomment-952468618

Note: I chose rayon 1.3.1 so that the rayon version used elsewhere in
the workspace does not change.

2 years agoAuto merge of #90387 - matthiaskrgr:rollup-b2x8v0x, r=matthiaskrgr
bors [Thu, 28 Oct 2021 22:44:45 +0000 (22:44 +0000)]
Auto merge of #90387 - matthiaskrgr:rollup-b2x8v0x, r=matthiaskrgr

Rollup of 3 pull requests

Successful merges:

 - #90082 (Fix minor typos)
 - #90336 (Remove extra lines in examples for `Duration::try_from_secs_*`)
 - #90376 (Various cleanups around opaque types)

Failed merges:

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

2 years agoRollup merge of #90376 - oli-obk:🧹, r=spastorino
Matthias Krüger [Thu, 28 Oct 2021 22:30:31 +0000 (00:30 +0200)]
Rollup merge of #90376 - oli-obk:🧹, r=spastorino

Various cleanups around opaque types

Best reviewed commit by commit.

This PR has no functional changes.

Mostly it's moving logic from an extension trait in rustc_trait_selection to inherent impls on rustc_infer.

2 years agoRollup merge of #90336 - mbartlett21:patch-4, r=Mark-Simulacrum
Matthias Krüger [Thu, 28 Oct 2021 22:30:30 +0000 (00:30 +0200)]
Rollup merge of #90336 - mbartlett21:patch-4, r=Mark-Simulacrum

Remove extra lines in examples for `Duration::try_from_secs_*`

None of the other examples have extra lines below the `#![feature(...)]` statements, so I thought it appropriate that these examples shouldn't either.

2 years agoRollup merge of #90082 - noncombatant:patch-1, r=GuillaumeGomez
Matthias Krüger [Thu, 28 Oct 2021 22:30:30 +0000 (00:30 +0200)]
Rollup merge of #90082 - noncombatant:patch-1, r=GuillaumeGomez

Fix minor typos

2 years agoAdd -Zunstable-options instead of feature
Mateusz Mikuła [Thu, 28 Oct 2021 21:38:21 +0000 (23:38 +0200)]
Add -Zunstable-options instead of feature

2 years agoAdd comments to hygiene tests
Matthew Jasper [Thu, 28 Oct 2021 20:48:39 +0000 (21:48 +0100)]
Add comments to hygiene tests

2 years agoRemove `ModData` from rustc_metadata
Matthew Jasper [Thu, 28 Oct 2021 20:48:21 +0000 (21:48 +0100)]
Remove `ModData` from rustc_metadata

This avoids having to decode 2 `Lazy`s when decoding a modules exports.

2 years agoAuto merge of #90281 - xldenis:public-borrow-set, r=nikomatsakis
bors [Thu, 28 Oct 2021 19:34:01 +0000 (19:34 +0000)]
Auto merge of #90281 - xldenis:public-borrow-set, r=nikomatsakis

Add BorrowSet to public api

This PR adds `BorrowSet` to the public api so that verification tools can obtain the activation and reservation points of two phase borrows without having to redo calculations themselves (and thus potentially differently from rustc).

Turns out we already can obtain `MoveData` thanks to the public `HasMoveData` trait, so constructing a `BorrowSet` should not provide much of an issue. However, I can't speak to the soundness of this approach, is it safe to take an under-approximation of `MoveData`?

r? `@nikomatsakis`

2 years agoAuto merge of #90218 - JakobDegen:adt_significant_drop_fix, r=nikomatsakis
bors [Thu, 28 Oct 2021 16:03:13 +0000 (16:03 +0000)]
Auto merge of #90218 - JakobDegen:adt_significant_drop_fix, r=nikomatsakis

Fixes incorrect handling of ADT's drop requirements

Fixes #90024 and a bunch of duplicates.

The main issue was just that the contract of `NeedsDropTypes::adt_components` was inconsistent; the list of types it might return were the generic parameters themselves or the fields of the ADT, depending on the nature of the drop impl. This meant that the caller could not determine whether a `.subst()` call was still needed on those types; it called `.subst()` in all cases, and this led to ICEs when the returned types were the generic params.

First contribution of more than a few lines, so feedback definitely appreciated.

2 years agoRevert "Add rustc lint, warning when iterating over hashmaps"
Mark Rousskov [Thu, 28 Oct 2021 15:01:42 +0000 (11:01 -0400)]
Revert "Add rustc lint, warning when iterating over hashmaps"

2 years agoAdd test cases
Ilya Yanok [Thu, 28 Oct 2021 14:25:46 +0000 (14:25 +0000)]
Add test cases

2 years agoMake `core::slice::from_raw_parts[_mut]` const
Maybe Waffle [Thu, 28 Oct 2021 14:15:25 +0000 (17:15 +0300)]
Make `core::slice::from_raw_parts[_mut]` const

2 years agoMove instantiate_opaque_types to rustc_infer.
Oli Scherer [Thu, 28 Oct 2021 14:12:24 +0000 (14:12 +0000)]
Move instantiate_opaque_types to rustc_infer.

It does not depend on anything from rustc_trait_selection anymore.

2 years agoMove some functions into `rustc_infer`.
Oli Scherer [Thu, 28 Oct 2021 13:54:11 +0000 (13:54 +0000)]
Move some functions into `rustc_infer`.
They don't depend on trait selection anymore, so there is no need for an extension trait.

2 years agoManually inline a function that is only ever called at the end of another function
Oli Scherer [Thu, 28 Oct 2021 13:42:16 +0000 (13:42 +0000)]
Manually inline a function that is only ever called at the end of another function

2 years agoRemove dead code.
Oli Scherer [Thu, 28 Oct 2021 13:38:41 +0000 (13:38 +0000)]
Remove dead code.

We don't do member constraint checks in regionck anymore.
All member constraint checks are done in mir borrowck.

2 years agoReformat the changed line to make tidy happy
Ilya Yanok [Thu, 28 Oct 2021 13:23:49 +0000 (13:23 +0000)]
Reformat the changed line to make tidy happy

2 years agoAuto merge of #90145 - cjgillot:sorted-map, r=michaelwoerister
bors [Thu, 28 Oct 2021 13:04:40 +0000 (13:04 +0000)]
Auto merge of #90145 - cjgillot:sorted-map, r=michaelwoerister

Use SortedMap in HIR.

Closes https://github.com/rust-lang/rust/issues/89788
r? `@ghost`

2 years agoUse `is_global` in `candidate_should_be_dropped_in_favor_of`
Ilya Yanok [Thu, 28 Oct 2021 12:49:46 +0000 (12:49 +0000)]
Use `is_global` in `candidate_should_be_dropped_in_favor_of`

This manifistated in #90195 with compiler being unable to keep
one candidate for a trait impl, if where is a global impl and more
than one trait bound in the where clause.

Before #87280 `candidate_should_be_dropped_in_favor_of` was using
`TypeFoldable::is_global()` that was enough to discard the two
`ParamCandidate`s. But #87280 changed it to use
`TypeFoldable::is_known_global()` instead, which is pessimistic, so
now the compiler drops the global impl instead (because
`is_known_global` is not sure) and then can't decide between the
two `ParamCandidate`s.

Switching it to use `is_global` again solves the issue.

Fixes #90195.

2 years agoFix incorrect doc link
Lukas Wirth [Thu, 28 Oct 2021 09:51:00 +0000 (11:51 +0200)]
Fix incorrect doc link

2 years agoAuto merge of #90339 - GuillaumeGomez:doc-alias-doc, r=GuillaumeGomez
bors [Thu, 28 Oct 2021 09:50:16 +0000 (09:50 +0000)]
Auto merge of #90339 - GuillaumeGomez:doc-alias-doc, r=GuillaumeGomez

Add missing documentation for doc alias

2 years agoAdd missing documentation for doc alias
Guillaume Gomez [Wed, 27 Oct 2021 09:11:15 +0000 (11:11 +0200)]
Add missing documentation for doc alias

2 years agoImprove perf measurements of `build_extern_trait_impl`
Noah Lev [Thu, 28 Oct 2021 03:06:48 +0000 (20:06 -0700)]
Improve perf measurements of `build_extern_trait_impl`

Before, it was only measuring one callsite of `build_impl`, and it
incremented the call count even if `build_impl` returned early because
the `did` was already inlined.

Now, it measures all calls, minus calls that return early.

2 years agoUse type based qualification for unions
Tomasz Miąsko [Thu, 28 Oct 2021 00:00:00 +0000 (00:00 +0000)]
Use type based qualification for unions

Union field access is currently qualified based on the qualification of
a value previously assigned to the union. At the same time, every union
access transmutes the content of the union, which might result in a
different qualification.

For example, consider constants A and B as defined below, under the
current rules neither contains interior mutability, since a value used
in the initial assignment did not contain `UnsafeCell` constructor.

```rust
#![feature(untagged_unions)]

union U { i: u32, c: std::cell::Cell<u32> }
const A: U = U { i: 0 };
const B: std::cell::Cell<u32> = unsafe { U { i: 0 }.c };
```

To avoid the issue, the changes here propose to consider the content of
a union as opaque and use type based qualification for union types.

2 years agoAuto merge of #90347 - matthiaskrgr:rollup-rp2ms7j, r=matthiaskrgr
bors [Wed, 27 Oct 2021 18:42:13 +0000 (18:42 +0000)]
Auto merge of #90347 - matthiaskrgr:rollup-rp2ms7j, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #90239 (Consistent big O notation in map.rs)
 - #90267 (fix: inner attribute followed by outer attribute causing ICE)
 - #90288 (Add hint for people missing `TryFrom`, `TryInto`, `FromIterator` import pre-2021)
 - #90304 (Add regression test for #75961)
 - #90344 (Add tracking issue number to const_cstr_unchecked)

Failed merges:

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

2 years agoRollup merge of #90344 - xfix:tracking-issue-const_cstr_unchecked, r=Mark-Simulacrum
Matthias Krüger [Wed, 27 Oct 2021 16:25:47 +0000 (18:25 +0200)]
Rollup merge of #90344 - xfix:tracking-issue-const_cstr_unchecked, r=Mark-Simulacrum

Add tracking issue number to const_cstr_unchecked

Also created a tracking issue, see #90343.

I think it makes sense to stabilize this somewhat soon considering abuse of `transmute` to have this feature in constants, see https://crates.io/crates/cstr for an example. Code can be rewritten to use `mem::transmute` to work on stable.

2 years agoRollup merge of #90304 - vandenheuvel:test_issue_75961, r=Mark-Simulacrum
Matthias Krüger [Wed, 27 Oct 2021 16:25:46 +0000 (18:25 +0200)]
Rollup merge of #90304 - vandenheuvel:test_issue_75961, r=Mark-Simulacrum

Add regression test for #75961

Closes #75961.
Closes #21203.

2 years agoRollup merge of #90288 - JakobDegen:import_diagnostics, r=davidtwco
Matthias Krüger [Wed, 27 Oct 2021 16:25:46 +0000 (18:25 +0200)]
Rollup merge of #90288 - JakobDegen:import_diagnostics, r=davidtwco

Add hint for people missing `TryFrom`, `TryInto`, `FromIterator` import pre-2021

Adds a hint anytime a `TryFrom`, `TryInto`, `FromIterator` import is suggested noting that these traits are automatically imported in Edition 2021.

2 years agoRollup merge of #90267 - EliseZeroTwo:elisezerotwo/fix_invalid_attrs_ice, r=Aaron1011
Matthias Krüger [Wed, 27 Oct 2021 16:25:44 +0000 (18:25 +0200)]
Rollup merge of #90267 - EliseZeroTwo:elisezerotwo/fix_invalid_attrs_ice, r=Aaron1011

fix: inner attribute followed by outer attribute causing ICE

Fixes #87936, #88938, and #89971.

This removes the assertion that validates that there are no outer attributes following inner attributes. Where the inner attribute is invalid you get an actual error.

2 years agoRollup merge of #90239 - r00ster91:patch-1, r=fee1-dead
Matthias Krüger [Wed, 27 Oct 2021 16:25:43 +0000 (18:25 +0200)]
Rollup merge of #90239 - r00ster91:patch-1, r=fee1-dead

Consistent big O notation in map.rs

Follow up to #89216

2 years agoRemove big O notation
r00ster91 [Wed, 27 Oct 2021 15:43:14 +0000 (17:43 +0200)]
Remove big O notation

2 years agoAuto merge of #90273 - nbdd0121:const, r=fee1-dead
bors [Wed, 27 Oct 2021 15:32:42 +0000 (15:32 +0000)]
Auto merge of #90273 - nbdd0121:const, r=fee1-dead

Clean up special function const checks

Mark them as const and `#[rustc_do_not_const_check]` instead of hard-coding them in const-eval checks.

r? `@oli-obk`
`@rustbot` label A-const-eval T-compiler

2 years agoreplace `&` with `&&` in {integer}::checked_rem
Pietro Albini [Wed, 27 Oct 2021 13:45:31 +0000 (15:45 +0200)]
replace `&` with `&&` in {integer}::checked_rem

Using short-circuit operators makes it easier to perform some kinds of
source code analysis, like MC/DC code coverage (a requirement in
safety-critical environments). The optimized x86 assembly is the same
between the old and new versions:

```
xor eax, eax
test esi, esi
je .LBB0_1
cmp edi, -2147483648
jne .LBB0_4
cmp esi, -1
jne .LBB0_4
ret
.LBB0_1:
ret
.LBB0_4:
mov eax, edi
cdq
idiv esi
mov eax, 1
ret
```

2 years agoreplace `&` with `&&` in {integer}::checked_div
Pietro Albini [Wed, 27 Oct 2021 13:25:00 +0000 (15:25 +0200)]
replace `&` with `&&` in {integer}::checked_div

Using short-circuit operators makes it easier to perform some kinds of
source code analysis, like MC/DC code coverage (a requirement in
safety-critical environments). The optimized x86 assembly is the same
between the old and new versions:

```
xor eax, eax
test esi, esi
je .LBB0_1
cmp edi, -2147483648
jne .LBB0_4
cmp esi, -1
jne .LBB0_4
ret
.LBB0_1:
ret
.LBB0_4:
mov eax, edi
cdq
idiv esi
mov edx, eax
mov eax, 1
ret
```

2 years agoreplace `|` with `||` in string validation
Pietro Albini [Wed, 27 Oct 2021 11:03:55 +0000 (13:03 +0200)]
replace `|` with `||` in string validation

Using short-circuiting operators makes it easier to perform some kinds
of source code analysis, like MC/DC code coverage (a requirement in
safety-critical environments). The optimized x86_64 assembly is
equivalent between the old and new versions.

Old assembly of that condition:

```
mov  rax, qword ptr [rdi + rdx + 8]
or   rax, qword ptr [rdi + rdx]
test rax, r9
je   .LBB0_7
```

New assembly of that condition:

```
mov  rax, qword ptr [rdi + rdx]
or   rax, qword ptr [rdi + rdx + 8]
test rax, r8
je   .LBB0_7
```

2 years agoreplace `|` with `||` in {unsigned_int}::borrowing_sub
Pietro Albini [Wed, 27 Oct 2021 14:56:57 +0000 (16:56 +0200)]
replace `|` with `||` in {unsigned_int}::borrowing_sub

Using short-circuiting operators makes it easier to perform some kinds
of source code analysis, like MC/DC code coverage (a requirement in
safety-critical environments). The optimized x86_64 assembly is the same
between the old and new versions:

```
mov eax, edi
add dl, -1
sbb eax, esi
setb dl
ret
```

2 years agoreplace `|` with `||` in {unsigned_int}::carrying_add
Pietro Albini [Wed, 27 Oct 2021 11:00:42 +0000 (13:00 +0200)]
replace `|` with `||` in {unsigned_int}::carrying_add

Using short-circuiting operators makes it easier to perform some kinds
of source code analysis, like MC/DC code coverage (a requirement in
safety-critical environments). The optimized x86_64 assembly is the same
between the old and new versions:

```
mov eax, edi
add dl, -1
adc eax, esi
setb dl
ret
```

2 years agoAdd tracking issue number to const_cstr_unchecked
Konrad Borowski [Wed, 27 Oct 2021 13:18:25 +0000 (15:18 +0200)]
Add tracking issue number to const_cstr_unchecked

2 years agoAuto merge of #90186 - jsha:fix-header-sizes, r=GuillaumeGomez
bors [Wed, 27 Oct 2021 12:27:47 +0000 (12:27 +0000)]
Auto merge of #90186 - jsha:fix-header-sizes, r=GuillaumeGomez

Fix documentation header sizes

And add a rustdoc-gui test confirming various header sizes.

Split off from #90156. This fixes a regression in #89506 where the heading level of titles within Markdown was too high (h2) for docblocks under structs, unions, and enum impls.

r? `@camelid`

Demo: https://jacob.hoffman-andrews.com/rust/fix-header-sizes/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E
Stable: https://doc.rust-lang.org/stable/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E
Beta: https://doc.rust-lang.org/beta/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E

2 years agoAuto merge of #89652 - rcvalle:rust-cfi, r=nagisa
bors [Wed, 27 Oct 2021 09:19:42 +0000 (09:19 +0000)]
Auto merge of #89652 - rcvalle:rust-cfi, r=nagisa

Add LLVM CFI support to the Rust compiler

This PR adds LLVM Control Flow Integrity (CFI) support to the Rust compiler. It initially provides forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their number of arguments.

Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by defining and using compatible type identifiers (see Type metadata in the design document in the tracking issue #89653).

LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto).

Thank you, `@eddyb` and `@pcc,` for all the help!

2 years agotest: add test for inner attribute followed by outer attribute causing ICE
EliseZeroTwo [Tue, 26 Oct 2021 09:45:15 +0000 (11:45 +0200)]
test: add test for inner attribute followed by outer attribute causing ICE

2 years agoAdd documentation for LLVM CFI support
Ramon de C Valle [Thu, 14 Oct 2021 19:24:53 +0000 (12:24 -0700)]
Add documentation for LLVM CFI support

This commit adds initial documentation for LLVM Control Flow Integrity
(CFI) support to the Rust compiler (see #89652 and #89653).

2 years agoRemove `is_const_fn` in `find_mir_or_eval_fn`
Gary Guo [Wed, 27 Oct 2021 06:21:17 +0000 (07:21 +0100)]
Remove `is_const_fn` in `find_mir_or_eval_fn`

2 years agoAuto merge of #90337 - matthiaskrgr:rollup-azkr158, r=matthiaskrgr
bors [Wed, 27 Oct 2021 06:16:47 +0000 (06:16 +0000)]
Auto merge of #90337 - matthiaskrgr:rollup-azkr158, r=matthiaskrgr

Rollup of 3 pull requests

Successful merges:

 - #90154 (rustdoc: Remove `GetDefId`)
 - #90232 (rustdoc: Use TTF based font instead of OTF for CJK glyphs to improve readability)
 - #90278 (rustdoc: use better highlighting for *const, *mut, and &mut)

Failed merges:

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

2 years agoAdd regression test for #75961
Bram van den Heuvel [Tue, 26 Oct 2021 10:33:49 +0000 (12:33 +0200)]
Add regression test for #75961

2 years agoRollup merge of #90278 - notriddle:notriddle/highlight-ptr, r=jyn541,GuillaumeGomez
Matthias Krüger [Wed, 27 Oct 2021 04:11:38 +0000 (06:11 +0200)]
Rollup merge of #90278 - notriddle:notriddle/highlight-ptr, r=jyn541,GuillaumeGomez

rustdoc: use better highlighting for *const, *mut, and &mut

This generates more consistent HTML for these RefKeyWord combinations.

Before:

![image](https://user-images.githubusercontent.com/1593513/138742752-7e00a3f7-4621-4c62-82d1-3e4c2ef503d1.png)

After:

![image](https://user-images.githubusercontent.com/1593513/138743955-90abcdcd-fc88-4e2f-95bb-c1b1635c0001.png)

2 years agoRollup merge of #90232 - konan8205:master, r=GuillaumeGomez
Matthias Krüger [Wed, 27 Oct 2021 04:11:36 +0000 (06:11 +0200)]
Rollup merge of #90232 - konan8205:master, r=GuillaumeGomez

rustdoc: Use TTF based font instead of OTF for CJK glyphs to improve readability

Due to Windows' implementation of font rendering, OpenType fonts can be distorted. So the existing font, Noto Sans KR, is not very readable on Windows. This PR improves readability of Korean glyphs on Windows.

## Before
![원1](https://user-images.githubusercontent.com/11029378/138592394-16b15787-532d-4421-a5eb-ed85675290fa.png)

## After
![원2](https://user-images.githubusercontent.com/11029378/138592409-f3a440ee-f0fc-40e4-9561-42c479439c9f.png)

The fonts included in this PR are licensed under the SIL Open Font License and generated with these commands:

```sh
pyftsubset NanumBarunGothic.ttf \
--unicodes=U+AC00-D7AF,U+1100-11FF,U+3130-318F,U+A960-A97F,U+D7B0-D7FF \
--output-file=NanumBarunGothic.ttf.woff --flavor=woff
```
```sh
pyftsubset NanumBarunGothic.ttf \
--unicodes=U+AC00-D7AF,U+1100-11FF,U+3130-318F,U+A960-A97F,U+D7B0-D7FF \
--output-file=NanumBarunGothic.ttf.woff2 --flavor=woff2
```

r? ``@GuillaumeGomez``

2 years agoRollup merge of #90154 - camelid:remove-getdefid, r=jyn514
Matthias Krüger [Wed, 27 Oct 2021 04:11:35 +0000 (06:11 +0200)]
Rollup merge of #90154 - camelid:remove-getdefid, r=jyn514

rustdoc: Remove `GetDefId`

See the individual commit messages for details.

r? `@jyn514`

2 years agoRemove extra lines in examples for `Duration::try_from_secs_*`
mbartlett21 [Wed, 27 Oct 2021 03:52:39 +0000 (13:52 +1000)]
Remove extra lines in examples for `Duration::try_from_secs_*`

2 years agoAuto merge of #89937 - JohnTitor:fix-89875, r=Amanieu
bors [Wed, 27 Oct 2021 03:08:47 +0000 (03:08 +0000)]
Auto merge of #89937 - JohnTitor:fix-89875, r=Amanieu

Properly check `target_features` not to trigger an assertion

Fixes #89875
I think it should be a condition instead of an assertion to check if it's a register as it's possible that `reg` is a register class.
Also, this isn't related to the issue directly, but `is_target_supported` doesn't check `target_features` attributes. Is there any way to check it on rustc_codegen_llvm?

r? `@Amanieu`

2 years agoReverting switching test to no_std and adjust output after rebase.
Jakob Degen [Wed, 27 Oct 2021 01:18:04 +0000 (21:18 -0400)]
Reverting switching test to no_std and adjust output after rebase.

2 years agoFix line numbers in test
Jakob Degen [Tue, 26 Oct 2021 03:14:48 +0000 (23:14 -0400)]
Fix line numbers in test

2 years agoMake `ui/suggestions/suggest-tryinto-edition-change.rs` no_std to avoid getting incon...
Jakob Degen [Tue, 26 Oct 2021 02:56:18 +0000 (22:56 -0400)]
Make `ui/suggestions/suggest-tryinto-edition-change.rs` no_std to avoid getting inconsistent output between local and CI.

2 years agoAdds hint if a trait fails to resolve and a newly added one in Edition 2021 is suggested
Jakob Degen [Tue, 26 Oct 2021 00:04:35 +0000 (20:04 -0400)]
Adds hint if a trait fails to resolve and a newly added one in Edition 2021 is suggested

2 years agoAdd test checking that Edition 2021 is suggested for .try_into() and fix other test
Jakob Degen [Mon, 25 Oct 2021 01:09:52 +0000 (21:09 -0400)]
Add test checking that Edition 2021 is suggested for .try_into() and fix other test

2 years agoAdd diagnostic in case of failed `.try_into()` method call pre-Edition 2021
Jakob Degen [Sat, 23 Oct 2021 03:21:46 +0000 (23:21 -0400)]
Add diagnostic in case of failed `.try_into()` method call pre-Edition 2021

2 years agoAuto merge of #90314 - matthiaskrgr:rollup-ag1js8n, r=matthiaskrgr
bors [Tue, 26 Oct 2021 17:50:46 +0000 (17:50 +0000)]
Auto merge of #90314 - matthiaskrgr:rollup-ag1js8n, r=matthiaskrgr

Rollup of 4 pull requests

Successful merges:

 - #90296 (Remove fNN::lerp)
 - #90302 (Remove unneeded into_iter)
 - #90303 (Add regression test for issue 90164)
 - #90305 (Add regression test for #87258)

Failed merges:

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

2 years agoRollup merge of #90305 - vandenheuvel:test_issue_87258, r=Mark-Simulacrum
Matthias Krüger [Tue, 26 Oct 2021 17:32:46 +0000 (19:32 +0200)]
Rollup merge of #90305 - vandenheuvel:test_issue_87258, r=Mark-Simulacrum

Add regression test for #87258

Closes #87258.

2 years agoRollup merge of #90303 - WaffleLapkin:regression_test_90164, r=JohnTitor
Matthias Krüger [Tue, 26 Oct 2021 17:32:45 +0000 (19:32 +0200)]
Rollup merge of #90303 - WaffleLapkin:regression_test_90164, r=JohnTitor

Add regression test for issue 90164

Closes #90164 (previously fixed by #90181)

2 years agoRollup merge of #90302 - GuillaumeGomez:rm-unneeded-into_iter, r=jyn514
Matthias Krüger [Tue, 26 Oct 2021 17:32:44 +0000 (19:32 +0200)]
Rollup merge of #90302 - GuillaumeGomez:rm-unneeded-into_iter, r=jyn514

Remove unneeded into_iter

As ``@camelid`` mentionned [here](https://github.com/rust-lang/rust/pull/89430#discussion_r735889324), the `into_iter` was unneeded.

r? ``@camelid``

2 years agoRollup merge of #90296 - CAD97:rip-lerp, r=Mark-Simulacrum
Matthias Krüger [Tue, 26 Oct 2021 17:32:44 +0000 (19:32 +0200)]
Rollup merge of #90296 - CAD97:rip-lerp, r=Mark-Simulacrum

Remove fNN::lerp

Lerp is [surprisingly complex with multiple tradeoffs depending on what guarantees you want to provide](https://github.com/rust-lang/rust/issues/86269#issuecomment-869108301) (and what you're willing to drop for raw speed), so we don't have consensus on what implementation to use, let alone what signature - `t.lerp(a, b)` nicely puts `a, b` together, but makes dispatch to lerp custom types with the same signature basically impossible, and major ecosystem crates (e.g. nalgebra, glium) use `a.lerp(b, t)`, which is easily confusable. It was suggested to maybe provide a `Lerp<T>` trait and `t.lerp([a, b])`, which _could_ be implemented by downstream math libraries for their types, but also significantly raises the bar from a simple fNN method to a full trait, and does nothing to solve the implementation question. (It also raises the question of whether we'd support higher-order bezier interpolation.)

The only consensus we have is the lack of consensus, and the [general temperature](https://github.com/rust-lang/rust/issues/86269#issuecomment-951347135) is that we should just remove this method (giving the method space back to 3rd party libs) and revisit this if (and likely only if) IEEE adds lerp to their specification.

If people want a lerp, they're _probably_ already using (or writing) a math support library, which provides a lerp function for its custom math types and can provide the same lerp implementation for the primitive types via an extension trait.

See also [previous Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/lerp.20API.20design)

cc ``@clarfonthey`` (original PR author), ``@m-ou-se`` (original r+), ``@scottmcm`` (last voice in tracking issue, prompted me to post this)

Closes #86269 (removed)

2 years agoAuto merge of #90290 - nyanpasu64:fix-string-as-mut-vec, r=m-ou-se
bors [Tue, 26 Oct 2021 14:44:47 +0000 (14:44 +0000)]
Auto merge of #90290 - nyanpasu64:fix-string-as-mut-vec, r=m-ou-se

Fix copy-paste error in String::as_mut_vec() docs

Did not expect the comments to be perfectly justified... can't wait to be told to change it to `Vec<u8>`, which destroys the justification 😼

2 years agoAdd regression test for #87258
Bram van den Heuvel [Tue, 26 Oct 2021 10:48:22 +0000 (12:48 +0200)]
Add regression test for #87258

2 years agotrack_caller for slice length assertions
Kornel [Tue, 26 Oct 2021 12:03:02 +0000 (13:03 +0100)]
track_caller for slice length assertions

2 years agoAuto merge of #90284 - tonyyzy:patch-1, r=JohnTitor
bors [Tue, 26 Oct 2021 11:45:13 +0000 (11:45 +0000)]
Auto merge of #90284 - tonyyzy:patch-1, r=JohnTitor

Remove redundant Aligner

The `Aligner` struct seems to be unnecessary.
Previously noted by `@arthurprs` https://github.com/rust-lang/rust/pull/44963#discussion_r145340754
Reddit discussion: https://www.reddit.com/r/rust/comments/pfvvz2/aligner_and_cachealigned/
Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=fa7ca554922755f9d1b62b017d785c6f

2 years agoRemove redundant Aligner
Tony Yang [Tue, 26 Oct 2021 10:34:03 +0000 (11:34 +0100)]
Remove redundant Aligner

The `Aligner` struct seems to be unnecessary.
Previously noted by @arthurprs https://github.com/rust-lang/rust/pull/44963#discussion_r145340754
Reddit discussion: https://www.reddit.com/r/rust/comments/pfvvz2/aligner_and_cachealigned/
Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=fa7ca554922755f9d1b62b017d785c6f

2 years agoAdd regression test for issue 90164
Maybe Waffle [Tue, 26 Oct 2021 10:23:27 +0000 (13:23 +0300)]
Add regression test for issue 90164

2 years agoRemove unneeded into_iter
Guillaume Gomez [Tue, 26 Oct 2021 09:50:52 +0000 (11:50 +0200)]
Remove unneeded into_iter

2 years agoAuto merge of #90075 - pierwill:fix-79717, r=petrochenkov
bors [Tue, 26 Oct 2021 07:57:51 +0000 (07:57 +0000)]
Auto merge of #90075 - pierwill:fix-79717, r=petrochenkov

Edit error messages for `rustc_resolve::AmbiguityKind` variants

Edit the language of the ambiguity descriptions for E0659. These strings now appear as notes.

Closes #79717.

2 years agoFix copy-paste error in String::as_mut_vec() docs
nyanpasu64 [Tue, 26 Oct 2021 01:42:22 +0000 (18:42 -0700)]
Fix copy-paste error in String::as_mut_vec() docs

2 years agoConsider indirect mutation during const qualification dataflow
Tomasz Miąsko [Sat, 23 Oct 2021 00:00:00 +0000 (00:00 +0000)]
Consider indirect mutation during const qualification dataflow

Previously a local would be qualified if either one of two separate data
flow computations indicated so. First determined if a local could
contain the qualif, but ignored any forms of indirect mutation. Second
determined if a local could be mutably borrowed (and so indirectly
mutated), but which in turn ignored the qualif.

The end result was incorrect because the effect of indirect mutation was
effectivelly ignored in the all but the final stage of computation.

In the new implementation the indirect mutation is directly incorporated
into the qualif data flow. The local variable becomes immediately
qualified once it is mutably borrowed and borrowed place type can
contain the qualif.

In general we will now reject additional programs, program that were
prevously unintentionally accepted.

There are also some cases which are now accepted but were previously
rejected, because previous implementation didn't consider whether
borrowed place could have the qualif under the consideration.

2 years agoAuto merge of #90299 - matthiaskrgr:rollup-n77ntld, r=matthiaskrgr
bors [Tue, 26 Oct 2021 04:44:51 +0000 (04:44 +0000)]
Auto merge of #90299 - matthiaskrgr:rollup-n77ntld, r=matthiaskrgr

Rollup of 4 pull requests

Successful merges:

 - #90181 (fix(rustc_typeck): report function argument errors on matching type)
 - #90241 (Make thiscall abi on unsupported platforms a hard error)
 - #90294 (Update books)
 - #90295 (Update cargo)

Failed merges:

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

2 years agoRollup merge of #90295 - ehuss:update-cargo, r=ehuss
Matthias Krüger [Tue, 26 Oct 2021 04:14:09 +0000 (06:14 +0200)]
Rollup merge of #90295 - ehuss:update-cargo, r=ehuss

Update cargo

4 commits in 7fbbf4e8f23e3c24b8afff541dcb17e53eb5ff88..6c1bc24b8b49d4bc965f67d7037906dc199c72b7
2021-10-19 02:16:48 +0000 to 2021-10-24 17:51:41 +0000
- Fix a clippy warning (rust-lang/cargo#10002)
- Upgrade Cargo to the 2021 edition (rust-lang/cargo#10000)
- Don't canonicalize executable path (rust-lang/cargo#9991)
- Bump to 0.59.0, update changelog (rust-lang/cargo#9998)

2 years agoRollup merge of #90294 - ehuss:update-books, r=ehuss
Matthias Krüger [Tue, 26 Oct 2021 04:14:08 +0000 (06:14 +0200)]
Rollup merge of #90294 - ehuss:update-books, r=ehuss

Update books

## nomicon

3 commits in 2d66852a27c5d0ec50ae021820d1de22caa2b1bd..358e6a61d5f4f0496d0a81e70cdcd25d05307342
2021-10-07 19:00:37 +0900 to 2021-10-20 11:23:12 -0700
- Write a basic "call Rust from C" example (rust-lang/nomicon#296)
- Clarify the Safe vs. Unsafe Rust relationship (rust-lang/nomicon#294)
- Fix typo with respect to dangling pointer (rust-lang/nomicon#319)

## book

8 commits in eb1282ec444db94055fa9531b6f3f803e86bb382..fd9299792852c9a368cb236748781852f75cdac6
2021-09-16 21:17:09 -0400 to 2021-10-22 21:59:46 -0400
- Reword description to emphasize what return does in a match arm
- Correct backwards wording describing From impls. Fixes rust-lang/book#2829
- Remove multiple negatives, add examples. Fixes rust-lang/book#2833
- Fix capitalization in sidebar. Fixes rust-lang/book#2860
- fix quotes
- comments from nostarch and responses for chapter 2
-  (rust-lang/book#2906)
- Merge pull request rust-lang/book#2892 from Enrico2/patch-1

## rust-by-example

1 commits in 9a60624fcad0140826c44389571dc622917cd632..27f1ff5e440ef78828b68ab882b98e1b10d9af32
2021-10-04 08:13:53 -0300 to 2021-10-13 08:04:40 -0300
- Added example of `impl Trait` as an argument (rust-lang/rust-by-example#1468)

## embedded-book

1 commits in 270fccd339e5972d9c900e788f197e81a0bcd956..51739471276b1776dea27cf562b974ef07e24685
2021-10-06 16:28:48 +0000 to 2021-10-17 16:48:42 +0000
- Fix typo in 'The Borrow Checker'  (rust-embedded/book#305)

2 years agoRollup merge of #90241 - DrMeepster:thiscall_lint_upgrade, r=petrochenkov
Matthias Krüger [Tue, 26 Oct 2021 04:14:07 +0000 (06:14 +0200)]
Rollup merge of #90241 - DrMeepster:thiscall_lint_upgrade, r=petrochenkov

Make thiscall abi on unsupported platforms a hard error

As suggested in https://github.com/rust-lang/rust/issues/42202#issuecomment-950205016, this PR makes use of the `thiscall` abi on unsupported a hard error instead of a lint.

2 years agoRollup merge of #90181 - notriddle:notriddle/error-pointer, r=estebank
Matthias Krüger [Tue, 26 Oct 2021 04:14:06 +0000 (06:14 +0200)]
Rollup merge of #90181 - notriddle:notriddle/error-pointer, r=estebank

fix(rustc_typeck): report function argument errors on matching type

Fixes #90101

2 years agoRemove fNN::lerp - consensus unlikely
CAD97 [Tue, 26 Oct 2021 03:22:17 +0000 (22:22 -0500)]
Remove fNN::lerp - consensus unlikely

2 years agoUpdate cargo
Eric Huss [Tue, 26 Oct 2021 03:30:21 +0000 (20:30 -0700)]
Update cargo