diff --git a/src/doc/footer.inc b/src/doc/footer.inc index 952846dd5e25d..7513e524e73a1 100644 --- a/src/doc/footer.inc +++ b/src/doc/footer.inc @@ -1,5 +1,5 @@ <footer><p> -Copyright © 2011-2015 The Rust Project Developers. Licensed under the +Copyright © 2011 The Rust Project Developers. Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a> or the <a href="https://opensource.org/licenses/MIT">MIT license</a>, at your option. </p><p> diff --git a/src/libcollections/fmt.rs b/src/libcollections/fmt.rs index 0ebb89b8a22a3..6f77d79ab0bfe 100644 --- a/src/libcollections/fmt.rs +++ b/src/libcollections/fmt.rs @@ -8,19 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Utilities for formatting and printing strings +//! Utilities for formatting and printing `String`s //! //! This module contains the runtime support for the `format!` syntax extension. //! This macro is implemented in the compiler to emit calls to this module in -//! order to format arguments at runtime into strings and streams. +//! order to format arguments at runtime into strings. //! //! # Usage //! //! The `format!` macro is intended to be familiar to those coming from C's -//! printf/fprintf functions or Python's `str.format` function. In its current -//! revision, the `format!` macro returns a `String` type which is the result of -//! the formatting. In the future it will also be able to pass in a stream to -//! format arguments directly while performing minimal allocations. +//! printf/fprintf functions or Python's `str.format` function. //! //! Some examples of the `format!` extension are: //! diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 72d326076384c..b6ae6fde1e35d 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -1830,6 +1830,9 @@ impl<A> SlicePartialEq<A> for [A] if self.len() != other.len() { return false; } + if self.as_ptr() == other.as_ptr() { + return true; + } unsafe { let size = mem::size_of_val(self); memcmp(self.as_ptr() as *const u8, diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 2c34caf63b846..32b81ab7f53a8 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -354,7 +354,7 @@ fn unwrap_or_0(opt: Option<&u8>) -> u8 { /// UTF-8-like encoding). #[unstable(feature = "str_internals", issue = "0")] #[inline] -pub fn next_code_point(bytes: &mut slice::Iter<u8>) -> Option<u32> { +pub fn next_code_point<'a, I: Iterator<Item = &'a u8>>(bytes: &mut I) -> Option<u32> { // Decode UTF-8 let x = match bytes.next() { None => return None, @@ -388,7 +388,8 @@ pub fn next_code_point(bytes: &mut slice::Iter<u8>) -> Option<u32> { /// Reads the last code point out of a byte iterator (assuming a /// UTF-8-like encoding). #[inline] -fn next_code_point_reverse(bytes: &mut slice::Iter<u8>) -> Option<u32> { +fn next_code_point_reverse<'a, + I: DoubleEndedIterator<Item = &'a u8>>(bytes: &mut I) -> Option<u32> { // Decode UTF-8 let w = match bytes.next_back() { None => return None, diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index fcb03aba6d12c..eb1fb43789f99 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -26,7 +26,7 @@ use syntax::parse::token::InternedString; use syntax::codemap::{Span, DUMMY_SP}; use syntax::ast; use syntax::ast::{NodeId, Attribute}; -use syntax::feature_gate::{GateIssue, emit_feature_err}; +use syntax::feature_gate::{GateIssue, emit_feature_err, find_lang_feature_accepted_version}; use syntax::attr::{self, Stability, Deprecation, AttrMetaMethods}; use util::nodemap::{DefIdMap, FnvHashSet, FnvHashMap}; @@ -37,6 +37,7 @@ use hir::pat_util::EnumerateAndAdjustIterator; use std::mem::replace; use std::cmp::Ordering; +use std::ops::Deref; #[derive(RustcEncodable, RustcDecodable, PartialEq, PartialOrd, Clone, Copy, Debug, Eq, Hash)] pub enum StabilityLevel { @@ -322,7 +323,7 @@ impl<'a, 'tcx> Index<'tcx> { /// features and possibly prints errors. Returns a list of all /// features used. pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) - -> FnvHashMap<InternedString, StabilityLevel> { + -> FnvHashMap<InternedString, attr::StabilityLevel> { let _task = tcx.dep_graph.in_task(DepNode::StabilityCheck); let ref active_lib_features = tcx.sess.features.borrow().declared_lib_features; @@ -343,7 +344,7 @@ pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) struct Checker<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx>, active_features: FnvHashSet<InternedString>, - used_features: FnvHashMap<InternedString, StabilityLevel>, + used_features: FnvHashMap<InternedString, attr::StabilityLevel>, // Within a block where feature gate checking can be skipped. in_skip_block: u32, } @@ -367,7 +368,8 @@ impl<'a, 'tcx> Checker<'a, 'tcx> { match *stab { Some(&Stability { level: attr::Unstable {ref reason, issue}, ref feature, .. }) => { - self.used_features.insert(feature.clone(), Unstable); + self.used_features.insert(feature.clone(), + attr::Unstable { reason: reason.clone(), issue: issue }); if !self.active_features.contains(feature) { let msg = match *reason { @@ -380,7 +382,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> { } } Some(&Stability { ref level, ref feature, .. }) => { - self.used_features.insert(feature.clone(), StabilityLevel::from_attr_level(level)); + self.used_features.insert(feature.clone(), level.clone()); // Stable APIs are always ok to call and deprecated APIs are // handled by a lint. @@ -716,28 +718,32 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { /// libraries, identify activated features that don't exist and error about them. pub fn check_unused_or_stable_features(sess: &Session, lib_features_used: &FnvHashMap<InternedString, - StabilityLevel>) { + attr::StabilityLevel>) { let ref declared_lib_features = sess.features.borrow().declared_lib_features; let mut remaining_lib_features: FnvHashMap<InternedString, Span> = declared_lib_features.clone().into_iter().collect(); - let stable_msg = "this feature is stable. attribute no longer needed"; + fn format_stable_since_msg(version: &str) -> String { + format!("this feature has been stable since {}. Attribute no longer needed", version) + } - for &span in &sess.features.borrow().declared_stable_lang_features { + for &(ref stable_lang_feature, span) in &sess.features.borrow().declared_stable_lang_features { + let version = find_lang_feature_accepted_version(stable_lang_feature.deref()) + .expect("unexpectedly couldn't find version feature was stabilized"); sess.add_lint(lint::builtin::STABLE_FEATURES, ast::CRATE_NODE_ID, span, - stable_msg.to_string()); + format_stable_since_msg(version)); } for (used_lib_feature, level) in lib_features_used { match remaining_lib_features.remove(used_lib_feature) { Some(span) => { - if *level == Stable { + if let &attr::StabilityLevel::Stable { since: ref version } = level { sess.add_lint(lint::builtin::STABLE_FEATURES, ast::CRATE_NODE_ID, span, - stable_msg.to_string()); + format_stable_since_msg(version.deref())); } } None => ( /* used but undeclared, handled during the previous ast visit */ ) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 45aa6f881e8e7..3d187cfc08175 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -665,7 +665,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// reference to the context, to allow formatting values that need it. pub fn create_and_enter<F, R>(s: &'tcx Session, arenas: &'tcx CtxtArenas<'tcx>, - def_map: RefCell<DefMap>, + def_map: DefMap, named_region_map: resolve_lifetime::NamedRegionMap, map: ast_map::Map<'tcx>, freevars: FreevarMap, @@ -693,7 +693,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { item_variance_map: RefCell::new(DepTrackingMap::new(dep_graph.clone())), variance_computed: Cell::new(false), sess: s, - def_map: def_map, + def_map: RefCell::new(def_map), tables: RefCell::new(Tables::empty()), impl_trait_refs: RefCell::new(DepTrackingMap::new(dep_graph.clone())), trait_defs: RefCell::new(DepTrackingMap::new(dep_graph.clone())), diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index d6d944fde5f5e..cbbbd84ec505a 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -44,7 +44,6 @@ use super::Compilation; use serialize::json; -use std::cell::RefCell; use std::collections::HashMap; use std::env; use std::ffi::{OsString, OsStr}; @@ -893,7 +892,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session, let trait_map = resolutions.trait_map; TyCtxt::create_and_enter(sess, arenas, - RefCell::new(resolutions.def_map), + resolutions.def_map, named_region_map, hir_map, resolutions.freevars, diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index b1df80403c063..6423d94e6f6fb 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -29,7 +29,6 @@ use rustc_metadata::cstore::CStore; use rustc_metadata::creader::read_local_crates; use rustc::hir::map as hir_map; use rustc::session::{self, config}; -use std::cell::RefCell; use std::rc::Rc; use syntax::ast; use syntax::abi::Abi; @@ -140,7 +139,7 @@ fn test_env<F>(source_string: &str, let index = stability::Index::new(&ast_map); TyCtxt::create_and_enter(&sess, &arenas, - RefCell::new(resolutions.def_map), + resolutions.def_map, named_region_map.unwrap(), ast_map, resolutions.freevars, diff --git a/src/librustc_mir/transform/type_check.rs b/src/librustc_mir/transform/type_check.rs index 40157aa934c65..80c56a5dc08f1 100644 --- a/src/librustc_mir/transform/type_check.rs +++ b/src/librustc_mir/transform/type_check.rs @@ -118,10 +118,6 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { self.cx.infcx.tcx } - fn infcx(&self) -> &'a InferCtxt<'a, 'gcx, 'tcx> { - self.cx.infcx - } - fn sanitize_type(&mut self, parent: &fmt::Debug, ty: Ty<'tcx>) -> Ty<'tcx> { if ty.needs_infer() || ty.has_escaping_regions() || ty.references_error() { span_mirbug_and_err!(self, parent, "bad type {:?}", ty) @@ -292,30 +288,11 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { }; if let Some(field) = variant.fields.get(field.index()) { - Ok(self.normalize(field.ty(tcx, substs))) + Ok(self.cx.normalize(&field.ty(tcx, substs))) } else { Err(FieldAccessError::OutOfRange { field_count: variant.fields.len() }) } } - - fn normalize(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { - let infcx = self.infcx(); - let mut selcx = traits::SelectionContext::new(infcx); - let cause = traits::ObligationCause::misc(self.last_span, 0); - let traits::Normalized { value: ty, obligations } = - traits::normalize(&mut selcx, cause, &ty); - - debug!("normalize: ty={:?} obligations={:?}", - ty, - obligations); - - let mut fulfill_cx = &mut self.cx.fulfillment_cx; - for obligation in obligations { - fulfill_cx.register_predicate_obligation(infcx, obligation); - } - - ty - } } pub struct TypeChecker<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { @@ -373,7 +350,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { } } - fn check_terminator(&self, + fn check_terminator(&mut self, mir: &Mir<'tcx>, term: &Terminator<'tcx>) { debug!("check_terminator: {:?}", term); @@ -431,6 +408,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { } }; let sig = tcx.erase_late_bound_regions(&func_ty.sig); + let sig = self.normalize(&sig); self.check_call_dest(mir, term, &sig, destination); if self.is_box_free(func) { @@ -558,6 +536,27 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { } } + + fn normalize<T>(&mut self, value: &T) -> T + where T: fmt::Debug + TypeFoldable<'tcx> + { + let mut selcx = traits::SelectionContext::new(self.infcx); + let cause = traits::ObligationCause::misc(self.last_span, 0); + let traits::Normalized { value, obligations } = + traits::normalize(&mut selcx, cause, value); + + debug!("normalize: value={:?} obligations={:?}", + value, + obligations); + + let mut fulfill_cx = &mut self.fulfillment_cx; + for obligation in obligations { + fulfill_cx.register_predicate_obligation(self.infcx, obligation); + } + + value + } + fn verify_obligations(&mut self, mir: &Mir<'tcx>) { self.last_span = mir.span; if let Err(e) = self.fulfillment_cx.select_all_or_error(self.infcx) { diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 2444f6acced24..36053d3c4ffa7 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -2422,13 +2422,16 @@ impl<'a> Resolver<'a> { } } } - } else if let Err(false) = self.resolve_path(pat_id, &path, 0, ValueNS) { - resolve_error( - self, - path.span, - ResolutionError::UnresolvedEnumVariantStructOrConst( - &path.segments.last().unwrap().identifier.name.as_str()) - ); + } else { + if let Err(false) = self.resolve_path(pat_id, &path, 0, ValueNS) { + // No error has been reported, so we need to do this ourselves. + resolve_error( + self, + path.span, + ResolutionError::UnresolvedEnumVariantStructOrConst( + &path.segments.last().unwrap().identifier.name.as_str()) + ); + } self.record_def(pattern.id, err_path_resolution()); } visit::walk_path(self, path); diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs index a1002fdb645fc..2d780559db122 100644 --- a/src/libstd/io/cursor.rs +++ b/src/libstd/io/cursor.rs @@ -230,6 +230,7 @@ impl<T> BufRead for Cursor<T> where T: AsRef<[u8]> { #[stable(feature = "rust1", since = "1.0.0")] impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] fn write(&mut self, data: &[u8]) -> io::Result<usize> { let pos = cmp::min(self.pos, self.inner.len() as u64); let amt = (&mut self.inner[(pos as usize)..]).write(data)?; @@ -269,6 +270,7 @@ impl Write for Cursor<Vec<u8>> { #[stable(feature = "cursor_box_slice", since = "1.5.0")] impl Write for Cursor<Box<[u8]>> { + #[inline] fn write(&mut self, buf: &[u8]) -> io::Result<usize> { let pos = cmp::min(self.pos, self.inner.len() as u64); let amt = (&mut self.inner[(pos as usize)..]).write(buf)?; diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 3522c8863cf52..69e24cf071902 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -179,7 +179,7 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt, for (i, lhs) in lhses.iter().enumerate() { // try each arm's matchers let lhs_tt = match *lhs { TokenTree::Delimited(_, ref delim) => &delim.tts[..], - _ => cx.span_fatal(sp, "malformed macro lhs") + _ => cx.span_bug(sp, "malformed macro lhs") }; match TokenTree::parse(cx, lhs_tt, arg) { @@ -187,7 +187,7 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt, let rhs = match rhses[i] { // ignore delimiters TokenTree::Delimited(_, ref delimed) => delimed.tts.clone(), - _ => cx.span_fatal(sp, "malformed macro rhs"), + _ => cx.span_bug(sp, "malformed macro rhs"), }; // rhs has holes ( `$id` and `$(...)` that need filled) let trncbr = new_tt_reader(&cx.parse_sess().span_diagnostic, @@ -326,19 +326,14 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt, NormalTT(exp, Some(def.span), def.allow_internal_unstable) } -// why is this here? because of https://github.com/rust-lang/rust/issues/27774 -fn ref_slice<A>(s: &A) -> &[A] { use std::slice::from_raw_parts; unsafe { from_raw_parts(s, 1) } } - fn check_lhs_nt_follows(cx: &mut ExtCtxt, lhs: &TokenTree) -> bool { // lhs is going to be like TokenTree::Delimited(...), where the // entire lhs is those tts. Or, it can be a "bare sequence", not wrapped in parens. match lhs { &TokenTree::Delimited(_, ref tts) => check_matcher(cx, &tts.tts), - tt @ &TokenTree::Sequence(..) => check_matcher(cx, ref_slice(tt)), _ => { - cx.span_err(lhs.get_span(), - "invalid macro matcher; matchers must be contained \ - in balanced delimiters or a repetition indicator"); + cx.span_err(lhs.get_span(), "invalid macro matcher; matchers must \ + be contained in balanced delimiters"); false } } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 5687099b27ced..08e593ca74780 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -59,8 +59,8 @@ macro_rules! declare_features { /// A set of features to be used by later passes. pub struct Features { - /// spans of #![feature] attrs for stable language features. for error reporting - pub declared_stable_lang_features: Vec<Span>, + /// #![feature] attrs for stable language features, for error reporting + pub declared_stable_lang_features: Vec<(InternedString, Span)>, /// #![feature] attrs for non-language (library) features pub declared_lib_features: Vec<(InternedString, Span)>, $(pub $feature: bool),+ @@ -753,6 +753,10 @@ pub fn check_attribute(attr: &ast::Attribute, handler: &Handler, cx.check_attribute(attr, true); } +pub fn find_lang_feature_accepted_version(feature: &str) -> Option<&'static str> { + ACCEPTED_FEATURES.iter().find(|t| t.0 == feature).map(|t| t.1) +} + fn find_lang_feature_issue(feature: &str) -> Option<u32> { if let Some(info) = ACTIVE_FEATURES.iter().find(|t| t.0 == feature) { let issue = info.2; @@ -1191,7 +1195,7 @@ pub fn get_features(span_handler: &Handler, krate: &ast::Crate) -> Features { } else if let Some(&(_, _, _)) = ACCEPTED_FEATURES.iter() .find(|& &(n, _, _)| name == n) { - features.declared_stable_lang_features.push(mi.span); + features.declared_stable_lang_features.push((name, mi.span)); } else { features.declared_lib_features.push((name, mi.span)); } diff --git a/src/test/compile-fail/E0117.rs b/src/test/compile-fail/E0117.rs new file mode 100644 index 0000000000000..16d713bba92ab --- /dev/null +++ b/src/test/compile-fail/E0117.rs @@ -0,0 +1,14 @@ +// Copyright 2016 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. + +impl Drop for u32 {} //~ ERROR E0117 + +fn main() { +} diff --git a/src/test/compile-fail/E0118.rs b/src/test/compile-fail/E0118.rs new file mode 100644 index 0000000000000..d37ff34b861f4 --- /dev/null +++ b/src/test/compile-fail/E0118.rs @@ -0,0 +1,18 @@ +// Copyright 2016 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. + +impl (u8, u8) { //~ ERROR E0118 + fn get_state(&self) -> String { + String::new() + } +} + +fn main() { +} diff --git a/src/test/compile-fail/E0119.rs b/src/test/compile-fail/E0119.rs new file mode 100644 index 0000000000000..9528631b3047b --- /dev/null +++ b/src/test/compile-fail/E0119.rs @@ -0,0 +1,28 @@ +// Copyright 2016 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. + +trait MyTrait { + fn get(&self) -> usize; +} + +impl<T> MyTrait for T { + fn get(&self) -> usize { 0 } +} + +struct Foo { + value: usize +} + +impl MyTrait for Foo { //~ ERROR E0119 + fn get(&self) -> usize { self.value } +} + +fn main() { +} diff --git a/src/test/run-pass/issue-21350.rs b/src/test/compile-fail/E0120.rs similarity index 64% rename from src/test/run-pass/issue-21350.rs rename to src/test/compile-fail/E0120.rs index ff205cd694c3a..de084274f6fb8 100644 --- a/src/test/run-pass/issue-21350.rs +++ b/src/test/compile-fail/E0120.rs @@ -1,4 +1,4 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,12 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Make sure that "bare sequences" don't ICE in follow checking +trait MyTrait {} -// pretty-expanded FIXME #23616 - -macro_rules! bare { - $($id:expr),+ => ( $($id)+ ) +impl Drop for MyTrait { //~ ERROR E0120 + fn drop(&mut self) {} } -fn main() { } +fn main() { +} diff --git a/src/test/compile-fail/E0121.rs b/src/test/compile-fail/E0121.rs new file mode 100644 index 0000000000000..b26b5f41bfe47 --- /dev/null +++ b/src/test/compile-fail/E0121.rs @@ -0,0 +1,16 @@ +// Copyright 2016 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 foo() -> _ { 5 } //~ ERROR E0121 + +static BAR: _ = "test"; //~ ERROR E0121 + +fn main() { +} diff --git a/src/test/compile-fail/E0124.rs b/src/test/compile-fail/E0124.rs new file mode 100644 index 0000000000000..414b19ead624d --- /dev/null +++ b/src/test/compile-fail/E0124.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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. + +struct Foo { + field1: i32, + field1: i32, //~ ERROR E0124 +} + +fn main() { +} diff --git a/src/test/compile-fail/E0128.rs b/src/test/compile-fail/E0128.rs new file mode 100644 index 0000000000000..37071012825ec --- /dev/null +++ b/src/test/compile-fail/E0128.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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. + +struct Foo<T=U, U=()> { //~ ERROR E0128 + field1: T, + field2: U, +} + +fn main() { +} diff --git a/src/test/compile-fail/E0130.rs b/src/test/compile-fail/E0130.rs new file mode 100644 index 0000000000000..ef5961e133894 --- /dev/null +++ b/src/test/compile-fail/E0130.rs @@ -0,0 +1,16 @@ +// Copyright 2016 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. + +extern { + fn foo((a, b): (u32, u32)); //~ ERROR E0130 +} + +fn main() { +} diff --git a/src/test/compile-fail/E0131.rs b/src/test/compile-fail/E0131.rs new file mode 100644 index 0000000000000..aa11577ccdf1e --- /dev/null +++ b/src/test/compile-fail/E0131.rs @@ -0,0 +1,12 @@ +// Copyright 2016 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<T>() { //~ ERROR E0131 +} diff --git a/src/test/compile-fail/E0132.rs b/src/test/compile-fail/E0132.rs new file mode 100644 index 0000000000000..ff19a577f903d --- /dev/null +++ b/src/test/compile-fail/E0132.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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(start)] + +#[start] +fn f<T>() {} //~ ERROR E0132 + +fn main() { +} diff --git a/src/test/compile-fail/E0133.rs b/src/test/compile-fail/E0133.rs new file mode 100644 index 0000000000000..630ee851d0af0 --- /dev/null +++ b/src/test/compile-fail/E0133.rs @@ -0,0 +1,15 @@ +// Copyright 2016 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. + +unsafe fn f() { return; } + +fn main() { + f(); //~ ERROR E0133 +} diff --git a/src/test/compile-fail/E0137.rs b/src/test/compile-fail/E0137.rs new file mode 100644 index 0000000000000..695ce7995a9a4 --- /dev/null +++ b/src/test/compile-fail/E0137.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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(main)] + +#[main] +fn foo() {} + +#[main] +fn f() {} //~ ERROR E0137 diff --git a/src/test/compile-fail/E0138.rs b/src/test/compile-fail/E0138.rs new file mode 100644 index 0000000000000..97d85e5e71e08 --- /dev/null +++ b/src/test/compile-fail/E0138.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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(start)] + +#[start] +fn foo(argc: isize, argv: *const *const u8) -> isize {} + +#[start] +fn f(argc: isize, argv: *const *const u8) -> isize {} //~ ERROR E0138 diff --git a/src/test/compile-fail/E0152.rs b/src/test/compile-fail/E0152.rs new file mode 100644 index 0000000000000..ae501b94e3f05 --- /dev/null +++ b/src/test/compile-fail/E0152.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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(lang_items)] + +#[lang = "panic_fmt"] +struct Foo; //~ ERROR E0152 + +fn main() { +} diff --git a/src/test/compile-fail/E0161.rs b/src/test/compile-fail/E0161.rs new file mode 100644 index 0000000000000..81adf9083024d --- /dev/null +++ b/src/test/compile-fail/E0161.rs @@ -0,0 +1,16 @@ +// Copyright 2016 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(box_syntax)] + +fn main() { + let _x: Box<str> = box *"hello"; //~ ERROR E0161 + //~^ ERROR E0507 +} diff --git a/src/test/compile-fail/malformed_macro_lhs.rs b/src/test/compile-fail/malformed_macro_lhs.rs index 88e19af2eea07..5d81e21f05684 100644 --- a/src/test/compile-fail/malformed_macro_lhs.rs +++ b/src/test/compile-fail/malformed_macro_lhs.rs @@ -9,9 +9,9 @@ // except according to those terms. macro_rules! my_precioooous { - $($t:tt)* => (1); + $($t:tt)* => (1); //~ ERROR invalid macro matcher } fn main() { - my_precioooous!(); //~ ERROR malformed macro lhs + my_precioooous!(); } diff --git a/src/test/compile-fail/stable-features.rs b/src/test/compile-fail/stable-features.rs index 30eb4112c3fb2..6f8c95c384032 100644 --- a/src/test/compile-fail/stable-features.rs +++ b/src/test/compile-fail/stable-features.rs @@ -12,8 +12,8 @@ // language and lib features. #![deny(stable_features)] -#![feature(test_accepted_feature)] //~ ERROR this feature is stable -#![feature(rust1)] //~ ERROR this feature is stable +#![feature(test_accepted_feature)] //~ ERROR this feature has been stable since 1.0.0 +#![feature(rust1)] //~ ERROR this feature has been stable since 1.0.0 fn main() { let _foo: Vec<()> = Vec::new(); diff --git a/src/test/run-pass/mir_call_with_associated_type.rs b/src/test/run-pass/mir_call_with_associated_type.rs new file mode 100644 index 0000000000000..08401c275a52c --- /dev/null +++ b/src/test/run-pass/mir_call_with_associated_type.rs @@ -0,0 +1,29 @@ +// Copyright 2016 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(rustc_attrs)] + +trait Trait { + type Type; +} + +impl<'a> Trait for &'a () { + type Type = u32; +} + +#[rustc_mir] +fn foo<'a>(t: <&'a () as Trait>::Type) -> <&'a () as Trait>::Type { + t +} + +#[rustc_mir] +fn main() { + assert_eq!(foo(4), 4); +}