diff options
| author | bors <bors@rust-lang.org> | 2025-02-11 10:17:02 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-02-11 10:17:02 +0000 |
| commit | 69482e8e5a5fa1441615b015ac2f59178d944696 (patch) | |
| tree | 5e5c68d395b54b36c7ffbe01aaf5ad71dafdc5d1 /compiler/rustc_builtin_macros/src | |
| parent | c182ce9cbc8c29ebc1b4559d027df545e6cdd287 (diff) | |
| parent | 21303103c3eef60e027630cd2aea5f54f868c734 (diff) | |
| download | rust-69482e8e5a5fa1441615b015ac2f59178d944696.tar.gz rust-69482e8e5a5fa1441615b015ac2f59178d944696.zip | |
Auto merge of #136851 - jhpratt:rollup-ftijn95, r=jhpratt
Rollup of 11 pull requests Successful merges: - #136606 (Fix long lines which rustfmt fails to format) - #136663 (Stabilize `NonZero::count_ones`) - #136672 (library: doc: core::alloc::Allocator: trivial typo fix) - #136704 (Improve examples for file locking) - #136721 (cg_llvm: Reduce visibility of some items outside the `llvm` module) - #136813 (rustc_target: Add the fp16 target feature for AArch32) - #136830 (fix i686-unknown-hurd-gnu x87 footnote) - #136832 (Fix platform support table for i686-unknown-uefi) - #136835 (Stop using span hack for contracts feature gating) - #136837 (Overhaul how contracts are lowered on fn-like bodies) - #136839 (fix ensure_monomorphic_enough) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_builtin_macros/src')
| -rw-r--r-- | compiler/rustc_builtin_macros/src/contracts.rs | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/compiler/rustc_builtin_macros/src/contracts.rs b/compiler/rustc_builtin_macros/src/contracts.rs index 85a30f7bdc9..6a24af361fe 100644 --- a/compiler/rustc_builtin_macros/src/contracts.rs +++ b/compiler/rustc_builtin_macros/src/contracts.rs @@ -1,11 +1,9 @@ -#![allow(unused_imports, unused_variables)] - use rustc_ast::token; use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree}; use rustc_errors::ErrorGuaranteed; use rustc_expand::base::{AttrProcMacro, ExtCtxt}; use rustc_span::Span; -use rustc_span::symbol::{Ident, Symbol, kw, sym}; +use rustc_span::symbol::{Ident, Symbol, kw}; pub(crate) struct ExpandRequires; @@ -121,23 +119,19 @@ fn expand_contract_clause( } } - // Record the span as a contract attribute expansion. - // This is used later to stop users from using the extended syntax directly - // which is gated via `contracts_internals`. - ecx.psess().contract_attribute_spans.push(attr_span); - Ok(new_tts) } fn expand_requires_tts( - _ecx: &mut ExtCtxt<'_>, + ecx: &mut ExtCtxt<'_>, attr_span: Span, annotation: TokenStream, annotated: TokenStream, ) -> Result<TokenStream, ErrorGuaranteed> { - expand_contract_clause(_ecx, attr_span, annotated, |new_tts| { + let feature_span = ecx.with_def_site_ctxt(attr_span); + expand_contract_clause(ecx, attr_span, annotated, |new_tts| { new_tts.push_tree(TokenTree::Token( - token::Token::from_ast_ident(Ident::new(kw::ContractRequires, attr_span)), + token::Token::from_ast_ident(Ident::new(kw::ContractRequires, feature_span)), Spacing::Joint, )); new_tts.push_tree(TokenTree::Token( @@ -155,14 +149,15 @@ fn expand_requires_tts( } fn expand_ensures_tts( - _ecx: &mut ExtCtxt<'_>, + ecx: &mut ExtCtxt<'_>, attr_span: Span, annotation: TokenStream, annotated: TokenStream, ) -> Result<TokenStream, ErrorGuaranteed> { - expand_contract_clause(_ecx, attr_span, annotated, |new_tts| { + let feature_span = ecx.with_def_site_ctxt(attr_span); + expand_contract_clause(ecx, attr_span, annotated, |new_tts| { new_tts.push_tree(TokenTree::Token( - token::Token::from_ast_ident(Ident::new(kw::ContractEnsures, attr_span)), + token::Token::from_ast_ident(Ident::new(kw::ContractEnsures, feature_span)), Spacing::Joint, )); new_tts.push_tree(TokenTree::Delimited( |
