Skip to content

Commit da7a0c0

Browse files
authored
Rollup merge of rust-lang#106928 - bvanjoi:print-keyword-raw-identifier, r=petrochenkov
add raw identifier for keyword in suggestion fix rust-lang#106841
2 parents 5f2ad80 + 97ae79a commit da7a0c0

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

compiler/rustc_middle/src/ty/print/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ pub trait PrettyPrinter<'tcx>:
393393
match self.tcx().trimmed_def_paths(()).get(&def_id) {
394394
None => Ok((self, false)),
395395
Some(symbol) => {
396-
self.write_str(symbol.as_str())?;
396+
write!(self, "{}", Ident::with_dummy_span(*symbol))?;
397397
Ok((self, true))
398398
}
399399
}

tests/ui/issues/issue-65634-raw-ident-suggestion.stderr renamed to tests/ui/issues/issue-65634-raw-ident-suggestion.edition2015.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
error[E0034]: multiple applicable items in scope
2-
--> $DIR/issue-65634-raw-ident-suggestion.rs:21:13
2+
--> $DIR/issue-65634-raw-ident-suggestion.rs:24:13
33
|
44
LL | r#fn {}.r#struct();
55
| ^^^^^^^^ multiple `r#struct` found
66
|
7-
note: candidate #1 is defined in an impl of the trait `async` for the type `fn`
8-
--> $DIR/issue-65634-raw-ident-suggestion.rs:4:5
7+
note: candidate #1 is defined in an impl of the trait `async` for the type `r#fn`
8+
--> $DIR/issue-65634-raw-ident-suggestion.rs:7:5
99
|
1010
LL | fn r#struct(&self) {
1111
| ^^^^^^^^^^^^^^^^^^
12-
note: candidate #2 is defined in an impl of the trait `await` for the type `fn`
13-
--> $DIR/issue-65634-raw-ident-suggestion.rs:10:5
12+
note: candidate #2 is defined in an impl of the trait `await` for the type `r#fn`
13+
--> $DIR/issue-65634-raw-ident-suggestion.rs:13:5
1414
|
1515
LL | fn r#struct(&self) {
1616
| ^^^^^^^^^^^^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
error[E0034]: multiple applicable items in scope
2+
--> $DIR/issue-65634-raw-ident-suggestion.rs:24:13
3+
|
4+
LL | r#fn {}.r#struct();
5+
| ^^^^^^^^ multiple `r#struct` found
6+
|
7+
note: candidate #1 is defined in an impl of the trait `r#async` for the type `r#fn`
8+
--> $DIR/issue-65634-raw-ident-suggestion.rs:7:5
9+
|
10+
LL | fn r#struct(&self) {
11+
| ^^^^^^^^^^^^^^^^^^
12+
note: candidate #2 is defined in an impl of the trait `r#await` for the type `r#fn`
13+
--> $DIR/issue-65634-raw-ident-suggestion.rs:13:5
14+
|
15+
LL | fn r#struct(&self) {
16+
| ^^^^^^^^^^^^^^^^^^
17+
help: disambiguate the associated function for candidate #1
18+
|
19+
LL | r#async::r#struct(&r#fn {});
20+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
21+
help: disambiguate the associated function for candidate #2
22+
|
23+
LL | r#await::r#struct(&r#fn {});
24+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
25+
26+
error: aborting due to previous error
27+
28+
For more information about this error, try `rustc --explain E0034`.

tests/ui/issues/issue-65634-raw-ident-suggestion.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// revisions: edition2015 edition2018
2+
//[edition2018]edition:2018
3+
14
#![allow(non_camel_case_types)]
25

36
trait r#async {

0 commit comments

Comments
 (0)