Skip to content
Merged
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
45bb409
Only show methods that appear in the impl block for types in the Impl…
ebarnard Jun 3, 2019
5fa8b52
move stray run-pass const tests into const/ folder
RalfJung Jun 9, 2019
ea1bec3
Turn down the myriad-closures test
alexcrichton Jun 14, 2019
007aaba
Remove unnecessary lift calls
Zoxc Jun 14, 2019
56e30e1
Tweak transparent enums and unions diagnostic spans
estebank Jun 11, 2019
f06b761
review comments: move diagnostic code out of happy path
estebank Jun 12, 2019
961ba8f
syntax: Factor out common fields from `SyntaxExtension` variants
petrochenkov Jun 16, 2019
679000c
allow_internal_unstable: Avoid some more allocations
petrochenkov Jun 16, 2019
085a8d0
syntax: Remove `DummyResolver`
petrochenkov Jun 17, 2019
68e1141
resolve: Avoid creating fresh syntax extensions for all non-macro att…
petrochenkov Jun 17, 2019
8ec502e
syntax: Introduce `default`/`with_unstable` constructors for `ExpnInfo`
petrochenkov Jun 17, 2019
2de2278
syntax: Move `default_transparency` into `ExpnInfo`
petrochenkov Jun 17, 2019
1ff3bce
hygiene: Avoid some unnecessary `ExpnInfo` clones
petrochenkov Jun 17, 2019
e152554
resolve/expand: Move expansion info setting to a single earlier point
petrochenkov Jun 18, 2019
0f9dc6c
Make MaybeUninit #[repr(transparent)]
mjbshaw Jun 12, 2019
dedf2ed
rustc_typeck: correctly compute `Substs` for `Res::SelfCtor`.
eddyb Jun 16, 2019
831ddf7
ci: Add a script for generating CPU usage graphs
alexcrichton Jun 14, 2019
d8eea92
create an issue for miri even in status test-fail
RalfJung Jun 18, 2019
d67db00
Preserve generator and yield source for error messages
cramertj Jun 18, 2019
9a7016d
Rollup merge of #61505 - ebarnard:doc-shrink, r=GuillaumeGomez
Centril Jun 18, 2019
65da792
Rollup merge of #61701 - RalfJung:const-tests, r=cramertj
Centril Jun 18, 2019
06d2a89
Rollup merge of #61748 - estebank:transparent-span, r=Centril
Centril Jun 18, 2019
e416932
Rollup merge of #61802 - mjbshaw:maybe-uninit-transparent, r=cramertj
Centril Jun 18, 2019
404c854
Rollup merge of #61839 - alexcrichton:pr-and-master-builds, r=pietroa…
Centril Jun 18, 2019
de8066f
Rollup merge of #61842 - Zoxc:trim-lift, r=eddyb
Centril Jun 18, 2019
4f24715
Rollup merge of #61843 - alexcrichton:disable-myriad-closures, r=piet…
Centril Jun 18, 2019
dcd5b20
Rollup merge of #61896 - eddyb:correct-self-ctor, r=petrochenkov
Centril Jun 18, 2019
d51002c
Rollup merge of #61898 - petrochenkov:sekind, r=eddyb
Centril Jun 18, 2019
9b7b47c
Rollup merge of #61938 - RalfJung:miri-toolstate, r=kennytm
Centril Jun 18, 2019
fde341a
Rollup merge of #61941 - cramertj:no-more-yield-errors, r=centril
Centril Jun 18, 2019
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
allow_internal_unstable: Avoid some more allocations
  • Loading branch information
petrochenkov committed Jun 18, 2019
commit 679000cc0e98b2810a2d1c76ae77ce2574a4ab91
15 changes: 10 additions & 5 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ pub struct LoweringContext<'a> {
current_hir_id_owner: Vec<(DefIndex, u32)>,
item_local_id_counters: NodeMap<u32>,
node_id_to_hir_id: IndexVec<NodeId, hir::HirId>,

allow_try_trait: Option<Lrc<[Symbol]>>,
allow_gen_future: Option<Lrc<[Symbol]>>,
}

pub trait Resolver {
Expand Down Expand Up @@ -267,6 +270,8 @@ pub fn lower_crate(
lifetimes_to_define: Vec::new(),
is_collecting_in_band_lifetimes: false,
in_scope_lifetimes: Vec::new(),
allow_try_trait: Some([sym::try_trait][..].into()),
allow_gen_future: Some([sym::gen_future][..].into()),
}.lower_crate(krate)
}

