From e1c7747cf06bc063a6586c1eab898703f61899d8 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Thu, 11 Jul 2019 16:54:33 -0700 Subject: Handle errors during error recovery gracefully --- src/test/ui/parser/issue-62546.rs | 3 +++ src/test/ui/parser/issue-62546.stderr | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/test/ui/parser/issue-62546.rs create mode 100644 src/test/ui/parser/issue-62546.stderr (limited to 'src/test') diff --git a/src/test/ui/parser/issue-62546.rs b/src/test/ui/parser/issue-62546.rs new file mode 100644 index 00000000000..75b95e74073 --- /dev/null +++ b/src/test/ui/parser/issue-62546.rs @@ -0,0 +1,3 @@ +pub t(# +//~^ ERROR missing `fn` or `struct` for function or struct definition +//~ ERROR this file contains an un-closed delimiter diff --git a/src/test/ui/parser/issue-62546.stderr b/src/test/ui/parser/issue-62546.stderr new file mode 100644 index 00000000000..631aac95505 --- /dev/null +++ b/src/test/ui/parser/issue-62546.stderr @@ -0,0 +1,17 @@ +error: this file contains an un-closed delimiter + --> $DIR/issue-62546.rs:3:53 + | +LL | pub t(# + | - un-closed delimiter +LL | +LL | + | ^ + +error: missing `fn` or `struct` for function or struct definition + --> $DIR/issue-62546.rs:1:4 + | +LL | pub t(# + | ---^- help: if you meant to call a macro, try: `t!` + +error: aborting due to 2 previous errors + -- cgit 1.4.1-3-g733a5 From e4b8af5d607b465f11615abefb5bbae20486887e Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Thu, 11 Jul 2019 13:54:54 +0200 Subject: Regression test for issue 60431. --- .../issue-60431-unsized-tail-behind-projection.rs | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/test/ui/layout/issue-60431-unsized-tail-behind-projection.rs (limited to 'src/test') diff --git a/src/test/ui/layout/issue-60431-unsized-tail-behind-projection.rs b/src/test/ui/layout/issue-60431-unsized-tail-behind-projection.rs new file mode 100644 index 00000000000..65845d2c9fe --- /dev/null +++ b/src/test/ui/layout/issue-60431-unsized-tail-behind-projection.rs @@ -0,0 +1,35 @@ +// rust-lang/rust#60431: This is a scenario where to determine the size of +// `&Ref`, we need to know the concrete type of the last field in +// `Ref` (i.e. its "struct tail"), and determining that concrete type +// requires normalizing `Obstack::Dyn`. +// +// The old "struct tail" computation did not perform such normalization, and so +// the compiler would ICE when trying to figure out if `Ref` is a +// dynamically-sized type (DST). + +// run-pass + +use std::mem; + +pub trait Arena { + type Dyn : ?Sized; +} + +pub struct DynRef { + _dummy: [()], +} + +pub struct Ref { + _value: u8, + _dyn_arena: A::Dyn, +} + +pub struct Obstack; + +impl Arena for Obstack { + type Dyn = DynRef; +} + +fn main() { + assert_eq!(mem::size_of::<&Ref>(), mem::size_of::<&[()]>()); +} -- cgit 1.4.1-3-g733a5 From 313ba7c4d11f52b808f29678b008bb0962f9af91 Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Sat, 13 Jul 2019 09:55:14 +0100 Subject: Make `newtype_index` hygienic and use allow_internal_unstable --- src/librustc/lib.rs | 2 -- src/librustc_data_structures/indexed_vec.rs | 33 +++++++++++++++-------------- src/librustc_mir/lib.rs | 2 -- src/librustc_target/abi/mod.rs | 1 + src/librustc_target/lib.rs | 5 ----- src/libsyntax/lib.rs | 2 -- src/test/run-pass-fulldeps/newtype_index.rs | 6 +++--- 7 files changed, 21 insertions(+), 30 deletions(-) (limited to 'src/test') diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index dc26140ace5..63e0107a4d8 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -49,7 +49,6 @@ #![feature(optin_builtin_traits)] #![feature(range_is_empty)] #![feature(rustc_diagnostic_macros)] -#![feature(rustc_attrs)] #![feature(slice_patterns)] #![feature(specialization)] #![feature(unboxed_closures)] @@ -57,7 +56,6 @@ #![feature(trace_macros)] #![feature(trusted_len)] #![feature(vec_remove_item)] -#![feature(step_trait)] #![feature(stmt_expr_attributes)] #![feature(integer_atomics)] #![feature(test)] diff --git a/src/librustc_data_structures/indexed_vec.rs b/src/librustc_data_structures/indexed_vec.rs index b3a810a622d..c3c76e81606 100644 --- a/src/librustc_data_structures/indexed_vec.rs +++ b/src/librustc_data_structures/indexed_vec.rs @@ -57,12 +57,13 @@ impl Idx for u32 { /// `u32::MAX`. You can also customize things like the `Debug` impl, /// what traits are derived, and so forth via the macro. #[macro_export] +#[allow_internal_unstable(step_trait, rustc_attrs)] macro_rules! newtype_index { // ---- public rules ---- // Use default constants ($(#[$attrs:meta])* $v:vis struct $name:ident { .. }) => ( - newtype_index!( + $crate::newtype_index!( // Leave out derives marker so we can use its absence to ensure it comes first @attrs [$(#[$attrs])*] @type [$name] @@ -74,7 +75,7 @@ macro_rules! newtype_index { // Define any constants ($(#[$attrs:meta])* $v:vis struct $name:ident { $($tokens:tt)+ }) => ( - newtype_index!( + $crate::newtype_index!( // Leave out derives marker so we can use its absence to ensure it comes first @attrs [$(#[$attrs])*] @type [$name] @@ -258,7 +259,7 @@ macro_rules! newtype_index { } } - newtype_index!( + $crate::newtype_index!( @handle_debug @derives [$($derives,)*] @type [$type] @@ -294,7 +295,7 @@ macro_rules! newtype_index { @derives [$_derive:ident, $($derives:ident,)*] @type [$type:ident] @debug_format [$debug_format:tt]) => ( - newtype_index!( + $crate::newtype_index!( @handle_debug @derives [$($derives,)*] @type [$type] @@ -309,7 +310,7 @@ macro_rules! newtype_index { @debug_format [$debug_format:tt] derive [$($derives:ident),*] $($tokens:tt)*) => ( - newtype_index!( + $crate::newtype_index!( @attrs [$(#[$attrs])*] @type [$type] @max [$max] @@ -329,7 +330,7 @@ macro_rules! newtype_index { derive [$($derives:ident,)+] ENCODABLE = custom $($tokens:tt)*) => ( - newtype_index!( + $crate::newtype_index!( @attrs [$(#[$attrs])*] @derives [$($derives,)+] @type [$type] @@ -348,7 +349,7 @@ macro_rules! newtype_index { @debug_format [$debug_format:tt] derive [$($derives:ident,)+] $($tokens:tt)*) => ( - newtype_index!( + $crate::newtype_index!( @derives [$($derives,)+ RustcEncodable,] @attrs [$(#[$attrs])*] @type [$type] @@ -356,7 +357,7 @@ macro_rules! newtype_index { @vis [$v] @debug_format [$debug_format] $($tokens)*); - newtype_index!(@decodable $type); + $crate::newtype_index!(@decodable $type); ); // The case where no derives are added, but encodable is overridden. Don't @@ -368,7 +369,7 @@ macro_rules! newtype_index { @debug_format [$debug_format:tt] ENCODABLE = custom $($tokens:tt)*) => ( - newtype_index!( + $crate::newtype_index!( @derives [] @attrs [$(#[$attrs])*] @type [$type] @@ -385,7 +386,7 @@ macro_rules! newtype_index { @vis [$v:vis] @debug_format [$debug_format:tt] $($tokens:tt)*) => ( - newtype_index!( + $crate::newtype_index!( @derives [RustcEncodable,] @attrs [$(#[$attrs])*] @type [$type] @@ -393,7 +394,7 @@ macro_rules! newtype_index { @vis [$v] @debug_format [$debug_format] $($tokens)*); - newtype_index!(@decodable $type); + $crate::newtype_index!(@decodable $type); ); (@decodable $type:ident) => ( @@ -420,7 +421,7 @@ macro_rules! newtype_index { @vis [$v:vis] @debug_format [$debug_format:tt] $name:ident = $constant:expr) => ( - newtype_index!( + $crate::newtype_index!( @derives [$($derives,)*] @attrs [$(#[$attrs])*] @type [$type] @@ -439,7 +440,7 @@ macro_rules! newtype_index { @debug_format [$debug_format:tt] $(#[doc = $doc:expr])* const $name:ident = $constant:expr) => ( - newtype_index!( + $crate::newtype_index!( @derives [$($derives,)*] @attrs [$(#[$attrs])*] @type [$type] @@ -458,7 +459,7 @@ macro_rules! newtype_index { @debug_format [$debug_format:tt] MAX = $max:expr, $($tokens:tt)*) => ( - newtype_index!( + $crate::newtype_index!( @derives [$($derives,)*] @attrs [$(#[$attrs])*] @type [$type] @@ -477,7 +478,7 @@ macro_rules! newtype_index { @debug_format [$_debug_format:tt] DEBUG_FORMAT = $debug_format:tt, $($tokens:tt)*) => ( - newtype_index!( + $crate::newtype_index!( @derives [$($derives,)*] @attrs [$(#[$attrs])*] @type [$type] @@ -499,7 +500,7 @@ macro_rules! newtype_index { $($tokens:tt)*) => ( $(#[doc = $doc])* pub const $name: $type = $type::from_u32_const($constant); - newtype_index!( + $crate::newtype_index!( @derives [$($derives,)*] @attrs [$(#[$attrs])*] @type [$type] diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index 4a80534503a..f5e4661afa6 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -15,12 +15,10 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! #![feature(decl_macro)] #![feature(exhaustive_patterns)] #![feature(rustc_diagnostic_macros)] -#![feature(rustc_attrs)] #![feature(never_type)] #![feature(specialization)] #![feature(try_trait)] #![feature(unicode_internals)] -#![feature(step_trait)] #![feature(slice_concat_ext)] #![feature(trusted_len)] #![feature(try_blocks)] diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs index 55cb1791443..01586e92aeb 100644 --- a/src/librustc_target/abi/mod.rs +++ b/src/librustc_target/abi/mod.rs @@ -6,6 +6,7 @@ use crate::spec::Target; use std::fmt; use std::ops::{Add, Deref, Sub, Mul, AddAssign, Range, RangeInclusive}; +use rustc_data_structures::newtype_index; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use syntax_pos::symbol::{sym, Symbol}; diff --git a/src/librustc_target/lib.rs b/src/librustc_target/lib.rs index c1ec4e59ef2..dcd1eb5acdc 100644 --- a/src/librustc_target/lib.rs +++ b/src/librustc_target/lib.rs @@ -11,9 +11,7 @@ #![feature(box_syntax)] #![feature(nll)] -#![feature(rustc_attrs)] #![feature(slice_patterns)] -#![feature(step_trait)] #![deny(rust_2018_idioms)] #![deny(unused_lifetimes)] @@ -23,8 +21,5 @@ #[allow(unused_extern_crates)] extern crate serialize as rustc_serialize; // used by deriving -#[macro_use] -extern crate rustc_data_structures; - pub mod abi; pub mod spec; diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index ee7fb97ffd7..591f2fb599b 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -18,9 +18,7 @@ #![feature(label_break_value)] #![feature(mem_take)] #![feature(nll)] -#![feature(rustc_attrs)] #![feature(rustc_diagnostic_macros)] -#![feature(step_trait)] #![feature(try_trait)] #![feature(unicode_internals)] diff --git a/src/test/run-pass-fulldeps/newtype_index.rs b/src/test/run-pass-fulldeps/newtype_index.rs index 18b845eeecb..1192a44a6ee 100644 --- a/src/test/run-pass-fulldeps/newtype_index.rs +++ b/src/test/run-pass-fulldeps/newtype_index.rs @@ -1,9 +1,9 @@ -#![feature(rustc_attrs, rustc_private, step_trait)] +#![feature(rustc_private)] -#[macro_use] extern crate rustc_data_structures; +extern crate rustc_data_structures; extern crate serialize as rustc_serialize; -use rustc_data_structures::indexed_vec::Idx; +use rustc_data_structures::{newtype_index, indexed_vec::Idx}; newtype_index!(struct MyIdx { MAX = 0xFFFF_FFFA }); -- cgit 1.4.1-3-g733a5