Skip to content

Commit ed3300c

Browse files
jstarkshds
andauthored
attributes: fix warnings and test failures (#3399)
Due to a change in the error messages produced by rustc, one of the UI tests for failing compilation of the `#[instrument]` attribute when applied to async functions was failing. This change updates the expected output so that the test passes. Some lint failures and errors in core were also fixed. Co-authored-by: Hayden Stainsby <hds@caffeineconcepts.com>
1 parent c297a37 commit ed3300c

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

tracing-attributes/tests/ui/fail/async_instrument.stderr

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ error[E0308]: mismatched types
1414
--> tests/ui/fail/async_instrument.rs:10:5
1515
|
1616
10 | ""
17-
| ^^- help: try using a conversion method: `.to_string()`
18-
| |
19-
| expected `String`, found `&str`
17+
| ^^ expected `String`, found `&str`
2018
|
2119
note: return type inferred to be `String` here
2220
--> tests/ui/fail/async_instrument.rs:9:31
2321
|
24-
9 | async fn simple_mismatch() -> String {
22+
9 | async fn simple_mismatch() -> String {
2523
| ^^^^^^
24+
help: try using a conversion method
25+
|
26+
10 | "".to_string()
27+
| ++++++++++++
2628

2729
error[E0277]: `(&str,)` doesn't implement `std::fmt::Display`
2830
--> tests/ui/fail/async_instrument.rs:14:57
@@ -76,15 +78,17 @@ error[E0308]: mismatched types
7678
--> tests/ui/fail/async_instrument.rs:35:16
7779
|
7880
35 | return "";
79-
| ^^- help: try using a conversion method: `.to_string()`
80-
| |
81-
| expected `String`, found `&str`
81+
| ^^ expected `String`, found `&str`
8282
|
8383
note: return type inferred to be `String` here
8484
--> tests/ui/fail/async_instrument.rs:33:28
8585
|
8686
33 | async fn early_return() -> String {
8787
| ^^^^^^
88+
help: try using a conversion method
89+
|
90+
35 | return "".to_string();
91+
| ++++++++++++
8892

8993
error[E0308]: mismatched types
9094
--> tests/ui/fail/async_instrument.rs:40:1

tracing-core/src/field.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,8 +1128,10 @@ mod test {
11281128
use crate::metadata::{Kind, Level, Metadata};
11291129

11301130
// Make sure TEST_CALLSITE_* have non-zero size, so they can't be located at the same address.
1131-
struct TestCallsite1();
1132-
static TEST_CALLSITE_1: TestCallsite1 = TestCallsite1();
1131+
struct TestCallsite1 {
1132+
_unused: u8,
1133+
}
1134+
static TEST_CALLSITE_1: TestCallsite1 = TestCallsite1 { _unused: 0 };
11331135
static TEST_META_1: Metadata<'static> = metadata! {
11341136
name: "field_test1",
11351137
target: module_path!(),
@@ -1149,8 +1151,10 @@ mod test {
11491151
}
11501152
}
11511153

1152-
struct TestCallsite2();
1153-
static TEST_CALLSITE_2: TestCallsite2 = TestCallsite2();
1154+
struct TestCallsite2 {
1155+
_unused: u8,
1156+
}
1157+
static TEST_CALLSITE_2: TestCallsite2 = TestCallsite2 { _unused: 0 };
11541158
static TEST_META_2: Metadata<'static> = metadata! {
11551159
name: "field_test2",
11561160
target: module_path!(),
@@ -1238,7 +1242,7 @@ mod test {
12381242

12391243
struct MyVisitor;
12401244
impl Visit for MyVisitor {
1241-
fn record_debug(&mut self, field: &Field, _: &dyn (fmt::Debug)) {
1245+
fn record_debug(&mut self, field: &Field, _: &dyn fmt::Debug) {
12421246
assert_eq!(field.callsite(), TEST_META_1.callsite())
12431247
}
12441248
}
@@ -1257,7 +1261,7 @@ mod test {
12571261

12581262
struct MyVisitor;
12591263
impl Visit for MyVisitor {
1260-
fn record_debug(&mut self, field: &Field, _: &dyn (fmt::Debug)) {
1264+
fn record_debug(&mut self, field: &Field, _: &dyn fmt::Debug) {
12611265
assert_eq!(field.name(), "bar")
12621266
}
12631267
}

0 commit comments

Comments
 (0)