88 Commits

Author SHA1 Message Date
Ralf Jung
910a59dfae unsafe keyword docs: emphasize that an unsafe fn in a trait does not get to choose its safety contract 2025-06-06 22:34:10 +02:00
Stuart Cook
30e556e772
Rollup merge of #140197 - ktnlvr:master, r=workingjubilee
Document breaking out of a named code block

Closes #110758.
2025-05-02 22:17:01 +10:00
Stuart Cook
192fbcc83a
Rollup merge of #139608 - Lynnesbian:improve-async-block-docs, r=ibraheemdev
Clarify `async` block behaviour

Adds some documentation for control flow behaviour pertaining to `return` and `?` within `async` blocks. Fixes (or at least improves) #101444.

r? rust-lang/docs
2025-05-02 22:16:59 +10:00
Lynnesbian
360012f41a
Amend language regarding the never type 2025-05-02 13:22:05 +10:00
Artur Roos
175f71750f Simplify docs for breaking out of a named code block 2025-05-01 22:09:07 +03:00
Matthias Krüger
806260e973
Rollup merge of #140216 - t5kd:master, r=tgross35
Document that "extern blocks must be unsafe" in Rust 2024

The [documentation on `extern`](https://doc.rust-lang.org/std/keyword.extern.html) contains the following code sample:
```rust
#[link(name = "my_c_library")]
extern "C" {
    fn my_c_function(x: i32) -> bool;
}
```

Due to #123743, attempting to compile such code with the 2024 edition of Rust fails:
```
error: extern blocks must be unsafe
```

This PR extends the `extern` documentation with a brief explanation of the new requirement. It also adds the missing `unsafe` keyword to the code sample, which should be compatible with rustc since v1.82.

**Related docs:**
- https://doc.rust-lang.org/reference/items/external-blocks.html
- https://doc.rust-lang.org/edition-guide/rust-2024/unsafe-extern.html
2025-04-26 07:13:07 +02:00
Tobias
1862feb0e7 Update extern docs for Rust 2024 and add safety remarks 2025-04-25 23:23:02 +02:00
ismailarilik
49cb451b5d docs(std): mention const blocks in const keyword doc page 2025-04-25 10:17:27 +03:00
Artur Roos
36ae6575fd Document breaking out of a named code block 2025-04-23 14:31:34 +03:00
Lynnesbian
e2caab1822
Doc more control flow behaviour for return keyword 2025-04-10 11:11:09 +10:00
Lynnesbian
a576362620
Document async block control flow in async keyword 2025-04-10 10:58:49 +10:00
Eric Huss
993359e701 Migrate std to Rust 2024 2025-03-11 09:46:34 -07:00
Santiago Pastorino
a68db7e3a8
Add examples in stdlib demonstrating the use syntax 2025-03-06 17:58:34 -03:00
Eric Huss
c1791a1b48 std: Apply missing_unsafe_on_extern 2025-02-13 13:10:27 -08:00
Eric Huss
9e60b0e554 std: Apply unsafe_attr_outside_unsafe 2025-02-13 13:10:27 -08:00
Marijn Schouten
166680c480 Update docs for impl keyword 2025-02-11 08:04:32 +01:00
León Orell Valerian Liehr
9e98d25729
Library: Finalize dyn compatibility renaming 2025-01-22 04:46:55 +01:00
Nicholas Nethercote
121e87bf14 Remove rustc::existing_doc_keyword lint.
`CheckAttrVisitor::check_doc_keyword` checks `#[doc(keyword = "..")]`
attributes to ensure they are on an empty module, and that the value is
a non-empty identifier.

The `rustc::existing_doc_keyword` lint checks these attributes to ensure
that the value is the name of a keyword.

It's silly to have two different checking mechanisms for these
attributes. This commit does the following.
- Changes `check_doc_keyword` to check that the value is the name of a
  keyword (avoiding the need for the identifier check, which removes a
  dependency on `rustc_lexer`).
- Removes the lint.
- Updates tests accordingly.

There is one hack: the `SelfTy` FIXME case used to used to be handled by
disabling the lint, but now is handled with a special case in
`is_doc_keyword`. That hack will go away if/when the FIXME is fixed.

Co-Authored-By: Guillaume Gomez <guillaume1.gomez@gmail.com>
2024-12-17 13:56:10 +11:00
Nicholas Nethercote
f10169c4ec Move doc(keyword = "while").
All the other unconditional keywords are in the alphabetical order, but
`while` is for some reason not.
2024-12-17 13:40:08 +11:00
Kornel
8b43a7ee5d
Document alternatives to static mut 2024-11-18 00:34:06 +00:00
printfn
be984c1889 Update use keyword docs to describe precise capturing 2024-10-18 21:17:08 +00:00
León Orell Valerian Liehr
e08dc0491a
Library: Rename "object safe" to "dyn compatible" 2024-10-09 18:48:29 +02:00
Monadic Cat
f34ff1e05a
Trivial grammar fix in const keyword docs
> `const` items looks remarkably similar to `static` items, [...]

Either this should be written as
> A `const` items looks remarkably similar to a `static` item,

or "looks" should be changed to "look".

I have selected the smaller diff.
2024-08-06 21:59:04 -05:00
John Arundel
a19472a93e Fix doc nits
Many tiny changes to stdlib doc comments to make them consistent (for example
"Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph
breaks, backticks for monospace style, and other minor nits.

https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
2024-07-26 13:26:33 +01:00
Wilfred Hughes
e1e719e1a1 Mention labelled blocks in break docs
`break` doesn't require a loop, so note this in the docs.
This is covered in the linked sections of the rust reference,
but this page implied that `break` is only for loops.
2024-03-15 10:51:57 -07:00
Bruce Mitchener
53245709f6 docs: Add example, reference link for type keyword.
Fixes #114281.
2023-08-21 20:00:43 +07:00
ozkanonur
4e7c14fe9f enable rust_2018_idioms for doctests
Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-05-07 00:12:29 +03:00
Josh Soref
9cb9346005 Spelling library/
* advance
* aligned
* borrowed
* calculate
* debugable
* debuggable
* declarations
* desugaring
* documentation
* enclave
* ignorable
* initialized
* iterator
* kaboom
* monomorphization
* nonexistent
* optimizer
* panicking
* process
* reentrant
* rustonomicon
* the
* uninitialized

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-26 02:10:22 -04:00
KaDiWa
ad2b34d0e3
remove some unneeded imports 2023-04-12 19:27:18 +02:00
Milo Moisson
18f5f0c473
use UpperCamelCase 2023-02-20 23:44:21 +01:00
Milo Moisson
76ac2705a5
docs: wrong naming convention in struct keyword doc 2023-02-20 16:40:46 +01:00
Ralf Jung
c30dcff97a review feedback 2022-10-07 15:21:47 +02:00
Ralf Jung
595e192274 unsafe keyword: trait examples and unsafe_op_in_unsafe_fn update 2022-09-29 16:03:07 +02:00
Dezhi Wu
b1430fb7ca Fix a bunch of typo
This PR will fix some typos detected by [typos].

I only picked the ones I was sure were spelling errors to fix, mostly in
the comments.

[typos]: https://github.com/crate-ci/typos
2022-08-31 18:24:55 +08:00
Yuki Okushi
6ac93185f4
Rollup merge of #98169 - pierwill:dyn-disp, r=JohnTitor
Keyword docs: Link to wikipedia article for dynamic dispatch
2022-06-17 07:16:58 +09:00
pierwill
dd0f5d8be0 Keyword docs: Link to wikipedia article for dynamic dispatch 2022-06-16 09:58:57 -05:00
Takayuki Maeda
ba41d4c855 remove an unnecessary space in doc 2022-06-13 09:51:13 +09:00
Jack Huey
410dcc9674 Fully stabilize NLL 2022-06-03 17:16:41 -04:00
Michael Howell
1d19462a45 Fix weird indentation in continue_keyword docs
This format was causing every line in the code examples to have a space
at the start.
2022-05-24 11:10:56 -07:00
Dylan DPC
463e516b0c
Rollup merge of #93692 - mfrw:mfrw/document-keyword-in, r=dtolnay
keyword_docs: document use of `in` with `pub` keyword

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>

Fixes: #93609
2022-03-19 02:02:02 +01:00
T-O-R-U-S
72a25d05bf Use implicit capture syntax in format_args
This updates the standard library's documentation to use the new syntax. The
documentation is worthwhile to update as it should be more idiomatic
(particularly for features like this, which are nice for users to get acquainted
with). The general codebase is likely more hassle than benefit to update: it'll
hurt git blame, and generally updates can be done by folks updating the code if
(and when) that makes things more readable with the new format.

A few places in the compiler and library code are updated (mostly just due to
already having been done when this commit was first authored).
2022-03-10 10:23:40 -05:00
Matthias Krüger
12705b4700
Rollup merge of #91192 - r00ster91:futuredocs, r=GuillaumeGomez
Some improvements to the async docs

The goal here is to make the docs overall a little bit more comprehensive and add more links between the things.

One thing that's not working yet is the links to the keywords. Somehow I couldn't get them to work.

r? ````@GuillaumeGomez```` do you know how I could get the keyword links to work?
2022-02-21 19:36:46 +01:00
r00ster91
297364eb07 Some improvements to the async docs 2022-02-19 17:17:40 +01:00
Muhammad Falak R Wani
6706ab8cfb
keyword_docs: document use of in with pub keyword
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
2022-02-06 11:23:02 +05:30
Lucas Kent
08829853d3 eplace usages of vec![].into_iter with [].into_iter 2022-01-09 14:09:25 +11:00
Cameron Steffen
9c83f8c4d1 Simplify for loop desugar 2021-11-21 08:15:21 -06:00
Eric Huss
9be22db5e1 Update books 2021-11-09 19:11:01 -08:00
tatami4
a452d02636
Fix typo in break docs 2021-09-16 14:51:14 +03:00
Frank Steffahn
5135d86920 Mention usage of const in raw pointer types at the top of the keyword's documentation page. 2021-09-05 19:14:55 +02:00
Frank Steffahn
2f9ddf3bc7 Fix typos “an”→“a” and a few different ones that appeared in the same search 2021-08-22 18:15:49 +02:00