Vendor dependencies

This commit is contained in:
2026-08-01 16:11:49 +03:00
parent 7f139a0241
commit 6b5e7f0f8b
29706 changed files with 9575646 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
fn main() {
defmt::info!("hello");
}
#[defmt::global_logger]
struct Logger;
unsafe impl defmt::Logger for Logger {
fn acquire() {}
unsafe fn flush() {}
unsafe fn release() {}
unsafe fn write(_bytes: &[u8]) {}
}
defmt::timestamp!("{=u32}", 0);
+81
View File
@@ -0,0 +1,81 @@
#![allow(dead_code)]
extern crate defmt as defmt2;
fn main() {
let baz: Baz<Qux> = Default::default();
defmt::info!("{}", baz);
}
trait Foo {
type Bar;
}
#[derive(defmt::Format, Default)]
struct Baz<T: Foo> {
field: T::Bar,
field2: Quux<T>,
}
#[derive(defmt::Format, Default)]
struct Qux;
impl Foo for Qux {
type Bar = Qux;
}
#[allow(dead_code)]
#[derive(defmt::Format, Default)]
enum Quux<T: Foo> {
#[default]
None,
Variant1(T),
Variant2 {
f: T::Bar,
},
Variant3(T::Bar),
}
#[allow(dead_code)]
#[derive(defmt::Format)]
#[defmt(crate = defmt2)]
struct Quz;
#[derive(defmt::Format)]
#[defmt(transparent)]
#[allow(dead_code)]
enum TransparentEnum<T: Foo> {
Quz(Quz),
Quux(Quux<T>),
Baz(Baz<T>),
U16(u16),
}
#[derive(defmt::Format)]
#[defmt(transparent)]
#[allow(dead_code)]
struct Transparent<T: Foo>(Quux<T>);
#[derive(defmt::Format)]
#[defmt(transparent)]
#[defmt(transparent, crate = defmt4)]
#[defmt(crate = defmt3, crate = defmt2)]
#[allow(dead_code)]
struct Variations<T: Foo>(Quux<T>);
struct Flavor;
trait FlavorT {
type List<'a, T: 'a + ::defmt::Format>: ::defmt::Format;
}
impl FlavorT for Flavor {
type List<'a, T: 'a + ::defmt::Format> = &'a [T];
}
#[derive(defmt::Format)]
#[defmt(bound())] // fixes the compile error from `ui/derive_bound_overflow.rs`
enum Flavored<F: FlavorT + 'static> {
Str(F::List<'static, Self>),
}
const _: () = {
const fn implements_format<T: defmt::Format>() {}
implements_format::<Flavored<Flavor>>();
};
File diff suppressed because it is too large Load Diff
+18
View File
@@ -0,0 +1,18 @@
#[test]
fn ui() {
// Run UI tests with logging enabled
std::env::set_var("DEFMT_LOG", "trace");
// only test error messages on the stable channel (nightly may change too often)
if rustc_version::version_meta()
.map(|meta| meta.channel == rustc_version::Channel::Stable)
.unwrap_or(false)
&& std::env::var_os("SKIP_UI_TESTS").is_none()
{
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/*.rs");
t.pass("tests/basic_usage.rs");
t.pass("tests/derive-bounds.rs");
}
}
@@ -0,0 +1,7 @@
#[derive(defmt::Format)]
struct S {
#[defmt()]
f: bool,
}
fn main() {}
@@ -0,0 +1,5 @@
error: expected 1 attribute argument
--> $DIR/derive-empty-attr.rs:3:7
|
3 | #[defmt()]
| ^^^^^^^
@@ -0,0 +1,7 @@
#[derive(defmt::Format)]
#[defmt(FooBar)]
struct S {
f: bool,
}
fn main() {}
@@ -0,0 +1,5 @@
error: unknown defmt attribute `FooBar`
--> tests/ui/derive-invalid-attr-arg-item.rs:2:9
|
2 | #[defmt(FooBar)]
| ^^^^^^
@@ -0,0 +1,7 @@
#[derive(defmt::Format)]
struct S {
#[defmt(FooBar)]
f: bool,
}
fn main() {}
@@ -0,0 +1,5 @@
error: expected `Debug2Format` or `Display2Format`
--> $DIR/derive-invalid-attr-arg.rs:3:13
|
3 | #[defmt(FooBar)]
| ^^^^^^
@@ -0,0 +1,13 @@
#[derive(defmt::Format)]
#[defmt(crate = unresolved)]
struct S {}
#[derive(defmt::Format)]
#[defmt(crate = "not a path")]
struct S2 {}
#[derive(defmt::Format)]
#[defmt(crate(defmt))]
struct S3 {}
fn main() {}
@@ -0,0 +1,25 @@
error: expected identifier
--> tests/ui/derive-invalid-crate-overwrite.rs:6:17
|
6 | #[defmt(crate = "not a path")]
| ^^^^^^^^^^^^
error: expected `=`
--> tests/ui/derive-invalid-crate-overwrite.rs:10:14
|
10 | #[defmt(crate(defmt))]
| ^
error[E0432]: unresolved import `unresolved`
--> tests/ui/derive-invalid-crate-overwrite.rs:1:10
|
1 | #[derive(defmt::Format)]
| ^^^^^^^^^^^^^ no external crate `unresolved`
|
= note: this error originates in the derive macro `defmt::Format` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: use of undeclared crate or module `unresolved`
--> tests/ui/derive-invalid-crate-overwrite.rs:2:17
|
2 | #[defmt(crate = unresolved)]
| ^^^^^^^^^^ use of undeclared crate or module `unresolved`
@@ -0,0 +1,8 @@
#[derive(defmt::Format)]
struct S {
#[defmt(Debug2Format)]
#[defmt()]
f: bool,
}
fn main() {}
@@ -0,0 +1,7 @@
error: multiple `defmt` attributes not supported
--> $DIR/derive-multi-attr.rs:3:5
|
3 | / #[defmt(Debug2Format)]
4 | | #[defmt()]
5 | | f: bool,
| |___________^
@@ -0,0 +1,16 @@
fn main() {}
#[derive(defmt::Format)]
#[defmt(transparent)]
enum Empty {}
#[derive(defmt::Format)]
#[defmt(transparent)]
struct Unit;
#[derive(defmt::Format)]
#[defmt(transparent)]
enum UnitVariants {
Foo,
Bar,
}
@@ -0,0 +1,29 @@
error: Transparent format can only be applied to structs with one field (got 0)
--> tests/ui/derive-transparent-empty.rs:7:10
|
7 | #[derive(defmt::Format)]
| ^^^^^^^^^^^^^
|
= note: this error originates in the derive macro `defmt::Format` (in Nightly builds, run with -Z macro-backtrace for more info)
error: Transparent format can only be applied when all variants have exactly one field (got 0)
--> tests/ui/derive-transparent-empty.rs:11:10
|
11 | #[derive(defmt::Format)]
| ^^^^^^^^^^^^^
|
= note: this error originates in the derive macro `defmt::Format` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0004]: non-exhaustive patterns: type `&&Empty` is non-empty
--> tests/ui/derive-transparent-empty.rs:3:10
|
3 | #[derive(defmt::Format)]
| ^^^^^^^^^^^^^
|
note: `Empty` defined here
--> tests/ui/derive-transparent-empty.rs:5:6
|
5 | enum Empty {}
| ^^^^^
= note: the matched value is of type `&&Empty`
= note: this error originates in the derive macro `defmt::Format` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -0,0 +1,14 @@
#[derive(defmt::Format)]
#[defmt(transparent)]
enum A {
Invalid { foo: u8, bar: i8 },
}
#[derive(defmt::Format)]
#[defmt(transparent)]
struct Foo {
foo: u8,
bar: i8,
}
fn main() {}
@@ -0,0 +1,13 @@
error: Transparent format can only be applied when all variants have exactly one field (got 2)
--> tests/ui/derive-transparent-multiple-fields.rs:4:13
|
4 | Invalid { foo: u8, bar: i8 },
| ^^^^^^^^^^^^^^^^^^^^
error: Transparent format can only be applied to structs with one field (got 2)
--> tests/ui/derive-transparent-multiple-fields.rs:7:10
|
7 | #[derive(defmt::Format)]
| ^^^^^^^^^^^^^
|
= note: this error originates in the derive macro `defmt::Format` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -0,0 +1,23 @@
struct Flavor;
trait FlavorT {
type List<'a, T: 'a + ::defmt::Format>: ::defmt::Format;
}
impl FlavorT for Flavor {
type List<'a, T: 'a + ::defmt::Format> = &'a [T];
}
#[derive(defmt::Format)]
// #[defmt(bound())] // fixes the compile error
enum Flavored<F: FlavorT + 'static> {
Str(F::List<'static, Self>),
}
const _: () = {
const fn implements_format<T: defmt::Format>() {}
implements_format::<Flavored<Flavor>>(); // overflow by the compiler, can only be fixed by removing the bound
};
fn main() {}
@@ -0,0 +1,32 @@
error[E0275]: overflow evaluating the requirement `<F as FlavorT>::List<'static, Flavored<F>>: Format`
--> tests/ui/derive_bound_overflow.rs:14:9
|
14 | Str(F::List<'static, Self>),
| ^^^^^^^^^^^^^^^^^^^^^^
|
note: required for `Flavored<F>` to implement `Format`
--> tests/ui/derive_bound_overflow.rs:11:10
|
11 | #[derive(defmt::Format)]
| ^^^^^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
12 | // #[defmt(bound())] // fixes the compile error
13 | enum Flavored<F: FlavorT + 'static> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required by a bound in `FlavorT::List`
--> tests/ui/derive_bound_overflow.rs:4:27
|
4 | type List<'a, T: 'a + ::defmt::Format>: ::defmt::Format;
| ^^^^^^^^^^^^^^^ required by this bound in `FlavorT::List`
= note: this error originates in the derive macro `defmt::Format` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0275]: overflow evaluating the requirement `Flavored<Flavor>: Format`
--> tests/ui/derive_bound_overflow.rs:20:5
|
20 | implements_format::<Flavored<Flavor>>(); // overflow by the compiler, can only be fixed by removing the bound
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: required by a bound in `implements_format`
--> tests/ui/derive_bound_overflow.rs:18:35
|
18 | const fn implements_format<T: defmt::Format>() {}
| ^^^^^^^^^^^^^ required by this bound in `implements_format`
@@ -0,0 +1,24 @@
struct Flavor;
trait FlavorT {
type Str;
}
impl FlavorT for Flavor {
type Str = &'static str;
}
#[derive(defmt::Format)]
#[defmt(bound())]
#[defmt(bound(F: Sized))]
enum Flavored<F: FlavorT> {
Str(F::Str),
}
const _: () = {
const fn implements_format<T: defmt::Format>() {}
implements_format::<Flavored<Flavor>>();
};
fn main() {}
@@ -0,0 +1,12 @@
error[E0277]: the trait bound `<F as FlavorT>::Str: Format` is not satisfied
--> tests/ui/derive_removed_bound.rs:11:10
|
11 | #[derive(defmt::Format)]
| ^^^^^^^^^^^^^ the trait `Format` is not implemented for `<F as FlavorT>::Str`
|
note: required by a bound in `defmt::export::fmt`
--> src/export/mod.rs
|
| pub fn fmt<T: Format + ?Sized>(f: &T) {
| ^^^^^^ required by this bound in `fmt`
= note: this error originates in the derive macro `defmt::Format` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -0,0 +1,3 @@
fn main() {
defmt::info!("{=u8:dunno}", 42)
}
@@ -0,0 +1,5 @@
error: unknown display hint: "dunno"
--> $DIR/log-invalid-hint.rs:2:18
|
2 | defmt::info!("{=u8:dunno}", 42)
| ^^^^^^^^^^^^^
@@ -0,0 +1,5 @@
struct Foo;
fn main() {
defmt::info!("{}", Foo)
}
@@ -0,0 +1,22 @@
error[E0277]: the trait bound `Foo: Format` is not satisfied
--> tests/ui/log-missing-format-impl.rs:4:5
|
4 | defmt::info!("{}", Foo)
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Format` is not implemented for `Foo`
|
= help: the following other types implement trait `Format`:
&T
&mut T
()
(T0, T1)
(T0, T1, T2)
(T0, T1, T2, T3)
(T0, T1, T2, T3, T4)
(T0, T1, T2, T3, T4, T5)
and $N others
note: required by a bound in `defmt::export::fmt`
--> src/export/mod.rs
|
| pub fn fmt<T: Format + ?Sized>(f: &T) {
| ^^^^^^ required by this bound in `fmt`
= note: this error originates in the macro `defmt::info` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -0,0 +1,5 @@
#![no_main]
#![no_std]
#[defmt::panic_handler]
fn foo(x: bool) -> ! { info!("{:?}", x); loop {} }
@@ -0,0 +1,5 @@
error: function must have signature `fn() -> !`
--> $DIR/panic-handler-argument.rs:5:4
|
5 | fn foo(x: bool) -> ! { info!("{:?}", x); loop {} }
| ^^^
@@ -0,0 +1,5 @@
#![no_main]
#![no_std]
#[defmt::panic_handler]
fn foo() {}
@@ -0,0 +1,5 @@
error: function must have signature `fn() -> !`
--> $DIR/panic-handler-empty.rs:5:4
|
5 | fn foo() {}
| ^^^
@@ -0,0 +1,8 @@
#![no_main]
#![no_std]
#[defmt::panic_handler]
#[export_name = "hello"]
fn foo() -> ! {
loop {}
}
@@ -0,0 +1,5 @@
error: `#[panic_handler]` attribute cannot be used together with `#[export_name]`
--> tests/ui/panic-handler-export-name.rs:5:1
|
5 | #[export_name = "hello"]
| ^
@@ -0,0 +1,8 @@
#![no_main]
#![no_std]
#[defmt::panic_handler]
#[no_mangle]
fn panic() -> ! {
loop {}
}
@@ -0,0 +1,5 @@
error: `#[panic_handler]` attribute cannot be used together with `#[no_mangle]`
--> tests/ui/panic-handler-no-mangle.rs:5:1
|
5 | #[no_mangle]
| ^
@@ -0,0 +1,9 @@
struct S;
impl defmt::Format for S {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "{=u8:dunno}", 42)
}
}
fn main() {}
@@ -0,0 +1,5 @@
error: unknown display hint: "dunno"
--> $DIR/write-invalid-hint.rs:5:26
|
5 | defmt::write!(f, "{=u8:dunno}", 42)
| ^^^^^^^^^^^^^
+18
View File
@@ -0,0 +1,18 @@
#[test]
fn ui_logs_off() {
// Run UI tests with logging disabled to ensure compiler errors are the same
std::env::set_var("DEFMT_LOG", "off");
// only test error messages on the stable channel (nightly may change too often)
if rustc_version::version_meta()
.map(|meta| meta.channel == rustc_version::Channel::Stable)
.unwrap_or(false)
&& std::env::var_os("SKIP_UI_TESTS").is_none()
{
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/*.rs");
t.pass("tests/basic_usage.rs");
t.pass("tests/derive-bounds.rs");
}
}