Skip to content

Commit 19a848d

Browse files
author
Samy Kacimi
committed
normalize use of backticks in compiler messages for librustc_metadata
#60532
1 parent 527dce7 commit 19a848d

15 files changed

+25
-24
lines changed

src/librustc_metadata/creader.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -938,14 +938,14 @@ impl<'a> CrateLoader<'a> {
938938
}
939939
match global_allocator {
940940
Some(Some(other_crate)) => {
941-
self.sess.err(&format!("the #[global_allocator] in {} \
941+
self.sess.err(&format!("the `#[global_allocator]` in {} \
942942
conflicts with this global \
943943
allocator in: {}",
944944
other_crate,
945945
data.root.name));
946946
}
947947
Some(None) => {
948-
self.sess.err(&format!("the #[global_allocator] in this \
948+
self.sess.err(&format!("the `#[global_allocator]` in this \
949949
crate conflicts with global \
950950
allocator in: {}", data.root.name));
951951
}
@@ -971,7 +971,7 @@ impl<'a> CrateLoader<'a> {
971971
if !has_default {
972972
self.sess.err("no global memory allocator found but one is \
973973
required; link to std or \
974-
add #[global_allocator] to a static item \
974+
add `#[global_allocator]` to a static item \
975975
that implements the GlobalAlloc trait.");
976976
}
977977
self.sess.allocator_kind.set(Some(AllocatorKind::DefaultLib));

src/librustc_metadata/error_codes.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ E0454: r##"
77
A link name was given with an empty name. Erroneous code example:
88
99
```ignore (cannot-test-this-because-rustdoc-stops-compile-fail-before-codegen)
10-
#[link(name = "")] extern {} // error: #[link(name = "")] given with empty name
10+
#[link(name = "")] extern {}
11+
// error: `#[link(name = "")]` given with empty name
1112
```
1213
1314
The rust compiler cannot link to an external library if you don't give it its
@@ -61,7 +62,7 @@ A link was used without a name parameter. Erroneous code example:
6162
6263
```ignore (cannot-test-this-because-rustdoc-stops-compile-fail-before-codegen)
6364
#[link(kind = "dylib")] extern {}
64-
// error: #[link(...)] specified without `name = "foo"`
65+
// error: `#[link(...)]` specified without `name = "foo"`
6566
```
6667
6768
Please add the name parameter to allow the rust compiler to find the library

src/librustc_metadata/native_libs.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl ItemLikeVisitor<'tcx> for Collector<'tcx> {
102102
match item.value_str() {
103103
Some(s) => lib.wasm_import_module = Some(s),
104104
None => {
105-
let msg = "must be of the form #[link(wasm_import_module = \"...\")]";
105+
let msg = "must be of the form `#[link(wasm_import_module = \"...\")]`";
106106
self.tcx.sess.span_err(item.span(), msg);
107107
}
108108
}
@@ -117,7 +117,7 @@ impl ItemLikeVisitor<'tcx> for Collector<'tcx> {
117117
let requires_name = kind_specified || lib.wasm_import_module.is_none();
118118
if lib.name.is_none() && requires_name {
119119
struct_span_err!(self.tcx.sess, m.span, E0459,
120-
"#[link(...)] specified without \
120+
"`#[link(...)]` specified without \
121121
`name = \"foo\"`")
122122
.span_label(m.span, "missing `name` argument")
123123
.emit();
@@ -136,7 +136,7 @@ impl Collector<'tcx> {
136136
match span {
137137
Some(span) => {
138138
struct_span_err!(self.tcx.sess, span, E0454,
139-
"#[link(name = \"\")] given with empty name")
139+
"`#[link(name = \"\")]` given with empty name")
140140
.span_label(span, "empty name given")
141141
.emit();
142142
}
@@ -187,7 +187,7 @@ impl Collector<'tcx> {
187187
&format!("an empty renaming target was specified for library `{}`",name));
188188
} else if !any_duplicate {
189189
self.tcx.sess.err(&format!("renaming of the library `{}` was specified, \
190-
however this crate contains no #[link(...)] \
190+
however this crate contains no `#[link(...)]` \
191191
attributes referencing this library.", name));
192192
} else if renames.contains(name) {
193193
self.tcx.sess.err(&format!("multiple renamings were \

src/test/ui/allocator/two-allocators2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// aux-build:system-allocator.rs
22
// no-prefer-dynamic
3-
// error-pattern: the #[global_allocator] in
3+
// error-pattern: the `#[global_allocator]` in
44

55
extern crate system_allocator;
66

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: the #[global_allocator] in this crate conflicts with global allocator in: system_allocator
1+
error: the `#[global_allocator]` in this crate conflicts with global allocator in: system_allocator
22

33
error: aborting due to previous error
44

src/test/ui/allocator/two-allocators3.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// aux-build:system-allocator.rs
22
// aux-build:system-allocator2.rs
33
// no-prefer-dynamic
4-
// error-pattern: the #[global_allocator] in
4+
// error-pattern: the `#[global_allocator]` in
55

66

77
extern crate system_allocator;
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: the #[global_allocator] in system_allocator conflicts with this global allocator in: system_allocator2
1+
error: the `#[global_allocator]` in system_allocator conflicts with this global allocator in: system_allocator2
22

33
error: aborting due to previous error
44

src/test/ui/bad/bad-extern-link-attrs.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error[E0459]: #[link(...)] specified without `name = "foo"`
1+
error[E0459]: `#[link(...)]` specified without `name = "foo"`
22
--> $DIR/bad-extern-link-attrs.rs:1:1
33
|
44
LL | #[link()]
55
| ^^^^^^^^^ missing `name` argument
66

7-
error[E0454]: #[link(name = "")] given with empty name
7+
error[E0454]: `#[link(name = "")]` given with empty name
88
--> $DIR/bad-extern-link-attrs.rs:2:1
99
|
1010
LL | #[link(name = "")]

src/test/ui/empty/empty-linkname.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0454]: #[link(name = "")] given with empty name
1+
error[E0454]: `#[link(name = "")]` given with empty name
22
--> $DIR/empty-linkname.rs:1:1
33
|
44
LL | #[link(name = "")]

src/test/ui/error-codes/E0454.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0454]: #[link(name = "")] given with empty name
1+
error[E0454]: `#[link(name = "")]` given with empty name
22
--> $DIR/E0454.rs:1:1
33
|
44
LL | #[link(name = "")] extern {}

src/test/ui/error-codes/E0458.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | #[link(kind = "wonderful_unicorn")] extern {}
66
| |
77
| unknown kind
88

9-
error[E0459]: #[link(...)] specified without `name = "foo"`
9+
error[E0459]: `#[link(...)]` specified without `name = "foo"`
1010
--> $DIR/E0458.rs:1:1
1111
|
1212
LL | #[link(kind = "wonderful_unicorn")] extern {}

src/test/ui/error-codes/E0459.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0459]: #[link(...)] specified without `name = "foo"`
1+
error[E0459]: `#[link(...)]` specified without `name = "foo"`
22
--> $DIR/E0459.rs:1:1
33
|
44
LL | #[link(kind = "dylib")] extern {}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: no global memory allocator found but one is required; link to std or add #[global_allocator] to a static item that implements the GlobalAlloc trait.
1+
error: no global memory allocator found but one is required; link to std or add `#[global_allocator]` to a static item that implements the GlobalAlloc trait.
22

33
error: aborting due to previous error
44

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: renaming of the library `foo` was specified, however this crate contains no #[link(...)] attributes referencing this library.
1+
error: renaming of the library `foo` was specified, however this crate contains no `#[link(...)]` attributes referencing this library.
22

33
error: aborting due to previous error
44

src/test/ui/wasm-import-module.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
error: must be of the form #[link(wasm_import_module = "...")]
1+
error: must be of the form `#[link(wasm_import_module = "...")]`
22
--> $DIR/wasm-import-module.rs:1:22
33
|
44
LL | #[link(name = "...", wasm_import_module)]
55
| ^^^^^^^^^^^^^^^^^^
66

7-
error: must be of the form #[link(wasm_import_module = "...")]
7+
error: must be of the form `#[link(wasm_import_module = "...")]`
88
--> $DIR/wasm-import-module.rs:4:22
99
|
1010
LL | #[link(name = "...", wasm_import_module(x))]
1111
| ^^^^^^^^^^^^^^^^^^^^^
1212

13-
error: must be of the form #[link(wasm_import_module = "...")]
13+
error: must be of the form `#[link(wasm_import_module = "...")]`
1414
--> $DIR/wasm-import-module.rs:7:22
1515
|
1616
LL | #[link(name = "...", wasm_import_module())]

0 commit comments

Comments
 (0)