Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #82885

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6a679ff
bypass auto_da_alloc for metadata files
the8472 Feb 12, 2021
6e52b23
Fix jemalloc usage on OSX
sfackler Feb 28, 2021
920e2d8
Add natvis for Result, NonNull, CString, CStr, and Cow
rylev Feb 26, 2021
bc18eb4
expand: Remove obsolete `DirectoryOwnership::UnownedViaMod`
petrochenkov Feb 22, 2021
39052c5
expand: Move module file path stack from global session to expansion …
petrochenkov Feb 21, 2021
5bdf81d
expand: Determine module directory path directly instead of relying o…
petrochenkov Feb 22, 2021
3d0b622
expand: Less path cloning during module loading
petrochenkov Feb 22, 2021
46b67aa
expand: Some more consistent naming in module loading
petrochenkov Feb 22, 2021
da3419e
rustc_interface: Hide some hacky details of early linting from expand
petrochenkov Feb 22, 2021
29a9ef2
expand: Align some code with the PR fixing inner attributes on out-of…
petrochenkov Feb 22, 2021
1e1d574
expand: Share some code between inline and out-of-line module treatment
petrochenkov Feb 22, 2021
1fe2eb8
expand: Introduce enum for module loading errors and make module load…
petrochenkov Feb 22, 2021
1b4860a
Update compiler/rustc/src/main.rs
sfackler Mar 5, 2021
6f49aad
Disable destination propagation on all mir-opt-levels
tmiasko Mar 6, 2021
069e612
rustc_ast: Replace `AstLike::finalize_tokens` with a getter `tokens_mut`
petrochenkov Mar 6, 2021
5dad6c2
Implement built-in attribute macro `#[cfg_eval]`
petrochenkov Mar 6, 2021
cf52469
Remove Item::kind, use tagged enum. Rename variants to match
CraftSpider Feb 28, 2021
ca48d15
Add roundtrip testing and bump format version
CraftSpider Mar 4, 2021
83cece4
Move tests to own file
CraftSpider Mar 5, 2021
70c9b37
x.py fmt
CraftSpider Mar 5, 2021
18841ec
Revert fmt version, add rustdoc-json-types to bootstrap tests
CraftSpider Mar 6, 2021
f9019b7
Move full configuration logic from `rustc_expand` to `rustc_builtin_m…
petrochenkov Mar 6, 2021
10ed08f
cfg_eval: Configure everything through mutable visitor methods
petrochenkov Mar 6, 2021
5d27728
rustc_builtin_macros: Share some more logic between `derive` and `cfg…
petrochenkov Mar 6, 2021
6b2eb0e
Edit ructc_ast_lowering docs
pierwill Mar 7, 2021
ab8995b
Generalize Write impl for Vec<u8> to Vec<u8, A>
athre0z Mar 7, 2021
743df86
Rollup merge of #82047 - the8472:fast-rename, r=davidtwco
Dylan-DPC Mar 8, 2021
f0393e8
Rollup merge of #82415 - petrochenkov:modin3, r=davidtwco
Dylan-DPC Mar 8, 2021
b9bdf69
Rollup merge of #82557 - rylev:natvis-improvements, r=varkor
Dylan-DPC Mar 8, 2021
648cb7f
Rollup merge of #82613 - CraftSpider:fix-de, r=aDotInTheVoid
Dylan-DPC Mar 8, 2021
b6d1f77
Rollup merge of #82642 - sfackler:jemalloc-zone, r=pnkfelix
Dylan-DPC Mar 8, 2021
577ee2f
Rollup merge of #82682 - petrochenkov:cfgeval, r=Aaron1011
Dylan-DPC Mar 8, 2021
a2a7c25
Rollup merge of #82684 - tmiasko:dest-prop, r=jonas-schievink
Dylan-DPC Mar 8, 2021
8c281ea
Rollup merge of #82857 - pierwill:edit-ast-lowering-lib, r=Dylan-DPC
Dylan-DPC Mar 8, 2021
0b98fa1
Rollup merge of #82862 - athre0z:generalize-vec-write-impl, r=TimDiek…
Dylan-DPC Mar 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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4568,6 +4568,7 @@ name = "rustdoc-json-types"
version = "0.1.0"
dependencies = [
"serde",
"serde_json",
]

[[package]]
Expand Down
14 changes: 14 additions & 0 deletions compiler/rustc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ fn main() {
static _F5: unsafe extern "C" fn(*mut c_void, usize) -> *mut c_void = jemalloc_sys::realloc;
#[used]
static _F6: unsafe extern "C" fn(*mut c_void) = jemalloc_sys::free;

// On OSX, jemalloc doesn't directly override malloc/free, but instead
// registers itself with the allocator's zone APIs in a ctor. However,
// the linker doesn't seem to consider ctors as "used" when statically
// linking, so we need to explicitly depend on the function.
#[cfg(target_os = "macos")]
{
extern "C" {
fn _rjem_je_zone_register();
}

#[used]
static _F7: unsafe extern "C" fn() = _rjem_je_zone_register;
}
}

