diff options
| author | bors <bors@rust-lang.org> | 2024-10-01 01:45:35 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-10-01 01:45:35 +0000 |
| commit | f79ef02e4bc87eb6dc8374cd4bde8e86f9695cf9 (patch) | |
| tree | 0767296b123911726dedd2b39929ec16a112a5e7 /tests/rustdoc/intra-doc/field.rs | |
| parent | c87004a1f5be671e3f03f69fb13d8915bdbb6a52 (diff) | |
| parent | e91e01509e1e034a71c545d42410d2ea4f7db89e (diff) | |
| download | rust-f79ef02e4bc87eb6dc8374cd4bde8e86f9695cf9.tar.gz rust-f79ef02e4bc87eb6dc8374cd4bde8e86f9695cf9.zip | |
Auto merge of #130587 - coolreader18:field-variant-doclink-disambig, r=notriddle,jyn514
Add `field@` and `variant@` doc-link disambiguators I'm not sure if this is big enough to need an fcp or not, but this is something I found missing when trying to refer to a field in macro-generated docs, not knowing if a method might be defined as well. Obviously, there are definitely other uses. In the case where it's not disambiguated, methods (and I suppose other associated items in the value namespace) still take priority, which `@jyn514` said was an oversight but I think is probably the desired behavior 99% of the time anyway - shadowing a field with an accessor method is a very common pattern. If fields and methods with the same name started conflicting, it would be a breaking change. Though, to quote them: > jyn: maybe you can break this only if both [the method and the field] are public > jyn: rustc has some future-incompat warning level > jyn: that gets through -A warnings and --cap-lints from cargo That'd be out of scope of this PR, though. Fixes #80283
Diffstat (limited to 'tests/rustdoc/intra-doc/field.rs')
| -rw-r--r-- | tests/rustdoc/intra-doc/field.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/rustdoc/intra-doc/field.rs b/tests/rustdoc/intra-doc/field.rs index ba6b320e560..e98419618e2 100644 --- a/tests/rustdoc/intra-doc/field.rs +++ b/tests/rustdoc/intra-doc/field.rs @@ -1,4 +1,24 @@ //@ has field/index.html '//a[@href="{{channel}}/core/ops/range/struct.Range.html#structfield.start"]' 'start' //@ has field/index.html '//a[@href="{{channel}}/std/io/error/enum.ErrorKind.html#variant.NotFound"]' 'not_found' +//@ has field/index.html '//a[@href="struct.FieldAndMethod.html#structfield.x"]' 'x' +//@ has field/index.html '//a[@href="enum.VariantAndMethod.html#variant.X"]' 'X' //! [start][std::ops::Range::start] //! [not_found][std::io::ErrorKind::NotFound] +//! [x][field@crate::FieldAndMethod::x] +//! [X][variant@crate::VariantAndMethod::X] + +pub struct FieldAndMethod { + pub x: i32, +} + +impl FieldAndMethod { + pub fn x(&self) {} +} + +pub enum VariantAndMethod { + X {}, +} + +impl VariantAndMethod { + fn X() {} +} |
