Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #41977

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ test = false

[dependencies]
build_helper = { path = "../build_helper" }
cmake = "0.1.17"
cmake = "0.1.23"
filetime = "0.1"
num_cpus = "1.0"
toml = "0.1"
getopts = "0.2"
rustc-serialize = "0.3"
gcc = "0.3.38"
gcc = "0.3.46"
libc = "0.2"
1 change: 1 addition & 0 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ pub fn llvm(build: &Build, target: &str) {
cfg.define("LLVM_USE_CRT_DEBUG", "MT");
cfg.define("LLVM_USE_CRT_RELEASE", "MT");
cfg.define("LLVM_USE_CRT_RELWITHDEBINFO", "MT");
cfg.static_crt(true);
}

if target.starts_with("i686") {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ impl<'a> ast_visit::Visitor<'a> for EarlyContext<'a> {
run_lints!(self, check_ident, early_passes, sp, id);
}

fn visit_mod(&mut self, m: &'a ast::Mod, s: Span, n: ast::NodeId) {
fn visit_mod(&mut self, m: &'a ast::Mod, s: Span, _a: &[ast::Attribute], n: ast::NodeId) {
run_lints!(self, check_mod, early_passes, m, s, n);
ast_visit::walk_mod(self, m);
run_lints!(self, check_mod_post, early_passes, m, s, n);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_passes/hir_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {

impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {

fn visit_mod(&mut self, m: &'v ast::Mod, _s: Span, _n: NodeId) {
fn visit_mod(&mut self, m: &'v ast::Mod, _s: Span, _a: &[ast::Attribute], _n: NodeId) {
self.record("Mod", Id::None, m);
ast_visit::walk_mod(self, m)
}
Expand Down
15 changes: 7 additions & 8 deletions src/librustc_resolve/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1222,27 +1222,26 @@ fn foo() {
"##,

E0435: r##"
A non-constant value was used to initialise a constant.
A non-constant value was used in a constant expression.

Erroneous code example:

```compile_fail,E0435
let foo = 42u32;
const FOO : u32 = foo; // error: attempt to use a non-constant value in a
// constant
let foo = 42;
let a: [u8; foo]; // error: attempt to use a non-constant value in a constant
```

To fix this error, please replace the value with a constant. Example:

```
const FOO : u32 = 42u32; // ok!
let a: [u8; 42]; // ok!
```

Or:

```
const OTHER_FOO : u32 = 42u32;
const FOO : u32 = OTHER_FOO; // ok!
const FOO: usize = 42;
let a: [u8; FOO]; // ok!
```
"##,

Expand Down Expand Up @@ -1560,7 +1559,7 @@ register_diagnostics! {
// E0157, unused error code
// E0257,
// E0258,
E0402, // cannot use an outer type parameter in this context
// E0402, // cannot use an outer type parameter in this context
// E0406, merged into 420
// E0410, merged into 408
// E0413, merged into 530
Expand Down
53 changes: 25 additions & 28 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ impl Ord for BindingError {
enum ResolutionError<'a> {
/// error E0401: can't use type parameters from outer function
TypeParametersFromOuterFunction,
/// error E0402: cannot use an outer type parameter in this context
OuterTypeParameterContext,
/// error E0403: the name is already used for a type parameter in this type parameter list
NameAlreadyUsedInTypeParameterList(Name, &'a Span),
/// error E0407: method is not a member of trait
Expand Down Expand Up @@ -187,12 +185,6 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
err.span_label(span, "use of type variable from outer function");
err
}
ResolutionError::OuterTypeParameterContext => {
struct_span_err!(resolver.session,
span,
E0402,
"cannot use an outer type parameter in this context")
}
ResolutionError::NameAlreadyUsedInTypeParameterList(name, first_use_span) => {
let mut err = struct_span_err!(resolver.session,
span,
Expand Down Expand Up @@ -1671,16 +1663,16 @@ impl<'a> Resolver<'a> {
this.check_proc_macro_attrs(&trait_item.attrs);

match trait_item.node {
TraitItemKind::Const(_, ref default) => {
TraitItemKind::Const(ref ty, ref default) => {
this.visit_ty(ty);

// Only impose the restrictions of
// ConstRibKind if there's an actual constant
// ConstRibKind for an actual constant
// expression in a provided default.
if default.is_some() {
if let Some(ref expr) = *default{
this.with_constant_rib(|this| {
visit::walk_trait_item(this, trait_item)
this.visit_expr(expr);
});
} else {
visit::walk_trait_item(this, trait_item)
}
}
TraitItemKind::Method(ref sig, _) => {
Expand Down Expand Up @@ -1709,9 +1701,13 @@ impl<'a> Resolver<'a> {
});
}

ItemKind::Const(..) | ItemKind::Static(..) => {
self.with_constant_rib(|this| {
visit::walk_item(this, item);
ItemKind::Static(ref ty, _, ref expr) |
ItemKind::Const(ref ty, ref expr) => {
self.with_item_rib(|this| {
this.visit_ty(ty);
this.with_constant_rib(|this| {
this.visit_expr(expr);
});
});
}

Expand Down Expand Up @@ -1782,13 +1778,21 @@ impl<'a> Resolver<'a> {
self.label_ribs.pop();
}

fn with_item_rib<F>(&mut self, f: F)
where F: FnOnce(&mut Resolver)
{
self.ribs[ValueNS].push(Rib::new(ItemRibKind));
self.ribs[TypeNS].push(Rib::new(ItemRibKind));
f(self);
self.ribs[TypeNS].pop();
self.ribs[ValueNS].pop();
}

fn with_constant_rib<F>(&mut self, f: F)
where F: FnOnce(&mut Resolver)
{
self.ribs[ValueNS].push(Rib::new(ConstantItemRibKind));
self.ribs[TypeNS].push(Rib::new(ConstantItemRibKind));
f(self);
self.ribs[TypeNS].pop();
self.ribs[ValueNS].pop();
}

Expand Down Expand Up @@ -2755,7 +2759,8 @@ impl<'a> Resolver<'a> {
for rib in ribs {
match rib.kind {
NormalRibKind | MethodRibKind(_) | ClosureRibKind(..) |
ModuleRibKind(..) | MacroDefinition(..) | ForwardTyParamBanRibKind => {
ModuleRibKind(..) | MacroDefinition(..) | ForwardTyParamBanRibKind |
ConstantItemRibKind => {
// Nothing to do. Continue.
}
ItemRibKind => {
Expand All @@ -2767,14 +2772,6 @@ impl<'a> Resolver<'a> {
}
return Def::Err;
}
ConstantItemRibKind => {
// see #9186
if record_used {
resolve_error(self, span,
ResolutionError::OuterTypeParameterContext);
}
return Def::Err;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_save_analysis/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ pub struct ModData {
pub items: Vec<NodeId>,
pub visibility: Visibility,
pub docs: String,
pub sig: Signature,
pub sig: Option<Signature>,
pub attributes: Vec<Attribute>,
}

Expand Down
25 changes: 25 additions & 0 deletions src/librustc_save_analysis/dump_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,31 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
}

impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll, D> {
fn visit_mod(&mut self, m: &'l ast::Mod, span: Span, attrs: &[ast::Attribute], id: NodeId) {
// Since we handle explicit modules ourselves in visit_item, this should
// only get called for the root module of a crate.
assert_eq!(id, ast::CRATE_NODE_ID);

let qualname = format!("::{}", self.tcx.node_path_str(id));

let cm = self.tcx.sess.codemap();
let filename = cm.span_to_filename(span);
self.dumper.mod_data(ModData {
id: id,
name: String::new(),
qualname: qualname,
span: span,
scope: id,
filename: filename,
items: m.items.iter().map(|i| i.id).collect(),
visibility: Visibility::Public,
docs: docs_for_attrs(attrs),
sig: None,
attributes: attrs.to_owned(),
}.lower(self.tcx));
self.nest_scope(id, |v| visit::walk_mod(v, m));
}

fn visit_item(&mut self, item: &'l ast::Item) {
use syntax::ast::ItemKind::*;
self.process_macro_use(item.span, item.id);
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_save_analysis/external_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ pub struct ModData {
pub items: Vec<DefId>,
pub visibility: Visibility,
pub docs: String,
pub sig: Signature,
pub sig: Option<Signature>,
pub attributes: Vec<Attribute>,
}

Expand All @@ -410,7 +410,7 @@ impl Lower for data::ModData {
items: self.items.into_iter().map(|id| make_def_id(id, &tcx.hir)).collect(),
visibility: self.visibility,
docs: self.docs,
sig: self.sig.lower(tcx),
sig: self.sig.map(|s| s.lower(tcx)),
attributes: self.attributes.lower(tcx),
}
}
Expand Down
Loading