- 12 5月, 2021 37 次提交
-
-
由 Aaron Hill 提交于
This PR implements span quoting, allowing proc-macros to produce spans pointing *into their own crate*. This is used by the unstable `proc_macro::quote!` macro, allowing us to get error messages like this: ``` error[E0412]: cannot find type `MissingType` in this scope --> $DIR/auxiliary/span-from-proc-macro.rs:37:20 | LL | pub fn error_from_attribute(_args: TokenStream, _input: TokenStream) -> TokenStream { | ----------------------------------------------------------------------------------- in this expansion of procedural macro `#[error_from_attribute]` ... LL | field: MissingType | ^^^^^^^^^^^ not found in this scope | ::: $DIR/span-from-proc-macro.rs:8:1 | LL | #[error_from_attribute] | ----------------------- in this macro invocation ``` Here, `MissingType` occurs inside the implementation of the proc-macro `#[error_from_attribute]`. Previosuly, this would always result in a span pointing at `#[error_from_attribute]` This will make many proc-macro-related error message much more useful - when a proc-macro generates code containing an error, users will get an error message pointing directly at that code (within the macro definition), instead of always getting a span pointing at the macro invocation site. This is implemented as follows: * When a proc-macro crate is being *compiled*, it causes the `quote!` macro to get run. This saves all of the sapns in the input to `quote!` into the metadata of *the proc-macro-crate* (which we are currently compiling). The `quote!` macro then expands to a call to `proc_macro::Span::recover_proc_macro_span(id)`, where `id` is an opaque identifier for the span in the crate metadata. * When the same proc-macro crate is *run* (e.g. it is loaded from disk and invoked by some consumer crate), the call to `proc_macro::Span::recover_proc_macro_span` causes us to load the span from the proc-macro crate's metadata. The proc-macro then produces a `TokenStream` containing a `Span` pointing into the proc-macro crate itself. The recursive nature of 'quote!' can be difficult to understand at first. The file `src/test/ui/proc-macro/quote-debug.stdout` shows the output of the `quote!` macro, which should make this eaier to understand. This PR also supports custom quoting spans in custom quote macros (e.g. the `quote` crate). All span quoting goes through the `proc_macro::quote_span` method, which can be called by a custom quote macro to perform span quoting. An example of this usage is provided in `src/test/ui/proc-macro/auxiliary/custom-quote.rs` Custom quoting currently has a few limitations: In order to quote a span, we need to generate a call to `proc_macro::Span::recover_proc_macro_span`. However, proc-macros support renaming the `proc_macro` crate, so we can't simply hardcode this path. Previously, the `quote_span` method used the path `crate::Span` - however, this only works when it is called by the builtin `quote!` macro in the same crate. To support being called from arbitrary crates, we need access to the name of the `proc_macro` crate to generate a path. This PR adds an additional argument to `quote_span` to specify the name of the `proc_macro` crate. Howver, this feels kind of hacky, and we may want to change this before stabilizing anything quote-related. Additionally, using `quote_span` currently requires enabling the `proc_macro_internals` feature. The builtin `quote!` macro has an `#[allow_internal_unstable]` attribute, but this won't work for custom quote implementations. This will likely require some additional tricks to apply `allow_internal_unstable` to the span of `proc_macro::Span::recover_proc_macro_span`.
-
由 bors 提交于
updated deps filetime v0.2.12 -> v0.2.14 https://github.com/alexcrichton/filetime/compare/0.2.12...0.2.14 socket2 v0.3.16 -> v0.3.19 https://github.com/rust-lang/socket2/commits/v0.3.x tar v0.4.29 -> v0.4.33 https://github.com/alexcrichton/tar-rs/compare/0.4.29...0.4.33 this drops dependency on redox_syscall 0.1.* --- measureme v9.1.0 -> v9.1.1 https://github.com/rust-lang/measureme/compare/9.1.0...9.1.1 this drops dependency on memmap v0.7.0 --- version_check v0.9.1 -> v0.9.3 https://github.com/SergioBenitez/version_check/compare/v0.9.1...v0.9.3 fixes version parse
-
由 bors 提交于
Rollup of 8 pull requests Successful merges: - #83501 (rustdoc: Add unstable CLI option to show basic type layout information) - #85018 (shrinking the deprecated method span) - #85124 (rustdoc: remove explicit boolean comparisons.) - #85136 (Change param name (k to key and v to value) in std::env module) - #85162 (Fix typo in variable name) - #85187 (Use .name_str() to format primitive types in error messages) - #85191 (Improve rustdoc gui tester) - #85196 (Revert "Auto merge of #84797 - richkadel:cover-unreachable-statements…) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
-
由 Yuki Okushi 提交于
Revert "Auto merge of #84797 - richkadel:cover-unreachable-statements… This reverts commit e5f83d24, reversing changes made to ac888e86. See https://github.com/rust-lang/rust/pull/84797#issuecomment-839068132 r? `@tmandry`
-
由 Yuki Okushi 提交于
Improve rustdoc gui tester I cherry-picked the commit from https://github.com/rust-lang/rust/pull/84834 (and modified it a bit). I also used this opportunity to update it to last version (forgot to update GUI test in https://github.com/rust-lang/rust/pull/85074, really can't wait to make https://github.com/rust-lang/rust/pull/84586 finally work). cc `@Mark-Simulacrum` for the changes in bootstrap. r? `@jsha`
-
由 Yuki Okushi 提交于
Use .name_str() to format primitive types in error messages This pull request fixes #84976. The problem described there is caused by this code https://github.com/rust-lang/rust/blob/506e75cbf8cb5305e49a41326307004ca3976029/compiler/rustc_middle/src/ty/error.rs#L161-L166 using `Debug` formatting (`{:?}`), while the proper solution is to call `name_str()` of `ty::IntTy`, `ty::UintTy` and `ty::FloatTy`, respectively.
-
由 Yuki Okushi 提交于
Fix typo in variable name All other sibling functions call this variable "slot", so "slote" was most likely a typo.
-
由 Yuki Okushi 提交于
Change param name (k to key and v to value) in std::env module 1. When I was reading code the ide displayed `k` and `v`, so I thought it would be better to show key and value? 2. I noticed var method already uses `key` instead of `k` so it is more consistent to use `key` instead of `k`? Thanks
-
由 Yuki Okushi 提交于
rustdoc: remove explicit boolean comparisons. For boolean variables it's shorter and more readable to check the value directly, or negate it with `!`. In a couple of cases I reordered an if/else pair because it made the initial `if` statement simpler. An example of a style guide recommending this: https://airbnb.io/javascript/#comparison--shortcuts r? `@GuillaumeGomez`
-
由 Yuki Okushi 提交于
shrinking the deprecated method span close https://github.com/rust-lang/rust/issues/84637
-
由 Yuki Okushi 提交于
rustdoc: Add unstable CLI option to show basic type layout information Closes #75988. Right now it just shows the size.
-
由 Fabian Wolff 提交于
-
由 Rich Kadel 提交于
This reverts commit e5f83d24, reversing changes made to ac888e86.
-
由 bors 提交于
BTree: no longer copy keys and values before dropping them When dropping BTreeMap or BTreeSet instances, keys-value pairs are up to now each copied and then dropped, at least according to source code. This is because the code for dropping and for iterators is shared. This PR postpones the treatment of doomed key-value pairs from the intermediate functions `deallocating_next`(`_back`) to the last minute, so the we can drop the keys and values in place. According to the library/alloc benchmarks, this does make a difference, (and a positive difference with an `#[inline]` on `drop_key_val`). It does not change anything for #81444 though. r? `@Mark-Simulacrum`
-
由 klensy 提交于
-
由 Guillaume Gomez 提交于
-
由 klensy 提交于
-
由 Guillaume Gomez 提交于
-
由 Guillaume Gomez 提交于
-
由 Jacob Hoffman-Andrews 提交于
For boolean variables it's shorter and more readable to check the value directly, or negate it with `!`. In a couple of cases I reordered an if/else pair because it made the initial `if` statement simpler. Removed unused isType parameter from two functions.
-
由 Camelid 提交于
There are issues with computing layout for type aliases; see #85103. Once the issues are fixed, we should re-enable layout docs for them.
-
由 Camelid 提交于
-
由 Camelid 提交于
This should prevent confusion about why generic types don't have layout docs.
-
由 Camelid 提交于
-
由 Camelid 提交于
-
由 Camelid 提交于
Co-authored-by: NIvan Tham <pickfire@riseup.net>
-
由 Camelid 提交于
-
由 Camelid 提交于
-
由 Camelid 提交于
-
由 Camelid 提交于
-
由 Camelid 提交于
At first you might think "why not just click through to the aliased type?", but if a type alias instantiates all of the generic parameters of the aliased type, then it can show layout info even though the aliased type cannot (because we can't compute the layout of a generic type). So I think it's still useful to show layout info for type aliases.
-
由 Camelid 提交于
-
由 Camelid 提交于
-
由 Camelid 提交于
Layout errors can occur with valid code, e.g. generic types.
-
由 Camelid 提交于
Right now it just shows the size.
-
由 bors 提交于
Improve diagnostics for GATs Fixes https://github.com/rust-lang/rust/issues/81801 Fixes https://github.com/rust-lang/rust/issues/81961 Fixes https://github.com/rust-lang/rust/issues/81862 r? `@estebank`
-
由 Fabian Wolff 提交于
-
- 11 5月, 2021 3 次提交
-
-
由 bors 提交于
array-to-raw-elem cast: test that Retag covers entire array Make sure that we `Retag` *before* doing the `ArrayToPointer` cast.
-
由 b-naber 提交于
-
由 bors 提交于
remove const_fn feature gate Fixes https://github.com/rust-lang/rust/issues/84510 r? `@oli-obk`
-