diff options
| author | Kivooeo <Kivooeo123@gmail.com> | 2025-06-13 02:30:47 +0500 |
|---|---|---|
| committer | Kivooeo <Kivooeo123@gmail.com> | 2025-07-01 16:26:57 +0500 |
| commit | 1daba456361d0bbac3d0bd9e0f11b7784d20ebe5 (patch) | |
| tree | 40d1ff4258c3d46b8f8568ee2ab35b481adaf6dc /tests/ui/higher-ranked | |
| parent | 3b57db4d87ea589ec05e2c7543fb6ad2df41795f (diff) | |
| download | rust-1daba456361d0bbac3d0bd9e0f11b7784d20ebe5.tar.gz rust-1daba456361d0bbac3d0bd9e0f11b7784d20ebe5.zip | |
cleaned up some tests
Diffstat (limited to 'tests/ui/higher-ranked')
| -rw-r--r-- | tests/ui/higher-ranked/higher-ranked-encoding.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/tests/ui/higher-ranked/higher-ranked-encoding.rs b/tests/ui/higher-ranked/higher-ranked-encoding.rs index eb2aef9cee1..463e0f50e53 100644 --- a/tests/ui/higher-ranked/higher-ranked-encoding.rs +++ b/tests/ui/higher-ranked/higher-ranked-encoding.rs @@ -1,9 +1,7 @@ -//@ run-pass +//! Regression test for https://github.com/rust-lang/rust/issues/15924 -#![allow(unused_imports)] -#![allow(unused_must_use)] +//@ run-pass -use std::fmt; use std::marker::PhantomData; trait Encoder { @@ -26,9 +24,8 @@ impl Encoder for JsonEncoder<'_> { type Error = (); } -fn encode_json<T: for<'r> Encodable<JsonEncoder<'r>>>( - object: &T, -) -> Result<String, ()> { +// This function uses higher-ranked trait bounds, which previously caused ICE +fn encode_json<T: for<'r> Encodable<JsonEncoder<'r>>>(object: &T) -> Result<String, ()> { let s = String::new(); { let mut encoder = JsonEncoder(PhantomData); @@ -37,13 +34,15 @@ fn encode_json<T: for<'r> Encodable<JsonEncoder<'r>>>( Ok(s) } +// Structure with HRTB constraint that was problematic struct Foo<T: for<'a> Encodable<JsonEncoder<'a>>> { v: T, } +// Drop implementation that exercises the HRTB bounds impl<T: for<'a> Encodable<JsonEncoder<'a>>> Drop for Foo<T> { fn drop(&mut self) { - encode_json(&self.v); + let _ = encode_json(&self.v); } } |
