Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
266ede1
Isolate compiler queries inside the Queries type.
cjgillot Nov 24, 2019
5098ba6
Move linking ouside the interface queries.
cjgillot Nov 24, 2019
27513a2
Tidy.
cjgillot Nov 24, 2019
becfe5c
Fix test.
cjgillot Nov 24, 2019
cd5d0c7
Rename continue_panic_fmt to panic_handler, and make it the #[panic_h…
RalfJung Nov 25, 2019
08f779c
better comment and rename BoxMeUp::box_me_up to take_box
RalfJung Nov 25, 2019
18bb912
Remove wrong comment.
cjgillot Nov 25, 2019
ea1b803
Pass Queries by reference.
cjgillot Nov 25, 2019
7d01b6c
Simplify early exits.
cjgillot Nov 25, 2019
8ffc944
Don't move stuff out of Compiler::enter.
cjgillot Nov 25, 2019
9d5f721
Superfluous lifetime.
cjgillot Nov 25, 2019
3c48579
more panicking comments
RalfJung Nov 25, 2019
3a8e1b6
panic_handler -> begin_panic_handler (and more comments)
RalfJung Nov 26, 2019
3e96ca2
abort on BoxMeUp misuse
RalfJung Nov 26, 2019
61486f4
expand comment
RalfJung Nov 26, 2019
4a19ef9
explain why __rust_start_panic does not take a Box
RalfJung Nov 26, 2019
babe9fc
rename update_count_then_panic -> rust_panic_without_hook
RalfJung Nov 26, 2019
68b1ac9
Reduce righward drift.
cjgillot Nov 26, 2019
144d1c2
Review nits.
cjgillot Nov 26, 2019
58a9c73
Make the HIR map own the Definitions.
cjgillot Nov 26, 2019
b99513b
Have Queries own the GlobalCtxt.
cjgillot Nov 26, 2019
7b71e9a
Formatting.
cjgillot Nov 26, 2019
7e72b36
Move local Arena to Queries.
cjgillot Nov 26, 2019
1f850f6
Record temporary static references in generator witnesses
matthewjasper Nov 26, 2019
79e2324
Rename lifetimes.
cjgillot Nov 27, 2019
e5ed101
Rename BoxedGlobalCtxt.
cjgillot Nov 27, 2019
77a4c85
Simplify handling of AllArenas.
cjgillot Nov 27, 2019
e321ba9
Misc renames.
cjgillot Nov 27, 2019
1e12f39
Allocate HIR Forest on arena.
cjgillot Nov 27, 2019
38f9cd4
Clean up E0080 long explanation
GuillaumeGomez Nov 27, 2019
ce69610
Clean up E0081 long explanation
GuillaumeGomez Nov 27, 2019
7edaeba
Clean up E0091 long explanation
GuillaumeGomez Nov 27, 2019
d411dd2
Elaborate on std::ptr::{as_ref,as_mod} and clarify docs
CreepySkeleton Nov 13, 2019
f11dd32
Use intra-doc links
CreepySkeleton Nov 27, 2019
59d7391
Draw vertical lines in compiler error messages with multiline annotat…
TheSamsa Nov 20, 2019
df625bd
Add async fn test for #66695
matthewjasper Nov 27, 2019
9b78191
Clarifies how to tag users for assigning PRs
Nov 27, 2019
2a7dc5e
Update CONTRIBUTING.md
Dylan-DPC Nov 28, 2019
77f2ac4
Update CONTRIBUTING.md
Dylan-DPC Nov 28, 2019
85a468b
Clarify `{f32,f64}::EPSILON` docs
ohadravid Nov 28, 2019
3048d7e
do not consider memory allocated by caller_location leaked
RalfJung Nov 28, 2019
f07bd06
allow customising ty::TraitRef's printing behavior
basil-cow Nov 21, 2019
26e5fd4
Minor documentation fix
Mikotochan Nov 29, 2019
764ef8c
Rollup merge of #66379 - CreepySkeleton:patch-1, r=RalfJung
RalfJung Nov 29, 2019
7b75a36
Rollup merge of #66589 - TheSamsa:master, r=Dylan-DPC
RalfJung Nov 29, 2019
64efc45
Rollup merge of #66613 - Areredify:trait-ref-print, r=eddyb
RalfJung Nov 29, 2019
56203be
Rollup merge of #66766 - RalfJung:panic-comments, r=SimonSapin
RalfJung Nov 29, 2019
6ea1df2
Rollup merge of #66791 - cjgillot:arena, r=Mark-Simulacrum
RalfJung Nov 29, 2019
37c1f52
Rollup merge of #66793 - matthewjasper:record-static-refs, r=cramertj
RalfJung Nov 29, 2019
0f6e636
Rollup merge of #66808 - GuillaumeGomez:cleanup-err-code-3, r=Dylan-DPC
RalfJung Nov 29, 2019
5c90811
Rollup merge of #66826 - mlodato517:mlodato517-clarify-pr-message-ass…
RalfJung Nov 29, 2019
3959378
Rollup merge of #66837 - ohadravid:epsilon-doc, r=dtolnay
RalfJung Nov 29, 2019
0f6745d
Rollup merge of #66844 - RalfJung:caller-location-leak, r=oli-obk
RalfJung Nov 29, 2019
0b1b36c
Rollup merge of #66872 - Mikotochan:patch-1, r=jonas-schievink
RalfJung Nov 29, 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
17 changes: 17 additions & 0 deletions src/librustc/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,23 @@ impl<'tcx> TyCtxt<'tcx> {
self.static_mutability(def_id) == Some(hir::Mutability::Mutable)
}

