Skip to content

Rollup of 7 pull requests #52567

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 26 commits into from
Closed
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
829bc26
rustc: Remove a workaroudn in ThinLTO fixed upstream
alexcrichton Jul 18, 2018
6d50672
Reword when `_` couldn't be inferred
Jul 18, 2018
5332375
proc_macro: Preserve spans of attributes on functions
alexcrichton Jul 19, 2018
f775c6d
Fix docker/run.sh script when run locally
alexcrichton Jul 19, 2018
0320d1b
Add tests for #34784
wesleywiser Jul 20, 2018
2db7bec
Add compile-fail test for #33264
wesleywiser Jul 20, 2018
1aeed60
Add run-pass test for #44005
wesleywiser Jul 20, 2018
608caeb
Add compile-fail test for #42060
wesleywiser Jul 20, 2018
ea495e3
Add compile-fail test for #43196
wesleywiser Jul 20, 2018
3e0cb23
Update compile-fail tests to be ui tests
wesleywiser Jul 20, 2018
576cfc5
Remove duplicate E0396 tests
ljedrz Jul 19, 2018
c44f724
resolve: Remove unused parameter from `resolve_ident_in_module`
petrochenkov Jul 16, 2018
2214349
resolve: Rename `global_macros` to `macro_prelude`
petrochenkov Jul 16, 2018
c2533b6
resolve: Remove `SingleImports` in favor of a simple set
petrochenkov Jul 17, 2018
414a86e
resolve: Add some comments to in-module resolution
petrochenkov Jul 18, 2018
2eb83ee
data_structures: Add a reference wrapper for pointer-indexed maps/sets
petrochenkov Jul 18, 2018
32453db
resolve: Fully prohibit shadowing of in-scope names by globs in macro…
petrochenkov Jul 19, 2018
e7aeb2b
resolve: Add more comments to in-module resolution
petrochenkov Jul 19, 2018
382285a
Revert some use of `PtrKey` to fix parallel_queries build
petrochenkov Jul 20, 2018
3840645
Rollup merge of #52505 - alexcrichton:remove-thinlto-hack, r=nikomats…
pietroalbini Jul 20, 2018
a1234ef
Rollup merge of #52507 - estebank:infer-type, r=nikomatsakis
pietroalbini Jul 20, 2018
6cd5dbf
Rollup merge of #52527 - ljedrz:cleanup_13973, r=oli-obk
pietroalbini Jul 20, 2018
420cba6
Rollup merge of #52536 - alexcrichton:attr-spans, r=nikomatsakis
pietroalbini Jul 20, 2018
172524b
Rollup merge of #52540 - alexcrichton:tweak-script, r=kennytm
pietroalbini Jul 20, 2018
ec4d796
Rollup merge of #52555 - petrochenkov:mresfact, r=alexcrichton
pietroalbini Jul 20, 2018
6045d93
Rollup merge of #52558 - wesleywiser:ice_melting, r=estebank
pietroalbini Jul 20, 2018
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
2 changes: 1 addition & 1 deletion src/ci/docker/run.sh
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@ objdir=$root_dir/obj

mkdir -p $HOME/.cargo
mkdir -p $objdir/tmp
mkdir $objdir/cores
mkdir -p $objdir/cores

args=
if [ "$SCCACHE_BUCKET" != "" ]; then
2 changes: 1 addition & 1 deletion src/liballoc/collections/btree/node.rs
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ impl<K, V> LeafNode<K, V> {
}

fn is_shared_root(&self) -> bool {
self as *const _ == &EMPTY_ROOT_NODE as *const _ as *const LeafNode<K, V>
ptr::eq(self, &EMPTY_ROOT_NODE as *const _ as *const _)
}
}

9 changes: 8 additions & 1 deletion src/librustc/infer/error_reporting/need_type_info.rs
Original file line number Diff line number Diff line change
@@ -97,7 +97,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
let name = self.extract_type_name(&ty);

let mut err_span = span;
let mut labels = vec![(span, format!("cannot infer type for `{}`", name))];
let mut labels = vec![(
span,
if &name == "_" {
"cannot infer type".to_string()
} else {
format!("cannot infer type for `{}`", name)
},
)];