rustc_driver::set_sigpipe_handler();
Expand Down
10 changes: 0 additions & 10 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,16 +915,6 @@ impl Stmt {
}
}

pub fn tokens_mut(&mut self) -> Option<&mut LazyTokenStream> {
match self.kind {
StmtKind::Local(ref mut local) => local.tokens.as_mut(),
StmtKind::Item(ref mut item) => item.tokens.as_mut(),
StmtKind::Expr(ref mut expr) | StmtKind::Semi(ref mut expr) => expr.tokens.as_mut(),
StmtKind::Empty => None,
StmtKind::MacCall(ref mut mac) => mac.tokens.as_mut(),
}
}

pub fn has_trailing_semicolon(&self) -> bool {
match &self.kind {
StmtKind::Semi(_) => true,
Expand Down
88 changes: 34 additions & 54 deletions compiler/rustc_ast/src/ast_like.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ use super::{AttrVec, Attribute, Stmt, StmtKind};
pub trait AstLike: Sized {
fn attrs(&self) -> &[Attribute];
fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec<Attribute>));
/// Called by `Parser::collect_tokens` to store the collected
/// tokens inside an AST node
fn finalize_tokens(&mut self, _tokens: LazyTokenStream) {
// This default impl makes this trait easier to implement
// in tools like `rust-analyzer`
panic!("`finalize_tokens` is not supported!")
}
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>>;
}

impl<T: AstLike + 'static> AstLike for P<T> {
Expand All @@ -27,8 +21,8 @@ impl<T: AstLike + 'static> AstLike for P<T> {
fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec<Attribute>)) {
(**self).visit_attrs(f);
}
fn finalize_tokens(&mut self, tokens: LazyTokenStream) {
(**self).finalize_tokens(tokens)
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> {
(**self).tokens_mut()
}
}

Expand All @@ -42,12 +36,12 @@ fn visit_attrvec(attrs: &mut AttrVec, f: impl FnOnce(&mut Vec<Attribute>)) {

impl AstLike for StmtKind {
fn attrs(&self) -> &[Attribute] {
match *self {
StmtKind::Local(ref local) => local.attrs(),
StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => expr.attrs(),
StmtKind::Item(ref item) => item.attrs(),
match self {
StmtKind::Local(local) => local.attrs(),
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.attrs(),
StmtKind::Item(item) => item.attrs(),
StmtKind::Empty => &[],
StmtKind::MacCall(ref mac) => &*mac.attrs,
StmtKind::MacCall(mac) => &mac.attrs,
}
}

Expand All @@ -60,17 +54,14 @@ impl AstLike for StmtKind {
StmtKind::MacCall(mac) => visit_attrvec(&mut mac.attrs, f),
}
}
fn finalize_tokens(&mut self, tokens: LazyTokenStream) {
let stmt_tokens = match self {
StmtKind::Local(ref mut local) => &mut local.tokens,
StmtKind::Item(ref mut item) => &mut item.tokens,
StmtKind::Expr(ref mut expr) | StmtKind::Semi(ref mut expr) => &mut expr.tokens,
StmtKind::Empty => return,
StmtKind::MacCall(ref mut mac) => &mut mac.tokens,
};
if stmt_tokens.is_none() {
*stmt_tokens = Some(tokens);
}
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> {
Some(match self {
StmtKind::Local(local) => &mut local.tokens,
StmtKind::Item(item) => &mut item.tokens,
StmtKind::Expr(expr) | StmtKind::Semi(expr) => &mut expr.tokens,
StmtKind::Empty => return None,
StmtKind::MacCall(mac) => &mut mac.tokens,
})
}
}

Expand All @@ -82,8 +73,8 @@ impl AstLike for Stmt {
fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec<Attribute>)) {
self.kind.visit_attrs(f);
}
fn finalize_tokens(&mut self, tokens: LazyTokenStream) {
self.kind.finalize_tokens(tokens)
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> {
self.kind.tokens_mut()
}
}

Expand All @@ -92,17 +83,13 @@ impl AstLike for Attribute {
&[]
}
fn visit_attrs(&mut self, _f: impl FnOnce(&mut Vec<Attribute>)) {}
fn finalize_tokens(&mut self, tokens: LazyTokenStream) {
match &mut self.kind {
AttrKind::Normal(_, attr_tokens) => {
if attr_tokens.is_none() {
*attr_tokens = Some(tokens);
}
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> {
Some(match &mut self.kind {
AttrKind::Normal(_, tokens) => tokens,
kind @ AttrKind::DocComment(..) => {
panic!("Called tokens_mut on doc comment attr {:?}", kind)
}
AttrKind::DocComment(..) => {
panic!("Called finalize_tokens on doc comment attr {:?}", self)
}
}
})
}
}

Expand All @@ -115,10 +102,8 @@ impl<T: AstLike> AstLike for Option<T> {
inner.visit_attrs(f);
}
}
fn finalize_tokens(&mut self, tokens: LazyTokenStream) {
if let Some(inner) = self {
inner.finalize_tokens(tokens);
}
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> {
self.as_mut().and_then(|inner| inner.tokens_mut())
}
}

Expand Down Expand Up @@ -152,11 +137,8 @@ macro_rules! derive_has_tokens_and_attrs {
VecOrAttrVec::visit(&mut self.attrs, f)
}

fn finalize_tokens(&mut self, tokens: LazyTokenStream) {
if self.tokens.is_none() {
self.tokens = Some(tokens);
}

fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> {
Some(&mut self.tokens)
}
}
)* }
Expand All @@ -173,7 +155,9 @@ macro_rules! derive_has_attrs_no_tokens {
VecOrAttrVec::visit(&mut self.attrs, f)
}

