Skip to content

Commit

Permalink
Auto merge of #41987 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Rollup of 7 pull requests

- Successful merges: #41612, #41826, #41939, #41946, #41950, #41975, #41979
- Failed merges:
  • Loading branch information
bors committed May 14, 2017
2 parents 93dd1ca + 7294ce1 commit 94497b7
Show file tree
Hide file tree
Showing 25 changed files with 196 additions and 81 deletions.
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
36 changes: 36 additions & 0 deletions src/libcore/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,42 @@ pub trait Drop {
/// }
/// ```
///
/// Here is an example of the same `Point` struct implementing the `Add` trait
/// using generics.
///
/// ```
/// use std::ops::Add;
///
/// #[derive(Debug)]
/// struct Point<T> {
/// x: T,
/// y: T,
/// }
///
/// // Notice that the implementation uses the `Output` associated type
/// impl<T: Add<Output=T>> Add for Point<T> {
/// type Output = Point<T>;
///
/// fn add(self, other: Point<T>) -> Point<T> {
/// Point {
/// x: self.x + other.x,
/// y: self.y + other.y,
/// }
/// }
/// }
///
/// impl<T: PartialEq> PartialEq for Point<T> {
/// fn eq(&self, other: &Self) -> bool {
/// self.x == other.x && self.y == other.y
/// }
/// }
///
/// fn main() {
/// assert_eq!(Point { x: 1, y: 0 } + Point { x: 2, y: 3 },
/// Point { x: 3, y: 3 });
/// }
/// ```
///
/// Note that `RHS = Self` by default, but this is not mandatory. For example,
/// [std::time::SystemTime] implements `Add<Duration>`, which permits
/// operations of the form `SystemTime = SystemTime + Duration`.
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
12 changes: 11 additions & 1 deletion src/librustdoc/externalfiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::io::prelude::*;
use std::io;
use std::path::Path;
use std::str;
use html::markdown::{Markdown, RenderType};

#[derive(Clone)]
pub struct ExternalHtml{
Expand All @@ -28,17 +29,26 @@ pub struct ExternalHtml{
}

impl ExternalHtml {
pub fn load(in_header: &[String], before_content: &[String], after_content: &[String])
pub fn load(in_header: &[String], before_content: &[String], after_content: &[String],
md_before_content: &[String], md_after_content: &[String], render: RenderType)
-> Option<ExternalHtml> {
load_external_files(in_header)
.and_then(|ih|
load_external_files(before_content)
.map(|bc| (ih, bc))
)
.and_then(|(ih, bc)|
load_external_files(md_before_content)
.map(|m_bc| (ih, format!("{}{}", bc, Markdown(&m_bc, render))))
)
.and_then(|(ih, bc)|
load_external_files(after_content)
.map(|ac| (ih, bc, ac))
)
.and_then(|(ih, bc, ac)|
load_external_files(md_after_content)
.map(|m_ac| (ih, bc, format!("{}{}", ac, Markdown(&m_ac, render))))
)
.map(|(ih, bc, ac)|
ExternalHtml {
in_header: ih,
Expand Down
Loading

0 comments on commit 94497b7

Please sign in to comment.