From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB6BB52F267; Tue, 29 Sep 2026 13:59:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.4 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790690393; cv=none; b=nz2Ms2pF5GDEInyZsq7h6ZP/8trPUbow4RmPWUwX0lCMWfaIYqA2TOTT8CcoNxWxNxxJqDb/Poy9325FJoJ1RvT1ZO2MZEd+Mz6xhjPAVs7MqPEbdLW1OA8VlmyiUltk0cM+Cybp3gFCB7upyv36qzuDZG6OP6TQHdShOVQJ2/I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790690393; c=relaxed/simple; bh=Hl30ZSw8nwgUEquDsIfDs10kvoTADxVJ9zbjiTMuFtU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OglofDAn7uLSaNkIGl9GhBSiqIlVbx/Ge3cVU9GObM5U+QqySQ4UoUrmyzoGpPmJ9W7Dm8jBbkTSa2SUdyD4wBhxGgzS8Pi8mmLbvb05e6Ff4cYFResDP9cZhxCjCnJVPUfseZXGeiUOtdD/Eu375hsqZhu9KP8hb7Z4aCu+ric= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=WfZzq1ya; arc=none smtp.client-ip=117.135.210.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="WfZzq1ya" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=CM WBfJ+s5JFeL1JextvUKdbY7lIqotqNlZbRk6WWyXk=; b=WfZzq1yajDcrMIIJU0 n4YM/MGXSbVCAFE4H769nphai4Bwt3C3C81nc/TXmupPMqHrRILoWZlGxC5TOn5p Ikf7wK0nX9L7/hw3XmfWAK0FOhCYN8hSzURtgqrcgFRZMDksoCLm8teg2S27ujnU khiaYPkXzt2LgAJi79EM8UEwU= Received: from localhost.localdomain (unknown []) by gzga-smtp-mtada-g0-4 (Coremail) with SMTP id _____wD3rr08xLtqmCNYBg--.46271S2; Tue, 29 Sep 2026 21:59:27 +0800 (CST) From: Kaiqi Guo To: rust-for-linux@vger.kernel.org, Miguel Ojeda Cc: Jesung Yang , Alexandre Courbot , Danilo Krummrich , nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Kaiqi Guo Subject: [PATCH v6 05/10] rust: macros: add private doctests for `TryFrom` derive macro Date: Tue, 29 Sep 2026 21:58:50 +0800 Message-ID: <20260929135855.36775-6-chaoji_xinren@163.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260929135855.36775-1-chaoji_xinren@163.com> References: <20260929135855.36775-1-chaoji_xinren@163.com> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wD3rr08xLtqmCNYBg--.46271S2 X-Coremail-Antispam: 1Uf129KBjvAXoW3Zr4DAFW7urWDCw15JrW8WFg_yoW8WF4fGo W8Ja1rG3s8AFnY9FnrJrnYyrZ5A3yS9r9IqryfXr1kCa43J3ySvFW8Jr1UCr1Yqa17JF13 J3yfJF4jyrs8Jwn8n29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7v73VFW2AGmfu7bjvjm3 AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjTRdwI6DUUUU X-CM-SenderInfo: pfkd0yplb0x0xuhqqiywtou0bp/xtbC4gDKRmq7xEClJAAA36 From: Jesung Yang Add internal doctests to verify the `TryFrom` derive macro's logic. This ensures comprehensive testing while keeping the public-facing documentation compact and readable. Signed-off-by: Jesung Yang Signed-off-by: Kaiqi Guo --- rust/macros/convert.rs | 578 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 578 insertions(+) diff --git a/rust/macros/convert.rs b/rust/macros/convert.rs index 31cdf84082e7..c07870914242 100644 --- a/rust/macros/convert.rs +++ b/rust/macros/convert.rs @@ -1024,3 +1024,581 @@ mod overflow_assert_works_on_unsigned_int {} /// ``` mod any_into_target_overflow_is_rejected {} } + +mod derive_try_from_tests { + /// ``` + /// use kernel::{ + /// macros::{ + /// Into, + /// TryFrom, // + /// }, + /// num::Bounded, + /// prelude::*, // + /// }; + /// + /// #[derive(Debug, Into, PartialEq, TryFrom)] + /// #[convert(bool, Bounded, Bounded, i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize)] + /// enum Foo { + /// A, + /// B, + /// } + /// + /// assert_eq!(false, Foo::A.into()); + /// assert_eq!(true, Foo::B.into()); + /// assert_eq!(Ok(Foo::A), Foo::try_from(false)); + /// assert_eq!(Ok(Foo::B), Foo::try_from(true)); + /// + /// let foo_a: Bounded = Foo::A.into(); + /// let foo_b: Bounded = Foo::B.into(); + /// assert_eq!(Bounded::::new::<0>(), foo_a); + /// assert_eq!(Bounded::::new::<1>(), foo_b); + /// assert_eq!(Ok(Foo::A), Foo::try_from(Bounded::::new::<0>())); + /// assert_eq!(Ok(Foo::B), Foo::try_from(Bounded::::new::<1>())); + /// assert_eq!(Err(EINVAL), Foo::try_from(Bounded::::new::<-1>())); + /// assert_eq!(Err(EINVAL), Foo::try_from(Bounded::::new::<2>())); + /// + /// let foo_a: Bounded = Foo::A.into(); + /// let foo_b: Bounded = Foo::B.into(); + /// assert_eq!(Bounded::::new::<0>(), foo_a); + /// assert_eq!(Bounded::::new::<1>(), foo_b); + /// assert_eq!(Ok(Foo::A), Foo::try_from(Bounded::::new::<0>())); + /// assert_eq!(Ok(Foo::B), Foo::try_from(Bounded::::new::<1>())); + /// assert_eq!(Err(EINVAL), Foo::try_from(Bounded::::new::<2>())); + /// + /// macro_rules! gen_signed_tests { + /// ($($type:ty),*) => { + /// $( + /// assert_eq!(0 as $type, Foo::A.into()); + /// assert_eq!(1 as $type, Foo::B.into()); + /// assert_eq!(Ok(Foo::A), Foo::try_from(0 as $type)); + /// assert_eq!(Ok(Foo::B), Foo::try_from(1 as $type)); + /// assert_eq!(Err(EINVAL), Foo::try_from((0 as $type) - 1)); + /// assert_eq!(Err(EINVAL), Foo::try_from((1 as $type) + 1)); + /// )* + /// }; + /// } + /// macro_rules! gen_unsigned_tests { + /// ($($type:ty),*) => { + /// $( + /// assert_eq!(0 as $type, Foo::A.into()); + /// assert_eq!(1 as $type, Foo::B.into()); + /// assert_eq!(Ok(Foo::A), Foo::try_from(0 as $type)); + /// assert_eq!(Ok(Foo::B), Foo::try_from(1 as $type)); + /// assert_eq!(Err(EINVAL), Foo::try_from((1 as $type) + 1)); + /// )* + /// }; + /// } + /// gen_signed_tests!(i8, i16, i32, i64, i128, isize); + /// gen_unsigned_tests!(u8, u16, u32, u64, u128, usize); + /// ``` + mod works_with_derive_into {} + + /// ``` + /// use kernel::{ + /// macros::TryFrom, + /// prelude::*, // + /// }; + /// + /// #[derive(Debug, PartialEq, TryFrom)] + /// #[try_from(u8)] + /// enum Foo { + /// // Works with const expressions. + /// A = add(0, 0), + /// B = 2_isize.pow(1) - 1, + /// } + /// + /// const fn add(a: isize, b: isize) -> isize { + /// a + b + /// } + /// + /// assert_eq!(Ok(Foo::A), Foo::try_from(0_u8)); + /// assert_eq!(Ok(Foo::B), Foo::try_from(1_u8)); + /// assert_eq!(Err(EINVAL), Foo::try_from(2_u8)); + /// ``` + mod works_with_const_expr {} + + /// ``` + /// use kernel::{ + /// macros::TryFrom, + /// prelude::*, // + /// }; + /// + /// #[derive(Debug, PartialEq, TryFrom)] + /// #[try_from(bool)] + /// enum Foo { + /// A, + /// B, + /// } + /// + /// assert_eq!(Ok(Foo::A), Foo::try_from(false)); + /// assert_eq!(Ok(Foo::B), Foo::try_from(true)); + /// + /// #[derive(Debug, PartialEq, TryFrom)] + /// #[try_from(bool)] + /// enum Bar { + /// A, + /// } + /// + /// assert_eq!(Ok(Bar::A), Bar::try_from(false)); + /// assert_eq!(Err(EINVAL), Bar::try_from(true)); + /// + /// #[derive(Debug, PartialEq, TryFrom)] + /// #[try_from(bool)] + /// enum Baz { + /// A = 1, + /// } + /// + /// assert_eq!(Err(EINVAL), Baz::try_from(false)); + /// assert_eq!(Ok(Baz::A), Baz::try_from(true)); + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(bool)] + /// enum Foo { + /// // `-1` cannot be represented with `bool`. + /// A = -1, + /// } + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(bool)] + /// enum Foo { + /// // `2` cannot be represented with `bool`. + /// A = 2, + /// } + /// ``` + mod overflow_assert_works_on_bool {} + + /// ``` + /// use kernel::{ + /// macros::TryFrom, + /// num::Bounded, + /// prelude::*, // + /// }; + /// + /// #[derive(Debug, PartialEq, TryFrom)] + /// #[try_from(Bounded)] + /// enum Foo { + /// A = -1 << 6, // The minimum value of `Bounded`. + /// B = (1 << 6) - 1, // The maximum value of `Bounded`. + /// } + /// + /// assert_eq!(Ok(Foo::A), Foo::try_from(Bounded::::new::<{ -1_i8 << 6 }>())); + /// assert_eq!(Ok(Foo::B), Foo::try_from(Bounded::::new::<{ (1_i8 << 6) - 1 }>())); + /// assert_eq!(Err(EINVAL), Foo::try_from(Bounded::::new::<{ (-1_i8 << 6) + 1 }>())); + /// assert_eq!(Err(EINVAL), Foo::try_from(Bounded::::new::<{ (1_i8 << 6) - 2 }>())); + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(Bounded)] + /// enum Foo { + /// // `1 << 6` cannot be represented with `Bounded`. + /// A = 1 << 6, + /// } + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(Bounded)] + /// enum Foo { + /// // `(-1 << 6) - 1` cannot be represented with `Bounded`. + /// A = (-1 << 6) - 1, + /// } + /// ``` + /// + /// ``` + /// use kernel::{ + /// macros::TryFrom, + /// num::Bounded, + /// prelude::*, // + /// }; + /// + /// #[derive(Debug, PartialEq, TryFrom)] + /// #[try_from(Bounded)] + /// enum Foo { + /// A = -1, // The minimum value of `Bounded`. + /// B, // The maximum value of `Bounded`. + /// } + /// + /// assert_eq!(Ok(Foo::A), Foo::try_from(Bounded::::new::<{ -1_i8 }>())); + /// assert_eq!(Ok(Foo::B), Foo::try_from(Bounded::::new::<{ 0_i8 } >())); + /// + /// #[derive(Debug, PartialEq, TryFrom)] + /// #[try_from(Bounded)] + /// enum Bar { + /// A = -1, // The minimum value of `Bounded`. + /// } + /// + /// assert_eq!(Ok(Bar::A), Bar::try_from(Bounded::::new::<{ -1_i8 }>())); + /// assert_eq!(Err(EINVAL), Bar::try_from(Bounded::::new::<{ 0_i8 } >())); + /// + /// #[derive(Debug, PartialEq, TryFrom)] + /// #[try_from(Bounded)] + /// enum Baz { + /// A, // The maximum value of `Bounded`. + /// } + /// + /// assert_eq!(Err(EINVAL), Baz::try_from(Bounded::::new::<{ -1_i8 }>())); + /// assert_eq!(Ok(Baz::A), Baz::try_from(Bounded::::new::<{ 0_i8 } >())); + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(Bounded)] + /// enum Foo { + /// // `1` cannot be represented with `Bounded`. + /// A = 1, + /// } + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(Bounded)] + /// enum Foo { + /// // `-2` cannot be represented with `Bounded`. + /// A = -2, + /// } + /// ``` + /// + /// ``` + /// use kernel::{ + /// macros::TryFrom, + /// num::Bounded, + /// prelude::*, // + /// }; + /// + /// #[derive(Debug, PartialEq, TryFrom)] + /// #[try_from(Bounded)] + /// #[repr(i64)] + /// enum Foo { + /// A = i32::MIN as i64, + /// B = i32::MAX as i64, + /// } + /// + /// assert_eq!(Ok(Foo::A), Foo::try_from(Bounded::::new::<{ i32::MIN }>())); + /// assert_eq!(Ok(Foo::B), Foo::try_from(Bounded::::new::<{ i32::MAX }>())); + /// assert_eq!(Err(EINVAL), Foo::try_from(Bounded::::new::<{ i32::MIN + 1 }>())); + /// assert_eq!(Err(EINVAL), Foo::try_from(Bounded::::new::<{ i32::MAX - 1 }>())); + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(Bounded)] + /// #[repr(i64)] + /// enum Foo { + /// // `1 << 31` cannot be represented with `Bounded`. + /// A = 1 << 31, + /// } + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(Bounded)] + /// #[repr(i64)] + /// enum Foo { + /// // `(-1 << 31) - 1` cannot be represented with `Bounded`. + /// A = (-1 << 31) - 1, + /// } + /// ``` + mod overflow_assert_works_on_signed_bounded {} + + /// ``` + /// use kernel::{ + /// macros::TryFrom, + /// num::Bounded, + /// prelude::*, // + /// }; + /// + /// #[derive(Debug, PartialEq, TryFrom)] + /// #[try_from(Bounded)] + /// enum Foo { + /// A, // The minimum value of `Bounded`. + /// B = (1 << 7) - 1, // The maximum value of `Bounded`. + /// } + /// + /// assert_eq!(Ok(Foo::A), Foo::try_from(Bounded::::new::<{ 0 }>())); + /// assert_eq!(Ok(Foo::B), Foo::try_from(Bounded::::new::<{ (1_u8 << 7) - 1 }>())); + /// assert_eq!(Err(EINVAL), Foo::try_from(Bounded::::new::<{ 1 }>())); + /// assert_eq!(Err(EINVAL), Foo::try_from(Bounded::::new::<{ (1_u8 << 7) - 2 }>())); + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(Bounded)] + /// enum Foo { + /// // `1 << 7` cannot be represented with `Bounded`. + /// A = 1 << 7, + /// } + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(Bounded)] + /// enum Foo { + /// // `-1` cannot be represented with `Bounded`. + /// A = -1, + /// } + /// ``` + /// + /// ``` + /// use kernel::{ + /// macros::TryFrom, + /// num::Bounded, + /// prelude::*, // + /// }; + /// + /// #[derive(Debug, PartialEq, TryFrom)] + /// #[try_from(Bounded)] + /// enum Foo { + /// A, // The minimum value of `Bounded`. + /// B, // The maximum value of `Bounded`. + /// } + /// + /// assert_eq!(Ok(Foo::A), Foo::try_from(Bounded::::new::<{ 0 }>())); + /// assert_eq!(Ok(Foo::B), Foo::try_from(Bounded::::new::<{ 1 }>())); + /// + /// #[derive(Debug, PartialEq, TryFrom)] + /// #[try_from(Bounded)] + /// enum Bar { + /// A, // The minimum value of `Bounded`. + /// } + /// + /// assert_eq!(Ok(Bar::A), Bar::try_from(Bounded::::new::<{ 0 }>())); + /// assert_eq!(Err(EINVAL), Bar::try_from(Bounded::::new::<{ 1 }>())); + /// + /// #[derive(Debug, PartialEq, TryFrom)] + /// #[try_from(Bounded)] + /// enum Baz { + /// A = 1, // The maximum value of `Bounded`. + /// } + /// + /// assert_eq!(Err(EINVAL), Baz::try_from(Bounded::::new::<{ 0 }>())); + /// assert_eq!(Ok(Baz::A), Baz::try_from(Bounded::::new::<{ 1 }>())); + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(Bounded)] + /// enum Foo { + /// // `2` cannot be represented with `Bounded`. + /// A = 2, + /// } + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(Bounded)] + /// enum Foo { + /// // `-1` cannot be represented with `Bounded`. + /// A = -1, + /// } + /// ``` + /// + /// ``` + /// use kernel::{ + /// macros::TryFrom, + /// num::Bounded, + /// prelude::*, // + /// }; + /// + /// #[derive(Debug, PartialEq, TryFrom)] + /// #[try_from(Bounded)] + /// #[repr(u64)] + /// enum Foo { + /// A = u32::MIN as u64, + /// B = u32::MAX as u64, + /// } + /// + /// assert_eq!(Ok(Foo::A), Foo::try_from(Bounded::::new::<{ u32::MIN }>())); + /// assert_eq!(Ok(Foo::B), Foo::try_from(Bounded::::new::<{ u32::MAX }>())); + /// assert_eq!(Err(EINVAL), Foo::try_from(Bounded::::new::<{ u32::MIN + 1 }>())); + /// assert_eq!(Err(EINVAL), Foo::try_from(Bounded::::new::<{ u32::MAX - 1 }>())); + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(Bounded)] + /// #[repr(u64)] + /// enum Foo { + /// // `1 << 32` cannot be represented with `Bounded`. + /// A = 1 << 32, + /// } + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(Bounded)] + /// #[repr(u64)] + /// enum Foo { + /// // `-1` cannot be represented with `Bounded`. + /// A = -1, + /// } + /// ``` + mod overflow_assert_works_on_unsigned_bounded {} + + /// ``` + /// use kernel::{ + /// macros::TryFrom, + /// num::Bounded, + /// prelude::*, // + /// }; + /// + /// #[derive(Debug, PartialEq, TryFrom)] + /// #[try_from(isize)] + /// #[repr(isize)] + /// enum Foo { + /// A = isize::MIN, + /// B = isize::MAX, + /// } + /// + /// assert_eq!(Ok(Foo::A), Foo::try_from(isize::MIN)); + /// assert_eq!(Ok(Foo::B), Foo::try_from(isize::MAX)); + /// assert_eq!(Err(EINVAL), Foo::try_from(isize::MIN + 1)); + /// assert_eq!(Err(EINVAL), Foo::try_from(isize::MAX - 1)); + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(isize)] + /// #[repr(usize)] + /// enum Foo { + /// A = (isize::MAX as usize) + 1 + /// } + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(i32)] + /// #[repr(i64)] + /// enum Foo { + /// A = (i32::MIN as i64) - 1, + /// } + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(i32)] + /// #[repr(i64)] + /// enum Foo { + /// A = (i32::MAX as i64) + 1, + /// } + /// ``` + mod overflow_assert_works_on_signed_int {} + + /// ``` + /// use kernel::{ + /// macros::TryFrom, + /// num::Bounded, + /// prelude::*, // + /// }; + /// + /// #[derive(Debug, PartialEq, TryFrom)] + /// #[try_from(usize)] + /// #[repr(usize)] + /// enum Foo { + /// A = usize::MIN, + /// B = usize::MAX, + /// } + /// + /// assert_eq!(Ok(Foo::A), Foo::try_from(usize::MIN)); + /// assert_eq!(Ok(Foo::B), Foo::try_from(usize::MAX)); + /// assert_eq!(Err(EINVAL), Foo::try_from(usize::MIN + 1)); + /// assert_eq!(Err(EINVAL), Foo::try_from(usize::MAX - 1)); + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(usize)] + /// #[repr(isize)] + /// enum Foo { + /// A = -1, + /// } + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(u32)] + /// #[repr(i64)] + /// enum Foo { + /// A = (u32::MIN as i64) - 1, + /// } + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(u32)] + /// #[repr(i64)] + /// enum Foo { + /// A = (u32::MAX as i64) + 1, + /// } + /// ``` + mod overflow_assert_works_on_unsigned_int {} + + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(Bounded, i8, i16, i32, i64)] + /// #[repr(i8)] + /// enum Foo { + /// // `i8::MAX` cannot be represented with `Bounded`. + /// A = i8::MAX, + /// } + /// ``` + /// + /// ```compile_fail + /// use kernel::macros::TryFrom; + /// + /// #[derive(TryFrom)] + /// #[try_from(i8, i16, i32, i64, Bounded)] + /// #[repr(i8)] + /// enum Foo { + /// // `i8::MAX` cannot be represented with `Bounded`. + /// A = i8::MAX, + /// } + /// ``` + mod any_try_from_target_overflow_is_rejected {} +}