Commit Graph

15272 Commits

Author SHA1 Message Date
Michael Goulet
1152e70363 Deeply deny fn and raw ptrs in const generics 2022-07-25 03:39:22 +00:00
Ralf Jung
34d0c0abf6
Rollup merge of - danbev:rustc_parse-config-doc-comments, r=cjgillot
Update doc comments that refer to config parameter

This commit updates the `source_file_to_parser` and the
`maybe_source_file_to_parse` function's doc comments which currently
refer to a `config` parameter. The doc comments have been updated to
refer to the `session` parameter similar to the doc comment for
`try_file_to_source_file`, which also takes a `&Session` parameter.
2022-07-24 14:04:29 -04:00
Ralf Jung
890cd7a496
Rollup merge of - RalfJung:interpret-int-ptr-transmute, r=oli-obk
remove some provenance-related machine hooks that Miri no longer needs

Then we can make `scalar_to_ptr` a method on `Scalar`. :)

Fixes https://github.com/rust-lang/miri/issues/2188
r? `@oli-obk`
2022-07-24 14:04:26 -04:00
Daniel Bevenius
045140a25b Update doc comments that refer to config parameter
This commit updates the source_file_to_parser and the
maybe_source_file_to_parse function's doc comments which currently
refer to a config parameter. The doc comments have been updated to
refer to the 'session' parameter similar to the doc comment for
try_file_to_source_file, which also takes a &Session parameter.
2022-07-24 16:40:24 +02:00
Amanieu d'Antras
d931a587e6 Revert "Mark atomics as unsupported on thumbv6m"
This reverts commit 7514610219.
2022-07-24 13:12:08 +01:00
bors
b4151a41a0 Auto merge of - fee1-dead-contrib:allow-super-trait-tilde-const, r=oli-obk
Allow `trait A: ~const B`

What's included: a minimal working change set for `~const` supertraits to work.

r? `@oli-obk`
2022-07-24 09:16:02 +00:00
Deadbeef
666022730f Instantiate constness in wfcheck 2022-07-24 07:57:05 +00:00
bors
4dbc89de3f Auto merge of - cuviper:hashbrown-0.12, r=Mark-Simulacrum
Upgrade indexmap and thorin-dwp to use hashbrown 0.12

This removes the last dependencies on hashbrown 0.11.

This also upgrades to hashbrown 0.12.3 to fix a double-free ().
2022-07-24 04:03:29 +00:00
bors
db8086eb60 Auto merge of - rcvalle:rust-cfi-2, r=nagisa
Add fine-grained LLVM CFI support to the Rust compiler

