Skip to content

Commit f7be4ce

Browse files
author
Nick Hamann
committed
---
yaml --- r: 226036 b: refs/heads/stable c: a6cc4dd h: refs/heads/master v: v3
1 parent a640349 commit f7be4ce

File tree

24 files changed

+98
-286
lines changed

24 files changed

+98
-286
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ refs/heads/tmp: e5d90d98402475b6e154ce216f9efcb80da1a747
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: 1fe32ca12c51afcd761d9962f51a74ff0d07a591
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: f50ae67ec2046e410ed070cff2f630a35dfe01ee
32+
refs/heads/stable: a6cc4dd308213390a53a53101424ca4ef2e351ab
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b

branches/stable/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
# The Rust Programming Language
22

3-
Rust is a fast systems programming language that guarantees
4-
memory safety and offers painless concurrency ([no data races]).
5-
It does not employ a garbage collector and has minimal runtime overhead.
3+
Rust is a systems programming language that is fast, memory safe and
4+
multithreaded, but does not employ a garbage collector or otherwise
5+
impose significant runtime overhead.
66

77
This repo contains the code for `rustc`, the Rust compiler, as well
88
as standard libraries, tools and documentation for Rust.
99

10-
[no data races]: http://blog.rust-lang.org/2015/04/10/Fearless-Concurrency.html
11-
1210
## Quick Start
1311

1412
Read ["Installing Rust"] from [The Book].

branches/stable/src/libcore/ptr.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,11 +512,6 @@ impl<T: ?Sized> PartialOrd for *mut T {
512512
#[unstable(feature = "unique", reason = "needs an RFC to flesh out design")]
513513
pub struct Unique<T: ?Sized> {
514514
pointer: NonZero<*const T>,
515-
// NOTE: this marker has no consequences for variance, but is necessary
516-
// for dropck to understand that we logically own a `T`.
517-
//
518-
// For details, see:
519-
// https://github.com/rust-lang/rfcs/blob/master/text/0769-sound-generic-drop.md#phantom-data
520515
_marker: PhantomData<T>,
521516
}
522517

branches/stable/src/librustc/lint/context.rs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ use self::TargetLint::*;
2828
use middle::privacy::ExportedItems;
2929
use middle::ty::{self, Ty};
3030
use session::{early_error, Session};
31+
use session::config::UnstableFeatures;
3132
use lint::{Level, LevelSource, Lint, LintId, LintArray, LintPass, LintPassObject};
32-
use lint::{Default, CommandLine, Node, Allow, Warn, Deny, Forbid};
33+
use lint::{Default, CommandLine, Node, Allow, Warn, Deny, Forbid, ReleaseChannel};
3334
use lint::builtin;
3435
use util::nodemap::FnvHashMap;
3536

@@ -207,6 +208,23 @@ impl LintStore {
207208
}
208209
}
209210
}
211+
212+
fn maybe_stage_features(&mut self, sess: &Session) {
213+
let lvl = match sess.opts.unstable_features {
214+
UnstableFeatures::Default => return,
215+
UnstableFeatures::Disallow => Forbid,
216+
UnstableFeatures::Cheat => Allow
217+
};
218+
match self.by_name.get("unstable_features") {
219+
Some(&Id(lint_id)) => if self.get_level_source(lint_id).0 != Forbid {
220+
self.set_level(lint_id, (lvl, ReleaseChannel))
221+
},
222+
Some(&Renamed(_, lint_id)) => if self.get_level_source(lint_id).0 != Forbid {
223+
self.set_level(lint_id, (lvl, ReleaseChannel))
224+
},
225+
None => unreachable!()
226+
}
227+
}
210228
}
211229

