8000 Rollup of 8 pull requests by Centril · Pull Request #62937 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 8 pull requests #62937

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

Closed
wants to merge 51 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
8c050fc
rustc: compute `ty::layout::Niche`'s `available` on the fly.
eddyb Jul 11, 2019
dfbf464
rustc_target: move abi::Niche from rustc::ty::layout.
eddyb Jul 12, 2019
88eced5
rustc: precompute the largest Niche and store it in LayoutDetails.
eddyb Jul 15, 2019
bb9bf0c
Add riscv32i-unknown-none-elf target
Disasm Jul 18, 2019
b9784b1
Don't link mcjit/interpreter LLVM components
nikic Jul 20, 2019
c442dae
Ignore NLL migrate mode test in the Polonius compare-mode
lqd Jun 11, 2019
d4ca9a3
Ignore test issue-45983 in the polonius compare mode
lqd Jun 11, 2019
273bfd4
Ignore two-phase-reservation-sharing-interference-2.rs in Polonius co…
lqd Jun 11, 2019
63c837e
Ignore feature-gate-nll.rs in Polonius compare mode
lqd Jun 11, 2019
51c15fa
Ignore test issue-45696-scribble-on-boxed-borrow.rs in Polonius compa…
lqd Jun 11, 2019
ff350f8
Bless output of test ui/emit-artifact-notifications.rs for Polonius
lqd Jun 11, 2019
2824db1
Bless output of test save-analysis/emit-notifications.rs for Polonius
lqd Jun 11, 2019
9410104
Bless output of test nll/loan_ends_mid_block_pair.rs for Polonius
lqd Jun 11, 2019
6a7c15e
Bless output of test consts/promote_const_let.rs for Polonius
lqd Jun 12, 2019
c5a1bc1
Bless output of test nll/get_default.rs for Polonius
lqd Jun 12, 2019
292d5c1
Bless output of test generator/ref-escapes-but-not-over-yield.rs for …
lqd Jun 12, 2019
6fe5292
Bless output of test borrowck/borrowck-escaping-closure-error-2.rs f…
lqd Jun 28, 2019
7db61e7
Bless output of test borrowck/two-phase-surprise-no-conflict.rs for P…
lqd Jun 28, 2019
08c25b5
Bless output of test dropck/dropck_trait_cycle_checked.rs for Polonius
lqd Jun 28, 2019
9a82f52
Create a dedicated polonius test folder
lqd Jul 5, 2019
6d9a4f9
Polonius facts: kill loans on Call terminators and StorageDead
lqd Jul 15, 2019
0bd2b32
Bless output of test borrowck/promote-ref-mut-in-let-issue-46557.rs …
lqd Jul 15, 2019
ed1625f
Ignore test hrtb/issue-30786.rs in Polonius compare mode
lqd Jul 15, 2019
40e6b02
Bless output of test nll/return-ref-mut-issue-46557.rs for Polonius
lqd Jul 15, 2019
9bd9b0d
Add test extracted from rand, checking that StorageDead kills loans
lqd Jul 15, 2019
606f798
Rename test so that both "kills-loans" tests match names
lqd Jul 15, 2019
9e0fb6f
Make both polonius loans tests check-pass
lqd Jul 15, 2019
823ab42
Bless output of test unboxed-closures/unboxed-closures-failed-recursi…
lqd Jul 15, 2019
2f3e36f
Polonius: generate `killed` facts for assignments to projections
lqd Jul 16, 2019
d41e002
Add test checking various assignments are accepted in Polonius
lqd Jul 16, 2019
770129c
Add test to check that assignments to projections do not kill too man…
lqd Jul 16, 2019
c7f9a71
issue-46589 passes in Polonius and fails in NLL, duplicate it and man…
lqd Jul 16, 2019
c0eab36
Bless output of test nll/loan_ends_mid_block_pair.rs for Polonius, again
lqd Jul 16, 2019
e16bede
fix tidy
lqd Jul 16, 2019
4b33968
add support for hexagon-unknown-linux-musl
androm3da Aug 10, 2018
1aeadcc
Require a value for configure --debuginfo-level
cuviper Jul 23, 2019
9073127
Break dependencies between `syntax_ext` and some other crates
petrochenkov Jul 17, 2019
2ef11ad
Move proc macro server into libsyntax
petrochenkov Jul 18, 2019
0513819
Move test harness generation into libsyntax_ext
petrochenkov Jul 18, 2019
db70c0a
Merge `rustc_allocator` into `libsyntax_ext`
petrochenkov Jul 16, 2019
28e0824
Move standard library injection into libsyntax_ext
petrochenkov Jul 18, 2019
3418aa1
syntax_ext: `proc_macro_decls` -> `proc_macro_harness`
petrochenkov Jul 18, 2019
61b680b
Attempt to fix backtrace tests on i686-msvc
alexcrichton Jul 23, 2019
0eac668
Rollup merge of #62692 - eddyb:precompute-niches, r=oli-obk
Centril Jul 24, 2019
947a3a5
Rollup merge of #62736 - lqd:polonius_tests3, r=matthewjasper
Centril Jul 24, 2019
574274f
Rollup merge of #62771 - petrochenkov:depext, r=eddyb
Centril Jul 24, 2019
b14acf4
Rollup merge of #62784 - Disasm:riscv32i, r=estebank
Centril Jul 24, 2019
f79ffa3
Rollup merge of #62814 - androm3da:hexagon_19jul_2019, r=alexcrichton
Centril Jul 24, 2019
58674e0
Rollup merge of #62827 - nikic:llvm-components, r=alexcrichton
Centril Jul 24, 2019
06ee158
Rollup merge of #62897 - alexcrichton:fix-i686-msvc-tests, r=pietroal…
Centril Jul 24, 2019
4008cf1
Rollup merge of #62906 - cuviper:debuginfo-level, r=Mark-Simulacrum
Centril Jul 24, 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
Move proc macro server into libsyntax
  • Loading branch information
