about summary refs log tree commit diff
path: root/compiler/rustc_span/src/symbol.rs
AgeCommit message (Collapse)AuthorLines
2023-12-19Desugar for await loopsEric Holk-0/+2
2023-12-19Plumb awaitness of for loopsEric Holk-0/+1
2023-12-11Auto merge of #117758 - Urgau:lint_pointer_trait_comparisons, r=davidtwcobors-0/+2
Add lint against ambiguous wide pointer comparisons This PR is the resolution of https://github.com/rust-lang/rust/issues/106447 decided in https://github.com/rust-lang/rust/issues/117717 by T-lang. ## `ambiguous_wide_pointer_comparisons` *warn-by-default* The `ambiguous_wide_pointer_comparisons` lint checks comparison of `*const/*mut ?Sized` as the operands. ### Example ```rust let ab = (A, B); let a = &ab.0 as *const dyn T; let b = &ab.1 as *const dyn T; let _ = a == b; ``` ### Explanation The comparison includes metadata which may not be expected. ------- This PR also drops `clippy::vtable_address_comparisons` which is superseded by this one. ~~One thing: is the current naming right? `invalid` seems a bit too much.~~ Fixes https://github.com/rust-lang/rust/issues/117717
2023-12-10Remove edition umbrella features.Eric Huss-3/+0
2023-12-10Auto merge of #116952 - compiler-errors:lifetime_capture_rules_2024, r=TaKO8Kibors-0/+1
Implement 2024-edition lifetime capture rules RFC Implements rust-lang/rfcs#3498.
2023-12-09Add simd_masked_{load,store} platform-intrinsicsJakub Okoński-0/+2
This maps to the LLVM intrinsics: llvm.masked.load and llvm.masked.store
2023-12-08Implement `async gen` blocksMichael Goulet-0/+5
2023-12-06Rollup merge of #118660 - cuviper:alloc_str, r=petrochenkovMatthias Krüger-5/+1
rustc_arena: add `alloc_str` Two places called `from_utf8_unchecked` for strings from `alloc_slice`, and one's SAFETY comment said this was for lack of `alloc_str` -- so let's just add that instead!
2023-12-06Auto merge of #118679 - matthiaskrgr:rollup-zr1l9w6, r=matthiaskrgrbors-0/+2
Rollup of 7 pull requests Successful merges: - #116496 (Provide context when `?` can't be called because of `Result<_, E>`) - #117563 (docs: clarify explicitly freeing heap allocated memory) - #117874 (`riscv32` platform support) - #118516 (Add ADT variant infomation to StableMIR and finish implementing TyKind::internal()) - #118650 (add comment about keeping flags in sync between bootstrap.py and bootstrap.rs) - #118664 (docs: remove #110800 from release notes) - #118669 (library: fix comment about const assert in win api) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-05rustc_arena: add `alloc_str`Josh Stone-5/+1
Two places called `from_utf8_unchecked` for strings from `alloc_slice`, and one's SAFETY comment said this was for lack of `alloc_str` -- so let's just add that instead!
2023-12-05Detect incorrect `;` in `Option::ok_or_else` and `Result::map_err`Esteban Küber-0/+2
Fix #72124.
2023-12-05Add lifetime_capture_rules_2024Michael Goulet-0/+1
2023-12-05Remove `#[rustc_host]`, use internal desugaringDeadbeef-1/+0
2023-12-02Add diagnostic item to PartialEq::{eq,ne}Urgau-0/+2
2023-12-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-1/+1
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug` follows the pattern used everywhere else: `span_err`, `span_warning`, etc.
2023-11-30Enable link-arg link kind inside of #[link] attributezetanumbers-0/+1
- Implement link-arg as an attribute - Apply suggestions from review - Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com> - Add unstable book entry
2023-11-29rustc_span: Remove unused symbols.Alona Enraght-Moony-27/+0
2023-11-29Add `never_patterns` feature gateNadrieril-0/+1
2023-11-23Add an experimental feature gate for function delegationVadim Petrochenkov-0/+1
In accordance with the [process](https://github.com/rust-lang/lang-team/blob/master/src/how_to/experiment.md). Detailed description of the feature can be found in the RFC repo - https://github.com/rust-lang/rfcs/pull/3530.
2023-11-22Replace `no_ord_impl` with `orderable`.Nicholas Nethercote-0/+1
Similar to the previous commit, this replaces `newtype_index`'s opt-out `no_ord_impl` attribute with the opt-in `orderable` attribute.
2023-11-16Remove option_payload_ptr; redundant to offset_ofGeorge Bateman-1/+0
2023-11-14Custom MIR: Support cleanup blocksTomasz Miąsko-0/+34
Cleanup blocks are declared with `bb (cleanup) = { ... }`. `Call` and `Drop` terminators take an additional argument describing the unwind action, which is one of the following: * `UnwindContinue()` * `UnwindUnreachable()` * `UnwindTerminate(reason)`, where reason is `ReasonAbi` or `ReasonInCleanup` * `UnwindCleanup(block)` Also support unwind resume and unwind terminate terminators: * `UnwindResume()` * `UnwindTerminate(reason)`
2023-11-07Auto merge of #117297 - clubby789:fn-trait-missing-paren, r=TaKO8Kibors-0/+3
Give a better diagnostic for missing parens in Fn* bounds Fixes #108109 It would be nice to try and recover here, but I'm not sure it's worth the effort, especially as the bounds on the recovered function would be incorrect.
2023-11-05Auto merge of #117537 - GKFX:offset-of-enum-feature, r=cjgillotbors-0/+1
Feature gate enums in offset_of As requested at https://github.com/rust-lang/rust/issues/106655#issuecomment-1790815262, put enums in offset_of behind their own feature gate. `@rustbot` label F-offset_of
2023-11-03Auto merge of #117507 - nnethercote:rustc_span, r=Nilstriebbors-3/+3
`rustc_span` cleanups Just some things I found while looking over this crate. r? `@oli-obk`
2023-11-03Feature gate enums in offset_ofGeorge Bateman-0/+1
2023-11-03Auto merge of #116439 - compiler-errors:on-unimplemented, r=davidtwcobors-0/+1
Pretty print `Fn` traits in `rustc_on_unimplemented` I don't think that users really ever should need to think about `Fn*` traits' tupled args for a simple trait error. r? diagnostics
2023-11-02Pretty print Fn traits in rustc_on_unimplementedMichael Goulet-0/+1
2023-11-03Use `FxIndexSet` in the symbol interner.Nicholas Nethercote-20/+11
It makes the code a little nicer. As part of this, the interner's `Default` impl is removed and `prefill` is used in a test instead.
2023-11-02Add a couple of clarifying comments.Nicholas Nethercote-3/+3
2023-11-01Give a better diagnostic for missing parens in Fn* boundsclubby789-0/+3
2023-10-29Auto merge of #116447 - oli-obk:gen_fn, r=compiler-errorsbors-2/+7
Implement `gen` blocks in the 2024 edition Coroutines tracking issue https://github.com/rust-lang/rust/issues/43122 `gen` block tracking issue https://github.com/rust-lang/rust/issues/117078 This PR implements `gen` blocks that implement `Iterator`. Most of the logic with `async` blocks is shared, and thus I renamed various types that were referring to `async` specifically. An example usage of `gen` blocks is ```rust fn foo() -> impl Iterator<Item = i32> { gen { yield 42; for i in 5..18 { if i.is_even() { continue } yield i * 2; } } } ``` The limitations (to be resolved) of the implementation are listed in the tracking issue
2023-10-27Feature gate `gen` blocks, even in 2024 editionOli Scherer-0/+2
2023-10-27Make `gen` blocks implement the `Iterator` traitOli Scherer-0/+1
2023-10-26Pre-intern a symbol for env!("CFG_RELEASE")David Tolnay-0/+1
2023-10-26Reserve `gen` keyword for `gen {}` blocks and `gen fn` in 2024 editionOli Scherer-2/+4
2023-10-25Make `Iterator` a lang itemOli Scherer-0/+1
2023-10-24Rollup merge of #116943 - heiher:target-features, r=wesleywiserMatthias Krüger-0/+1
Add target features for LoongArch
2023-10-24compiler: Add target features for LoongArchWANG Rui-0/+1
2023-10-23Let's see what those opaque types actually areMichael Goulet-0/+1
2023-10-20Re-add `generators` as a removed feature and point to the new feature nameOli Scherer-0/+2
2023-10-20s/generator/coroutine/Oli Scherer-4/+4
2023-10-16debug Span::ctxt() call detectionArthur Lafrance-1/+1
2023-10-16basic lint v2 implementedArthur Lafrance-1/+1
2023-10-16implement the basics of the lint static analysisArthur Lafrance-0/+1
2023-10-08rustdoc: remove rust logo from non-Rust cratesMichael Howell-0/+1
2023-10-05Add more diagnostic items for clippyJason Newcomb-0/+49
2023-10-01Auto merge of #115670 - Zoxc:outline-panic-macro-1, r=Mark-Simulacrumbors-1/+1
Partially outline code inside the panic! macro This outlines code inside the panic! macro in some cases. This is split out from https://github.com/rust-lang/rust/pull/115562 to exclude changes to rustc.
2023-09-18Prototype using const generic for simd_shuffle IDX arrayOli Scherer-0/+1
2023-09-16Auto merge of #110800 - GuillaumeGomez:custom_code_classes_in_docs, r=t-rustdocbors-0/+1
Accept additional user-defined syntax classes in fenced code blocks Part of #79483. This is a re-opening of https://github.com/rust-lang/rust/pull/79454 after a big update/cleanup. I also converted the syntax to pandoc as suggested by `@notriddle:` the idea is to be as compatible as possible with the existing instead of having our own syntax. ## Motivation From the original issue: https://github.com/rust-lang/rust/issues/78917 > The technique used by `inline-c-rs` can be ported to other languages. It's just super fun to see C code inside Rust documentation that is also tested by `cargo doc`. I'm sure this technique can be used by other languages in the future. Having custom CSS classes for syntax highlighting will allow tools like `highlight.js` to be used in order to provide highlighting for languages other than Rust while not increasing technical burden on rustdoc. ## What is the feature about? In short, this PR changes two things, both related to codeblocks in doc comments in Rust documentation: * Allow to disable generation of `language-*` CSS classes with the `custom` attribute. * Add your own CSS classes to a code block so that you can use other tools to highlight them. #### The `custom` attribute Let's start with the new `custom` attribute: it will disable the generation of the `language-*` CSS class on the generated HTML code block. For example: ```rust /// ```custom,c /// int main(void) { /// return 0; /// } /// ``` ``` The generated HTML code block will not have `class="language-c"` because the `custom` attribute has been set. The `custom` attribute becomes especially useful with the other thing added by this feature: adding your own CSS classes. #### Adding your own CSS classes The second part of this feature is to allow users to add CSS classes themselves so that they can then add a JS library which will do it (like `highlight.js` or `prism.js`), allowing to support highlighting for other languages than Rust without increasing burden on rustdoc. To disable the automatic `language-*` CSS class generation, you need to use the `custom` attribute as well. This allow users to write the following: ```rust /// Some code block with `{class=language-c}` as the language string. /// /// ```custom,{class=language-c} /// int main(void) { /// return 0; /// } /// ``` fn main() {} ``` This will notably produce the following HTML: ```html <pre class="language-c"> int main(void) { return 0; }</pre> ``` Instead of: ```html <pre class="rust rust-example-rendered"> <span class="ident">int</span> <span class="ident">main</span>(<span class="ident">void</span>) { <span class="kw">return</span> <span class="number">0</span>; } </pre> ``` To be noted, we could have written `{.language-c}` to achieve the same result. `.` and `class=` have the same effect. One last syntax point: content between parens (`(like this)`) is now considered as comment and is not taken into account at all. In addition to this, I added an `unknown` field into `LangString` (the parsed code block "attribute") because of cases like this: ```rust /// ```custom,class:language-c /// main; /// ``` pub fn foo() {} ``` Without this `unknown` field, it would generate in the DOM: `<pre class="language-class:language-c language-c">`, which is quite bad. So instead, it now stores all unknown tags into the `unknown` field and use the first one as "language". So in this case, since there is no unknown tag, it'll simply generate `<pre class="language-c">`. I added tests to cover this. Finally, I added a parser for the codeblock attributes to make it much easier to maintain. It'll be pretty easy to extend. As to why this syntax for adding attributes was picked: it's [Pandoc's syntax](https://pandoc.org/MANUAL.html#extension-fenced_code_attributes). Even if it seems clunkier in some cases, it's extensible, and most third-party Markdown renderers are smart enough to ignore Pandoc's brace-delimited attributes (from [this comment](https://github.com/rust-lang/rust/pull/110800#issuecomment-1522044456)). ## Raised concerns #### It's not obvious when the `language-*` attribute generation will be added or not. It is added by default. If you want to disable it, you will need to use the `custom` attribute. #### Why not using HTML in markdown directly then? Code examples in most languages are likely to contain `<`, `>`, `&` and `"` characters. These characters [require escaping](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre) when written inside the `<pre>` element. Using the \`\`\` code blocks allows rustdoc to take care of escaping, which means doc authors can paste code samples directly without manually converting them to HTML. cc `@poliorcetics` r? `@notriddle`