Logo
Explore Help
Register Sign In
rust-lang/rust
1
0
Fork 0
You've already forked rust
Code Issues Pull Requests Actions 1 Packages Projects Releases Wiki Activity
Files
647f1536d2f50b203ca9a67396225c4f7771e1c8
rust/tests/ui/structs/default-field-values/auxiliary/struct_field_default.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
166 B
Rust
Raw Normal View History

Support x-crate default fields
2024-12-07 03:04:51 +00:00
#![feature(default_field_values)]
pub struct A {
pub a: isize = 42,
}
Detect struct construction with private field in field with default When trying to construct a struct that has a public field of a private type, suggest using `..` if that field has a default value. ``` error[E0603]: struct `Priv1` is private --> $DIR/non-exhaustive-ctor.rs:25:39 | LL | let _ = S { field: (), field1: m::Priv1 {} }; | ------ ^^^^^ private struct | | | while setting this field | note: the struct `Priv1` is defined here --> $DIR/non-exhaustive-ctor.rs:14:4 | LL | struct Priv1 {} | ^^^^^^^^^^^^ help: the field `field1` you're trying to set has a default value, you can use `..` to use it | LL | let _ = S { field: (), .. }; | ~~ ```
2025-01-21 21:07:20 +00:00
struct Priv;
pub struct B {
pub a: Priv = Priv,
}
pub struct C {
pub a: Priv,
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.6 Page: 477ms Template: 4ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API