Skip to content

Commit 98cba9e

Browse files
committed
---
yaml --- r: 235599 b: refs/heads/stable c: 7e9e389 h: refs/heads/master i: 235597: 8bc2eba 235595: a046703 235591: c4f28da 235583: 2693e47 v: v3
1 parent 16edf31 commit 98cba9e

File tree

36 files changed

+302
-180
lines changed

36 files changed

+302
-180
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 18557500cb91596f3614d4cf65439f8c5f47b2e0
32+
refs/heads/stable: 7e9e3896dfcef4852ca8ad90f91baf5187b0248e
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/libcore/fmt/num.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
1313
// FIXME: #6220 Implement floating point formatting
1414

15+
#![allow(unsigned_negation)]
16+
1517
use prelude::*;
1618

1719
use fmt;

branches/stable/src/libcore/ops.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ pub trait Neg {
517517
macro_rules! neg_impl_core {
518518
($id:ident => $body:expr, $($t:ty)*) => ($(
519519
#[stable(feature = "rust1", since = "1.0.0")]
520+
#[allow(unsigned_negation)]
520521
impl Neg for $t {
521522
#[stable(feature = "rust1", since = "1.0.0")]
522523
type Output = $t;

branches/stable/src/libcoretest/fmt/num.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10+
#![allow(unsigned_negation)]
11+
1012
use core::fmt::radix;
1113

1214
#[test]

branches/stable/src/librand/isaac.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ impl IsaacRng {
126126

127127
/// Refills the output buffer (`self.rsl`)
128128
#[inline]
129+
#[allow(unsigned_negation)]
129130
fn isaac(&mut self) {
130131
self.c = self.c + w(1);
131132
// abbreviations

branches/stable/src/librustc/lint/context.rs

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,6 @@ enum TargetLint {
7575

7676
/// Temporary renaming, used for easing migration pain; see #16545
7777
Renamed(String, LintId),
78-
79-
/// Lint with this name existed previously, but has been removed/deprecated.
80-
/// The string argument is the reason for removal.
81-
Removed(String),
82-
}
83-
84-
enum FindLintError {
85-
NotFound,
86-
Removed
8778
}
8879

8980
impl LintStore {
@@ -175,42 +166,30 @@ impl LintStore {
175166
self.by_name.insert(old_name.to_string(), Renamed(new_name.to_string(), target));
176167
}
177168

178-
pub fn register_removed(&mut self, name: &str, reason: &str) {
179-
self.by_name.insert(name.into(), Removed(reason.into()));
180-
}
181-
182169
#[allow(unused_variables)]
183170
fn find_lint(&self, lint_name: &str, sess: &Session, span: Option<Span>)
184-
-> Result<LintId, FindLintError>
171+
-> Option<LintId>
185172
{
186173
match self.by_name.get(lint_name) {
187-
Some(&Id(lint_id)) => Ok(lint_id),
174+
Some(&Id(lint_id)) => Some(lint_id),
188175
Some(&Renamed(ref new_name, lint_id)) => {
189176
let warning = format!("lint {} has been renamed to {}",
190177
lint_name, new_name);
191178
match span {
192179
Some(span) => sess.span_warn(span, &warning[..]),
193180
None => sess.warn(&warning[..]),
194181
};
195-
Ok(lint_id)
196-
},
197-
Some(&Removed(ref reason)) => {
198-
let warning = format!("lint {} has been removed: {}", lint_name, reason);
199-
match span {
200-
Some(span) => sess.span_warn(span, &warning[..]),
201-
None => sess.warn(&warning[..])
202-
}
203-
Err(FindLintError::Removed)
204-
},
205-
None => Err(FindLintError::NotFound)
182+
Some(lint_id)
183+
}
184+
None => None
206185
}
207186
}
208187

209188
pub fn process_command_line(&mut self, sess: &Session) {
210189
for &(ref lint_name, level) in &sess.opts.lint_opts {
211190
match self.find_lint(&lint_name[..], sess, None) {
212-
Ok(lint_id) => self.set_level(lint_id, (level, CommandLine)),
213-
Err(_) => {
191+
Some(lint_id) => self.set_level(lint_id, (level, CommandLine)),
192+
None => {
214193
match self.lint_groups.iter().map(|(&x, pair)| (x, pair.0.clone()))
215194
.collect::<FnvHashMap<&'static str,
216195
Vec<LintId>>>()
@@ -419,8 +398,8 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
419398
}
420399
Ok((lint_name, level, span)) => {
421400
match self.lints.find_lint(&lint_name, &self.tcx.sess, Some(span)) {
422-
Ok(lint_id) => vec![(lint_id, level, span)],
423-
Err(FindLintError::NotFound) => {
401+
Some(lint_id) => vec![(lint_id, level, span)],
402+
None => {
424403
match self.lints.lint_groups.get(&lint_name[..]) {
425404
Some(&(ref v, _)) => v.iter()
426405
.map(|lint_id: &LintId|
@@ -433,8 +412,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
433412
continue;
434413
}
435414
}
436-
},
437-
Err(FindLintError::Removed) => { continue; }
415+
}
438416
}
439417
}
440418
};

branches/stable/src/librustc/middle/const_eval.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#![allow(non_camel_case_types)]
12+
#![allow(unsigned_negation)]
1213

1314
use self::ConstVal::*;
1415

@@ -26,6 +27,7 @@ use util::num::ToPrimitive;
2627
use syntax::ast::{self, Expr};
2728
use syntax::ast_util;
2829
use syntax::codemap::Span;
30+
use syntax::feature_gate;
2931
use syntax::parse::token::InternedString;
3032
use syntax::ptr::P;
3133
use syntax::{codemap, visit};
@@ -743,6 +745,13 @@ pub fn eval_const_expr_with_substs<'tcx, S>(tcx: &ty::ctxt<'tcx>,
743745
Float(f) => Float(-f),
744746
Int(n) => try!(const_int_checked_neg(n, e, expr_int_type)),
745747
Uint(i) => {
748+
if !tcx.sess.features.borrow().negate_unsigned {
749+
feature_gate::emit_feature_err(
750+
&tcx.sess.parse_sess.span_diagnostic,
751+
"negate_unsigned",
752+
e.span,
753+
"unary negation of unsigned integers may be removed in the future");
754+
}
746755
try!(const_uint_checked_neg(i, e, expr_uint_type))
747756
}
748757
Str(_) => signal!(e, NegateOnString),

branches/stable/src/librustc_lint/builtin.rs

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ impl LintPass for WhileTrue {
8888
}
8989
}
9090

91+
declare_lint! {
92+
UNSIGNED_NEGATION,
93+
Warn,
94+
"using an unary minus operator on unsigned type"
95+
}
96+
9197
declare_lint! {
9298
UNUSED_COMPARISONS,
9399
Warn,
@@ -122,7 +128,8 @@ impl TypeLimits {
122128

123129
impl LintPass for TypeLimits {
124130
fn get_lints(&self) -> LintArray {
125-
lint_array!(UNUSED_COMPARISONS, OVERFLOWING_LITERALS, EXCEEDING_BITSHIFTS)
131+
lint_array!(UNSIGNED_NEGATION, UNUSED_COMPARISONS, OVERFLOWING_LITERALS,
132+
EXCEEDING_BITSHIFTS)
126133
}
127134

128135
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
@@ -132,12 +139,9 @@ impl LintPass for TypeLimits {
132139
ast::ExprLit(ref lit) => {
133140
match lit.node {
134141
ast::LitInt(_, ast::UnsignedIntLit(_)) => {
135-
check_unsigned_negation_feature(cx, e.span);
136-
},
137-
ast::LitInt(_, ast::UnsuffixedIntLit(_)) => {
138-
if let ty::TyUint(_) = cx.tcx.expr_ty(e).sty {
139-
check_unsigned_negation_feature(cx, e.span);
140-
}
142+
cx.span_lint(UNSIGNED_NEGATION, e.span,
143+
"negation of unsigned int literal may \
144+
be unintentional");
141145
},
142146
_ => ()
143147
}
@@ -146,7 +150,9 @@ impl LintPass for TypeLimits {
146150
let t = cx.tcx.expr_ty(&**expr);
147151
match t.sty {
148152
ty::TyUint(_) => {
149-
check_unsigned_negation_feature(cx, e.span);
153+
cx.span_lint(UNSIGNED_NEGATION, e.span,
154+
"negation of unsigned int variable may \
155+
be unintentional");
150156
},
151157
_ => ()
152158
}
@@ -379,18 +385,6 @@ impl LintPass for TypeLimits {
379385
_ => false
380386
}
381387
}
382-
383-
fn check_unsigned_negation_feature(cx: &Context, span: Span) {
384-
if !cx.sess().features.borrow().negate_unsigned {
385-
// FIXME(#27141): change this to syntax::feature_gate::emit_feature_err…
386-
cx.sess().span_warn(span,
387-
"unary negation of unsigned integers will be feature gated in the future");
388-
// …and remove following two expressions.
389-
if option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some() { return; }
390-
cx.sess().fileline_help(span, "add #![feature(negate_unsigned)] to the \
391-
crate attributes to enable the gate in advance");
392-
}
393-
}
394388
}
395389
}
396390

branches/stable/src/librustc_lint/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,4 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
134134
store.register_renamed("raw_pointer_deriving", "raw_pointer_derive");
135135

136136
store.register_renamed("unknown_features", "unused_features");
137-
138-
store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate");
139137
}

branches/stable/src/librustc_trans/trans/adt.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
//! used unboxed and any field can have pointers (including mutable)
4242
//! taken to it, implementing them for Rust seems difficult.
4343
44+
#![allow(unsigned_negation)]
45+
4446
pub use self::Repr::*;
4547

4648
use std::rc::Rc;

branches/stable/src/librustc_trans/trans/debuginfo/metadata.rs

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -796,31 +796,12 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
796796
}
797797
}
798798
ty::TyBareFn(_, ref barefnty) => {
799-
let fn_metadata = subroutine_type_metadata(cx,
800-
unique_type_id,
801-
&barefnty.sig,
802-
usage_site_span).metadata;
803-
match debug_context(cx).type_map
804-
.borrow()
805-
.find_metadata_for_unique_id(unique_type_id) {
806-
Some(metadata) => return metadata,
807-
None => { /* proceed normally */ }
808-
};
809-
810-
// This is actually a function pointer, so wrap it in pointer DI
811-
MetadataCreationResult::new(pointer_type_metadata(cx, t, fn_metadata), false)
812-
799+
subroutine_type_metadata(cx, unique_type_id, &barefnty.sig, usage_site_span)
813800
}
814801
ty::TyClosure(def_id, substs) => {
815802
let infcx = infer::normalizing_infer_ctxt(cx.tcx(), &cx.tcx().tables);
816-
let upvars = infcx.closure_upvars(def_id, substs).unwrap();
817-
let upvar_types = upvars.iter().map(|u| u.ty).collect::<Vec<_>>();
818-
819-
prepare_tuple_metadata(cx,
820-
t,
821-
&upvar_types[..],
822-
unique_type_id,
823-
usage_site_span).finalize(cx)
803+
let sig = infcx.closure_type(def_id, substs).sig;
804+
subroutine_type_metadata(cx, unique_type_id, &sig, usage_site_span)
824805
}
825806
ty::TyStruct(def_id, substs) => {
826807
prepare_struct_metadata(cx,
@@ -939,7 +920,7 @@ pub fn scope_metadata(fcx: &FunctionContext,
939920
}
940921
}
941922

942-
pub fn diverging_type_metadata(cx: &CrateContext) -> DIType {
923+
fn diverging_type_metadata(cx: &CrateContext) -> DIType {
943924
unsafe {
944925
llvm::LLVMDIBuilderCreateBasicType(
945926
DIB(cx),

branches/stable/src/librustc_trans/trans/debuginfo/mod.rs

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ use self::utils::{DIB, span_start, assert_type_for_node_id, contains_nodebug_att
1818
create_DIArray, is_node_local_to_unit};
1919
use self::namespace::{namespace_for_item, NamespaceTreeNode};
2020
use self::type_names::compute_debuginfo_type_name;
21-
use self::metadata::{type_metadata, diverging_type_metadata};
22-
use self::metadata::{file_metadata, scope_metadata, TypeMap, compile_unit_metadata};
21+
use self::metadata::{type_metadata, file_metadata, scope_metadata, TypeMap, compile_unit_metadata};
2322
use self::source_loc::InternalDebugLocation;
2423

2524
use llvm;
@@ -30,8 +29,8 @@ use middle::subst::{self, Substs};
3029
use rustc::ast_map;
3130
use trans::common::{NodeIdAndSpan, CrateContext, FunctionContext, Block};
3231
use trans;
33-
use trans::{monomorphize, type_of};
34-
use middle::ty::{self, Ty};
32+
use trans::monomorphize;
33+
use middle::ty::Ty;
3534
use session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
3635
use util::nodemap::{NodeMap, FnvHashMap, FnvHashSet};
3736

@@ -41,7 +40,7 @@ use std::ffi::CString;
4140
use std::ptr;
4241
use std::rc::Rc;
4342
use syntax::codemap::{Span, Pos};
44-
use syntax::{abi, ast, codemap, ast_util};
43+
use syntax::{ast, codemap, ast_util};
4544
use syntax::attr::IntType;
4645
use syntax::parse::token::{self, special_idents};
4746

@@ -326,6 +325,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
326325
let function_type_metadata = unsafe {
327326
let fn_signature = get_function_signature(cx,
328327
fn_ast_id,
328+
&*fn_decl,
329329
param_substs,
330330
span);
331331
llvm::LLVMDIBuilderCreateSubroutineType(DIB(cx), file_metadata, fn_signature)
@@ -402,49 +402,35 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
402402

403403
fn get_function_signature<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
404404
fn_ast_id: ast::NodeId,
405+
fn_decl: &ast::FnDecl,
405406
param_substs: &Substs<'tcx>,
406407
error_reporting_span: Span) -> DIArray {
407408
if cx.sess().opts.debuginfo == LimitedDebugInfo {
408409
return create_DIArray(DIB(cx), &[]);
409410
}
410411

411-
// Return type -- llvm::DIBuilder wants this at index 0
412-
assert_type_for_node_id(cx, fn_ast_id, error_reporting_span);
413-
let fn_type = cx.tcx().node_id_to_type(fn_ast_id);
414-
415-
let (sig, abi) = match fn_type.sty {
416-
ty::TyBareFn(_, ref barefnty) => {
417-
(cx.tcx().erase_late_bound_regions(&barefnty.sig), barefnty.abi)
418-
}
419-
ty::TyClosure(def_id, substs) => {
420-
let closure_type = cx.tcx().closure_type(def_id, substs);
421-
(cx.tcx().erase_late_bound_regions(&closure_type.sig), closure_type.abi)
422-
}
423-
424-
_ => cx.sess().bug("get_function_metdata: Expected a function type!")
425-
};
426-
let sig = monomorphize::apply_param_substs(cx.tcx(), param_substs, &sig);
427-
428-
let mut signature = Vec::with_capacity(sig.inputs.len() + 1);
412+
let mut signature = Vec::with_capacity(fn_decl.inputs.len() + 1);
429413

430414
// Return type -- llvm::DIBuilder wants this at index 0
431-
signature.push(match sig.output {
432-
ty::FnConverging(ret_ty) => match ret_ty.sty {
433-
ty::TyTuple(ref tys) if tys.is_empty() => ptr::null_mut(),
434-
_ => type_metadata(cx, ret_ty, codemap::DUMMY_SP)
435-
},
436-
ty::FnDiverging => diverging_type_metadata(cx)
437-
});
438-
439-
let inputs = &if abi == abi::RustCall {
440-
type_of::untuple_arguments(cx, &sig.inputs)
415+
assert_type_for_node_id(cx, fn_ast_id, error_reporting_span);
416+
let return_type = cx.tcx().node_id_to_type(fn_ast_id);
417+
let return_type = monomorphize::apply_param_substs(cx.tcx(),
418+
param_substs,
419+
&return_type);
420+
if return_type.is_nil() {
421+
signature.push(ptr::null_mut())
441422
} else {
442-
sig.inputs
443-
};
423+
signature.push(type_metadata(cx, return_type, codemap::DUMMY_SP));
424+
}
444425

445426
// Arguments types
446-
for &argument_type in inputs {
447-
signature.push(type_metadata(cx, argument_type, codemap::DUMMY_SP));
427+
for arg in &fn_decl.inputs {
428+
assert_type_for_node_id(cx, arg.pat.id, arg.pat.span);
429+
let arg_type = cx.tcx().node_id_to_type(arg.pat.id);
430+
let arg_type = monomorphize::apply_param_substs(cx.tcx(),
431+
param_substs,
432+
&arg_type);
433+
signature.push(type_metadata(cx, arg_type, codemap::DUMMY_SP));
448434
}
449435

450436
return create_DIArray(DIB(cx), &signature[..]);

0 commit comments

Comments
 (0)