Skip to content

Commit 727e689

Browse files
committed
---
yaml --- r: 227699 b: refs/heads/try c: 6bff14f h: refs/heads/master i: 227697: 1c859cf 227695: d4c08cf v: v3
1 parent ba92801 commit 727e689

File tree

24 files changed

+298
-96
lines changed

24 files changed

+298
-96
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: aca2057ed5fb7af3f8905b2bc01f72fa001c35c8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: a6cc4dd308213390a53a53101424ca4ef2e351ab
4+
refs/heads/try: 6bff14ffea5a3ca3f3b439b011954b521eb21a09
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/README.md

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

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.
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.
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+
1012
## Quick Start
1113

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

branches/try/src/libcore/ptr.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,11 @@ 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
515520
_marker: PhantomData<T>,
516521
}
517522

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

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ 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;
3231
use lint::{Level, LevelSource, Lint, LintId, LintArray, LintPass, LintPassObject};
33-
use lint::{Default, CommandLine, Node, Allow, Warn, Deny, Forbid, ReleaseChannel};
32+
use lint::{Default, CommandLine, Node, Allow, Warn, Deny, Forbid};
3433
use lint::builtin;
3534
use util::nodemap::FnvHashMap;
3635

@@ -208,23 +207,6 @@ impl LintStore {
208207
}
209208
}
210209
}
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-
}
228210
}
229211

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

309291
let name = lint.name_lower();
310292
let mut def = None;
311-
let mut note = None;
312293
let msg = match source {
313294
Default => {
314295
format!("{}, #[{}({})] on by default", msg,
@@ -325,12 +306,6 @@ pub fn raw_emit_lint(sess: &Session, lint: &'static Lint,
325306
def = Some(src);
326307
msg.to_string()
327308
}
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-
}
334309
};
335310

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

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

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-
695663
let krate = tcx.map.krate();
696664
let mut cx = Context::new(tcx, krate, exported_items);
697665

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,6 @@ 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
253250
}
254251

255252
pub type LevelSource = (Level, LintSource);

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

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ 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;
3536

3637
use getopts;
3738
use std::collections::HashMap;
@@ -119,21 +120,6 @@ pub struct Options {
119120
pub unstable_features: UnstableFeatures
120121
}
121122

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-
137123
#[derive(Clone, PartialEq, Eq)]
138124
pub enum PrintRequest {
139125
FileNames,
@@ -1074,7 +1060,7 @@ pub fn get_unstable_features_setting() -> UnstableFeatures {
10741060
match (disable_unstable_features, bootstrap_secret_key, bootstrap_provided_key) {
10751061
(_, Some(ref s), Some(ref p)) if s == p => UnstableFeatures::Cheat,
10761062
(true, _, _) => UnstableFeatures::Disallow,
1077-
(false, _, _) => UnstableFeatures::Default
1063+
(false, _, _) => UnstableFeatures::Allow
10781064
}
10791065
}
10801066

branches/try/src/librustc_driver/driver.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,8 @@ 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);
531+
&krate, &attributes,
532+
sess.opts.unstable_features);
532533
*sess.features.borrow_mut() = features;
533534
sess.abort_if_errors();
534535
});
@@ -558,7 +559,8 @@ pub fn phase_2_configure_and_expand(sess: &Session,
558559
let features =
559560
syntax::feature_gate::check_crate(sess.codemap(),
560561
&sess.parse_sess.span_diagnostic,
561-
&krate, &attributes);
562+
&krate, &attributes,
563+
sess.opts.unstable_features);
562564
*sess.features.borrow_mut() = features;
563565
sess.abort_if_errors();
564566
});
@@ -778,18 +780,11 @@ pub fn phase_5_run_llvm_passes(sess: &Session,
778780
pub fn phase_6_link_output(sess: &Session,
779781
trans: &trans::CrateTranslation,
780782
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-
786783
time(sess.time_passes(), "linking", (), |_|
787784
link::link_binary(sess,
788785
trans,
789786
outputs,
790787
&trans.link.crate_name));
791-
792-
env::set_var("PATH", &old_path);
793788
}
794789

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

branches/try/src/librustc_driver/test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ 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;
3839

3940
struct Env<'a, 'tcx: 'a> {
4041
infcx: &'a infer::InferCtxt<'a, 'tcx>,
@@ -102,6 +103,7 @@ fn test_env<F>(source_string: &str,
102103
let mut options =
103104
config::basic_options();
104105
options.debugging_opts.verbose = true;
106+
options.unstable_features = UnstableFeatures::Allow;
105107
let codemap =
106108
CodeMap::new();
107109
let diagnostic_handler =

branches/try/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"
2216+
"enabling unstable features (deprecated. do not use)"
22172217
}
22182218

22192219
impl LintPass for UnstableFeatures {

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ 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;
3233
use std::fs::{self, PathExt};
3334
use std::io::{self, Read, Write};
3435
use std::mem;
@@ -794,7 +795,16 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool,
794795

795796
// The invocations of cc share some flags across platforms
796797
let pname = get_cc_prog(sess);
797-
let mut cmd = Command::new(&pname[..]);
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());
798808

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

branches/try/src/librustc_typeck/astconv.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,13 @@ 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(ref data) => {
293+
ast::ParenthesizedParameters(..) => {
294294
span_err!(tcx.sess, span, E0214,
295-
"parenthesized parameters may only be used with a trait");
296-
convert_parenthesized_parameters(this, rscope, span, decl_generics, data)
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![])
297300
}
298301
};
299302

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

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

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

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

6164
// If the item has the name of a field, give a help note
62-
if let (&ty::TyStruct(did, _), Some(_)) = (&rcvr_ty.sty, rcvr_expr) {
65+
if let (&ty::TyStruct(did, substs), Some(expr)) = (&rcvr_ty.sty, rcvr_expr) {
6366
let fields = ty::lookup_struct_fields(cx, did);
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));
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+
}
68117
}
69118
}
70119

branches/try/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;
1615
use rustc::middle::{privacy, ty};
1716
use rustc::ast_map;
1817
use rustc::lint;
1918
use rustc_trans::back::link;
2019
use rustc_resolve as resolve;
2120

2221
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::Default,
109+
unstable_features: UnstableFeatures::Allow,
110110
..config::basic_options().clone()
111111
};
112112

branches/try/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 `usize`, and the returned line is not
334+
/// The expanded expression has type `u32`, 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 `usize`, and the returned column is not
349+
/// The expanded expression has type `u32`, 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)