Skip to content

Commit feea133

Browse files
petrochenkovpietroalbini
authored andcommitted
resolve: More precise spans for privacy errors
1 parent 8c65675 commit feea133

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+276
-281
lines changed

src/librustc_resolve/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,7 @@ enum NameBindingKind<'a> {
11701170
}
11711171
}
11721172

1173-
struct PrivacyError<'a>(Span, Name, &'a NameBinding<'a>);
1173+
struct PrivacyError<'a>(Span, Ident, &'a NameBinding<'a>);
11741174

11751175
struct UseError<'a> {
11761176
err: DiagnosticBuilder<'a>,
@@ -4672,9 +4672,11 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
46724672
}
46734673
}
46744674

4675-
for &PrivacyError(span, name, binding) in &self.privacy_errors {
4676-
if !reported_spans.insert(span) { continue }
4677-
span_err!(self.session, span, E0603, "{} `{}` is private", binding.descr(), name);
4675+
for &PrivacyError(dedup_span, ident, binding) in &self.privacy_errors {
4676+
if reported_spans.insert(dedup_span) {
4677+
span_err!(self.session, ident.span, E0603, "{} `{}` is private",
4678+
binding.descr(), ident.name);
4679+
}
46784680
}
46794681
}
46804682

src/librustc_resolve/resolve_imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
275275
return Ok(self.dummy_binding);
276276
}
277277
if !self.is_accessible(binding.vis) {
278-
self.privacy_errors.push(PrivacyError(path_span, ident.name, binding));
278+
self.privacy_errors.push(PrivacyError(path_span, ident, binding));
279279
}
280280
}
281281

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0603]: constant `PRIVATE` is private
2-
--> $DIR/E0603.rs:16:5
2+
--> $DIR/E0603.rs:16:17
33
|
44
LL | SomeModule::PRIVATE; //~ ERROR E0603
5-
| ^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^
66

77
error: aborting due to previous error
88

src/test/ui/error-festival.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ LL | y = 2;
55
| ^ did you mean `x`?
66

77
error[E0603]: constant `FOO` is private
8-
--> $DIR/error-festival.rs:32:5
8+
--> $DIR/error-festival.rs:32:10
99
|
1010
LL | foo::FOO;
11-
| ^^^^^^^^
11+
| ^^^
1212

1313
error[E0368]: binary assignment operation `+=` cannot be applied to type `&str`
1414
--> $DIR/error-festival.rs:22:5

src/test/ui/export-import.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0603]: function `unexported` is private
2-
--> $DIR/export-import.rs:11:5
2+
--> $DIR/export-import.rs:11:8
33
|
44
LL | use m::unexported;
5-
| ^^^^^^^^^^^^^
5+
| ^^^^^^^^^^
66

77
error: aborting due to previous error
88

src/test/ui/export-tag-variant.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0603]: enum `y` is private
2-
--> $DIR/export-tag-variant.rs:17:21
2+
--> $DIR/export-tag-variant.rs:17:26
33
|
44
LL | fn main() { let z = foo::y::y1; } //~ ERROR: enum `y` is private
5-
| ^^^^^^^^^^
5+
| ^
66

77
error: aborting due to previous error
88

src/test/ui/export.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ LL | fn z(y: isize) { log(debug, y); }
2323
| ^^^^^ not found in this scope
2424

2525
error[E0603]: function `z` is private
26-
--> $DIR/export.rs:20:13
26+
--> $DIR/export.rs:20:18
2727
|
2828
LL | fn main() { foo::z(10); } //~ ERROR function `z` is private
29-
| ^^^^^^
29+
| ^
3030

3131
error: aborting due to 5 previous errors
3232

src/test/ui/extern/extern-crate-visibility.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
error[E0603]: extern crate `core` is private
2-
--> $DIR/extern-crate-visibility.rs:16:5
2+
--> $DIR/extern-crate-visibility.rs:16:10
33
|
44
LL | use foo::core::cell; //~ ERROR extern crate `core` is private
5-
| ^^^^^^^^^^^^^^^
5+
| ^^^^
66

77
error[E0603]: extern crate `core` is private
8-
--> $DIR/extern-crate-visibility.rs:19:5
8+
--> $DIR/extern-crate-visibility.rs:19:10
99
|
1010
LL | foo::core::cell::Cell::new(0); //~ ERROR extern crate `core` is private
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
11+
| ^^^^
1212

1313
error: aborting due to 2 previous errors
1414

src/test/ui/hygiene/privacy.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0603]: function `f` is private
2-
--> $DIR/privacy.rs:26:9
2+
--> $DIR/privacy.rs:26:14
33
|
44
LL | foo::f() //~ ERROR `f` is private
5-
| ^^^^^^
5+
| ^
66

77
error: aborting due to previous error
88

src/test/ui/import.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ LL | use foo; //~ ERROR unresolved import `foo` [E0432]
1111
| ^^^ no `foo` in the root
1212

1313
error[E0603]: unresolved item `foo` is private
14-
--> $DIR/import.rs:23:5
14+
--> $DIR/import.rs:23:10
1515
|
1616
LL | zed::foo(); //~ ERROR `foo` is private
17-
| ^^^^^^^^
17+
| ^^^
1818

1919
error: aborting due to 3 previous errors
2020

0 commit comments

Comments
 (0)