/// Get the type of the pointer to the static that we use in MIR.
pub fn static_ptr_ty(&self, def_id: DefId) -> Ty<'tcx> {
// Make sure that any constants in the static's type are evaluated.
let static_ty = self.normalize_erasing_regions(
ty::ParamEnv::empty(),
self.type_of(def_id),
);

if self.is_mutable_static(def_id) {
self.mk_mut_ptr(static_ty)
} else if self.is_foreign_item(def_id) {
self.mk_imm_ptr(static_ty)
} else {
self.mk_imm_ref(self.lifetimes.re_erased, static_ty)
}
}

/// Expands the given impl trait type, stopping if the type is recursive.
pub fn try_expand_impl_trait_type(
self,
Expand Down
9 changes: 1 addition & 8 deletions src/librustc_mir/hair/cx/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -933,14 +933,7 @@ fn convert_path_expr<'a, 'tcx>(
// We encode uses of statics as a `*&STATIC` where the `&STATIC` part is
// a constant reference (or constant raw pointer for `static mut`) in MIR
Res::Def(DefKind::Static, id) => {
let ty = cx.tcx.type_of(id);
let ty = if cx.tcx.is_mutable_static(id) {
cx.tcx.mk_mut_ptr(ty)
} else if cx.tcx.is_foreign_item(id) {
cx.tcx.mk_imm_ptr(ty)
} else {
cx.tcx.mk_imm_ref(cx.tcx.lifetimes.re_static, ty)
};
let ty = cx.tcx.static_ptr_ty(id);
let ptr = cx.tcx.alloc_map.lock().create_static_alloc(id);
let temp_lifetime = cx.region_scope_tree.temporary_scope(expr.hir_id.local_id);
ExprKind::Deref { arg: Expr {
Expand Down
13 changes: 11 additions & 2 deletions src/librustc_typeck/check/generator_interior.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
}

fn visit_expr(&mut self, expr: &'tcx Expr) {
let scope = self.region_scope_tree.temporary_scope(expr.hir_id.local_id);

match &expr.kind {
ExprKind::Call(callee, args) => match &callee.kind {
ExprKind::Path(qpath) => {
Expand All @@ -210,13 +212,20 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
}
_ => intravisit::walk_expr(self, expr),
}
ExprKind::Path(qpath) => {
let res = self.fcx.tables.borrow().qpath_res(qpath, expr.hir_id);
if let Res::Def(DefKind::Static, def_id) = res {
// Statics are lowered to temporary references or
// pointers in MIR, so record that type.
let ptr_ty = self.fcx.tcx.static_ptr_ty(def_id);
self.record(ptr_ty, scope, Some(expr), expr.span);
}
}
_ => intravisit::walk_expr(self, expr),
}

self.expr_count += 1;

let scope = self.region_scope_tree.temporary_scope(expr.hir_id.local_id);

// If there are adjustments, then record the final type --
// this is the actual value that is being produced.
if let Some(adjusted_ty) = self.fcx.tables.borrow().expr_ty_adjusted_opt(expr) {
Expand Down
24 changes: 24 additions & 0 deletions src/test/ui/async-await/issues/issue-66695-static-refs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// build-pass
// edition:2018

static A: [i32; 5] = [1, 2, 3, 4, 5];

async fn fun() {
let u = A[async { 1 }.await];
match A {
i if async { true }.await => (),
_ => (),
}
}

fn main() {
async {
let u = A[async { 1 }.await];
};
async {
match A {
i if async { true }.await => (),
_ => (),
}
};
}
16 changes: 16 additions & 0 deletions src/test/ui/generator/static-reference-across-yield.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// build-pass
#![feature(generators)]

static A: [i32; 5] = [1, 2, 3, 4, 5];

fn main() {
static || {
let u = A[{yield; 1}];
};
static || {
match A {
i if { yield; true } => (),
_ => (),
}
};
}