Expand Down Expand Up @@ -1156,7 +1161,7 @@ impl<'a> LoweringContext<'a> {
let unstable_span = self.mark_span_with_reason(
CompilerDesugaringKind::Async,
span,
Some(vec![sym::gen_future].into()),
self.allow_gen_future.clone(),
);
let gen_future = self.expr_std_path(
unstable_span, &[sym::future, sym::from_generator], None, ThinVec::new());
Expand Down Expand Up @@ -4382,7 +4387,7 @@ impl<'a> LoweringContext<'a> {
let unstable_span = this.mark_span_with_reason(
CompilerDesugaringKind::TryBlock,
body.span,
Some(vec![sym::try_trait].into()),
this.allow_try_trait.clone(),
);
let mut block = this.lower_block(body, true).into_inner();
let tail = block.expr.take().map_or_else(
Expand Down Expand Up @@ -4968,13 +4973,13 @@ impl<'a> LoweringContext<'a> {
let unstable_span = self.mark_span_with_reason(
CompilerDesugaringKind::QuestionMark,
e.span,
Some(vec![sym::try_trait].into()),
self.allow_try_trait.clone(),
);
let try_span = self.sess.source_map().end_point(e.span);
let try_span = self.mark_span_with_reason(
CompilerDesugaringKind::QuestionMark,
try_span,
Some(vec![sym::try_trait].into()),
self.allow_try_trait.clone(),
);

// `Try::into_result(<expr>)`
Expand Down Expand Up @@ -5776,7 +5781,7 @@ impl<'a> LoweringContext<'a> {
let gen_future_span = self.mark_span_with_reason(
CompilerDesugaringKind::Await,
await_span,
Some(vec![sym::gen_future].into()),
self.allow_gen_future.clone(),
);

// let mut pinned = <expr>;
Expand Down
19 changes: 3 additions & 16 deletions src/libsyntax_ext/deriving/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use syntax::edition::Edition;
use syntax::ext::base::{Annotatable, ExtCtxt, Resolver, MultiItemModifier};
use syntax::ext::base::{SyntaxExtension, SyntaxExtensionKind};
use syntax::ext::build::AstBuilder;
use syntax::ext::hygiene::{Mark, SyntaxContext};
use syntax::ptr::P;
use syntax::symbol::{Symbol, sym};
use syntax_pos::Span;
Expand Down Expand Up @@ -71,6 +70,7 @@ macro_rules! derive_traits {

pub fn register_builtin_derives(resolver: &mut dyn Resolver, edition: Edition) {
let allow_internal_unstable = Some([
sym::core_intrinsics,
sym::rustc_attrs,
Symbol::intern("derive_clone_copy"),
Symbol::intern("derive_eq"),
Expand Down Expand Up @@ -163,24 +163,11 @@ fn hygienic_type_parameter(item: &Annotatable, base: &str) -> String {

/// Constructs an expression that calls an intrinsic
fn call_intrinsic(cx: &ExtCtxt<'_>,
mut span: Span,
span: Span,
intrinsic: &str,
args: Vec<P<ast::Expr>>)
-> P<ast::Expr> {
let intrinsic_allowed_via_allow_internal_unstable = cx
.current_expansion.mark.expn_info().unwrap()
.allow_internal_unstable.map_or(false, |features| features.iter().any(|&s|
s == sym::core_intrinsics
));
if intrinsic_allowed_via_allow_internal_unstable {
span = span.with_ctxt(cx.backtrace());
} else { // Avoid instability errors with user defined curstom derives, cc #36316
let mut info = cx.current_expansion.mark.expn_info().unwrap();
info.allow_internal_unstable = Some(vec![sym::core_intrinsics].into());
let mark = Mark::fresh(Mark::root());
mark.set_expn_info(info);
span = span.with_ctxt(SyntaxContext::empty().apply_mark(mark));
}
let span = span.with_ctxt(cx.backtrace());
let path = cx.std_path(&[sym::intrinsics, Symbol::intern(intrinsic)]);
let call = cx.expr_call_global(span, path, args);

Expand Down
5 changes: 3 additions & 2 deletions src/libsyntax_ext/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,15 @@ pub fn register_builtins(resolver: &mut dyn syntax::ext::base::Resolver,
}

// format_args uses `unstable` things internally.
let allow_internal_unstable = Some([sym::fmt_internals][..].into());
register(Symbol::intern("format_args"), SyntaxExtension {
allow_internal_unstable: Some([sym::fmt_internals][..].into()),
allow_internal_unstable: allow_internal_unstable.clone(),
..SyntaxExtension::default(
SyntaxExtensionKind::LegacyBang(Box::new(format::expand_format_args)), edition
)
});
register(sym::format_args_nl, SyntaxExtension {
allow_internal_unstable: Some([sym::fmt_internals][..].into()),
allow_internal_unstable,
..SyntaxExtension::default(
SyntaxExtensionKind::LegacyBang(Box::new(format::expand_format_args_nl)), edition
)
Expand Down