let mut local_visitor = FindLocalByTypeVisitor {
infcx: &self,
4 changes: 2 additions & 2 deletions src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ use hir::intravisit;
use hir;
use lint::builtin::BuiltinLintDiagnostics;
use session::{Session, DiagnosticMessageId};
use std::hash;
use std::{hash, ptr};
use syntax::ast;
use syntax::codemap::{MultiSpan, ExpnFormat};
use syntax::edition::Edition;
@@ -354,7 +354,7 @@ pub struct LintId {

impl PartialEq for LintId {
fn eq(&self, other: &LintId) -> bool {
(self.lint as *const Lint) == (other.lint as *const Lint)
ptr::eq(self.lint, other.lint)
}
}

9 changes: 4 additions & 5 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ use std::ops::Deref;
use rustc_data_structures::sync::{self, Lrc, ParallelIterator, par_iter};
use std::slice;
use std::vec::IntoIter;
use std::mem;
use std::{mem, ptr};
use syntax::ast::{self, DUMMY_NODE_ID, Name, Ident, NodeId};
use syntax::attr;
use syntax::ext::hygiene::Mark;
@@ -527,8 +527,7 @@ impl<'tcx> PartialOrd for TyS<'tcx> {
impl<'tcx> PartialEq for TyS<'tcx> {
#[inline]
fn eq(&self, other: &TyS<'tcx>) -> bool {
// (self as *const _) == (other as *const _)
(self as *const TyS<'tcx>) == (other as *const TyS<'tcx>)
ptr::eq(self, other)
}
}
impl<'tcx> Eq for TyS<'tcx> {}
@@ -678,7 +677,7 @@ impl<T> PartialOrd for Slice<T> where T: PartialOrd {
impl<T: PartialEq> PartialEq for Slice<T> {
#[inline]
fn eq(&self, other: &Slice<T>) -> bool {
(self as *const _) == (other as *const _)
ptr::eq(self, other)
}
}
impl<T: Eq> Eq for Slice<T> {}
@@ -1730,7 +1729,7 @@ impl Ord for AdtDef {
impl PartialEq for AdtDef {
// AdtDef are always interned and this is part of TyS equality
#[inline]
fn eq(&self, other: &Self) -> bool { self as *const _ == other as *const _ }
fn eq(&self, other: &Self) -> bool { ptr::eq(self, other) }
}

impl Eq for AdtDef {}
4 changes: 2 additions & 2 deletions src/librustc/ty/query/job.rs
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ use ty::query::plumbing::CycleError;
use ty::context::TyCtxt;
use errors::Diagnostic;
use std::process;
use std::fmt;
use std::{fmt, ptr};
use std::collections::HashSet;
#[cfg(parallel_queries)]
use {
@@ -124,7 +124,7 @@ impl<'tcx> QueryJob<'tcx> {
while let Some(job) = current_job {
cycle.insert(0, job.info.clone());

if &*job as *const _ == self as *const _ {
if ptr::eq(&*job, self) {
// This is the end of the cycle
// The span entry we included was for the usage
// of the cycle itself, and not part of the cycle
14 changes: 0 additions & 14 deletions src/librustc_codegen_llvm/back/lto.rs
Original file line number Diff line number Diff line change
@@ -759,20 +759,6 @@ impl ThinModule {
cgcx.save_temp_bitcode(&module, "thin-lto-after-pm");
timeline.record("thin-done");

// FIXME: this is a hack around a bug in LLVM right now. Discovered in
// #46910 it was found out that on 32-bit MSVC LLVM will hit a codegen
// error if there's an available_externally function in the LLVM module.
// Typically we don't actually use these functions but ThinLTO makes
// heavy use of them when inlining across modules.
//
// Tracked upstream at https://bugs.llvm.org/show_bug.cgi?id=35736 this
// function call (and its definition on the C++ side of things)
// shouldn't be necessary eventually and we can safetly delete these few
// lines.
llvm::LLVMRustThinLTORemoveAvailableExternally(llmod);
cgcx.save_temp_bitcode(&module, "thin-lto-after-rm-ae");
timeline.record("no-ae");

Ok(module)
}
}
21 changes: 11 additions & 10 deletions src/librustc_data_structures/lib.rs
Original file line number Diff line number Diff line change
@@ -56,29 +56,30 @@ extern crate rustc_cratesio_shim;

pub use rustc_serialize::hex::ToHex;

pub mod array_vec;
pub mod accumulate_vec;
pub mod small_vec;
pub mod array_vec;
pub mod base_n;
pub mod bitslice;
pub mod bitvec;
pub mod flock;
pub mod fx;
pub mod graph;
pub mod indexed_set;
pub mod indexed_vec;
pub mod obligation_forest;
pub mod owning_ref;
pub mod ptr_key;
pub mod sip128;
pub mod small_vec;
pub mod snapshot_map;
pub use ena::snapshot_vec;
pub mod sorted_map;
pub mod stable_hasher;
pub mod transitive_relation;
pub use ena::unify;
pub mod fx;
pub mod tuple_slice;
pub mod graph;
pub mod flock;
pub mod sync;
pub mod owning_ref;
pub mod tiny_list;
pub mod sorted_map;
pub mod transitive_relation;
pub mod tuple_slice;
pub use ena::unify;
pub mod work_queue;

pub struct OnDrop<F: Fn()>(pub F);
45 changes: 45 additions & 0 deletions src/librustc_data_structures/ptr_key.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::{hash, ptr};
use std::ops::Deref;

/// A wrapper around reference that compares and hashes like a pointer.
/// Can be used as a key in sets/maps indexed by pointers to avoid `unsafe`.
#[derive(Debug)]
pub struct PtrKey<'a, T: 'a>(pub &'a T);

impl<'a, T> Clone for PtrKey<'a, T> {
fn clone(&self) -> Self { *self }
}

impl<'a, T> Copy for PtrKey<'a, T> {}

impl<'a, T> PartialEq for PtrKey<'a, T> {
fn eq(&self, rhs: &Self) -> bool {
ptr::eq(self.0, rhs.0)
}
}

impl<'a, T> Eq for PtrKey<'a, T> {}

impl<'a, T> hash::Hash for PtrKey<'a, T> {
fn hash<H: hash::Hasher>(&self, hasher: &mut H) {
(self.0 as *const T).hash(hasher)
}
}

impl<'a, T> Deref for PtrKey<'a, T> {
type Target = T;

fn deref(&self) -> &Self::Target {
self.0
}
}
1 change: 0 additions & 1 deletion src/librustc_llvm/ffi.rs
Original file line number Diff line number Diff line change
@@ -1791,7 +1791,6 @@ extern "C" {
CU1: *mut *mut c_void,
CU2: *mut *mut c_void);
pub fn LLVMRustThinLTOPatchDICompileUnit(M: ModuleRef, CU: *mut c_void);
pub fn LLVMRustThinLTORemoveAvailableExternally(M: ModuleRef);

pub fn LLVMRustLinkerNew(M: ModuleRef) -> LinkerRef;
pub fn LLVMRustLinkerAdd(linker: LinkerRef,
5 changes: 2 additions & 3 deletions src/librustc_resolve/build_reduced_graph.rs
Original file line number Diff line number Diff line change
@@ -651,7 +651,7 @@ impl<'a> Resolver<'a> {
binding: &'a NameBinding<'a>,
span: Span,
allow_shadowing: bool) {
if self.global_macros.insert(name, binding).is_some() && !allow_shadowing {
if self.macro_prelude.insert(name, binding).is_some() && !allow_shadowing {
let msg = format!("`{}` is already in scope", name);
let note =
"macro-expanded `#[macro_use]`s may not shadow existing macros (see RFC 1560)";
@@ -704,8 +704,7 @@ impl<'a> Resolver<'a> {
} else {
for (name, span) in legacy_imports.imports {
let ident = Ident::with_empty_ctxt(name);
let result = self.resolve_ident_in_module(module, ident, MacroNS,
false, false, span);
let result = self.resolve_ident_in_module(module, ident, MacroNS, false, span);
if let Ok(binding) = result {
let directive = macro_use_directive(span);
self.potentially_unused_imports.push(directive);
17 changes: 8 additions & 9 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
@@ -1393,7 +1393,7 @@ pub struct Resolver<'a> {

crate_loader: &'a mut dyn CrateLoader,
macro_names: FxHashSet<Ident>,
global_macros: FxHashMap<Name, &'a NameBinding<'a>>,
macro_prelude: FxHashMap<Name, &'a NameBinding<'a>>,
pub all_macros: FxHashMap<Name, Def>,
lexical_macro_resolutions: Vec<(Ident, &'a Cell<LegacyScope<'a>>)>,
macro_map: FxHashMap<DefId, Lrc<SyntaxExtension>>,
@@ -1715,7 +1715,7 @@ impl<'a> Resolver<'a> {

crate_loader,
macro_names: FxHashSet(),
global_macros: FxHashMap(),
macro_prelude: FxHashMap(),
all_macros: FxHashMap(),
lexical_macro_resolutions: Vec::new(),
macro_map: FxHashMap(),
@@ -2002,7 +2002,6 @@ impl<'a> Resolver<'a> {
module: Module<'a>,
mut ident: Ident,
ns: Namespace,
ignore_unresolved_invocations: bool,
record_used: bool,
span: Span)
-> Result<&'a NameBinding<'a>, Determinacy> {
@@ -2012,7 +2011,7 @@ impl<'a> Resolver<'a> {
self.current_module = self.macro_def_scope(def);
}
let result = self.resolve_ident_in_module_unadjusted(
module, ident, ns, ignore_unresolved_invocations, record_used, span,
module, ident, ns, false, record_used, span,
);
self.current_module = orig_current_module;
result
@@ -2518,7 +2517,7 @@ impl<'a> Resolver<'a> {
// If there is a TraitRef in scope for an impl, then the method must be in the
// trait.
if let Some((module, _)) = self.current_trait_ref {
if self.resolve_ident_in_module(module, ident, ns, false, false, span).is_err() {
if self.resolve_ident_in_module(module, ident, ns, false, span).is_err() {
let path = &self.current_trait_ref.as_ref().unwrap().1.path;
resolve_error(self, span, err(ident.name, &path_names_to_string(path)));
}
@@ -3225,7 +3224,7 @@ impl<'a> Resolver<'a> {
};
}
}
let is_global = self.global_macros.get(&path[0].name).cloned()
let is_global = self.macro_prelude.get(&path[0].name).cloned()
.map(|binding| binding.get_macro(self).kind() == MacroKind::Bang).unwrap_or(false);
if primary_ns != MacroNS && (is_global ||
self.macro_names.contains(&path[0].modern())) {
@@ -3468,7 +3467,7 @@ impl<'a> Resolver<'a> {
}

let binding = if let Some(module) = module {
self.resolve_ident_in_module(module, ident, ns, false, record_used, path_span)
self.resolve_ident_in_module(module, ident, ns, record_used, path_span)
} else if opt_ns == Some(MacroNS) {
self.resolve_lexical_macro_path_segment(ident, ns, record_used, path_span)
.map(MacroBinding::binding)
@@ -3762,7 +3761,7 @@ impl<'a> Resolver<'a> {
// Look for associated items in the current trait.
if let Some((module, _)) = self.current_trait_ref {
if let Ok(binding) =
self.resolve_ident_in_module(module, ident, ns, false, false, module.span) {
self.resolve_ident_in_module(module, ident, ns, false, module.span) {
let def = binding.def();
if filter_fn(def) {
return Some(if self.has_self.contains(&def.def_id()) {
@@ -4075,7 +4074,7 @@ impl<'a> Resolver<'a> {
let mut found_traits = Vec::new();
// Look for the current trait.
if let Some((module, _)) = self.current_trait_ref {
if self.resolve_ident_in_module(module, ident, ns, false, false, module.span).is_ok() {
if self.resolve_ident_in_module(module, ident, ns, false, module.span).is_ok() {
let def_id = module.def_id().unwrap();
found_traits.push(TraitCandidate { def_id: def_id, import_id: None });
}
17 changes: 8 additions & 9 deletions src/librustc_resolve/macros.rs
Original file line number Diff line number Diff line change
@@ -220,7 +220,7 @@ impl<'a> base::Resolver for Resolver<'a> {
vis: ty::Visibility::Invisible,
expansion: Mark::root(),
});
self.global_macros.insert(ident.name, binding);
self.macro_prelude.insert(ident.name, binding);
}

fn resolve_imports(&mut self) {
@@ -238,7 +238,7 @@ impl<'a> base::Resolver for Resolver<'a> {
attr::mark_known(&attrs[i]);
}

match self.global_macros.get(&name).cloned() {
match self.macro_prelude.get(&name).cloned() {
Some(binding) => match *binding.get_macro(self) {
MultiModifier(..) | MultiDecorator(..) | SyntaxExtension::AttrProcMacro(..) => {
return Some(attrs.remove(i))
@@ -274,7 +274,7 @@ impl<'a> base::Resolver for Resolver<'a> {
}
let trait_name = traits[j].segments[0].ident.name;
let legacy_name = Symbol::intern(&format!("derive_{}", trait_name));
if !self.global_macros.contains_key(&legacy_name) {
if !self.macro_prelude.contains_key(&legacy_name) {
continue
}
let span = traits.remove(j).span;
@@ -565,7 +565,7 @@ impl<'a> Resolver<'a> {
module, ident, ns, true, record_used, path_span,
).map(MacroBinding::Modern)
} else {
self.global_macros.get(&ident.name).cloned().ok_or(determinacy)
self.macro_prelude.get(&ident.name).cloned().ok_or(determinacy)
.map(MacroBinding::Global)
};
self.current_module = orig_current_module;
@@ -588,8 +588,7 @@ impl<'a> Resolver<'a> {
return potential_illegal_shadower;
}
}
if binding.expansion != Mark::root() ||
(binding.is_glob_import() && module.unwrap().def().is_some()) {
if binding.is_glob_import() || binding.expansion != Mark::root() {
potential_illegal_shadower = result;
} else {
return result;
@@ -652,7 +651,7 @@ impl<'a> Resolver<'a> {

let binding = if let Some(binding) = binding {
MacroBinding::Legacy(binding)
} else if let Some(binding) = self.global_macros.get(&ident.name).cloned() {
} else if let Some(binding) = self.macro_prelude.get(&ident.name).cloned() {
if !self.use_extern_macros {
self.record_use(ident, MacroNS, binding, DUMMY_SP);
}
@@ -762,8 +761,8 @@ impl<'a> Resolver<'a> {
// Then check global macros.
}.or_else(|| {
// FIXME: get_macro needs an &mut Resolver, can we do it without cloning?
let global_macros = self.global_macros.clone();
let names = global_macros.iter().filter_map(|(name, binding)| {
let macro_prelude = self.macro_prelude.clone();
let names = macro_prelude.iter().filter_map(|(name, binding)| {
if binding.get_macro(self).kind() == kind {
Some(name)
} else {
193 changes: 70 additions & 123 deletions src/librustc_resolve/resolve_imports.rs

Large diffs are not rendered by default.

49 changes: 44 additions & 5 deletions src/libsyntax/parse/token.rs
Original file line number Diff line number Diff line change
@@ -777,11 +777,50 @@ fn prepend_attrs(sess: &ParseSess,
for attr in attrs {
assert_eq!(attr.style, ast::AttrStyle::Outer,
"inner attributes should prevent cached tokens from existing");
// FIXME: Avoid this pretty-print + reparse hack as bove
let name = FileName::MacroExpansion;
let source = pprust::attr_to_string(attr);
let stream = parse_stream_from_source_str(name, source, sess, Some(span));
builder.push(stream);

if attr.is_sugared_doc {
let stream = parse_stream_from_source_str(
FileName::MacroExpansion,
pprust::attr_to_string(attr),
sess,
Some(span),
);
builder.push(stream);
continue
}

// synthesize # [ $path $tokens ] manually here
let mut brackets = tokenstream::TokenStreamBuilder::new();

// For simple paths, push the identifier directly
if attr.path.segments.len() == 1 && attr.path.segments[0].args.is_none() {
let ident = attr.path.segments[0].ident;
let token = Ident(ident, ident.as_str().starts_with("r#"));
brackets.push(tokenstream::TokenTree::Token(ident.span, token));

// ... and for more complicated paths, fall back to a reparse hack that
// should eventually be removed.
} else {
let stream = parse_stream_from_source_str(
FileName::MacroExpansion,
pprust::path_to_string(&attr.path),
sess,
Some(span),
);
brackets.push(stream);
}

brackets.push(attr.tokens.clone());

let tokens = tokenstream::Delimited {
delim: DelimToken::Bracket,
tts: brackets.build().into(),
};
// The span we list here for `#` and for `[ ... ]` are both wrong in
// that it encompasses more than each token, but it hopefully is "good
// enough" for now at least.
builder.push(tokenstream::TokenTree::Token(attr.span, Pound));
builder.push(tokenstream::TokenTree::Delimited(attr.span, tokens));
}
builder.push(tokens.clone());
Some(builder.build())
14 changes: 0 additions & 14 deletions src/rustllvm/PassWrapper.cpp
Original file line number Diff line number Diff line change
@@ -1228,15 +1228,6 @@ LLVMRustThinLTOPatchDICompileUnit(LLVMModuleRef Mod, DICompileUnit *Unit) {
MD->addOperand(Unit);
}

extern "C" void
LLVMRustThinLTORemoveAvailableExternally(LLVMModuleRef Mod) {
Module *M = unwrap(Mod);
for (Function &F : M->functions()) {
if (F.hasAvailableExternallyLinkage())
F.deleteBody();
}
}

#else

extern "C" bool
@@ -1328,9 +1319,4 @@ LLVMRustThinLTOPatchDICompileUnit(LLVMModuleRef Mod) {
report_fatal_error("ThinLTO not available");
}

extern "C" void
LLVMRustThinLTORemoveAvailableExternally(LLVMModuleRef Mod) {
report_fatal_error("ThinLTO not available");
}

#endif // LLVM_VERSION_GE(4, 0)
10 changes: 0 additions & 10 deletions src/test/run-pass/const-block.rs
Original file line number Diff line number Diff line change
@@ -39,13 +39,6 @@ static BLOCK_FN: fn(usize) -> usize = { foo::<usize> };

static BLOCK_ENUM_CONSTRUCTOR: fn(usize) -> Option<usize> = { 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);
}
37 changes: 37 additions & 0 deletions src/test/run-pass/issue-33264.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![allow(dead_code, non_upper_case_globals)]
#![feature(asm)]

#[repr(C)]
pub struct D32x4(f32,f32,f32,f32);

impl D32x4 {
fn add(&self, vec: Self) -> Self {
unsafe {
let ret: Self;
asm!("
movaps $1, %xmm1
movaps $2, %xmm2
addps %xmm1, %xmm2
movaps $xmm1, $0
"
: "=r"(ret)
: "1"(self), "2"(vec)
: "xmm1", "xmm2"
);
ret
}
}
}

fn main() { }

21 changes: 21 additions & 0 deletions src/test/run-pass/issue-34784.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

const C: *const u8 = &0;

fn foo(x: *const u8) {
match x {
C => {}
_ => {}
}
}

fn main() {}

39 changes: 39 additions & 0 deletions src/test/run-pass/issue-44005.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

pub trait Foo<'a> {
type Bar;
fn foo(&'a self) -> Self::Bar;
}

impl<'a, 'b, T: 'a> Foo<'a> for &'b T {
type Bar = &'a T;
fn foo(&'a self) -> &'a T {
self
}
}

pub fn uncallable<T, F>(x: T, f: F)
where T: for<'a> Foo<'a>,
F: for<'a> Fn(<T as Foo<'a>>::Bar)
{
f(x.foo());
}

pub fn catalyst(x: &i32) {
broken(x, |_| {})
}

pub fn broken<F: Fn(&i32)>(x: &i32, f: F) {
uncallable(x, |y| f(y));
}

fn main() { }

22 changes: 22 additions & 0 deletions src/test/ui-fulldeps/proc-macro/attribute-spans-preserved.rs
Original file line number Diff line number Diff line change
@@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// aux-build:attribute-spans-preserved.rs

#![feature(use_extern_macros)]

extern crate attribute_spans_preserved as foo;

use foo::foo;

#[ foo ( let y: u32 = "z"; ) ] //~ ERROR: mismatched types
#[ bar let x: u32 = "y"; ] //~ ERROR: mismatched types
fn main() {
}
21 changes: 21 additions & 0 deletions src/test/ui-fulldeps/proc-macro/attribute-spans-preserved.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error[E0308]: mismatched types
--> $DIR/attribute-spans-preserved.rs:19:23
|
LL | #[ foo ( let y: u32 = "z"; ) ] //~ ERROR: mismatched types
| ^^^ expected u32, found reference
|
= note: expected type `u32`
found type `&'static str`

error[E0308]: mismatched types
--> $DIR/attribute-spans-preserved.rs:20:21
|
LL | #[ bar let x: u32 = "y"; ] //~ ERROR: mismatched types
| ^^^ expected u32, found reference
|
= note: expected type `u32`
found type `&'static str`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main ( ) { let y : u32 = "z" ; let x : u32 = "y" ; }
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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_attribute]
pub fn foo(attr: TokenStream, f: TokenStream) -> TokenStream {
let mut tokens = f.into_iter();
assert_eq!(tokens.next().unwrap().to_string(), "#");
let next_attr = match tokens.next().unwrap() {
TokenTree::Group(g) => g,
_ => panic!(),
};

let fn_tok = tokens.next().unwrap();
let ident_tok = tokens.next().unwrap();
let args_tok = tokens.next().unwrap();
let body = tokens.next().unwrap();

let new_body = attr.into_iter()
.chain(next_attr.stream().into_iter().skip(1));

let tokens = vec![
fn_tok,
ident_tok,
args_tok,
Group::new(Delimiter::Brace, new_body.collect()).into(),
].into_iter().collect::<TokenStream>();
println!("{}", tokens);
return tokens
}
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0282.stderr
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
LL | let x = "hello".chars().rev().collect(); //~ ERROR E0282
| ^
| |
| cannot infer type for `_`
| cannot infer type
| consider giving `x` a type

error: aborting due to previous error
44 changes: 44 additions & 0 deletions src/test/ui/imports/glob-shadowing.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(decl_macro)]

mod m {
pub macro env($e: expr) { $e }
pub macro fenv() { 0 }
}

mod glob_in_normal_module {
use m::*;
fn check() {
let x = env!("PATH"); //~ ERROR `env` is ambiguous
}
}

mod glob_in_block_module {
fn block() {
use m::*;
fn check() {
let x = env!("PATH"); //~ ERROR `env` is ambiguous
}
}
}

mod glob_shadows_item {
pub macro fenv($e: expr) { $e }
fn block() {
use m::*;
fn check() {
let x = fenv!(); //~ ERROR `fenv` is ambiguous
}
}
}

fn main() {}
49 changes: 49 additions & 0 deletions src/test/ui/imports/glob-shadowing.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
error[E0659]: `env` is ambiguous
--> $DIR/glob-shadowing.rs:21:17
|
LL | let x = env!("PATH"); //~ ERROR `env` is ambiguous
| ^^^
|
note: `env` could refer to the name imported here
--> $DIR/glob-shadowing.rs:19:9
|
LL | use m::*;
| ^^^^
= note: `env` is also a builtin macro
= note: consider adding an explicit import of `env` to disambiguate

error[E0659]: `env` is ambiguous
--> $DIR/glob-shadowing.rs:29:21
|
LL | let x = env!("PATH"); //~ ERROR `env` is ambiguous
| ^^^
|
note: `env` could refer to the name imported here
--> $DIR/glob-shadowing.rs:27:13
|
LL | use m::*;
| ^^^^
= note: `env` is also a builtin macro
= note: consider adding an explicit import of `env` to disambiguate

error[E0659]: `fenv` is ambiguous
--> $DIR/glob-shadowing.rs:39:21
|
LL | let x = fenv!(); //~ ERROR `fenv` is ambiguous
| ^^^^
|
note: `fenv` could refer to the name imported here
--> $DIR/glob-shadowing.rs:37:13
|
LL | use m::*;
| ^^^^
note: `fenv` could also refer to the name defined here
--> $DIR/glob-shadowing.rs:35:5
|
LL | pub macro fenv($e: expr) { $e }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: consider adding an explicit import of `fenv` to disambiguate

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0659`.
2 changes: 1 addition & 1 deletion src/test/ui/issue-12187-1.stderr
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
LL | let &v = new();
| -^
| ||
| |cannot infer type for `_`
| |cannot infer type
| consider giving the pattern a type

error: aborting due to previous error
2 changes: 1 addition & 1 deletion src/test/ui/issue-12187-2.stderr
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
LL | let &v = new();
| -^
| ||
| |cannot infer type for `_`
| |cannot infer type
| consider giving the pattern a type

error: aborting due to previous error
2 changes: 1 addition & 1 deletion src/test/ui/issue-15965.stderr
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
LL | / { return () }
LL | | //~^ ERROR type annotations needed [E0282]
LL | | ()
| |______^ cannot infer type for `_`
| |______^ cannot infer type
|
= note: type must be known at this point

2 changes: 1 addition & 1 deletion src/test/ui/issue-18159.stderr
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
LL | let x; //~ ERROR type annotations needed
| ^
| |
| cannot infer type for `_`
| cannot infer type
| consider giving `x` a type

error: aborting due to previous error
2 changes: 1 addition & 1 deletion src/test/ui/issue-20261.stderr
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
LL | for (ref i,) in [].iter() {
| --------- the element type for this iterator is not specified
LL | i.clone();
| ^^^^^ cannot infer type for `_`
| ^^^^^ cannot infer type
|
= note: type must be known at this point

2 changes: 1 addition & 1 deletion src/test/ui/issue-2151.stderr
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
LL | let x = panic!();
| - consider giving `x` a type
LL | x.clone(); //~ ERROR type annotations needed
| ^ cannot infer type for `_`
| ^ cannot infer type
|
= note: type must be known at this point

2 changes: 1 addition & 1 deletion src/test/ui/issue-23041.stderr
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
--> $DIR/issue-23041.rs:16:22
|
LL | b.downcast_ref::<fn(_)->_>(); //~ ERROR E0282
| ^^^^^^^^ cannot infer type for `_`
| ^^^^^^^^ cannot infer type

error: aborting due to previous error

2 changes: 1 addition & 1 deletion src/test/ui/issue-24013.stderr
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
--> $DIR/issue-24013.rs:15:20
|
LL | unsafe {swap::<&mut _>(transmute(&a), transmute(&b))};
| ^^^^^^ cannot infer type for `_`
| ^^^^^^ cannot infer type

error: aborting due to previous error

20 changes: 20 additions & 0 deletions src/test/ui/issue-34784.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

const C: *const [u8; 4] = b"abcd";

fn main() {
match C {
C => {}
//~^ ERROR this expression will panic at runtime
_ => {}
}
}

10 changes: 10 additions & 0 deletions src/test/ui/issue-34784.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: this expression will panic at runtime
--> $DIR/issue-34784.rs:15:9
|
LL | C => {}
| ^ "pointer arithmetic or comparison" needs an rfc before being allowed inside constants
|
= note: #[deny(const_err)] on by default

error: aborting due to previous error

22 changes: 22 additions & 0 deletions src/test/ui/issue-42060.rs
Original file line number Diff line number Diff line change
@@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

fn main() {
let thing = ();
let other: typeof(thing) = thing; //~ ERROR attempt to use a non-constant value in a constant
//~^ ERROR `typeof` is a reserved keyword but unimplemented [E0516]
}

fn f(){
let q = 1;
<typeof(q)>::N //~ ERROR attempt to use a non-constant value in a constant
//~^ ERROR `typeof` is a reserved keyword but unimplemented [E0516]
}

28 changes: 28 additions & 0 deletions src/test/ui/issue-42060.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/issue-42060.rs:13:23
|
LL | let other: typeof(thing) = thing; //~ ERROR attempt to use a non-constant value in a constant
| ^^^^^ non-constant value

error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/issue-42060.rs:19:13
|
LL | <typeof(q)>::N //~ ERROR attempt to use a non-constant value in a constant
| ^ non-constant value

error[E0516]: `typeof` is a reserved keyword but unimplemented
--> $DIR/issue-42060.rs:13:16
|
LL | let other: typeof(thing) = thing; //~ ERROR attempt to use a non-constant value in a constant
| ^^^^^^^^^^^^^ reserved keyword

error[E0516]: `typeof` is a reserved keyword but unimplemented
--> $DIR/issue-42060.rs:19:6
|
LL | <typeof(q)>::N //~ ERROR attempt to use a non-constant value in a constant
| ^^^^^^^^^ reserved keyword

error: aborting due to 4 previous errors

Some errors occurred: E0435, E0516.
For more information about an error, try `rustc --explain E0435`.
17 changes: 17 additions & 0 deletions src/test/ui/issue-43196.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

fn main() {
|
}
//~^ ERROR expected `|`, found `}`
|
//~^ ERROR expected item, found `|`

16 changes: 16 additions & 0 deletions src/test/ui/issue-43196.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
error: expected `|`, found `}`
--> $DIR/issue-43196.rs:13:1
|
LL | |
| - expected `|` here
LL | }
| ^ unexpected token

error: expected item, found `|`
--> $DIR/issue-43196.rs:15:1
|
LL | |
| ^ expected item

error: aborting due to 2 previous errors

2 changes: 1 addition & 1 deletion src/test/ui/issue-7813.stderr
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
--> $DIR/issue-7813.rs:12:13
|
LL | let v = &[]; //~ ERROR type annotations needed
| - ^^^ cannot infer type for `_`
| - ^^^ cannot infer type
| |
| consider giving `v` a type

2 changes: 1 addition & 1 deletion src/test/ui/span/issue-42234-unknown-receiver-type.stderr
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ error[E0282]: type annotations needed
|
LL | / data.iter() //~ ERROR 22:5: 23:20: type annotations needed
LL | | .sum::<_>()
| |___________________^ cannot infer type for `_`
| |___________________^ cannot infer type
|
= note: type must be known at this point

4 changes: 2 additions & 2 deletions src/test/ui/span/method-and-field-eager-resolution.stderr
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
LL | let mut x = Default::default();
| ----- consider giving `x` a type
LL | x.0;
| ^ cannot infer type for `_`
| ^ cannot infer type
|
= note: type must be known at this point

@@ -14,7 +14,7 @@ error[E0282]: type annotations needed
LL | let mut x = Default::default();
| ----- consider giving `x` a type
LL | x[0];
| ^ cannot infer type for `_`
| ^ cannot infer type
|
= note: type must be known at this point

2 changes: 1 addition & 1 deletion src/test/ui/type-check/cannot_infer_local_or_array.stderr
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
--> $DIR/cannot_infer_local_or_array.rs:12:13
|
LL | let x = []; //~ ERROR type annotations needed
| - ^^ cannot infer type for `_`
| - ^^ cannot infer type
| |
| consider giving `x` a type