Skip to content

Commit 1d9bb5e

Browse files
committed
Fixed test and moved it into right directory
1 parent fc24def commit 1d9bb5e

File tree

6 files changed

+37
-19
lines changed

6 files changed

+37
-19
lines changed

compiler/rustc_hir_typeck/messages.ftl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@ hir_typeck_no_associated_item = no {$item_kind} named `{$item_ident}` found for
153153
*[other] {" "}in the current scope
154154
}
155155
156+
hir_typeck_expr_rarrow_call = `->` used for field access or method call
157+
.suggestion = try using `.` instead
158+
.help = the `.` operator will automatically dereference the value, except if the value is a raw pointer
159+
160+
hir_typeck_expr_rarrow_call_on_a_raw_ptr = `->` used for field access or method call
161+
.suggestion = try using `.` on a manually dereferenced value
162+
.help = the value is a raw pointer, derefence it with `*` first
163+
156164
hir_typeck_no_field_on_type = no field `{$field}` on type `{$ty}`
157165
158166
hir_typeck_no_field_on_variant = no field named `{$field}` on enum variant `{$container}::{$ident}`

compiler/rustc_parse/messages.ftl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,6 @@ parse_expected_struct_field = expected one of `,`, `:`, or `{"}"}`, found `{$tok
246246
247247
parse_expected_trait_in_trait_impl_found_type = expected a trait, found type
248248
249-
parse_expr_rarrow_call = `->` used for field access or method call
250-
.suggestion = try using `.` instead
251-
.help = the `.` operator will automatically dereference the value, except if the value is a raw pointer
252-
253249
parse_extern_crate_name_with_dashes = crate name using dashes are not valid in `extern crate` statements
254250
.label = dash-separated idents are not valid
255251
.suggestion = if the original crate name uses dashes you need to use underscores in the code

compiler/rustc_parse/src/errors.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3333,7 +3333,6 @@ pub(crate) struct AsyncImpl {
33333333
#[help]
33343334
pub(crate) struct ExprRArrowCall {
33353335
#[primary_span]
3336-
#[suggestion(style = "verbose", applicability = "machine-applicable", code = ".")]
33373336
pub span: Span,
33383337
}
33393338

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//@ run-rustfix
2+
#![allow(
3+
dead_code,
4+
unused_must_use
5+
)]
6+
7+
struct Named {
8+
foo: usize,
9+
}
10+
11+
struct Unnamed(usize);
12+
13+
unsafe fn named_struct_field_access(named: *mut Named) {
14+
(*named).foo += 1; //~ ERROR `->` used for field access or method call
15+
//~^ ERROR no field `foo` on type `*mut Named`
16+
}
17+
18+
unsafe fn unnamed_struct_field_access(unnamed: *mut Unnamed) {
19+
(*unnamed).0 += 1; //~ ERROR `->` used for field access or method call
20+
//~^ ERROR no field `0` on type `*mut Unnamed`
21+
}
22+
23+
fn main() {}

tests/ui/suggestions/expr-rarrow-call-on-a-raw-pointer.rs renamed to tests/ui/parser/expr-rarrow-call-on-a-raw-pointer.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ struct Named {
1010

1111
struct Unnamed(usize);
1212

13-
fn named_struct_field_access(named: *mut Named) {
13+
unsafe fn named_struct_field_access(named: *mut Named) {
1414
named->foo += 1; //~ ERROR `->` used for field access or method call
15+
//~^ ERROR no field `foo` on type `*mut Named`
1516
}
1617

17-
fn unnamed_struct_field_access(unnamed: *mut Unnamed) {
18+
unsafe fn unnamed_struct_field_access(unnamed: *mut Unnamed) {
1819
unnamed->0 += 1; //~ ERROR `->` used for field access or method call
20+
//~^ ERROR no field `0` on type `*mut Unnamed`
1921
}
2022

2123
fn main() {}

tests/ui/suggestions/expr-rarrow-call-on-a-raw-pointer.stderr renamed to tests/ui/parser/expr-rarrow-call-on-a-raw-pointer.stderr

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,14 @@ LL | named->foo += 1;
55
| ^^
66
|
77
= help: the `.` operator will automatically dereference the value, except if the value is a raw pointer
8-
help: try using `.` instead
9-
|
10-
LL - named->foo += 1;
11-
LL + named.foo += 1;
12-
|
138

149
error: `->` used for field access or method call
15-
--> $DIR/expr-rarrow-call-on-a-raw-pointer.rs:18:12
10+
--> $DIR/expr-rarrow-call-on-a-raw-pointer.rs:19:12
1611
|
1712
LL | unnamed->0 += 1;
1813
| ^^
1914
|
2015
= help: the `.` operator will automatically dereference the value, except if the value is a raw pointer
21-
help: try using `.` instead
22-
|
23-
LL - unnamed->0 += 1;
24-
LL + unnamed.0 += 1;
25-
|
2616

2717
error[E0609]: no field `foo` on type `*mut Named`
2818
--> $DIR/expr-rarrow-call-on-a-raw-pointer.rs:14:12
@@ -37,7 +27,7 @@ LL + (*named).foo += 1;
3727
|
3828

3929
error[E0609]: no field `0` on type `*mut Unnamed`
40-
--> $DIR/expr-rarrow-call-on-a-raw-pointer.rs:18:14
30+
--> $DIR/expr-rarrow-call-on-a-raw-pointer.rs:19:14
4131
|
4232
LL | unnamed->0 += 1;
4333
| ^ unknown field

0 commit comments

Comments
 (0)