Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cpp2rust/rule_preprocessing/cpp_rule_indexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ std::string ClassOf(clang::QualType type) {
return ClassOf(clang::QualType(qualifier.getAsType(), 0));
}
}
if (auto tag = type->getAsTagDecl()) {
return RulesLoader::ClassKey(tag);
}
return {};
}

Expand Down
9 changes: 4 additions & 5 deletions rule-preprocessor/src/syntactic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,10 @@ impl<'a> FnIrBuilder<'a> {
for pred in wc.predicates() {
let Some(ty) = pred.ty() else { continue };
let name = ty.syntax().text().to_string();
let bounds = extract_bounds(pred.type_bound_list());
generics
.entry(name)
.and_modify(|existing| existing.extend(bounds.clone()))
.or_insert(bounds);
let Some(existing) = generics.get_mut(&name) else {
continue;
};
existing.extend(extract_bounds(pred.type_bound_list()));
}
}

Expand Down
2 changes: 2 additions & 0 deletions rules/cstddef/src_cxx17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ std::byte f2(const std::byte &a0, unsigned a1) { return a0 >> a1; }
std::byte f3(std::byte &a0, unsigned a1) { return a0 <<= a1; }

std::byte f4(std::byte &a0, unsigned a1) { return a0 >>= a1; }

template <typename T1> std::byte f5(std::byte a0, T1 a1) { return a0 << a1; }
7 changes: 7 additions & 0 deletions rules/cstddef/tgt_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@ fn f4(a0: &mut u8, a1: u32) -> u8 {
*a0 = n_;
*a0
}

fn f5<T1>(a0: u8, a1: T1) -> u8
where
u8: ::std::ops::Shl<T1, Output = u8>,
{
a0 << a1
}
4 changes: 4 additions & 0 deletions tests/unit/byte.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@ int main() {
unsigned ushift4 = 3;
b1 >>= ushift4;
assert(b1 == std::byte(0x04));

int ishift = 1;
std::byte shl2 = b1 << ishift;
assert(shl2 == std::byte(0x08));
return 0;
}
3 changes: 3 additions & 0 deletions tests/unit/out/refcount/byte.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ fn main_0() -> i32 {
b1
};
assert!((b1 == ((4) as u8)));
let mut ishift: i32 = 1;
let mut shl2: u8 = b1 << ishift;
assert!((shl2 == ((8) as u8)));
return 0;
}
pub fn __cpp2rust_init_globals() {}
3 changes: 3 additions & 0 deletions tests/unit/out/unsafe/byte.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ unsafe fn main_0() -> i32 {
b1
};
assert!(((b1) == ((4) as u8)));
let mut ishift: i32 = 1;
let mut shl2: u8 = b1 << ishift;
assert!(((shl2) == ((8) as u8)));
return 0;
}
pub unsafe fn __cpp2rust_init_globals() {}
Loading