petrochenkov committed Jul 24, 2019
commit 2ef11add1018a807ee6f85b1b37aa84d8b60106d
1 change: 0 additions & 1 deletion src/librustc_metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ rustc_target = { path = "../librustc_target" }
serialize = { path = "../libserialize" }
stable_deref_trait = "1.0.0"
syntax = { path = "../libsyntax" }
syntax_ext = { path = "../libsyntax_ext" }
syntax_pos = { path = "../libsyntax_pos" }
3 changes: 1 addition & 2 deletions src/librustc_metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,7 @@ impl<'a> CrateLoader<'a> {
use std::{env, mem};
use crate::dynamic_lib::DynamicLibrary;
use proc_macro::bridge::client::ProcMacro;
use syntax_ext::deriving::custom::ProcMacroDerive;
use syntax_ext::proc_macro_impl::{AttrProcMacro, BangProcMacro};
use syntax::ext::proc_macro::{BangProcMacro, AttrProcMacro, ProcMacroDerive};

let path = match dylib {
Some(dylib) => dylib,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ use syntax::attr;
use syntax::source_map;
use syntax::edition::Edition;
use syntax::ext::base::{SyntaxExtension, SyntaxExtensionKind};
use syntax::ext::proc_macro::BangProcMacro;
use syntax::parse::source_file_to_stream;
use syntax::parse::parser::emit_unclosed_delims;
use syntax::symbol::{Symbol, sym};
use syntax_ext::proc_macro_impl::BangProcMacro;
use syntax_pos::{Span, NO_EXPANSION, FileName};
use rustc_data_structures::bit_set::BitSet;

Expand Down
72 changes: 0 additions & 72 deletions src/libsyntax/ext/derive.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::attr::{self, HasAttrs};
use crate::source_map::{dummy_spanned, respan};
use crate::config::StripUnconfigured;
use crate::ext::base::*;
use crate::ext::derive::{add_derived_markers, collect_derives};
use crate::ext::proc_macro::{add_derived_markers, collect_derives};
use crate::ext::hygiene::{ExpnId, SyntaxContext, ExpnInfo, ExpnKind};
use crate::ext::placeholders::{placeholder, PlaceholderExpander};
use crate::feature_gate::{self, Features, GateIssue, is_builtin_attr, emit_feature_err};
Expand Down
246 changes: 244 additions & 2 deletions src/libsyntax/ext/proc_macro.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,249 @@
use crate::ast::Attribute;
use crate::symbol::sym;
use crate::ast::{self, ItemKind, Attribute, Mac};
use crate::attr::{mark_used, mark_known, HasAttrs};
use crate::errors::{Applicability, FatalError};
use crate::ext::base::{self, *};
use crate::ext::build::AstBuilder;
use crate::ext::proc_macro_server;
use crate::parse::{self, token};
use crate::parse::parser::PathStyle;
use crate::symbol::{sym, Symbol};
use crate::tokenstream::{self, TokenStream};
use crate::visit::Visitor;

use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sync::Lrc;
use syntax_pos::hygiene::{ExpnInfo, ExpnKind};
use syntax_pos::{Span, DUMMY_SP};

const EXEC_STRATEGY: proc_macro::bridge::server::SameThread =
proc_macro::bridge::server::SameThread;

pub struct BangProcMacro {
pub client: proc_macro::bridge::client::Client<
fn(proc_macro::TokenStream) -> proc_macro::TokenStream,
>,
}

impl base::ProcMacro for BangProcMacro {
fn expand<'cx>(&self,
ecx: &'cx mut ExtCtxt<'_>,
span: Span,
input: TokenStream)
-> TokenStream {
let server = proc_macro_server::Rustc::new(ecx);
match self.client.run(&EXEC_STRATEGY, server, input) {
Ok(stream) => stream,
Err(e) => {
let msg = "proc macro panicked";
let mut err = ecx.struct_span_fatal(span, msg);
if let Some(s) = e.as_str() {
err.help(&format!("message: {}", s));
}

err.emit();
FatalError.raise();
}
}
}
}

pub struct AttrProcMacro {
pub client: proc_macro::bridge::client::Client<
fn(proc_macro::TokenStream, proc_macro::TokenStream) -> proc_macro::TokenStream,
>,
}

impl base::AttrProcMacro for AttrProcMacro {
fn expand<'cx>(&self,
ecx: &'cx mut ExtCtxt<'_>,
span: Span,
annotation: TokenStream,
annotated: TokenStream)
-> TokenStream {
let server = proc_macro_server::Rustc::new(ecx);
match self.client.run(&EXEC_STRATEGY, server, annotation, annotated) {
Ok(stream) => stream,
Err(e) => {
let msg = "custom attribute panicked";
let mut err = ecx.struct_span_fatal(span, msg);
if let Some(s) = e.as_str() {
err.help(&format!("message: {}", s));
}

err.emit();
FatalError.raise();
}
}
}
}

