Skip to content

Commit 94497b7

Browse files
committed
Auto merge of #41987 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 7 pull requests - Successful merges: #41612, #41826, #41939, #41946, #41950, #41975, #41979 - Failed merges:
2 parents 93dd1ca + 7294ce1 commit 94497b7

25 files changed

+196
-81
lines changed

src/Cargo.lock

+17-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bootstrap/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ test = false
3030

3131
[dependencies]
3232
build_helper = { path = "../build_helper" }
33-
cmake = "0.1.17"
33+
cmake = "0.1.23"
3434
filetime = "0.1"
3535
num_cpus = "1.0"
3636
toml = "0.1"
3737
getopts = "0.2"
3838
rustc-serialize = "0.3"
39-
gcc = "0.3.38"
39+
gcc = "0.3.46"
4040
libc = "0.2"

src/bootstrap/native.rs

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ pub fn llvm(build: &Build, target: &str) {
108108
cfg.define("LLVM_USE_CRT_DEBUG", "MT");
109109
cfg.define("LLVM_USE_CRT_RELEASE", "MT");
110110
cfg.define("LLVM_USE_CRT_RELWITHDEBINFO", "MT");
111+
cfg.static_crt(true);
111112
}
112113

113114
if target.starts_with("i686") {

src/libcore/ops.rs

+36
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,42 @@ pub trait Drop {
235235
/// }
236236
/// ```
237237
///
238+
/// Here is an example of the same `Point` struct implementing the `Add` trait
239+
/// using generics.
240+
///
241+
/// ```
242+
/// use std::ops::Add;
243+
///
244+
/// #[derive(Debug)]
245+
/// struct Point<T> {
246+
/// x: T,
247+
/// y: T,
248+
/// }
249+
///
250+
/// // Notice that the implementation uses the `Output` associated type
251+
/// impl<T: Add<Output=T>> Add for Point<T> {
252+
/// type Output = Point<T>;
253+
///
254+
/// fn add(self, other: Point<T>) -> Point<T> {
255+
/// Point {
256+
/// x: self.x + other.x,
257+
/// y: self.y + other.y,
258+
/// }
259+
/// }
260+
/// }
261+
///
262+
/// impl<T: PartialEq> PartialEq for Point<T> {
263+
/// fn eq(&self, other: &Self) -> bool {
264+
/// self.x == other.x && self.y == other.y
265+
/// }
266+
/// }
267+
///
268+
/// fn main() {
269+
/// assert_eq!(Point { x: 1, y: 0 } + Point { x: 2, y: 3 },
270+
/// Point { x: 3, y: 3 });
271+
/// }
272+
/// ```
273+
///
238274
/// Note that `RHS = Self` by default, but this is not mandatory. For example,
239275
/// [std::time::SystemTime] implements `Add<Duration>`, which permits
240276
/// operations of the form `SystemTime = SystemTime + Duration`.

src/librustc_resolve/diagnostics.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1222,27 +1222,26 @@ fn foo() {
12221222
"##,
12231223

12241224
E0435: r##"
1225-
A non-constant value was used to initialise a constant.
1225+
A non-constant value was used in a constant expression.
12261226
12271227
Erroneous code example:
12281228
12291229
```compile_fail,E0435
1230-
let foo = 42u32;
1231-
const FOO : u32 = foo; // error: attempt to use a non-constant value in a
1232-
// constant
1230+
let foo = 42;
1231+
let a: [u8; foo]; // error: attempt to use a non-constant value in a constant
12331232
```
12341233
12351234
To fix this error, please replace the value with a constant. Example:
12361235
12371236
```
1238-
const FOO : u32 = 42u32; // ok!
1237+
let a: [u8; 42]; // ok!
12391238
```
12401239
12411240
Or:
12421241
12431242
```
1244-
const OTHER_FOO : u32 = 42u32;
1245-
const FOO : u32 = OTHER_FOO; // ok!
1243+
const FOO: usize = 42;
1244+
let a: [u8; FOO]; // ok!
12461245
```
12471246
"##,
12481247

@@ -1560,7 +1559,7 @@ register_diagnostics! {
15601559
// E0157, unused error code
15611560
// E0257,
15621561
// E0258,
1563-
E0402, // cannot use an outer type parameter in this context
1562+
// E0402, // cannot use an outer type parameter in this context
15641563
// E0406, merged into 420
15651564
// E0410, merged into 408
15661565
// E0413, merged into 530

src/librustc_resolve/lib.rs

+25-28
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ impl Ord for BindingError {
127127
enum ResolutionError<'a> {
128128
/// error E0401: can't use type parameters from outer function
129129
TypeParametersFromOuterFunction,
130-
/// error E0402: cannot use an outer type parameter in this context
131-
OuterTypeParameterContext,
132130
/// error E0403: the name is already used for a type parameter in this type parameter list
133131
NameAlreadyUsedInTypeParameterList(Name, &'a Span),
134132
/// error E0407: method is not a member of trait
@@ -187,12 +185,6 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
187185
err.span_label(span, "use of type variable from outer function");
188186
err
189187
}
190-
ResolutionError::OuterTypeParameterContext => {
191-
struct_span_err!(resolver.session,
192-
span,
193-
E0402,
194-
"cannot use an outer type parameter in this context")
195-
}
196188
ResolutionError::NameAlreadyUsedInTypeParameterList(name, first_use_span) => {
197189
let mut err = struct_span_err!(resolver.session,
198190
span,
@@ -1671,16 +1663,16 @@ impl<'a> Resolver<'a> {
16711663
this.check_proc_macro_attrs(&trait_item.attrs);
16721664

16731665
match trait_item.node {
1674-
TraitItemKind::Const(_, ref default) => {
1666+
TraitItemKind::Const(ref ty, ref default) => {
1667+
this.visit_ty(ty);
1668+
16751669
// Only impose the restrictions of
1676-
// ConstRibKind if there's an actual constant
1670+
// ConstRibKind for an actual constant
16771671
// expression in a provided default.
1678-
if default.is_some() {
1672+
if let Some(ref expr) = *default{
16791673
this.with_constant_rib(|this| {
1680-
visit::walk_trait_item(this, trait_item)
1674+
this.visit_expr(expr);
16811675
});
1682-
} else {
1683-
visit::walk_trait_item(this, trait_item)
16841676
}
16851677
}
16861678
TraitItemKind::Method(ref sig, _) => {
@@ -1709,9 +1701,13 @@ impl<'a> Resolver<'a> {
17091701
});
17101702
}
17111703

1712-
ItemKind::Const(..) | ItemKind::Static(..) => {
1713-
self.with_constant_rib(|this| {
1714-
visit::walk_item(this, item);
1704+
ItemKind::Static(ref ty, _, ref expr) |
1705+
ItemKind::Const(ref ty, ref expr) => {
1706+
self.with_item_rib(|this| {
1707+
this.visit_ty(ty);
1708+
this.with_constant_rib(|this| {
1709+
this.visit_expr(expr);
1710+
});
17151711
});
17161712
}
17171713

@@ -1782,13 +1778,21 @@ impl<'a> Resolver<'a> {
17821778
self.label_ribs.pop();
17831779
}
17841780

1781+
fn with_item_rib<F>(&mut self, f: F)
1782+
where F: FnOnce(&mut Resolver)
1783+
{
1784+
self.ribs[ValueNS].push(Rib::new(ItemRibKind));
1785+
self.ribs[TypeNS].push(Rib::new(ItemRibKind));
1786+
f(self);
1787+
self.ribs[TypeNS].pop();
1788+
self.ribs[ValueNS].pop();
1789+
}
1790+
17851791
fn with_constant_rib<F>(&mut self, f: F)
17861792
where F: FnOnce(&mut Resolver)
17871793
{
17881794
self.ribs[ValueNS].push(Rib::new(ConstantItemRibKind));
1789-
self.ribs[TypeNS].push(Rib::new(ConstantItemRibKind));
17901795
f(self);
1791-
self.ribs[TypeNS].pop();
17921796
self.ribs[ValueNS].pop();
17931797
}
17941798

@@ -2755,7 +2759,8 @@ impl<'a> Resolver<'a> {
27552759
for rib in ribs {
27562760
match rib.kind {
27572761
NormalRibKind | MethodRibKind(_) | ClosureRibKind(..) |
2758-
ModuleRibKind(..) | MacroDefinition(..) | ForwardTyParamBanRibKind => {
2762+
ModuleRibKind(..) | MacroDefinition(..) | ForwardTyParamBanRibKind |
2763+
ConstantItemRibKind => {
27592764
// Nothing to do. Continue.
27602765
}
27612766
ItemRibKind => {
@@ -2767,14 +2772,6 @@ impl<'a> Resolver<'a> {
27672772
}
27682773
return Def::Err;
27692774
}
2770-
ConstantItemRibKind => {
2771-
// see #9186
2772-
if record_used {
2773-
resolve_error(self, span,
2774-
ResolutionError::OuterTypeParameterContext);
2775-
}
2776-
return Def::Err;
2777-
}
27782775
}
27792776
}
27802777
}

src/librustdoc/externalfiles.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use std::io::prelude::*;
1313
use std::io;
1414
use std::path::Path;
1515
use std::str;
16+
use html::markdown::{Markdown, RenderType};
1617

1718
#[derive(Clone)]
1819
pub struct ExternalHtml{
@@ -28,17 +29,26 @@ pub struct ExternalHtml{
2829
}
2930

3031
impl ExternalHtml {
31-
pub fn load(in_header: &[String], before_content: &[String], after_content: &[String])
32+
pub fn load(in_header: &[String], before_content: &[String], after_content: &[String],
33+
md_before_content: &[String], md_after_content: &[String], render: RenderType)
3234
-> Option<ExternalHtml> {
3335
load_external_files(in_header)
3436
.and_then(|ih|
3537
load_external_files(before_content)
3638
.map(|bc| (ih, bc))
3739
)
40+
.and_then(|(ih, bc)|
41+
load_external_files(md_before_content)
42+
.map(|m_bc| (ih, format!("{}{}", bc, Markdown(&m_bc, render))))
43+
)
3844
.and_then(|(ih, bc)|
3945
load_external_files(after_content)
4046
.map(|ac| (ih, bc, ac))
4147
)
48+
.and_then(|(ih, bc, ac)|
49+
load_external_files(md_after_content)
50+
.map(|m_ac| (ih, bc, format!("{}{}", ac, Markdown(&m_ac, render))))
51+
)
4252
.map(|(ih, bc, ac)|
4353
ExternalHtml {
4454
in_header: ih,

0 commit comments

Comments
 (0)