Skip to content

Commit f63df98

Browse files
committed
---
yaml --- r: 221109 b: refs/heads/tmp c: 47265bb h: refs/heads/master i: 221107: fa89f4a v: v3
1 parent 099979f commit f63df98

File tree

20 files changed

+165
-107
lines changed

20 files changed

+165
-107
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2626
refs/heads/beta: c8bab9d06a179028a0d5129aa62f09d694d9cc49
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: 7e9e3896dfcef4852ca8ad90f91baf5187b0248e
28+
refs/heads/tmp: 47265bbf37385a087235a8c5eddea5944ae6465e
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: e58601ab085591c71a27ae82137fc313222c2270
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

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

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

15-
#![allow(unsigned_negation)]
16-
1715
use prelude::*;
1816

1917
use fmt;

branches/tmp/src/libcore/ops.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,6 @@ 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)]
521520
impl Neg for $t {
522521
#[stable(feature = "rust1", since = "1.0.0")]
523522
type Output = $t;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
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-
1210
use core::fmt::radix;
1311

1412
#[test]

branches/tmp/src/librand/isaac.rs

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

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

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

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ 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
7887
}
7988

8089
impl LintStore {
@@ -166,30 +175,42 @@ impl LintStore {
166175
self.by_name.insert(old_name.to_string(), Renamed(new_name.to_string(), target));
167176
}
168177

178+
pub fn register_removed(&mut self, name: &str, reason: &str) {
179+
self.by_name.insert(name.into(), Removed(reason.into()));
180+
}
181+
169182
#[allow(unused_variables)]
170183
fn find_lint(&self, lint_name: &str, sess: &Session, span: Option<Span>)
171-
-> Option<LintId>
184+
-> Result<LintId, FindLintError>
172185
{
173186
match self.by_name.get(lint_name) {
174-
Some(&Id(lint_id)) => Some(lint_id),
187+
Some(&Id(lint_id)) => Ok(lint_id),
175188
Some(&Renamed(ref new_name, lint_id)) => {
176189
let warning = format!("lint {} has been renamed to {}",
177190
lint_name, new_name);
178191
match span {
179192
Some(span) => sess.span_warn(span, &warning[..]),
180193
None => sess.warn(&warning[..]),
181194
};
182-
Some(lint_id)
183-
}
184-
None => None
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)
185206
}
186207
}
187208