pub struct ProcMacroDerive {
pub client: proc_macro::bridge::client::Client<
fn(proc_macro::TokenStream) -> proc_macro::TokenStream,
>,
pub attrs: Vec<ast::Name>,
}

impl MultiItemModifier for ProcMacroDerive {
fn expand(&self,
ecx: &mut ExtCtxt<'_>,
span: Span,
_meta_item: &ast::MetaItem,
item: Annotatable)
-> Vec<Annotatable> {
let item = match item {
Annotatable::Item(item) => item,
Annotatable::ImplItem(_) |
Annotatable::TraitItem(_) |
Annotatable::ForeignItem(_) |
Annotatable::Stmt(_) |
Annotatable::Expr(_) => {
ecx.span_err(span, "proc-macro derives may only be \
applied to a struct, enum, or union");
return Vec::new()
}
};
match item.node {
ItemKind::Struct(..) |
ItemKind::Enum(..) |
ItemKind::Union(..) => {},
_ => {
ecx.span_err(span, "proc-macro derives may only be \
applied to a struct, enum, or union");
return Vec::new()
}
}

// Mark attributes as known, and used.
MarkAttrs(&self.attrs).visit_item(&item);

let token = token::Interpolated(Lrc::new(token::NtItem(item)));
let input = tokenstream::TokenTree::token(token, DUMMY_SP).into();

let server = proc_macro_server::Rustc::new(ecx);
let stream = match self.client.run(&EXEC_STRATEGY, server, input) {
Ok(stream) => stream,
Err(e) => {
let msg = "proc-macro derive panicked";
let mut err = ecx.struct_span_fatal(span, msg);
if let Some(s) = e.as_str() {
err.help(&format!("message: {}", s));
}

err.emit();
FatalError.raise();
}
};

let error_count_before = ecx.parse_sess.span_diagnostic.err_count();
let msg = "proc-macro derive produced unparseable tokens";

let mut parser = parse::stream_to_parser(ecx.parse_sess, stream, Some("proc-macro derive"));
let mut items = vec![];

loop {
match parser.parse_item() {
Ok(None) => break,
Ok(Some(item)) => {
items.push(Annotatable::Item(item))
}
Err(mut err) => {
// FIXME: handle this better
err.cancel();
ecx.struct_span_fatal(span, msg).emit();
FatalError.raise();
}
}
}


// fail if there have been errors emitted
if ecx.parse_sess.span_diagnostic.err_count() > error_count_before {
ecx.struct_span_fatal(span, msg).emit();
FatalError.raise();
}

items
}
}

