Skip to content

Commit 7f50e40

Browse files
committed
---
yaml --- r: 117877 b: refs/heads/auto c: bccdba0 h: refs/heads/master i: 117875: ddf7b41 v: v3
1 parent c7120f3 commit 7f50e40

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+587
-512
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 5c81a186e9d835ca66865bd9807524b805a06d8d
16+
refs/heads/auto: bccdba02960b3cd428addbc2c856065ebb81eb04
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/doc/rust.md

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,6 +1829,8 @@ type int8_t = i8;
18291829

18301830
### Static-only attributes
18311831

1832+
- `address_insignificant` - references to this static may alias with
1833+
references to other statics, potentially of unrelated type.
18321834
- `thread_local` - on a `static mut`, this signals that the value of this
18331835
static may change depending on the current thread. The exact consequences of
18341836
this are implementation-defined.
@@ -2139,22 +2141,13 @@ These types help drive the compiler's analysis
21392141
### Inline attributes
21402142

21412143
The inline attribute is used to suggest to the compiler to perform an inline
2142-
expansion and place a copy of the function or static in the caller rather than
2143-
generating code to call the function or access the static where it is defined.
2144+
expansion and place a copy of the function in the caller rather than generating
2145+
code to call the function where it is defined.
21442146

21452147
The compiler automatically inlines functions based on internal heuristics.
21462148
Incorrectly inlining functions can actually making the program slower, so it
21472149
should be used with care.
21482150

2149-
Immutable statics are always considered inlineable
2150-
unless marked with `#[inline(never)]`.
2151-
It is undefined
2152-
whether two different inlineable statics
2153-
have the same memory address.
2154-
In other words,
2155-
the compiler is free
2156-
to collapse duplicate inlineable statics together.
2157-
21582151
`#[inline]` and `#[inline(always)]` always causes the function to be serialized
21592152
into crate metadata to allow cross-crate inlining.
21602153

