Skip to content

Commit c7b8dd4

Browse files
committed
make_direct_deprecated: dont overwrite already set attributes
1 parent cfb47ca commit c7b8dd4

File tree

1 file changed

+10
-4
lines changed
  • compiler/rustc_target/src/abi/call

1 file changed

+10
-4
lines changed

compiler/rustc_target/src/abi/call/mod.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -584,20 +584,26 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
584584
/// Only exists because of past ABI mistakes that will take time to fix
585585
/// (see <https://github.com/rust-lang/rust/issues/115666>).
586586
pub fn make_direct_deprecated(&mut self) {
587-
self.mode = PassMode::Direct(ArgAttributes::new());
587+
match self.mode {
588+
PassMode::Indirect { .. } => {
589+
self.mode = PassMode::Direct(ArgAttributes::new());
590+
}
591+
PassMode::Ignore | PassMode::Direct(_) | PassMode::Pair(_, _) => return, // already direct
592+
_ => panic!("Tried to make {:?} direct", self.mode),
593+
}
588594
}
589595

590596
pub fn make_indirect(&mut self) {
591597
match self.mode {
592-
PassMode::Direct(_) | PassMode::Pair(_, _) => {}
598+
PassMode::Direct(_) | PassMode::Pair(_, _) => {
599+
self.mode = Self::indirect_pass_mode(&self.layout);
600+
}
593601
PassMode::Indirect { attrs: _, meta_attrs: _, on_stack: false } => {
594602
// already indirect
595603
return;
596604
}
597605
_ => panic!("Tried to make {:?} indirect", self.mode),
598606
}
599-
600-
self.mode = Self::indirect_pass_mode(&self.layout);
601607
}
602608

603609
pub fn make_indirect_byval(&mut self, byval_align: Option<Align>) {

0 commit comments

Comments
 (0)