struct MarkAttrs<'a>(&'a [ast::Name]);

impl<'a> Visitor<'a> for MarkAttrs<'a> {
fn visit_attribute(&mut self, attr: &Attribute) {
if let Some(ident) = attr.ident() {
if self.0.contains(&ident.name) {
mark_used(attr);
mark_known(attr);
}
}
}

fn visit_mac(&mut self, _mac: &Mac) {}
}

pub fn is_proc_macro_attr(attr: &Attribute) -> bool {
[sym::proc_macro, sym::proc_macro_attribute, sym::proc_macro_derive]
.iter().any(|kind| attr.check_name(*kind))
}

crate fn collect_derives(cx: &mut ExtCtxt<'_>, attrs: &mut Vec<ast::Attribute>) -> Vec<ast::Path> {
let mut result = Vec::new();
attrs.retain(|attr| {
if attr.path != sym::derive {
return true;
}
if !attr.is_meta_item_list() {
cx.struct_span_err(attr.span, "malformed `derive` attribute input")
.span_suggestion(
attr.span,
"missing traits to be derived",
"#[derive(Trait1, Trait2, ...)]".to_owned(),
Applicability::HasPlaceholders,
).emit();
return false;
}

match attr.parse_list(cx.parse_sess,
|parser| parser.parse_path_allowing_meta(PathStyle::Mod)) {
Ok(traits) => {
result.extend(traits);
true
}
Err(mut e) => {
e.emit();
false
}
}
});
result
}

crate fn add_derived_markers<T: HasAttrs>(
cx: &mut ExtCtxt<'_>, span: Span, traits: &[ast::Path], item: &mut T
) {
let (mut names, mut pretty_name) = (FxHashSet::default(), String::new());
for (i, path) in traits.iter().enumerate() {
if i > 0 {
pretty_name.push_str(", ");
}
pretty_name.push_str(&path.to_string());
names.insert(unwrap_or!(path.segments.get(0), continue).ident.name);
}

let span = span.fresh_expansion(cx.current_expansion.mark, ExpnInfo::allow_unstable(
ExpnKind::Macro(MacroKind::Derive, Symbol::intern(&pretty_name)), span,
cx.parse_sess.edition, cx.allow_derive_markers.clone(),
));

item.visit_attrs(|attrs| {
if names.contains(&sym::Eq) && 56B8 amp; names.contains(&sym::PartialEq) {
let meta = cx.meta_word(span, sym::structural_match);
attrs.push(cx.attribute(span, meta));
}
if names.contains(&sym::Copy) {
let meta = cx.meta_word(span, sym::rustc_copy_clone_marker);
attrs.push(cx.attribute(span, meta));
}
});
}
Loading
0