branches/auto/src/librustc/metadata/tydecode.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,10 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
346346
assert_eq!(next(st), '[');
347347
let def = parse_def(st, NominalType, |x,y| conv(x,y));
348348
let substs = parse_substs(st, |x,y| conv(x,y));
349+
let store = parse_trait_store(st, |x,y| conv(x,y));
349350
let bounds = parse_bounds(st, |x,y| conv(x,y));
350351
assert_eq!(next(st), ']');
351-
return ty::mk_trait(st.tcx, def, substs, bounds.builtin_bounds);
352+
return ty::mk_trait(st.tcx, def, substs, store, bounds.builtin_bounds);
352353
}
353354
'p' => {
354355
let did = parse_def(st, TypeParameter, |x,y| conv(x,y));

branches/auto/src/librustc/metadata/tyencode.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,12 @@ fn enc_sty(w: &mut MemWriter, cx: &ctxt, st: &ty::sty) {
232232
ty::ty_trait(box ty::TyTrait {
233233
def_id,
234234
ref substs,
235+
store,
235236
bounds
236237
}) => {
237238
mywrite!(w, "x[{}|", (cx.ds)(def_id));
238239
enc_substs(w, cx, substs);
240+
enc_trait_store(w, cx, store);
239241
let bounds = ty::ParamBounds {builtin_bounds: bounds,
240242
trait_bounds: Vec::new()};
241243
enc_bounds(w, cx, &bounds);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ pub fn lit_to_const(lit: &Lit) -> const_val {
506506
LitBinary(ref data) => {
507507
const_binary(Rc::new(data.iter().map(|x| *x).collect()))
508508
}
509+
LitByte(n) => const_uint(n as u64),
509510
LitChar(n) => const_uint(n as u64),
510511
LitInt(n, _) => const_int(n),
511512
LitUint(n, _) => const_uint(n),

branches/auto/src/librustc/middle/kind.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,9 @@ fn check_bounds_on_type_parameters(cx: &mut Context, e: &Expr) {
361361
fn check_trait_cast(cx: &mut Context, source_ty: ty::t, target_ty: ty::t, span: Span) {
362362
check_cast_for_escaping_regions(cx, source_ty, target_ty, span);
363363
match ty::get(target_ty).sty {
364-
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ ty, .. }) => match ty::get(ty).sty {
365-
ty::ty_trait(box ty::TyTrait { bounds, .. }) => {
366-
check_trait_cast_bounds(cx, span, source_ty, bounds);
367-
}
368-
_ => {}
369-
},
364+
ty::ty_trait(box ty::TyTrait { bounds, .. }) => {
365+
check_trait_cast_bounds(cx, span, source_ty, bounds);
366+
}
370367
_ => {}
371368
}
372369
}
@@ -533,8 +530,9 @@ pub fn check_cast_for_escaping_regions(
533530
{
534531
// Determine what type we are casting to; if it is not a trait, then no
535532
// worries.
536-
if !ty::type_is_trait(target_ty) {
537-
return;
533+
match ty::get(target_ty).sty {
534+
ty::ty_trait(..) => {}
535+
_ => { return; }
538536
}
539537

540538
// Collect up the regions that appear in the target type. We want to

branches/auto/src/librustc/middle/lint.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,7 @@ fn check_type_limits(cx: &Context, e: &ast::Expr) {
805805
} else { t };
806806
let (min, max) = uint_ty_range(uint_type);
807807
let lit_val: u64 = match lit.node {
808+
ast::LitByte(_v) => return, // _v is u8, within range by definition
808809
ast::LitInt(v, _) => v as u64,
809810
ast::LitUint(v, _) => v,
810811
ast::LitIntUnsuffixed(v) => v as u64,
@@ -980,6 +981,9 @@ fn check_heap_type(cx: &Context, span: Span, ty: ty::t) {
980981
n_box += 1;
981982
}
982983
ty::ty_uniq(_) |
984+
ty::ty_trait(box ty::TyTrait {
985+
store: ty::UniqTraitStore, ..
986+
}) |
983987
ty::ty_closure(box ty::ClosureTy {
984988
store: ty::UniqTraitStore,
985989
..
@@ -1084,6 +1088,7 @@ fn check_unused_attribute(cx: &Context, attr: &ast::Attribute) {
10841088

10851089
// FIXME: #14406 these are processed in trans, which happens after the
10861090
// lint pass
1091+
"address_insignificant",
10871092
"cold",
10881093
"inline",
10891094
"link",

branches/auto/src/librustc/middle/mem_categorization.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ pub enum deref_kind {
174174
pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
175175
match ty::get(t).sty {
176176
ty::ty_uniq(_) |
177+
ty::ty_trait(box ty::TyTrait { store: ty::UniqTraitStore, .. }) |
177178
ty::ty_closure(box ty::ClosureTy {store: ty::UniqTraitStore, ..}) => {
178179
Some(deref_ptr(OwnedPtr))
179180
}
@@ -182,6 +183,13 @@ pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
182183
let kind = ty::BorrowKind::from_mutbl(mt.mutbl);
183184
Some(deref_ptr(BorrowedPtr(kind, r)))
184185
}
186+
ty::ty_trait(box ty::TyTrait {
187+
store: ty::RegionTraitStore(r, mutbl),
188+
..
189+
}) => {
190+
let kind = ty::BorrowKind::from_mutbl(mutbl);
191+
Some(deref_ptr(BorrowedPtr(kind, r)))
192+
}
185193

186194
ty::ty_closure(box ty::ClosureTy {
187195
store: ty::RegionTraitStore(r, _),

branches/auto/src/librustc/middle/reachable.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,15 @@ use std::collections::HashSet;
2626
use syntax::abi;
2727
use syntax::ast;
2828
use syntax::ast_map;
29-
use syntax::ast_util::is_local;
30-
use syntax::ast_util;
31-
use syntax::attr::{InlineAlways, InlineHint, InlineNever, InlineNone};
29+
use syntax::ast_util::{is_local};
3230
use syntax::attr;
3331
use syntax::visit::Visitor;
3432
use syntax::visit;
3533

3634
// Returns true if the given set of attributes contains the `#[inline]`
3735
// attribute.
3836
fn attributes_specify_inlining(attrs: &[ast::Attribute]) -> bool {
39-
match attr::find_inline_attr(attrs) {
40-
InlineNone | InlineNever => false,
41-
InlineAlways | InlineHint => true,
42-
}
37+
attr::contains_name(attrs, "inline")
4338
}
4439

4540
// Returns true if the given set of generics implies that the item it's
@@ -123,8 +118,8 @@ impl<'a> Visitor<()> for ReachableContext<'a> {
123118
match def {
124119
// If this path leads to a static, then we may have
125120
// to do some work to figure out whether the static
126-
// is indeed reachable. (Inlineable statics are
127-
// never reachable.)
121+
// is indeed reachable (address_insignificant
122+
// statics are *never* reachable).
128123
def::DefStatic(..) => {
129124
self.worklist.push(def_id.node);
130125
}
@@ -286,10 +281,9 @@ impl<'a> ReachableContext<'a> {
286281

287282
// Statics with insignificant addresses are not reachable
288283
// because they're inlined specially into all other crates.
289-
ast::ItemStatic(_, mutbl, ref init) => {
290-
if !ast_util::static_has_significant_address(
291-
mutbl,
292-
item.attrs.as_slice()) {
284+
ast::ItemStatic(_, _, ref init) => {
285+
if attr::contains_name(item.attrs.as_slice(),
286+
"address_insignificant") {
293287
self.reachable_symbols.remove(&search_item);
294288
}
295289
visit::walk_expr(self, &**init, ());

branches/auto/src/librustc/middle/trans/adt.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,12 @@ impl Case {
292292
fn find_ptr(&self) -> Option<uint> {
293293
self.tys.iter().position(|&ty| {
294294
match ty::get(ty).sty {
295-
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => match ty::get(ty).sty {
296-
ty::ty_vec(_, None) | ty::ty_str| ty::ty_trait(..) => false,
295+
ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty {
296+
ty::ty_vec(_, None) | ty::ty_str => false,
297297
_ => true,
298298
},
299-
ty::ty_box(..) | ty::ty_bare_fn(..) => true,
299+
ty::ty_uniq(..) | ty::ty_box(..) |
300+
ty::ty_bare_fn(..) => true,
300301
// Is that everything? Would closures or slices qualify?
301302
_ => false
302303
}

branches/auto/src/librustc/middle/trans/base.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,9 +1794,6 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t) -> Vec<(uint, u6
17941794
match ty::get(ret_ty).sty {
17951795
// `~` pointer return values never alias because ownership
17961796
// is transferred
1797-
ty::ty_uniq(it) if match ty::get(it).sty {
1798-
ty::ty_str | ty::ty_vec(..) | ty::ty_trait(..) => true, _ => false
1799-
} => {}
18001797
ty::ty_uniq(_) => {
18011798
attrs.push((lib::llvm::ReturnIndex as uint, lib::llvm::NoAliasAttribute as u64));
18021799
}
@@ -1806,9 +1803,9 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t) -> Vec<(uint, u6
18061803
// We can also mark the return value as `nonnull` in certain cases
18071804
match ty::get(ret_ty).sty {
18081805
// These are not really pointers but pairs, (pointer, len)
1809-
ty::ty_uniq(it) |
1806+
ty::ty_rptr(_, ty::mt { ty: it, .. }) |
18101807
ty::ty_rptr(_, ty::mt { ty: it, .. }) if match ty::get(it).sty {
1811-
ty::ty_str | ty::ty_vec(..) | ty::ty_trait(..) => true, _ => false
1808+
ty::ty_str | ty::ty_vec(..) => true, _ => false
18121809
} => {}
18131810
ty::ty_uniq(_) | ty::ty_rptr(_, _) => {
18141811
attrs.push((lib::llvm::ReturnIndex as uint, lib::llvm::NonNullAttribute as u64));
@@ -1997,7 +1994,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
19971994
let sym = exported_name(ccx, id, ty, i.attrs.as_slice());
19981995

19991996
let v = match i.node {
2000-
ast::ItemStatic(_, mutbl, ref expr) => {
1997+
ast::ItemStatic(_, _, ref expr) => {
20011998
// If this static came from an external crate, then
20021999
// we need to get the symbol from csearch instead of
20032000
// using the current crate's name/version
@@ -2032,24 +2029,28 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
20322029

20332030
// Apply the `unnamed_addr` attribute if
20342031
// requested
2035-
if !ast_util::static_has_significant_address(
2036-
mutbl,
2037-
i.attrs.as_slice()) {
2032+
if attr::contains_name(i.attrs.as_slice(),
2033+
"address_insignificant") {
2034+
if ccx.reachable.contains(&id) {
2035+
ccx.sess().span_bug(i.span,
2036+
"insignificant static is reachable");
2037+
}
20382038
lib::llvm::SetUnnamedAddr(g, true);
20392039

20402040
// This is a curious case where we must make
20412041
// all of these statics inlineable. If a
2042-
// global is not tagged as `#[inline(never)]`,
2043-
// then LLVM won't coalesce globals unless they
2044-
// have an internal linkage type. This means that
2042+
// global is tagged as
2043+
// address_insignificant, then LLVM won't
2044+
// coalesce globals unless they have an
2045+
// internal linkage type. This means that
20452046
// external crates cannot use this global.
20462047
// This is a problem for things like inner
20472048
// statics in generic functions, because the
20482049
// function will be inlined into another
20492050
// crate and then attempt to link to the
20502051
// static in the original crate, only to
20512052
// find that it's not there. On the other
2052-
// side of inlining, the crates knows to
2053+
// side of inlininig, the crates knows to
20532054
// not declare this static as
20542055
// available_externally (because it isn't)
20552056
inlineable = true;

branches/auto/src/librustc/middle/trans/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub fn type_is_immediate(ccx: &CrateContext, ty: ty::t) -> bool {
6767
ty::type_is_unique(ty) || ty::type_is_region_ptr(ty) ||
6868
type_is_newtype_immediate(ccx, ty) || ty::type_is_bot(ty) ||
6969
ty::type_is_simd(tcx, ty);
70-
if simple && !ty::type_is_trait(ty) {
70+
if simple {
7171
return true;
7272
}
7373
match ty::get(ty).sty {

branches/auto/src/librustc/middle/trans/consts.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: ast::Lit)
4343
-> ValueRef {
4444
let _icx = push_ctxt("trans_lit");
4545
match lit.node {
46+
ast::LitByte(b) => C_integral(Type::uint_from_ty(cx, ast::TyU8), b as u64, false),
4647
ast::LitChar(i) => C_integral(Type::char(cx), i as u64, false),
4748
ast::LitInt(i, t) => C_integral(Type::int_from_ty(cx, t), i as u64, true),
4849
ast::LitUint(u, t) => C_integral(Type::uint_from_ty(cx, t), u, false),
@@ -143,9 +144,7 @@ fn const_deref(cx: &CrateContext, v: ValueRef, t: ty::t, explicit: bool)
143144
let dv = match ty::get(t).sty {
144145
ty::ty_ptr(mt) | ty::ty_rptr(_, mt) => {
145146
match ty::get(mt.ty).sty {
146-
ty::ty_vec(_, None) | ty::ty_str | ty::ty_trait(..) => {
147-
cx.sess().bug("unexpected unsized type")
148-
}
147+
ty::ty_vec(_, None) | ty::ty_str => cx.sess().bug("unexpected slice"),
149148
_ => const_deref_ptr(cx, v),
150149
}
151150
}

branches/auto/src/librustc/middle/trans/datum.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ pub fn appropriate_rvalue_mode(ccx: &CrateContext, ty: ty::t) -> RvalueMode {
157157
* on whether type is immediate or not.
158158
*/
159159

160-
if type_is_immediate(ccx, ty) {
160+
if type_is_zero_size(ccx, ty) {
161+
ByValue
162+
} else if type_is_immediate(ccx, ty) {
161163
ByValue
162164
} else {
163165
ByRef

0 commit comments

Comments
 (0)