From 0700558673a545413de75bab8c0a9be27e524b5c Mon Sep 17 00:00:00 2001 From: ljedrz Date: Thu, 19 Jul 2018 10:11:55 +0200 Subject: Enable run-pass/sepcomp-lib-lto.rs on Android --- src/test/run-pass/sepcomp-lib-lto.rs | 1 - 1 file changed, 1 deletion(-) (limited to 'src/test') diff --git a/src/test/run-pass/sepcomp-lib-lto.rs b/src/test/run-pass/sepcomp-lib-lto.rs index f3e52fbd32f..8d73f4db7d2 100644 --- a/src/test/run-pass/sepcomp-lib-lto.rs +++ b/src/test/run-pass/sepcomp-lib-lto.rs @@ -14,7 +14,6 @@ // aux-build:sepcomp_lib.rs // compile-flags: -C lto -g // no-prefer-dynamic -// ignore-android FIXME #18800 extern crate sepcomp_lib; use sepcomp_lib::a::one; -- cgit 1.4.1-3-g733a5 From f2f7ab9da835f5fd66722f2efec9285ea72ad0f4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 19 Jul 2018 07:43:58 -0700 Subject: rustc: Fix two custom attributes with custom derive This commit fixes an issue where multiple custom attributes could not be fed into a custom derive in some situations with the `use_extern_macros` feature enabled. The problem was that the macro expander didn't consider that it was making progress when we were deducing that attributes should be lumped in with custom derive invocations. The fix applied here was to track in the expander if our attribute is changing (getting stashed away elsewhere and replaced with a new invocation). If it is swapped then it's considered progress, otherwise behavior should remain the same. Closes #52525 --- src/libsyntax/ext/expand.rs | 17 +++++++++++++++ .../proc-macro/auxiliary/derive-two-attrs.rs | 22 ++++++++++++++++++++ .../proc-macro/derive-two-attrs.rs | 24 ++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-two-attrs.rs create mode 100644 src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs (limited to 'src/test') diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 1241e230b26..d64f3de8daa 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -240,6 +240,13 @@ impl Invocation { InvocationKind::Derive { ref path, .. } => path.span, } } + + pub fn attr_id(&self) -> Option { + match self.kind { + InvocationKind::Attr { attr: Some(ref attr), .. } => Some(attr.id), + _ => None, + } + } } pub struct MacroExpander<'a, 'b:'a> { @@ -331,10 +338,20 @@ impl<'a, 'b> MacroExpander<'a, 'b> { let scope = if self.monotonic { invoc.expansion_data.mark } else { orig_expansion_data.mark }; + let attr_id_before = invoc.attr_id(); let ext = match self.cx.resolver.resolve_invoc(&mut invoc, scope, force) { Ok(ext) => Some(ext), Err(Determinacy::Determined) => None, Err(Determinacy::Undetermined) => { + // Sometimes attributes which we thought were invocations + // end up being custom attributes for custom derives. If + // that's the case our `invoc` will have changed out from + // under us. If this is the case we're making progress so we + // want to flag it as such, and we test this by looking if + // the `attr_id()` method has been changing over time. + if invoc.attr_id() != attr_id_before { + progress = true; + } undetermined_invocations.push(invoc); continue } diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-two-attrs.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-two-attrs.rs new file mode 100644 index 00000000000..d02edb50fb2 --- /dev/null +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-two-attrs.rs @@ -0,0 +1,22 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::*; + +#[proc_macro_derive(A, attributes(b))] +pub fn foo(_x: TokenStream) -> TokenStream { + TokenStream::new() +} diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs b/src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs new file mode 100644 index 00000000000..6a0a3b3a941 --- /dev/null +++ b/src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs @@ -0,0 +1,24 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:derive-two-attrs.rs + +#![feature(use_extern_macros)] + +extern crate derive_two_attrs as foo; + +use foo::A; + +#[derive(A)] +#[b] +#[b] +struct B; + +fn main() {} -- cgit 1.4.1-3-g733a5 From 576cfc510aefc1b21c1ff3a0e8ff5efe84529434 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Thu, 19 Jul 2018 10:28:25 +0200 Subject: Remove duplicate E0396 tests --- src/test/run-pass/const-block.rs | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src/test') diff --git a/src/test/run-pass/const-block.rs b/src/test/run-pass/const-block.rs index e56d01d7ba8..e6f191ea952 100644 --- a/src/test/run-pass/const-block.rs +++ b/src/test/run-pass/const-block.rs @@ -39,13 +39,6 @@ static BLOCK_FN: fn(usize) -> usize = { foo:: }; static BLOCK_ENUM_CONSTRUCTOR: fn(usize) -> Option = { Some }; -// FIXME #13972 -// static BLOCK_UNSAFE_SAFE_PTR: &'static isize = unsafe { &*(0xdeadbeef as *const isize) }; -// static BLOCK_UNSAFE_SAFE_PTR_2: &'static isize = unsafe { -// const X: *const isize = 0xdeadbeef as *const isize; -// &*X -// }; - pub fn main() { assert_eq!(BLOCK_INTEGRAL, 1); assert_eq!(BLOCK_EXPLICIT_UNIT, ()); @@ -58,7 +51,4 @@ pub fn main() { assert_eq!(BLOCK_FN_INFERRED(300), 300); assert_eq!(BLOCK_FN(300), 300); assert_eq!(BLOCK_ENUM_CONSTRUCTOR(200), Some(200)); - // FIXME #13972 - // assert_eq!(BLOCK_UNSAFE_SAFE_PTR as *const isize as usize, 0xdeadbeef); - // assert_eq!(BLOCK_UNSAFE_SAFE_PTR_2 as *const isize as usize, 0xdeadbeef); } -- cgit 1.4.1-3-g733a5