This PR improves the LLVM Control Flow Integrity (CFI) support in the Rust compiler by providing forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types.

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 identifying C char and integer type uses at the time types are encoded (see Type metadata in the design document in the tracking issue https://github.com/rust-lang/rust/issues/89653).

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

Thank you again, `@eddyb,` `@nagisa,` `@pcc,` and `@tmiasko` for all the help!
2022-07-24 01:22:36 +00:00
bors
fcad91868a Auto merge of - GuillaumeGomez:rollup-38v0x7y, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 -  (Make `ui-fulldeps/gated-plugins` and `ui-fulldeps/multiple-plugins` tests stage 2 only)
 -  (Add some additional double-adjustment regression tests)
 -  (Do not resolve associated const when there is no provided value)
 -  (Mark atomics as unsupported on thumbv6m)
 -  (Lock stdout once when listing tests)
 -  (Remove Clean trait implementation for hir::Ty and middle::Ty)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-23 22:41:48 +00:00
Guillaume Gomez
90c6cde43a
Rollup merge of - nikic:thumbv6m-atomics, r=nagisa
Mark atomics as unsupported on thumbv6m

The thumbv6m target does not support atomics. Historically, LLVM
had a bug where atomic load/stores for this target were emitted
as plain load/stores rather than as libatomic calls. This was
fixed in https://reviews.llvm.org/D120026, which will be part of
LLVM 15. As we require that "atomic support" does not use libatomic,
we need to indicate that this target does not have native atomics.
2022-07-23 23:34:31 +02:00
Guillaume Gomez
3648dd552a
Rollup merge of - compiler-errors:assoc-const-missing-item, r=lcnr
Do not resolve associated const when there is no provided value

Fixes , since now we just delay a bug when we're not able to evaluate a const item due to the value not actually being provided by anything. This means compilation proceeds forward to where the "missing item in impl" error is emitted.

----

The root issue here is that when we're looking for the defining `LeafDef` in `resolve_associated_item`, we end up getting the trait's AssocItem instead of the impl's AssocItem (which does not exist). This resolution "succeeds" even if the trait's item has no default value, and then since this item has no value to evaluate, it turns into a const eval error.

This root issue becomes problematic (as in ) when this const eval error happens in wfcheck (for example, due to normalizing the param-env of something that references this const). Since this happens sooner than the check that an impl actually provides all of the items that a trait requires (which happens during later typecheck), we end up aborting compilation early with only this un-informative message.

I'm not exactly sure _why_ this bug arises due to  -- perhaps valtrees are evaluated more eagerly than in the old system?

r? ``@oli-obk`` or ``@lcnr`` since y'all are familiar with const eval and reviewed , though feel free to reassign.

This is a regression from stable to beta, so I would be open to considering this for beta backport. It seems correct to me, especially given the improvements in the other UI tests this PR touches, but may have some side-effects that I'm unaware of...?
2022-07-23 23:34:30 +02:00
bors
93ffde6f04 Auto merge of - ivanloz:master, r=nagisa
Add support for LLVM ShadowCallStack.

LLVMs ShadowCallStack provides backward edge control flow integrity protection by using a separate shadow stack to store and retrieve a function's return address.

LLVM currently only supports this for AArch64 targets. The x18 register is used to hold the pointer to the shadow stack, and therefore this only works on ABIs which reserve x18. Further details are available in the [LLVM ShadowCallStack](https://clang.llvm.org/docs/ShadowCallStack.html) docs.

# Usage
`-Zsanitizer=shadow-call-stack`

# Comments/Caveats
* Currently only enabled for the aarch64-linux-android target
* Requires the platform to define a runtime to initialize the shadow stack, see the [LLVM docs](https://clang.llvm.org/docs/ShadowCallStack.html) for more detail.
2022-07-23 20:01:07 +00:00
Ramon de C Valle
5ad7a646a5 Add fine-grained LLVM CFI support to the Rust compiler
This commit improves the LLVM Control Flow Integrity (CFI) support in
the Rust compiler by providing forward-edge control flow protection for
Rust-compiled code only by aggregating function pointers in groups
identified by their return and parameter types.

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 identifying C char and integer type uses at the
time types are encoded (see Type metadata in the design document in the
tracking issue ).

LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e.,
-Clto).
2022-07-23 10:51:34 -07:00
Ralf Jung
4e89a7c293 now we can make scalar_to_ptr a method on Scalar 2022-07-23 10:36:57 -04:00
Deadbeef
08cb878430 Remap elaborated obligation constness 2022-07-23 14:25:55 +00:00
Deadbeef
9b75f2d498 Allow ~const on super traits 2022-07-23 14:25:55 +00:00
Ralf Jung
665a7e8f56 remove some provenance-related machine hooks that Miri no longer needs 2022-07-23 10:15:37 -04:00
bors
2e43d068ce Auto merge of - matthiaskrgr:rollup-yg0xxkx, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 -  (Don't suggest unnameable generic arguments)
 -  (Update mdbook)
 -  (Use span_bug in case of unexpected rib kind)
 -  (Fix typo/grammar in locator.rs doc comment)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-23 10:40:41 +00:00
Matthias Krüger
7c5df1f425
Rollup merge of - danbev:locator.rs-typo, r=Dylan-DPC
Fix typo/grammar in locator.rs doc comment
2022-07-23 12:08:14 +02:00
Matthias Krüger
f510d98ad3
Rollup merge of - jmqd:master, r=oli-obk
Use span_bug in case of unexpected rib kind

Extremely minor QOL change to improve the ICE compiler output in case
this default match case is encountered (an unexpected rib kind).

I have limited experience in this area of the compiler; please let me know
if a span more precise than `param.ident.span` is more applicable.
2022-07-23 12:08:13 +02:00
Matthias Krüger
b6d6f100a1
Rollup merge of - fmease:fix-issue-99565, r=estebank
Don't suggest unnameable generic arguments

Fixes .

`@rustbot` label T-compiler A-diagnostics
r? `@rust-lang/wg-diagnostics`
2022-07-23 12:08:11 +02:00
bors
47ba935965 Auto merge of - NiklasJonsson:84447/rustc_expand, r=compiler-errors
rustc_expand: Switch FxHashMap to FxIndexMap where iteration is used

Relates 
2022-07-23 07:59:54 +00:00
Daniel Bevenius
db977ca37e Fix typo/grammar in locator.rs doc comment 2022-07-23 07:31:20 +02:00
Jordan McQueen
e0c9be539a Use span_bug in case of unexpected rib kind
Extremely minor QOL change to improve the ICE output in case this
default match case is encountered (an unexpected rib kind).
2022-07-23 13:26:45 +09:00
bors
8aedb9c68d Auto merge of - RalfJung:rollup-0h066kc, r=RalfJung
Rollup of 3 pull requests

Successful merges:

 -  (Update books)
 -  (cargotest: do not run quickcheck tests in xsv)
 -  (interpret: fix vtable check debug assertion)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-23 00:01:19 +00:00
Ralf Jung
25de227b43
Rollup merge of - RalfJung:vtable-check, r=eddyb
interpret: fix vtable check debug assertion

Fixes https://github.com/rust-lang/rust/issues/99605
Thanks to `@eddyb` for suggesting the fix!
2022-07-22 17:26:10 -04:00
Michael Goulet
22b2aae737 Do not resolve associated const when there is no provided value 2022-07-22 18:58:07 +00:00
Ralf Jung
5b7197af7f do not mark interior mutable shared refs as dereferenceable 2022-07-22 14:25:41 -04:00
Ralf Jung
307e80c1a6 rename PointerKind::Shared → SharedMutable to indicate this is NOT the usual shared reference 2022-07-22 14:22:05 -04:00
Ralf Jung
19e29e9a57 interpret: fix vtable check debug assertion 2022-07-22 10:37:03 -04:00
bors
22d25f21dc Auto merge of - fee1-dead-contrib:const_fix_hax, r=oli-obk
Fix hack that remaps env constness.

WARNING: might have perf implications.

Are there any more problems with having a constness in the `ParamEnv` now? :)

r? `@oli-obk`
2022-07-22 12:48:29 +00:00
Nikita Popov
7514610219 Mark atomics as unsupported on thumbv6m
The thumbv6m target does not support atomics. Historically, LLVM
had a bug where atomic load/stores for this target were emitted
as plain load/stores rather than as libatomic calls. This was
fixed in https://reviews.llvm.org/D120026, which will be part of
LLVM 15. As we require that "atomic support" does not use libatomic,
we need to indicate that this target does not have native atomics.
2022-07-22 10:54:39 +02:00
Dylan DPC
92bebac0b9
Rollup merge of - compiler-errors:bidirectional-block-suggestions, r=fee1-dead
Improve suggestions for returning binding

Fixes 

Also reworks the cause codes for match and if a bit, I think cleaning them up in a positive way.
We no longer need to call `could_remove_semicolon` in successful code, which might save a few cycles?
2022-07-22 11:53:42 +05:30
Dylan DPC
449ffe0bd5
Rollup merge of - Logarithmus:feature/99255-omit-const-generic-suffixes, r=petrochenkov
feat: omit suffixes in const generics (e.g. `1_i32`)

Closes 
2022-07-22 11:53:40 +05:30
Dylan DPC
6e3dd69e36
Rollup merge of - tmiasko:unreachable-coverage, r=wesleywiser
Fix unreachable coverage generation for inlined functions

To generate a function coverage we need at least one coverage counter,
so a coverage from unreachable blocks is retained only when some live
counters remain.

The previous implementation incorrectly retained unreachable coverage,
because it didn't account for the fact that those live counters can
belong to another function due to inlining.

Fixes .
2022-07-22 11:53:40 +05:30
León Orell Valerian Liehr
c98399f5eb Don't suggest unnameable generic arguments 2022-07-22 04:55:31 +02:00
bors
aa01891700 Auto merge of - RalfJung:vtable, r=oli-obk
make vtable pointers entirely opaque

This implements the scheme discussed in https://github.com/rust-lang/unsafe-code-guidelines/issues/338: vtable pointers should be considered entirely opaque and not even readable by Rust code, similar to function pointers.

- We have a new kind of `GlobalAlloc` that symbolically refers to a vtable.
- Miri uses that kind of allocation when generating a vtable.
- The codegen backends, upon encountering such an allocation, call `vtable_allocation` to obtain an actually dataful allocation for this vtable.
- We need new intrinsics to obtain the size and align from a vtable (for some `ptr::metadata` APIs), since direct accesses are UB now.

I had to touch quite a bit of code that I am not very familiar with, so some of this might not make much sense...
r? `@oli-obk`
2022-07-22 01:33:49 +00:00
bors
62b272d25c Auto merge of - lcnr:check-regions-infcx, r=oli-obk
move `considering_regions` to the infcx

it seems weird to prove some obligations which constrain inference vars while ignoring regions  in a context which considers regions. This is especially weird because even for a fulfillment context with ignored regions, we still added region outlives bounds when directly relating regions.

tbh our handling of regions is still very weird, but at least this is a step in the right direction imo.

r? rust-lang/types
2022-07-21 19:43:21 +00:00
Michael Goulet
3eef023da0 Address more nits 2022-07-21 16:43:10 +00:00
Matthias Krüger
b068dc7392
Rollup merge of - fee1-dead-contrib:remap_constness_fix, r=oli-obk
Fix `remap_constness`

`~const Drop` was renamed to `~const Destruct` and this special case should
be removed
2022-07-21 18:42:11 +02:00
Matthias Krüger
14c385d3d6
Rollup merge of - pierwill:patch-6, r=tmiasko
Edit `rustc_index::vec::IndexVec::pick3_mut` docs

Clarify when this method will panic.

Part of .
2022-07-21 18:42:10 +02:00
Matthias Krüger
31284d2ef2
Rollup merge of - lcnr:orphan_check-rework, r=oli-obk
Rewrite `orphan_check_trait_ref` to use a `TypeVisitor`

The current impl is far more confusing than it has any right to be 

r? rust-lang/types
2022-07-21 18:42:09 +02:00
Matthias Krüger
230b775719
Rollup merge of - matthiaskrgr:2022_07_perf, r=estebank
couple of clippy::perf fixes
2022-07-21 18:42:07 +02:00
Matthias Krüger
da18bd18ca
Rollup merge of - compiler-errors:normalize-arg-spans, r=oli-obk
Normalize the arg spans to be within the call span

Makes more sense to point out the arg's span, and not the expression inside the macro
2022-07-21 18:42:06 +02:00
Wesley Wiser
9473141253
Update compiler/rustc_mir_transform/src/simplify.rs 2022-07-21 11:51:40 -04:00
Michael Goulet
cd89978d86 Generalize same_type_modulo_infer 2022-07-21 15:45:35 +00:00
Deadbeef
b7de175ffe Fix remap_constness
`~const Drop` was renamed to `~const Destruct` and this special case should
be removed
2022-07-21 14:02:38 +00:00
pierwill
aad1aa3408 Edit rustc_index::vec::IndexVec::pick3_mut docs
Clarify when this method will panic.

Also fix formatting for `pick2_mut`.
2022-07-21 08:52:18 -05:00
lcnr
43ccacf89b region_outlives_predicate no snapshot 2022-07-21 13:09:01 +02:00