Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 70ac00e

Browse files
committed
CFI: Fix fn items, closures, and Fn trait objects
Fix casting between function items, closures, and Fn trait objects by transforming function items, closures, and Fn trait objects into function pointers for encoding.
1 parent 8b9e47c commit 70ac00e

13 files changed

+525
-104
lines changed

‎compiler/rustc_middle/src/ty/context.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1841,7 +1841,7 @@ impl<'tcx> TyCtxt<'tcx> {
18411841
/// does not compute the full elaborated super-predicates but just the set of def-ids. It is used
18421842
/// to identify which traits may define a given associated type to help avoid cycle errors.
18431843
/// Returns a `DefId` iterator.
1844-
fn super_traits_of(self, trait_def_id: DefId) -> impl Iterator<Item = DefId> + 'tcx {
1844+
pubfn super_traits_of(self, trait_def_id: DefId) -> impl Iterator<Item = DefId> + 'tcx {
18451845
let mut set = FxHashSet::default();
18461846
let mut stack = vec![trait_def_id];
18471847

‎compiler/rustc_middle/src/ty/sty.rs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,6 +1836,11 @@ impl<'tcx> Ty<'tcx> {
18361836
self.0.0.flags
18371837
}
18381838

1839+
#[inline]
1840+
pub fn is_tuple(self) -> bool {
1841+
matches!(self.kind(), Tuple(..))
1842+
}
1843+
18391844
#[inline]
18401845
pub fn is_unit(self) -> bool {
18411846
match self.kind() {
@@ -2208,6 +2213,11 @@ impl<'tcx> Ty<'tcx> {
22082213
matches!(self.kind(), FnDef(..) | FnPtr(_))
22092214
}
22102215

2216+
#[inline]
2217+
pub fn is_fn_def(self) -> bool {
2218+
matches!(self.kind(), FnDef(..))
2219+
}
2220+
22112221
#[inline]
22122222
pub fn is_fn_ptr(self) -> bool {
22132223
matches!(self.kind(), FnPtr(_))

‎compiler/rustc_symbol_mangling/src/lib.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
#![feature(rustdoc_internals)]
9393
#![feature(let_chains)]
9494
#![allow(internal_features)]
95+
#![feature(iter_order_by)]
9596

9697
#[macro_use]
9798
extern crate rustc_middle;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /