Skip to content

Commit b2d30b7

Browse files
committed
Removed @self and @trait.
1 parent c13a929 commit b2d30b7

File tree

122 files changed

+627
-1694
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+627
-1694
lines changed

src/doc/rust.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ to pointers to the trait name, used as a type.
13351335
# impl Shape for int { }
13361336
# let mycircle = 0;
13371337
1338-
let myshape: @Shape = @mycircle as @Shape;
1338+
let myshape: ~Shape = ~mycircle as ~Shape;
13391339
~~~~
13401340

13411341
The resulting value is a managed box containing the value that was cast,
@@ -1396,7 +1396,7 @@ Likewise, supertrait methods may also be called on trait objects.
13961396
# impl Circle for int { fn radius(&self) -> f64 { 0.0 } }
13971397
# let mycircle = 0;
13981398
1399-
let mycircle: Circle = @mycircle as @Circle;
1399+
let mycircle: Circle = ~mycircle as ~Circle;
14001400
let nonsense = mycircle.radius() * mycircle.area();
14011401
~~~~
14021402

@@ -3290,8 +3290,8 @@ Whereas most calls to trait methods are "early bound" (statically resolved) to s
32903290
a call to a method on an object type is only resolved to a vtable entry at compile time.
32913291
The actual implementation for each vtable entry can vary on an object-by-object basis.
32923292

3293-
Given a pointer-typed expression `E` of type `&T`, `~T` or `@T`, where `T` implements trait `R`,
3294-
casting `E` to the corresponding pointer type `&R`, `~R` or `@R` results in a value of the _object type_ `R`.
3293+
Given a pointer-typed expression `E` of type `&T` or `~T`, where `T` implements trait `R`,
3294+
casting `E` to the corresponding pointer type `&R` or `~R` results in a value of the _object type_ `R`.
32953295
This result is represented as a pair of pointers:
32963296
the vtable pointer for the `T` implementation of `R`, and the pointer value of `E`.
32973297

@@ -3306,12 +3306,12 @@ impl Printable for int {
33063306
fn to_string(&self) -> ~str { self.to_str() }
33073307
}
33083308
3309-
fn print(a: @Printable) {
3309+
fn print(a: ~Printable) {
33103310
println!("{}", a.to_string());
33113311
}
33123312
33133313
fn main() {
3314-
print(@10 as @Printable);
3314+
print(~10 as ~Printable);
33153315
}
33163316
~~~~
33173317

src/doc/tutorial.md

+10-17
Original file line numberDiff line numberDiff line change
@@ -1857,7 +1857,7 @@ like any other function, except for the name `self`.
18571857
18581858
The type of `self` is the type on which the method is implemented,
18591859
or a pointer thereof. As an argument it is written either `self`,
1860-
`&self`, `@self`, or `~self`.
1860+
`&self`, or `~self`.
18611861
A caller must in turn have a compatible pointer type to call the method.
18621862
18631863
~~~
@@ -1870,14 +1870,12 @@ A caller must in turn have a compatible pointer type to call the method.
18701870
# }
18711871
impl Shape {
18721872
fn draw_reference(&self) { ... }
1873-
fn draw_managed(@self) { ... }
18741873
fn draw_owned(~self) { ... }
18751874
fn draw_value(self) { ... }
18761875
}
18771876

18781877
let s = Circle(Point { x: 1.0, y: 2.0 }, 3.0);
18791878

1880-
(@s).draw_managed();
18811879
(~s).draw_owned();
18821880
(&s).draw_reference();
18831881
s.draw_value();
@@ -1897,7 +1895,6 @@ to a reference.
18971895
# }
18981896
# impl Shape {
18991897
# fn draw_reference(&self) { ... }
1900-
# fn draw_managed(@self) { ... }
19011898
# fn draw_owned(~self) { ... }
19021899
# fn draw_value(self) { ... }
19031900
# }
@@ -2368,29 +2365,29 @@ an _object_.
23682365
23692366
~~~~
23702367
# trait Drawable { fn draw(&self); }
2371-
fn draw_all(shapes: &[@Drawable]) {
2368+
fn draw_all(shapes: &[~Drawable]) {
23722369
for shape in shapes.iter() { shape.draw(); }
23732370
}
23742371
~~~~
23752372
2376-
In this example, there is no type parameter. Instead, the `@Drawable`
2377-
type denotes any managed box value that implements the `Drawable`
2378-
trait. To construct such a value, you use the `as` operator to cast a
2379-
value to an object:
2373+
In this example, there is no type parameter. Instead, the `~Drawable`
2374+
type denotes any owned box value that implements the `Drawable` trait.
2375+
To construct such a value, you use the `as` operator to cast a value
2376+
to an object:
23802377
23812378
~~~~
23822379
# type Circle = int; type Rectangle = bool;
23832380
# trait Drawable { fn draw(&self); }
23842381
# fn new_circle() -> Circle { 1 }
23852382
# fn new_rectangle() -> Rectangle { true }
2386-
# fn draw_all(shapes: &[@Drawable]) {}
2383+
# fn draw_all(shapes: &[~Drawable]) {}
23872384
23882385
impl Drawable for Circle { fn draw(&self) { ... } }
23892386
impl Drawable for Rectangle { fn draw(&self) { ... } }
23902387
2391-
let c: @Circle = @new_circle();
2392-
let r: @Rectangle = @new_rectangle();
2393-
draw_all([c as @Drawable, r as @Drawable]);
2388+
let c: ~Circle = ~new_circle();
2389+
let r: ~Rectangle = ~new_rectangle();
2390+
draw_all([c as ~Drawable, r as ~Drawable]);
23942391
~~~~
23952392
23962393
We omit the code for `new_circle` and `new_rectangle`; imagine that
@@ -2407,8 +2404,6 @@ for example, an `@Circle` may not be cast to an `~Drawable`.
24072404
# impl Drawable for int { fn draw(&self) {} }
24082405
# fn new_circle() -> int { 1 }
24092406
# fn new_rectangle() -> int { 2 }
2410-
// A managed object
2411-
let boxy: @Drawable = @new_circle() as @Drawable;
24122407
// An owned object
24132408
let owny: ~Drawable = ~new_circle() as ~Drawable;
24142409
// A borrowed object
@@ -2427,7 +2422,6 @@ particular set of built-in kinds that their contents must fulfill in
24272422
order to be packaged up in a trait object of that storage class.
24282423
24292424
* The contents of owned traits (`~Trait`) must fulfill the `Send` bound.
2430-
* The contents of managed traits (`@Trait`) must fulfill the `'static` bound.
24312425
* The contents of reference traits (`&Trait`) are not constrained by any bound.
24322426
24332427
Consequently, the trait objects themselves automatically fulfill their
@@ -2439,7 +2433,6 @@ to fulfilling `Send`, contents must also fulfill `Freeze`, and as a consequence,
24392433
the trait itself fulfills `Freeze`.
24402434
24412435
* `~Trait:Send` is equivalent to `~Trait`.
2442-
* `@Trait:'static` is equivalent to `@Trait`.
24432436
* `&Trait:` is equivalent to `&Trait`.
24442437
24452438
Builtin kind bounds can also be specified on closure types in the same way (for

src/librustc/driver/driver.rs

+30-41
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ use syntax::attr;
4242
use syntax::attr::{AttrMetaMethods};
4343
use syntax::codemap;
4444
use syntax::diagnostic;
45+
use syntax::diagnostic::Emitter;
4546
use syntax::ext::base::CrateLoader;
4647
use syntax::parse;
4748
use syntax::parse::token::InternedString;
@@ -136,10 +137,10 @@ pub fn build_configuration(sess: Session) ->
136137
}
137138

138139
// Convert strings provided as --cfg [cfgspec] into a crate_cfg
139-
fn parse_cfgspecs(cfgspecs: ~[~str], demitter: @diagnostic::Emitter)
140+
fn parse_cfgspecs(cfgspecs: ~[~str])
140141
-> ast::CrateConfig {
141142
cfgspecs.move_iter().map(|s| {
142-
let sess = parse::new_parse_sess(Some(demitter));
143+
let sess = parse::new_parse_sess();
143144
parse::parse_meta_from_source_str("cfgspec".to_str(), s, ~[], sess)
144145
}).collect::<ast::CrateConfig>()
145146
}
@@ -539,9 +540,7 @@ pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &Input,
539540
phase_6_link_output(sess, &trans, &outputs);
540541
}
541542

542-
struct IdentifiedAnnotation {
543-
contents: (),
544-
}
543+
struct IdentifiedAnnotation;
545544

546545
impl pprust::PpAnn for IdentifiedAnnotation {
547546
fn pre(&self, node: pprust::AnnNode) -> io::IoResult<()> {
@@ -619,18 +618,16 @@ pub fn pretty_print_input(sess: Session,
619618
620619
let annotation = match ppm {
621620
PpmIdentified | PpmExpandedIdentified => {
622-
@IdentifiedAnnotation {
623-
contents: (),
624-
} as @pprust::PpAnn
621+
~IdentifiedAnnotation as ~pprust::PpAnn
625622
}
626623
PpmTyped => {
627624
let ast_map = ast_map.expect("--pretty=typed missing ast_map");
628625
let analysis = phase_3_run_analysis_passes(sess, &crate, ast_map);
629-
@TypedAnnotation {
626+
~TypedAnnotation {
630627
analysis: analysis
631-
} as @pprust::PpAnn
628+
} as ~pprust::PpAnn:
632629
}
633-
_ => @pprust::NoAnn as @pprust::PpAnn,
630+
_ => ~pprust::NoAnn as ~pprust::PpAnn:,
634631
};
635632
636633
let src = &sess.codemap.get_filemap(source_name(input)).src;
@@ -682,17 +679,15 @@ static architecture_abis : &'static [(&'static str, abi::Architecture)] = &'stat
682679
683680
("mips", abi::Mips)];
684681
685-
pub fn build_target_config(sopts: @session::Options,
686-
demitter: @diagnostic::Emitter)
682+
pub fn build_target_config(sopts: @session::Options)
687683
-> @session::Config {
688684
let os = match get_os(sopts.target_triple) {
689685
Some(os) => os,
690-
None => early_error(demitter, "unknown operating system")
686+
None => early_error("unknown operating system")
691687
};
692688
let arch = match get_arch(sopts.target_triple) {
693689
Some(arch) => arch,
694-
None => early_error(demitter,
695-
"unknown architecture: " + sopts.target_triple)
690+
None => early_error("unknown architecture: " + sopts.target_triple)
696691
};
697692
let (int_type, uint_type) = match arch {
698693
abi::X86 => (ast::TyI32, ast::TyU32),
@@ -730,8 +725,7 @@ pub fn host_triple() -> ~str {
730725
}
731726
732727
pub fn build_session_options(binary: ~str,
733-
matches: &getopts::Matches,
734-
demitter: @diagnostic::Emitter)
728+
matches: &getopts::Matches)
735729
-> @session::Options {
736730
let crate_types = matches.opt_strs("crate-type").flat_map(|s| {
737731
s.split(',').map(|part| {
@@ -741,8 +735,7 @@ pub fn build_session_options(binary: ~str,
741735
"staticlib" => session::CrateTypeStaticlib,
742736
"dylib" => session::CrateTypeDylib,
743737
"bin" => session::CrateTypeExecutable,
744-
_ => early_error(demitter,
745-
format!("unknown crate type: `{}`", part))
738+
_ => early_error(format!("unknown crate type: `{}`", part))
746739
}
747740
}).collect()
748741
});
@@ -767,8 +760,8 @@ pub fn build_session_options(binary: ~str,
767760
let lint_name = lint_name.replace("-", "_");
768761
match lint_dict.find_equiv(&lint_name) {
769762
None => {
770-
early_error(demitter, format!("unknown {} flag: {}",
771-
level_name, lint_name));
763+
early_error(format!("unknown {} flag: {}",
764+
level_name, lint_name));
772765
}
773766
Some(lint) => {
774767
lint_opts.push((lint.lint, *level));
@@ -787,7 +780,7 @@ pub fn build_session_options(binary: ~str,
787780
if *name == *debug_flag { this_bit = bit; break; }
788781
}
789782
if this_bit == 0 {
790-
early_error(demitter, format!("unknown debug flag: {}", *debug_flag))
783+
early_error(format!("unknown debug flag: {}", *debug_flag))
791784
}
792785
debugging_opts |= this_bit;
793786
}
@@ -807,9 +800,7 @@ pub fn build_session_options(binary: ~str,
807800
"bc" => link::OutputTypeBitcode,
808801
"obj" => link::OutputTypeObject,
809802
"link" => link::OutputTypeExe,
810-
_ => early_error(demitter,
811-
format!("unknown emission type: `{}`",
812-
part))
803+
_ => early_error(format!("unknown emission type: `{}`", part))
813804
}
814805
}).collect()
815806
})
@@ -830,7 +821,7 @@ pub fn build_session_options(binary: ~str,
830821
No
831822
} else if matches.opt_present("O") {
832823
if matches.opt_present("opt-level") {
833-
early_error(demitter, "-O and --opt-level both provided");
824+
early_error("-O and --opt-level both provided");
834825
}
835826
Default
836827
} else if matches.opt_present("opt-level") {
@@ -840,7 +831,7 @@ pub fn build_session_options(binary: ~str,
840831
~"2" => Default,
841832
~"3" => Aggressive,
842833
_ => {
843-
early_error(demitter, "optimization level needs to be between 0-3")
834+
early_error("optimization level needs to be between 0-3")
844835
}
845836
}
846837
} else { No }
@@ -865,7 +856,7 @@ pub fn build_session_options(binary: ~str,
865856
}).collect()
866857
});
867858

868-
let cfg = parse_cfgspecs(matches.opt_strs("cfg"), demitter);
859+
let cfg = parse_cfgspecs(matches.opt_strs("cfg"));
869860
let test = matches.opt_present("test");
870861
let android_cross_path = matches.opt_str("android-cross-path");
871862
let write_dependency_info = (matches.opt_present("dep-info"),
@@ -926,25 +917,23 @@ pub fn build_session_options(binary: ~str,
926917
}
927918

928919
pub fn build_session(sopts: @session::Options,
929-
local_crate_source_file: Option<Path>,
930-
demitter: @diagnostic::Emitter)
920+
local_crate_source_file: Option<Path>)
931921
-> Session {
932922
let codemap = @codemap::CodeMap::new();
933923
let diagnostic_handler =
934-
diagnostic::mk_handler(Some(demitter));
924+
diagnostic::mk_handler();
935925
let span_diagnostic_handler =
936926
diagnostic::mk_span_handler(diagnostic_handler, codemap);
937927

938-
build_session_(sopts, local_crate_source_file, codemap, demitter, span_diagnostic_handler)
928+
build_session_(sopts, local_crate_source_file, codemap, span_diagnostic_handler)
939929
}
940930

941931
pub fn build_session_(sopts: @session::Options,
942932
local_crate_source_file: Option<Path>,
943933
codemap: @codemap::CodeMap,
944-
demitter: @diagnostic::Emitter,
945934
span_diagnostic_handler: @diagnostic::SpanHandler)
946935
-> Session {
947-
let target_cfg = build_target_config(sopts, demitter);
936+
let target_cfg = build_target_config(sopts);
948937
let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler, codemap);
949938
let cstore = @CStore::new(token::get_ident_interner());
950939
let filesearch = @filesearch::FileSearch::new(
@@ -1167,8 +1156,8 @@ pub fn build_output_filenames(input: &Input,
11671156
}
11681157
}
11691158

1170-
pub fn early_error(emitter: &diagnostic::Emitter, msg: &str) -> ! {
1171-
emitter.emit(None, msg, diagnostic::Fatal);
1159+
pub fn early_error(msg: &str) -> ! {
1160+
diagnostic::DefaultEmitter.emit(None, msg, diagnostic::Fatal);
11721161
fail!(diagnostic::FatalError);
11731162
}
11741163

@@ -1198,8 +1187,8 @@ mod test {
11981187
Ok(m) => m,
11991188
Err(f) => fail!("test_switch_implies_cfg_test: {}", f.to_err_msg())
12001189
};
1201-
let sessopts = build_session_options(~"rustc", matches, @diagnostic::DefaultEmitter);
1202-
let sess = build_session(sessopts, None, @diagnostic::DefaultEmitter);
1190+
let sessopts = build_session_options(~"rustc", matches);
1191+
let sess = build_session(sessopts, None);
12031192
let cfg = build_configuration(sess);
12041193
assert!((attr::contains_name(cfg, "test")));
12051194
}
@@ -1216,8 +1205,8 @@ mod test {
12161205
f.to_err_msg());
12171206
}
12181207
};
1219-
let sessopts = build_session_options(~"rustc", matches, @diagnostic::DefaultEmitter);
1220-
let sess = build_session(sessopts, None, @diagnostic::DefaultEmitter);
1208+
let sessopts = build_session_options(~"rustc", matches);
1209+
let sess = build_session(sessopts, None);
12211210
let cfg = build_configuration(sess);
12221211
let mut test_items = cfg.iter().filter(|m| m.name().equiv(&("test")));
12231212
assert!(test_items.next().is_some());

0 commit comments

Comments
 (0)