212230
/// Context for lint checking.
@@ -290,6 +308,7 @@ pub fn raw_emit_lint(sess: &Session, lint: &'static Lint,
290308

291309
let name = lint.name_lower();
292310
let mut def = None;
311+
let mut note = None;
293312
let msg = match source {
294313
Default => {
295314
format!("{}, #[{}({})] on by default", msg,
@@ -306,6 +325,12 @@ pub fn raw_emit_lint(sess: &Session, lint: &'static Lint,
306325
def = Some(src);
307326
msg.to_string()
308327
}
328+
ReleaseChannel => {
329+
let release_channel = option_env!("CFG_RELEASE_CHANNEL").unwrap_or("(unknown)");
330+
note = Some(format!("this feature may not be used in the {} release channel",
331+
release_channel));
332+
msg.to_string()
333+
}
309334
};
310335

311336
// For purposes of printing, we can treat forbid as deny.
@@ -319,6 +344,10 @@ pub fn raw_emit_lint(sess: &Session, lint: &'static Lint,
319344
_ => sess.bug("impossible level in raw_emit_lint"),
320345
}
321346

347+
if let Some(note) = note {
348+
sess.note(&note[..]);
349+
}
350+
322351
if let Some(span) = def {
323352
sess.span_note(span, "lint level defined here");
324353
}
@@ -660,6 +689,9 @@ impl LintPass for GatherNodeLevels {
660689
pub fn check_crate(tcx: &ty::ctxt,
661690
exported_items: &ExportedItems) {
662691

692+
// If this is a feature-staged build of rustc then flip several lints to 'forbid'
693+
tcx.sess.lint_store.borrow_mut().maybe_stage_features(&tcx.sess);
694+
663695
let krate = tcx.map.krate();
664696
let mut cx = Context::new(tcx, krate, exported_items);
665697

branches/stable/src/librustc/lint/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ pub enum LintSource {
247247

248248
/// Lint level was set by a command-line flag.
249249
CommandLine,
250+
251+
/// Lint level was set by the release channel.
252+
ReleaseChannel
250253
}
251254

252255
pub type LevelSource = (Level, LintSource);

branches/stable/src/librustc/session/config.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ use syntax::attr::AttrMetaMethods;
3232
use syntax::diagnostic::{ColorConfig, Auto, Always, Never, SpanHandler};
3333
use syntax::parse;
3434
use syntax::parse::token::InternedString;
35-
use syntax::feature_gate::UnstableFeatures;
3635

3736
use getopts;
3837
use std::collections::HashMap;
@@ -120,6 +119,21 @@ pub struct Options {
120119
pub unstable_features: UnstableFeatures
121120
}
122121

122+
#[derive(Clone, Copy)]
123+
pub enum UnstableFeatures {
124+
/// Hard errors for unstable features are active, as on
125+
/// beta/stable channels.
126+
Disallow,
127+
/// Use the default lint levels
128+
Default,
129+
/// Errors are bypassed for bootstrapping. This is required any time
130+
/// during the build that feature-related lints are set to warn or above
131+
/// because the build turns on warnings-as-errors and uses lots of unstable
132+
/// features. As a result, this this is always required for building Rust
133+
/// itself.
134+
Cheat
135+
}
136+
123137
#[derive(Clone, PartialEq, Eq)]
124138
pub enum PrintRequest {
125139
FileNames,
@@ -1060,7 +1074,7 @@ pub fn get_unstable_features_setting() -> UnstableFeatures {
10601074
match (disable_unstable_features, bootstrap_secret_key, bootstrap_provided_key) {
10611075
(_, Some(ref s), Some(ref p)) if s == p => UnstableFeatures::Cheat,
10621076
(true, _, _) => UnstableFeatures::Disallow,
1063-
(false, _, _) => UnstableFeatures::Allow
1077+
(false, _, _) => UnstableFeatures::Default
10641078
}
10651079
}
10661080

branches/stable/src/librustc_driver/driver.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
528528
let features =
529529
syntax::feature_gate::check_crate(sess.codemap(),
530530
&sess.parse_sess.span_diagnostic,
531-
&krate, &attributes,
532-
sess.opts.unstable_features);
531+
&krate, &attributes);
533532
*sess.features.borrow_mut() = features;
534533
sess.abort_if_errors();
535534
});
@@ -559,8 +558,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
559558
let features =
560559
syntax::feature_gate::check_crate(sess.codemap(),
561560
&sess.parse_sess.span_diagnostic,
562-
&krate, &attributes,
563-
sess.opts.unstable_features);
561+
&krate, &attributes);
564562
*sess.features.borrow_mut() = features;
565563
sess.abort_if_errors();
566564
});
@@ -780,11 +778,18 @@ pub fn phase_5_run_llvm_passes(sess: &Session,
780778
pub fn phase_6_link_output(sess: &Session,
781779
trans: &trans::CrateTranslation,
782780
outputs: &OutputFilenames) {
781+
let old_path = env::var_os("PATH").unwrap_or(OsString::new());
782+
let mut new_path = sess.host_filesearch(PathKind::All).get_tools_search_paths();
783+
new_path.extend(env::split_paths(&old_path));
784+
env::set_var("PATH", &env::join_paths(&new_path).unwrap());
785+
783786
time(sess.time_passes(), "linking", (), |_|
784787
link::link_binary(sess,
785788
trans,
786789
outputs,
787790
&trans.link.crate_name));
791+
792+
env::set_var("PATH", &old_path);
788793
}
789794

790795
fn escape_dep_filename(filename: &str) -> String {

branches/stable/src/librustc_driver/test.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ use syntax::codemap;
3535
use syntax::codemap::{Span, CodeMap, DUMMY_SP};
3636
use syntax::diagnostic::{Level, RenderSpan, Bug, Fatal, Error, Warning, Note, Help};
3737
use syntax::parse::token;
38-
use syntax::feature_gate::UnstableFeatures;
3938

4039
struct Env<'a, 'tcx: 'a> {
4140
infcx: &'a infer::InferCtxt<'a, 'tcx>,
@@ -103,7 +102,6 @@ fn test_env<F>(source_string: &str,
103102
let mut options =
104103
config::basic_options();
105104
options.debugging_opts.verbose = true;
106-
options.unstable_features = UnstableFeatures::Allow;
107105
let codemap =
108106
CodeMap::new();
109107
let diagnostic_handler =

branches/stable/src/librustc_lint/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2213,7 +2213,7 @@ pub struct UnstableFeatures;
22132213
declare_lint! {
22142214
UNSTABLE_FEATURES,
22152215
Allow,
2216-
"enabling unstable features (deprecated. do not use)"
2216+
"enabling unstable features"
22172217
}
22182218

22192219
impl LintPass for UnstableFeatures {

branches/stable/src/librustc_trans/back/link.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use util::sha2::{Digest, Sha256};
2929
use util::fs::fix_windows_verbatim_for_gcc;
3030
use rustc_back::tempdir::TempDir;
3131

32-
use std::env;
3332
use std::fs::{self, PathExt};
3433
use std::io::{self, Read, Write};
3534
use std::mem;
@@ -795,16 +794,7 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool,
795794

796795
// The invocations of cc share some flags across platforms
797796
let pname = get_cc_prog(sess);
798-
let mut cmd = Command::new(&pname);
799-
800-
// The compiler's sysroot often has some bundled tools, so add it to the
801-
// PATH for the child.
802-
let mut new_path = sess.host_filesearch(PathKind::All)
803-
.get_tools_search_paths();
804-
if let Some(path) = env::var_os("PATH") {
805-
new_path.extend(env::split_paths(&path));
806-
}
807-
cmd.env("PATH", env::join_paths(new_path).unwrap());
797+
let mut cmd = Command::new(&pname[..]);
808798

809799
let root = sess.target_filesearch(PathKind::Native).get_lib_path();
810800
cmd.args(&sess.target.target.options.pre_link_args);

branches/stable/src/librustc_typeck/astconv.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,10 @@ pub fn ast_path_substs_for_ty<'tcx>(
290290
ast::AngleBracketedParameters(ref data) => {
291291
convert_angle_bracketed_parameters(this, rscope, span, decl_generics, data)
292292
}
293-
ast::ParenthesizedParameters(..) => {
293+
ast::ParenthesizedParameters(ref data) => {
294294
span_err!(tcx.sess, span, E0214,
295-
"parenthesized parameters may only be used with a trait");
296-
let ty_param_defs = decl_generics.types.get_slice(TypeSpace);
297-
(Substs::empty(),
298-
ty_param_defs.iter().map(|_| tcx.types.err).collect(),
299-
vec![])
295+
"parenthesized parameters may only be used with a trait");
296+
convert_parenthesized_parameters(this, rscope, span, decl_generics, data)
300297
}
301298
};
302299

branches/stable/src/librustc_typeck/check/method/suggest.rs

Lines changed: 6 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ use CrateCtxt;
1515

1616
use astconv::AstConv;
1717
use check::{self, FnCtxt};
18-
use middle::ty::{self, Ty, ToPolyTraitRef, AsPredicate};
18+
use middle::ty::{self, Ty};
1919
use middle::def;
20-
use middle::lang_items::FnOnceTraitLangItem;
21-
use middle::subst::Substs;
22-
use middle::traits::{Obligation, SelectionContext};
2320
use metadata::{csearch, cstore, decoder};
2421

2522
use syntax::{ast, ast_util};
@@ -62,58 +59,12 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
6259
None);
6360

6461
// If the item has the name of a field, give a help note
65-
if let (&ty::TyStruct(did, substs), Some(expr)) = (&rcvr_ty.sty, rcvr_expr) {
62+
if let (&ty::TyStruct(did, _), Some(_)) = (&rcvr_ty.sty, rcvr_expr) {
6663
let fields = ty::lookup_struct_fields(cx, did);
67-
68-
if let Some(field) = fields.iter().find(|f| f.name == item_name) {
69-
let expr_string = match cx.sess.codemap().span_to_snippet(expr.span) {
70-
Ok(expr_string) => expr_string,
71-
_ => "s".into() // Default to a generic placeholder for the
72-
// expression when we can't generate a string
73-
// snippet
74-
};
75-
76-
let span_stored_function = || {
77-
cx.sess.span_note(span,
78-
&format!("use `({0}.{1})(...)` if you meant to call \
79-
the function stored in the `{1}` field",
80-
expr_string, item_name));
81-
};
82-
83-
let span_did_you_mean = || {
84-
cx.sess.span_note(span, &format!("did you mean to write `{0}.{1}`?",
85-
expr_string, item_name));
86-
};
87-
88-
// Determine if the field can be used as a function in some way
89-
let field_ty = ty::lookup_field_type(cx, did, field.id, substs);
90-
if let Ok(fn_once_trait_did) = cx.lang_items.require(FnOnceTraitLangItem) {
91-
let infcx = fcx.infcx();
92-
infcx.probe(|_| {
93-
let fn_once_substs = Substs::new_trait(vec![infcx.next_ty_var()],
94-
Vec::new(),
95-
field_ty);
96-
let trait_ref = ty::TraitRef::new(fn_once_trait_did,
97-
cx.mk_substs(fn_once_substs));
98-
let poly_trait_ref = trait_ref.to_poly_trait_ref();
99-
let obligation = Obligation::misc(span,
100-
fcx.body_id,
101-
poly_trait_ref.as_predicate());
102-
let mut selcx = SelectionContext::new(infcx, fcx);
103-
104-
if selcx.evaluate_obligation(&obligation) {
105-
span_stored_function();
106-
} else {
107-
span_did_you_mean();
108-
}
109-
});
110-
} else {
111-
match field_ty.sty {
112-
// fallback to matching a closure or function pointer
113-
ty::TyClosure(..) | ty::TyBareFn(..) => span_stored_function(),
114-
_ => span_did_you_mean(),
115-
}
116-
}
64+
if fields.iter().any(|f| f.name == item_name) {
65+
cx.sess.span_note(span,
66+
&format!("use `(s.{0})(...)` if you meant to call the \
67+
function stored in the `{0}` field", item_name));
11768
}
11869
}
11970

branches/stable/src/librustdoc/core.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ pub use self::MaybeTyped::*;
1212
use rustc_lint;
1313
use rustc_driver::driver;
1414
use rustc::session::{self, config};
15+
use rustc::session::config::UnstableFeatures;
1516
use rustc::middle::{privacy, ty};
1617
use rustc::ast_map;
1718
use rustc::lint;
1819
use rustc_trans::back::link;
1920
use rustc_resolve as resolve;
2021

2122
use syntax::{ast, codemap, diagnostic};
22-
use syntax::feature_gate::UnstableFeatures;
2323

2424
use std::cell::{RefCell, Cell};
2525
use std::collections::{HashMap, HashSet};
@@ -106,7 +106,7 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec<String>, externs: Externs,
106106
target_triple: triple.unwrap_or(config::host_triple().to_string()),
107107
cfg: config::parse_cfgspecs(cfgs),
108108
// Ensure that rustdoc works even if rustc is feature-staged
109-
unstable_features: UnstableFeatures::Allow,
109+
unstable_features: UnstableFeatures::Default,
110110
..config::basic_options().clone()
111111
};
112112

branches/stable/src/libstd/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ pub mod builtin {
331331

332332
/// A macro which expands to the line number on which it was invoked.
333333
///
334-
/// The expanded expression has type `u32`, and the returned line is not
334+
/// The expanded expression has type `usize`, and the returned line is not
335335
/// the invocation of the `line!()` macro itself, but rather the first macro
336336
/// invocation leading up to the invocation of the `line!()` macro.
337337
///
@@ -346,7 +346,7 @@ pub mod builtin {
346346

347347
/// A macro which expands to the column number on which it was invoked.
348348
///
349-
/// The expanded expression has type `u32`, and the returned column is not
349+
/// The expanded expression has type `usize`, and the returned column is not
350350
/// the invocation of the `column!()` macro itself, but rather the first macro
351351
/// invocation leading up to the invocation of the `column!()` macro.
352352
///

0 commit comments

Comments
 (0)