188209
pub fn process_command_line(&mut self, sess: &Session) {
189210
for &(ref lint_name, level) in &sess.opts.lint_opts {
190211
match self.find_lint(&lint_name[..], sess, None) {
191-
Some(lint_id) => self.set_level(lint_id, (level, CommandLine)),
192-
None => {
212+
Ok(lint_id) => self.set_level(lint_id, (level, CommandLine)),
213+
Err(_) => {
193214
match self.lint_groups.iter().map(|(&x, pair)| (x, pair.0.clone()))
194215
.collect::<FnvHashMap<&'static str,
195216
Vec<LintId>>>()
@@ -398,8 +419,8 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
398419
}
399420
Ok((lint_name, level, span)) => {
400421
match self.lints.find_lint(&lint_name, &self.tcx.sess, Some(span)) {
401-
Some(lint_id) => vec![(lint_id, level, span)],
402-
None => {
422+
Ok(lint_id) => vec![(lint_id, level, span)],
423+
Err(FindLintError::NotFound) => {
403424
match self.lints.lint_groups.get(&lint_name[..]) {
404425
Some(&(ref v, _)) => v.iter()
405426
.map(|lint_id: &LintId|
@@ -412,7 +433,8 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
412433
continue;
413434
}
414435
}
415-
}
436+
},
437+
Err(FindLintError::Removed) => { continue; }
416438
}
417439
}
418440
};

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

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

1111
#![allow(non_camel_case_types)]
12-
#![allow(unsigned_negation)]
1312

1413
use self::ConstVal::*;
1514

@@ -27,7 +26,6 @@ use util::num::ToPrimitive;
2726
use syntax::ast::{self, Expr};
2827
use syntax::ast_util;
2928
use syntax::codemap::Span;
30-
use syntax::feature_gate;
3129
use syntax::parse::token::InternedString;
3230
use syntax::ptr::P;
3331
use syntax::{codemap, visit};
@@ -745,13 +743,6 @@ pub fn eval_const_expr_with_substs<'tcx, S>(tcx: &ty::ctxt<'tcx>,
745743
Float(f) => Float(-f),
746744
Int(n) => try!(const_int_checked_neg(n, e, expr_int_type)),
747745
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-
}
755746
try!(const_uint_checked_neg(i, e, expr_uint_type))
756747
}
757748
Str(_) => signal!(e, NegateOnString),

branches/tmp/src/librustc_lint/builtin.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,6 @@ 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-
9791
declare_lint! {
9892
UNUSED_COMPARISONS,
9993
Warn,
@@ -128,8 +122,7 @@ impl TypeLimits {
128122

129123
impl LintPass for TypeLimits {
130124
fn get_lints(&self) -> LintArray {
131-
lint_array!(UNSIGNED_NEGATION, UNUSED_COMPARISONS, OVERFLOWING_LITERALS,
132-
EXCEEDING_BITSHIFTS)
125+
lint_array!(UNUSED_COMPARISONS, OVERFLOWING_LITERALS, EXCEEDING_BITSHIFTS)
133126
}
134127

135128
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
@@ -139,9 +132,12 @@ impl LintPass for TypeLimits {
139132
ast::ExprLit(ref lit) => {
140133
match lit.node {
141134
ast::LitInt(_, ast::UnsignedIntLit(_)) => {
142-
cx.span_lint(UNSIGNED_NEGATION, e.span,
143-
"negation of unsigned int literal may \
144-
be unintentional");
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+
}
145141
},
146142
_ => ()
147143
}
@@ -150,9 +146,7 @@ impl LintPass for TypeLimits {
150146
let t = cx.tcx.expr_ty(&**expr);
151147
match t.sty {
152148
ty::TyUint(_) => {
153-
cx.span_lint(UNSIGNED_NEGATION, e.span,
154-
"negation of unsigned int variable may \
155-
be unintentional");
149+
check_unsigned_negation_feature(cx, e.span);
156150
},
157151
_ => ()
158152
}
@@ -385,6 +379,18 @@ impl LintPass for TypeLimits {
385379
_ => false
386380
}
387381
}
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+
}
388394
}
389395
}
390396

branches/tmp/src/librustc_lint/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,6 @@ 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");
137139
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
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-
4644
pub use self::Repr::*;
4745

4846
use std::rc::Rc;

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

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -796,12 +796,31 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
796796
}
797797
}
798798
ty::TyBareFn(_, ref barefnty) => {
799-
subroutine_type_metadata(cx, unique_type_id, &barefnty.sig, usage_site_span)
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+
800813
}
801814
ty::TyClosure(def_id, substs) => {
802815
let infcx = infer::normalizing_infer_ctxt(cx.tcx(), &cx.tcx().tables);
803-
let sig = infcx.closure_type(def_id, substs).sig;
804-
subroutine_type_metadata(cx, unique_type_id, &sig, usage_site_span)
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)
805824
}
806825
ty::TyStruct(def_id, substs) => {
807826
prepare_struct_metadata(cx,
@@ -920,7 +939,7 @@ pub fn scope_metadata(fcx: &FunctionContext,
920939
}
921940
}
922941

923-
fn diverging_type_metadata(cx: &CrateContext) -> DIType {
942+
pub fn diverging_type_metadata(cx: &CrateContext) -> DIType {
924943
unsafe {
925944
llvm::LLVMDIBuilderCreateBasicType(
926945
DIB(cx),

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

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ 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, file_metadata, scope_metadata, TypeMap, compile_unit_metadata};
21+
use self::metadata::{type_metadata, diverging_type_metadata};
22+
use self::metadata::{file_metadata, scope_metadata, TypeMap, compile_unit_metadata};
2223
use self::source_loc::InternalDebugLocation;
2324

2425
use llvm;
@@ -29,8 +30,8 @@ use middle::subst::{self, Substs};
2930
use rustc::ast_map;
3031
use trans::common::{NodeIdAndSpan, CrateContext, FunctionContext, Block};
3132
use trans;
32-
use trans::monomorphize;
33-
use middle::ty::Ty;
33+
use trans::{monomorphize, type_of};
34+
use middle::ty::{self, Ty};
3435
use session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
3536
use util::nodemap::{NodeMap, FnvHashMap, FnvHashSet};
3637

@@ -40,7 +41,7 @@ use std::ffi::CString;
4041
use std::ptr;
4142
use std::rc::Rc;
4243
use syntax::codemap::{Span, Pos};
43-
use syntax::{ast, codemap, ast_util};
44+
use syntax::{abi, ast, codemap, ast_util};
4445
use syntax::attr::IntType;
4546
use syntax::parse::token::{self, special_idents};
4647

@@ -325,7 +326,6 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
325326
let function_type_metadata = unsafe {
326327
let fn_signature = get_function_signature(cx,
327328
fn_ast_id,
328-
&*fn_decl,
329329
param_substs,
330330
span);
331331
llvm::LLVMDIBuilderCreateSubroutineType(DIB(cx), file_metadata, fn_signature)
@@ -402,35 +402,49 @@ 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,
406405
param_substs: &Substs<'tcx>,
407406
error_reporting_span: Span) -> DIArray {
408407
if cx.sess().opts.debuginfo == LimitedDebugInfo {
409408
return create_DIArray(DIB(cx), &[]);
410409
}
411410

412-
let mut signature = Vec::with_capacity(fn_decl.inputs.len() + 1);
413-
414411
// Return type -- llvm::DIBuilder wants this at index 0
415412
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())
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);
429+
430+
// 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)
422441
} else {
423-
signature.push(type_metadata(cx, return_type, codemap::DUMMY_SP));
424-
}
442+
sig.inputs
443+
};
425444

426445
// Arguments types
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));
446+
for &argument_type in inputs {
447+
signature.push(type_metadata(cx, argument_type, codemap::DUMMY_SP));
434448
}
435449

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

0 commit comments

Comments
 (0)