Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ff697c6
On macOS, make strip="symbols" not pass any options to strip
joshtriplett Aug 18, 2021
142f6c0
Implement #[link_ordinal] attribute in the context of #[link(kind = "…
ricobbe Sep 11, 2021
fa23d4f
Implement #85440
smoelius Sep 18, 2021
a6738c7
Add tests
smoelius Sep 19, 2021
4be574e
Add 'core::array::from_fn' and 'core::array::try_from_fn'
c410-f3r Sep 30, 2021
fdccc7d
Use reference instead of raw pointer
c410-f3r Sep 30, 2021
325025e
Improve previous commit
steffahn Sep 30, 2021
13bfcb7
Merge pull request #2 from steffahn/collect_into_array_fix_ub
c410-f3r Sep 30, 2021
355c7e9
Remove an unnecessary use of unwrap_unchecked
steffahn Sep 30, 2021
32b6ac5
Check `allow_unstable` before checking environment variables
smoelius Sep 30, 2021
91ad91e
Skip platforms without unwinding support
c410-f3r Oct 3, 2021
e16e15f
Add documentation
smoelius Oct 4, 2021
ecf4741
Add tracking issue
smoelius Oct 6, 2021
c3dfda0
Rebase Result::map_or_else doc wording on top of #89400.
orlp Sep 9, 2021
ce21756
Access Session while decoding expn_id.
cjgillot Oct 2, 2021
daf8903
Do not re-hash foreign spans.
cjgillot Oct 2, 2021
4028b09
Do not ICE if some foreign expansions were not encoded.
cjgillot Oct 2, 2021
a17193d
Enable AutoFDO.
May 7, 2021
afe5335
Use correct edition for panic in [debug_]assert!() etc.
m-ou-se Oct 7, 2021
fcd9fa9
Add tests for panic and [debug_]assert in Rust 2021.
m-ou-se Oct 7, 2021
6162fc0
Add wrapper for -Z gcc-ld=lld to invoke rust-lld with the correct flavor
hkratz Sep 25, 2021
01073dc
Rollup merge of #75644 - c410-f3r:array, r=yaahc
Manishearth Oct 8, 2021
6e14116
Rollup merge of #87918 - mikebenfield:pr-afdo, r=nikic
Manishearth Oct 8, 2021
ed501a9
Rollup merge of #88137 - joshtriplett:osx-strip-symbols-no-option, r=…
Manishearth Oct 8, 2021
837a032
Rollup merge of #88772 - orlp:result-map-or-else-docfix, r=yaahc
Manishearth Oct 8, 2021
c478bc0
Rollup merge of #89025 - ricobbe:raw-dylib-link-ordinal, r=michaelwoe…
Manishearth Oct 8, 2021
8f254a7
Rollup merge of #89082 - smoelius:master, r=kennytm
Manishearth Oct 8, 2021
30fa4ad
Rollup merge of #89288 - rusticstuff:lld_wrapper, r=Mark-Simulacrum
Manishearth Oct 8, 2021
8437cef
Rollup merge of #89476 - cjgillot:expn-id, r=petrochenkov
Manishearth Oct 8, 2021
414ca04
Rollup merge of #89622 - m-ou-se:debug-assert-2021, r=estebank
Manishearth Oct 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use correct edition for panic in [debug_]assert!() etc.
  • Loading branch information
m-ou-se committed Oct 7, 2021
commit afe5335b978bc490f27d45a42bac770383450268
6 changes: 3 additions & 3 deletions compiler/rustc_builtin_macros/src/assert.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use rustc_errors::{Applicability, DiagnosticBuilder};

use crate::panic::use_panic_2021;
use rustc_ast::ptr::P;
use rustc_ast::token;
use rustc_ast::tokenstream::{DelimSpan, TokenStream};
use rustc_ast::{self as ast, *};
use rustc_ast_pretty::pprust;
use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_expand::base::*;
use rustc_parse::parser::Parser;
use rustc_span::symbol::{sym, Ident, Symbol};
Expand All @@ -28,7 +28,7 @@ pub fn expand_assert<'cx>(
let sp = cx.with_call_site_ctxt(span);

let panic_call = if let Some(tokens) = custom_message {
let path = if span.rust_2021() {
let path = if use_panic_2021(span) {
// On edition 2021, we always call `$crate::panic::panic_2021!()`.
Path {
span: sp,
Expand Down
19 changes: 18 additions & 1 deletion compiler/rustc_builtin_macros/src/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use rustc_ast::ptr::P;
use rustc_ast::tokenstream::{DelimSpan, TokenStream};
use rustc_ast::*;
use rustc_expand::base::*;
use rustc_span::edition::Edition;
use rustc_span::symbol::sym;
use rustc_span::Span;

Expand All @@ -19,7 +20,7 @@ pub fn expand_panic<'cx>(
sp: Span,
tts: TokenStream,
) -> Box<dyn MacResult + 'cx> {
let panic = if sp.rust_2021() { sym::panic_2021 } else { sym::panic_2015 };
let panic = if use_panic_2021(sp) { sym::panic_2021 } else { sym::panic_2015 };

let sp = cx.with_call_site_ctxt(sp);

Expand All @@ -46,3 +47,19 @@ pub fn expand_panic<'cx>(
),
)
}

pub fn use_panic_2021(mut span: Span) -> bool {
// To determine the editon, we check the first span up the expansion
// stack that does not have #[allow_internal_unstable(edition_panic)].
// (To avoid using the edition of e.g. the assert!() or debug_assert!() definition.)
loop {
let expn = span.ctxt().outer_expn_data();
if let Some(features) = expn.allow_internal_unstable {
if features.iter().any(|&f| f == sym::edition_panic) {
span = expn.call_site;
continue;
}
}
break expn.edition >= Edition::Edition2021;
}
}
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ symbols! {
dyn_metadata,
dyn_trait,
edition_macro_pats,
edition_panic,
eh_catch_typeinfo,
eh_personality,
emit_enum,
Expand Down
1 change: 1 addition & 0 deletions library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ pub macro assert_matches {
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "debug_assert_macro"]
#[allow_internal_unstable(edition_panic)]
macro_rules! debug_assert {
($($arg:tt)*) => (if $crate::cfg!(debug_assertions) { $crate::assert!($($arg)*); })
}
Expand Down