Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Regression test for https://github.com/rust-lang/rust/issues/81447
// Checks that the lint for private fields is prioritized over the self lint.

mod some_module {
pub struct Test<T: ?Sized>(T);
}

use some_module::Test;

struct TestBuilder;

impl TestBuilder {
fn build(self) -> Test {
//~^ ERROR missing generics for struct `Test`
Test(self)
//~^ ERROR cannot initialize a tuple struct which contains private fields
}
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
error[E0107]: missing generics for struct `Test`
--> $DIR/private-tuple-struct-field-self-arg-issue-81447.rs:13:23
|
LL | fn build(self) -> Test {
| ^^^^ expected 1 generic argument
|
note: struct defined here, with 1 generic parameter: `T`
--> $DIR/private-tuple-struct-field-self-arg-issue-81447.rs:5:16
|
LL | pub struct Test<T: ?Sized>(T);
| ^^^^ -
help: add missing generic argument
|
LL | fn build(self) -> Test<T> {
| +++

error[E0423]: cannot initialize a tuple struct which contains private fields
--> $DIR/private-tuple-struct-field-self-arg-issue-81447.rs:15:9
|
LL | Test(self)
| ^^^^
|
= note: a struct named `Test` exists in another namespace
= note: constructor is not visible here due to private fields

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0107, E0423.
For more information about an error, try `rustc --explain E0107`.
Loading