fn finalize_tokens(&mut self, _tokens: LazyTokenStream) {}
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> {
None
}
}
)* }
}
Expand All @@ -185,14 +169,10 @@ macro_rules! derive_has_tokens_no_attrs {
&[]
}

fn visit_attrs(&mut self, _f: impl FnOnce(&mut Vec<Attribute>)) {
}

fn finalize_tokens(&mut self, tokens: LazyTokenStream) {
if self.tokens.is_none() {
self.tokens = Some(tokens);
}
fn visit_attrs(&mut self, _f: impl FnOnce(&mut Vec<Attribute>)) {}

fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> {
Some(&mut self.tokens)
}
}
)* }
Expand Down
16 changes: 9 additions & 7 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//! For the simpler lowering steps, IDs and spans should be preserved. Unlike
//! expansion we do not preserve the process of lowering in the spans, so spans
//! should not be modified here. When creating a new node (as opposed to
//! 'folding' an existing one), then you create a new ID using `next_id()`.
//! "folding" an existing one), create a new ID using `next_id()`.
//!
//! You must ensure that IDs are unique. That means that you should only use the
//! ID from an AST node in a single HIR node (you can assume that AST node-IDs
Expand All @@ -26,7 +26,7 @@
//! span and spans don't need to be kept in order, etc. Where code is preserved
//! by lowering, it should have the same span as in the AST. Where HIR nodes are
//! new it is probably best to give a span for the whole AST node being lowered.
//! All nodes should have real spans, don't use dummy spans. Tools are likely to
//! All nodes should have real spans; don't use dummy spans. Tools are likely to
//! get confused if the spans from leaf AST nodes occur in multiple places
//! in the HIR, especially for multiple identifiers.

Expand Down Expand Up @@ -95,7 +95,7 @@ struct LoweringContext<'a, 'hir: 'a> {
/// librustc_middle is independent of the parser, we use dynamic dispatch here.
nt_to_tokenstream: NtToTokenstream,

/// Used to allocate HIR nodes
/// Used to allocate HIR nodes.
arena: &'hir Arena<'hir>,

/// The items being lowered are collected here.
Expand Down Expand Up @@ -128,7 +128,7 @@ struct LoweringContext<'a, 'hir: 'a> {
is_in_trait_impl: bool,
is_in_dyn_type: bool,

/// What to do when we encounter either an "anonymous lifetime
/// What to do when we encounter an "anonymous lifetime
/// reference". The term "anonymous" is meant to encompass both
/// `'_` lifetimes as well as fully elided cases where nothing is
/// written at all (e.g., `&T` or `std::cell::Ref<T>`).
Expand Down Expand Up @@ -238,11 +238,13 @@ enum ImplTraitContext<'b, 'a> {
OtherOpaqueTy {
/// Set of lifetimes that this opaque type can capture, if it uses
/// them. This includes lifetimes bound since we entered this context.
/// For example, in
/// For example:
///
/// ```
/// type A<'b> = impl for<'a> Trait<'a, Out = impl Sized + 'a>;
/// ```
///
/// the inner opaque type captures `'a` because it uses it. It doesn't
/// Here the inner opaque type captures `'a` because it uses it. It doesn't
/// need to capture `'b` because it already inherits the lifetime
/// parameter from `A`.
// FIXME(impl_trait): but `required_region_bounds` will ICE later
Expand Down Expand Up @@ -2110,7 +2112,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
hir::FnRetTy::Return(self.arena.alloc(opaque_ty))
}

/// Transforms `-> T` into `Future<Output = T>`
/// Transforms `-> T` into `Future<Output = T>`.
fn lower_async_fn_output_type_to_future_bound(
&mut self,
output: &FnRetTy,
Expand Down
Loading