diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:58 +0000 |
commit | a4b7ed7a42c716ab9f05e351f003d589124fd55d (patch) | |
tree | b620cd3f223850b28716e474e80c58059dca5dd4 /tests/run-make-fulldeps/emit | |
parent | Adding upstream version 1.67.1+dfsg1. (diff) | |
download | rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.tar.xz rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.zip |
Adding upstream version 1.68.2+dfsg1.upstream/1.68.2+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/run-make-fulldeps/emit')
-rw-r--r-- | tests/run-make-fulldeps/emit/Makefile | 21 | ||||
-rw-r--r-- | tests/run-make-fulldeps/emit/test-24876.rs | 9 | ||||
-rw-r--r-- | tests/run-make-fulldeps/emit/test-26235.rs | 46 |
3 files changed, 76 insertions, 0 deletions
diff --git a/tests/run-make-fulldeps/emit/Makefile b/tests/run-make-fulldeps/emit/Makefile new file mode 100644 index 000000000..78e68bd61 --- /dev/null +++ b/tests/run-make-fulldeps/emit/Makefile @@ -0,0 +1,21 @@ +include ../tools.mk + +all: + $(RUSTC) -Copt-level=0 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs + $(RUSTC) -Copt-level=1 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs + $(RUSTC) -Copt-level=2 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs + $(RUSTC) -Copt-level=3 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs + $(RUSTC) -Copt-level=s --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs + $(RUSTC) -Copt-level=z --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs + $(RUSTC) -Copt-level=0 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs + $(call RUN,test-26235) || exit 1 + $(RUSTC) -Copt-level=1 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs + $(call RUN,test-26235) || exit 1 + $(RUSTC) -Copt-level=2 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs + $(call RUN,test-26235) || exit 1 + $(RUSTC) -Copt-level=3 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs + $(call RUN,test-26235) || exit 1 + $(RUSTC) -Copt-level=s --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs + $(call RUN,test-26235) || exit 1 + $(RUSTC) -Copt-level=z --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs + $(call RUN,test-26235) || exit 1 diff --git a/tests/run-make-fulldeps/emit/test-24876.rs b/tests/run-make-fulldeps/emit/test-24876.rs new file mode 100644 index 000000000..734e2ee4b --- /dev/null +++ b/tests/run-make-fulldeps/emit/test-24876.rs @@ -0,0 +1,9 @@ +// Checks for issue #24876 + +fn main() { + let mut v = 0; + for i in 0..0 { + v += i; + } + println!("{}", v) +} diff --git a/tests/run-make-fulldeps/emit/test-26235.rs b/tests/run-make-fulldeps/emit/test-26235.rs new file mode 100644 index 000000000..07d975f33 --- /dev/null +++ b/tests/run-make-fulldeps/emit/test-26235.rs @@ -0,0 +1,46 @@ +// Checks for issue #26235 + +fn main() { + use std::thread; + + type Key = u32; + const NUM_THREADS: usize = 2; + + #[derive(Clone,Copy)] + struct Stats<S> { + upsert: S, + delete: S, + insert: S, + update: S + }; + + impl<S> Stats<S> where S: Copy { + fn dot<B, F, T>(self, s: Stats<T>, f: F) -> Stats<B> where F: Fn(S, T) -> B { + let Stats { upsert: u1, delete: d1, insert: i1, update: p1 } = self; + let Stats { upsert: u2, delete: d2, insert: i2, update: p2 } = s; + Stats { upsert: f(u1, u2), delete: f(d1, d2), insert: f(i1, i2), update: f(p1, p2) } + } + + fn new(init: S) -> Self { + Stats { upsert: init, delete: init, insert: init, update: init } + } + } + + fn make_threads() -> Vec<thread::JoinHandle<()>> { + let mut t = Vec::with_capacity(NUM_THREADS); + for _ in 0..NUM_THREADS { + t.push(thread::spawn(move || {})); + } + t + } + + let stats = [Stats::new(0); NUM_THREADS]; + make_threads(); + + { + let Stats { ref upsert, ref delete, ref insert, ref update } = stats.iter().fold( + Stats::new(0), |res, &s| res.dot(s, |x: Key, y: Key| x.wrapping_add(y))); + println!("upserts: {}, deletes: {}, inserts: {}, updates: {}", + upsert, delete, insert, update); + } +} |