Skip to content

Commit 1cfad44

Browse files
committed
---
yaml --- r: 106347 b: refs/heads/auto c: ff64381 h: refs/heads/master i: 106345: ab8e33a 106343: 573e6c3 v: v3
1 parent d1edb95 commit 1cfad44

File tree

9 files changed

+88
-10
lines changed

9 files changed

+88
-10
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: f1739b14a1346419a4598339aee32aab07e0d12e
16+
refs/heads/auto: ff64381c8bf6a49a0671287de5f5b7316ae2ef9c
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/Makefile.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ include config.mk
177177

178178
# Just a few macros used everywhere
179179
include $(CFG_SRC_DIR)mk/util.mk
180-
# All crates and their dependencies
181-
include $(CFG_SRC_DIR)mk/crates.mk
182180
# Reconfiguring when the makefiles or submodules change
183181
include $(CFG_SRC_DIR)mk/reconfig.mk
182+
# All crates and their dependencies
183+
include $(CFG_SRC_DIR)mk/crates.mk
184184
# Various bits of setup, common macros, and top-level rules
185185
include $(CFG_SRC_DIR)mk/main.mk
186186
# C and assembly components that are not LLVM

branches/auto/mk/crates.mk

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ COMPILER_DOC_CRATES := rustc syntax
105105
# $(1) is the crate to generate variables for
106106
define RUST_CRATE
107107
CRATEFILE_$(1) := $$(S)src/lib$(1)/lib.rs
108-
RSINPUTS_$(1) := $$(wildcard $$(addprefix $(S)src/lib$(1), \
109-
*.rs */*.rs */*/*.rs */*/*/*.rs))
108+
RSINPUTS_$(1) := $$(call rwildcard,$(S)src/lib$(1)/,*.rs)
110109
RUST_DEPS_$(1) := $$(filter-out native:%,$$(DEPS_$(1)))
111110
NATIVE_DEPS_$(1) := $$(patsubst native:%,%,$$(filter native:%,$$(DEPS_$(1))))
112111
endef
@@ -117,8 +116,7 @@ $(foreach crate,$(CRATES),$(eval $(call RUST_CRATE,$(crate))))
117116
#
118117
# $(1) is the crate to generate variables for
119118
define RUST_TOOL
120-
TOOL_INPUTS_$(1) := $$(wildcard $$(addprefix $$(dir $$(TOOL_SOURCE_$(1))), \
121-
*.rs */*.rs */*/*.rs */*/*/*.rs))
119+
TOOL_INPUTS_$(1) := $$(call rwildcard,$$(dir $$(TOOL_SOURCE_$(1))),*.rs)
122120
endef
123121

124122
$(foreach crate,$(TOOLS),$(eval $(call RUST_TOOL,$(crate))))

branches/auto/mk/install.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
install: dist-install-dir-$(CFG_BUILD)
1313
$(Q)sh tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --prefix="$(CFG_PREFIX)" --libdir="$(CFG_LIBDIR)" --mandir="$(CFG_MANDIR)"
1414
# Remove tmp files while we can because they may have been created under sudo
15-
$(Q)rm -R tmp/dist/$(PKG_NAME)-$(CFG_BUILD/
15+
$(Q)rm -R tmp/dist/$(PKG_NAME)-$(CFG_BUILD)
1616

1717
uninstall: dist-install-dir-$(CFG_BUILD)
1818
$(Q)sh tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --uninstall --prefix="$(CFG_PREFIX)" --libdir="$(CFG_LIBDIR)" --mandir="$(CFG_MANDIR)"

branches/auto/mk/rt.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ $$(LIBUV_DIR_$(1))/Release/libuv.a: $$(LIBUV_DEPS) $$(LIBUV_MAKEFILE_$(1)) \
215215
BUILDTYPE=Release \
216216
NO_LOAD="$$(LIBUV_NO_LOAD)" \
217217
V=$$(VERBOSE)
218+
$$(Q)touch $$@
218219

219220
endif
220221

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ pub enum Lint {
115115
DeprecatedOwnedVector,
116116

117117
Warnings,
118+
119+
RawPointerDeriving,
118120
}
119121

120122
pub fn level_to_str(lv: level) -> &'static str {
@@ -406,6 +408,13 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[
406408
desc: "use of a `~[T]` vector",
407409
default: allow,
408410
}),
411+
412+
("raw_pointer_deriving",
413+
LintSpec {
414+
lint: RawPointerDeriving,
415+
desc: "uses of #[deriving] with raw pointers are rarely correct",
416+
default: warn,
417+
}),
409418
];
410419

411420
/*
@@ -959,6 +968,37 @@ fn check_heap_item(cx: &Context, it: &ast::Item) {
959968
}
960969
}
961970

971+
struct RawPtrDerivingVisitor<'a> {
972+
cx: &'a Context<'a>
973+
}
974+
975+
impl<'a> Visitor<()> for RawPtrDerivingVisitor<'a> {
976+
fn visit_ty(&mut self, ty: &ast::Ty, _: ()) {
977+
static MSG: &'static str = "use of `#[deriving]` with a raw pointer";
978+
match ty.node {
979+
ast::TyPtr(..) => self.cx.span_lint(RawPointerDeriving, ty.span, MSG),
980+
_ => {}
981+
}
982+
visit::walk_ty(self, ty, ());
983+
}
984+
// explicit override to a no-op to reduce code bloat
985+
fn visit_expr(&mut self, _: &ast::Expr, _: ()) {}
986+
fn visit_block(&mut self, _: &ast::Block, _: ()) {}
987+
}
988+
989+
fn check_raw_ptr_deriving(cx: &Context, item: &ast::Item) {
990+
if !attr::contains_name(item.attrs.as_slice(), "deriving") {
991+
return
992+
}
993+
match item.node {
994+
ast::ItemStruct(..) | ast::ItemEnum(..) => {
995+
let mut visitor = RawPtrDerivingVisitor { cx: cx };
996+
visit::walk_item(&mut visitor, item, ());
997+
}
998+
_ => {}
999+
}
1000+
}
1001+
9621002
static crate_attrs: &'static [&'static str] = &[
9631003
"crate_type", "feature", "no_start", "no_main", "no_std", "crate_id",
9641004
"desc", "comment", "license", "copyright", // not used in rustc now
@@ -1585,6 +1625,7 @@ impl<'a> Visitor<()> for Context<'a> {
15851625
check_heap_item(cx, it);
15861626
check_missing_doc_item(cx, it);
15871627
check_attrs_usage(cx, it.attrs.as_slice());
1628+
check_raw_ptr_deriving(cx, it);
15881629

15891630
cx.visit_ids(|v| v.visit_item(it, ()));
15901631

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ pub struct t_box_ {
384384
// alive, and using ty::get is unsafe when the ctxt is no longer alive.
385385
enum t_opaque {}
386386

387+
#[allow(raw_pointer_deriving)]
387388
#[deriving(Clone, Eq, TotalEq, Hash)]
388389
pub struct t { priv inner: *t_opaque }
389390

branches/auto/src/librustdoc/passes.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ impl<'a> fold::DocFolder for Stripper<'a> {
128128
}
129129
}
130130

131-
clean::ViewItemItem(..) |
132-
clean::ModuleItem(..) => {
131+
clean::ViewItemItem(..) => {
133132
if i.visibility != Some(ast::Public) {
134133
return None
135134
}
@@ -141,6 +140,9 @@ impl<'a> fold::DocFolder for Stripper<'a> {
141140
}
142141
}
143142

143+
// handled below
144+
clean::ModuleItem(..) => {}
145+
144146
// trait impls for private items should be stripped
145147
clean::ImplItem(clean::Impl{ for_: clean::ResolvedPath{ id: ref for_id, .. }, .. }) => {
146148
if !self.exported_items.contains(for_id) {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[feature(struct_variant)];
12+
#[allow(dead_code)];
13+
#[deny(raw_pointer_deriving)];
14+
15+
#[deriving(Clone)]
16+
struct Foo {
17+
x: *int //~ ERROR use of `#[deriving]` with a raw pointer
18+
}
19+
20+
#[deriving(Clone)]
21+
struct Bar(*mut int); //~ ERROR use of `#[deriving]` with a raw pointer
22+
23+
#[deriving(Clone)]
24+
enum Baz {
25+
A(*int), //~ ERROR use of `#[deriving]` with a raw pointer
26+
B { x: *mut int } //~ ERROR use of `#[deriving]` with a raw pointer
27+
}
28+
29+
#[deriving(Clone)]
30+
struct Buzz {
31+
x: (*int, //~ ERROR use of `#[deriving]` with a raw pointer
32+
*uint) //~ ERROR use of `#[deriving]` with a raw pointer
33+
}
34+
35+
fn main() {}

0 commit comments

Comments
 (0)