diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-07-17 10:41:44 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-17 10:41:44 +0200 |
| commit | 14b6ac4d6d4fde01c3a4cc36023d1a3929729cbe (patch) | |
| tree | 736c784b8f4e9b5c6142e33d360a43962a1dc4e5 /tests/ui/privacy | |
| parent | 08fa97173e70ff5a91ae41420559749c967ce3f7 (diff) | |
| parent | 4a261a15131e5eec10252d5131c8a3c3f89edbf7 (diff) | |
| download | rust-14b6ac4d6d4fde01c3a4cc36023d1a3929729cbe.tar.gz rust-14b6ac4d6d4fde01c3a4cc36023d1a3929729cbe.zip | |
Rollup merge of #143431 - xizheyin:143392, r=compiler-errors
Use relative visibility when noting sealed trait to reduce false positive Fixes rust-lang/rust#143392 I used relative visibility instead of just determining if it's public or not. r? compiler
Diffstat (limited to 'tests/ui/privacy')
| -rw-r--r-- | tests/ui/privacy/sealed-traits/false-sealed-traits-note.rs | 13 | ||||
| -rw-r--r-- | tests/ui/privacy/sealed-traits/false-sealed-traits-note.stderr | 20 |
2 files changed, 33 insertions, 0 deletions
diff --git a/tests/ui/privacy/sealed-traits/false-sealed-traits-note.rs b/tests/ui/privacy/sealed-traits/false-sealed-traits-note.rs new file mode 100644 index 00000000000..13f3065e442 --- /dev/null +++ b/tests/ui/privacy/sealed-traits/false-sealed-traits-note.rs @@ -0,0 +1,13 @@ +// We should not emit sealed traits note, see issue #143392 + +mod inner { + pub trait TraitA {} + + pub trait TraitB: TraitA {} +} + +struct Struct; + +impl inner::TraitB for Struct {} //~ ERROR the trait bound `Struct: TraitA` is not satisfied [E0277] + +fn main(){} diff --git a/tests/ui/privacy/sealed-traits/false-sealed-traits-note.stderr b/tests/ui/privacy/sealed-traits/false-sealed-traits-note.stderr new file mode 100644 index 00000000000..f80d985ad6e --- /dev/null +++ b/tests/ui/privacy/sealed-traits/false-sealed-traits-note.stderr @@ -0,0 +1,20 @@ +error[E0277]: the trait bound `Struct: TraitA` is not satisfied + --> $DIR/false-sealed-traits-note.rs:11:24 + | +LL | impl inner::TraitB for Struct {} + | ^^^^^^ the trait `TraitA` is not implemented for `Struct` + | +help: this trait has no implementations, consider adding one + --> $DIR/false-sealed-traits-note.rs:4:5 + | +LL | pub trait TraitA {} + | ^^^^^^^^^^^^^^^^ +note: required by a bound in `TraitB` + --> $DIR/false-sealed-traits-note.rs:6:23 + | +LL | pub trait TraitB: TraitA {} + | ^^^^^^ required by this bound in `TraitB` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. |
