jiebi/CodeConvo huggingface dataset:
tcx.sess.bug(&format!("using operand temp {:?} as lvalue", lvalue)), }, mir::Lvalue::Arg(index) => self.args[index as usize], <del> mir::Lvalue::Static(_def_id) => unimplemented!(), </del> <ins> mir::Lvalue::Static(def_id) => { let const_ty = self.mir.lvalue_ty(tcx, lvalue); LvalueRef::new(common::get_static_val(ccx, def_id, const_ty.to_ty(tcx)), const_ty) }, </ins> mir::Lvalue::ReturnPointer => { let return_ty = bcx.monomorphize(&self.mir.return_ty); let llval = fcx.get_ret_slot(bcx, return_ty, "return");
[rust]: https://www.rust-lang.org <del> “The Rust Programming Language” is split into eight sections. This introduction </del> <ins> “The Rust Programming Language” is split into sections. This introduction </ins> is the first. After this: * [Getting started][gs] - Set up your computer for Rust development. <del> * [Learn Rust][lr] - Learn Rust programming through small projects. * [Effective Rust][er] - Higher-level concepts for writing excellent Rust code. </del> <ins> * [Tutorial: Guessing Game][gg] - Learn some Rust with a small project. </ins> * [Syntax and Semantics][ss] - Each bit of Rust, broken down into small chunks. <ins> * [Effective Rust][er] - Higher-level concepts for writing excellent Rust code. </ins> * [Nightly Rust][nr] - Cutting-edge features that aren’t in stable builds yet. * [Glossary][gl] - A reference of terms used in the book. * [Bibliography][bi] - Background on Rust's influences, papers about Rust. [gs]: getting-started.html <del> [lr]: learn-rust.html </del> <ins> [gg]: guessing-game.html </ins> [er]: effective-rust.html [ss]: syntax-and-semantics.html [nr]: nightly-rust.html [gl]: glossary.html [bi]: bibliography.html <del> After reading this introduction, you’ll want to dive into either ‘Learn Rust’ or ‘Syntax and Semantics’, depending on your preference: ‘Learn Rust’ if you want to dive in with a project, or ‘Syntax and Semantics’ if you prefer to start small, and learn a single concept thoroughly before moving onto the next. Copious cross-linking connects these parts together. </del> ### Contributing The source files from which this book is generated can be found on
# Summary * [Getting Started](getting-started.md) <del> * [Learn Rust](learn-rust.md) * [Guessing Game](guessing-game.md) * [Dining Philosophers](dining-philosophers.md) * [Rust Inside Other Languages](rust-inside-other-languages.md) </del> <ins> * [Tutorial: Guessing Game](guessing-game.md) </ins> * [Syntax and Semantics](syntax-and-semantics.md) * [Variable Bindings](variable-bindings.md) * [Functions](functions.md)
% Guessing Game <del> For our first project, we’ll implement a classic beginner programming problem: the guessing game. Here’s how it works: Our program will generate a random integer between one and a hundred. It will then prompt us to enter a guess. Upon entering our guess, it will tell us if we’re too low or too high. Once we guess correctly, it will congratulate us. Sounds good? </del> <ins> Let’s learn some Rust! For our first project, we’ll implement a classic beginner programming problem: the guessing game. Here’s how it works: Our program will generate a random integer between one and a hundred. It will then prompt us to enter a guess. Upon entering our guess, it will tell us if we’re too low or too high. Once we guess correctly, it will congratulate us. Sounds good? Along the way, we’ll learn a little bit about Rust. The next section, ‘Syntax and Semantics’, will dive deeper into each part. </ins> # Set up
let a = Ipv4Addr::new(127, 0, 0, 1); assert_eq!(Ipv4Addr::from(2130706433), a); } <ins> #[test] fn ord() { assert!(Ipv4Addr::new(100, 64, 3, 3) < Ipv4Addr::new(192, 0, 2, 2)); assert!("2001:db8:f00::1002".parse::<Ipv6Addr>().unwrap() < "2001:db8:f00::2001".parse::<Ipv6Addr>().unwrap()); } </ins> }
<ins> // Regression test for #29988 // compile-flags: -C no-prepopulate-passes // only-x86_64 // ignore-windows #[repr(C)] struct S { f1: i32, f2: i32, f3: i32, } extern { fn foo(s: S); } fn main() { let s = S { f1: 1, f2: 2, f3: 3 }; unsafe { // CHECK: load { i64, i32 }, { i64, i32 }* {{.*}}, align 4 // CHECK: call void @foo({ i64, i32 } {{.*}}) foo(s); } } </ins>
<ins> error[E0308]: mismatched types --> $DIR/issue-67945-1.rs:3:20 | LL | enum Bug<S> { |          - this type parameter LL |     Var = { LL |         let x: S = 0; |                -   ^ expected type parameter `S`, found integer |                | |                expected due to this | = note: expected type parameter `S` found type `{integer}` error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. </ins>
<ins> error[E0308]: mismatched types --> $DIR/issue-67945-2.rs:4:11 | LL | enum Bug<S> { |          - this type parameter LL |     Var = 0: S, |           ^ expected type parameter `S`, found integer | = note: expected type parameter `S` found type `{integer}` error[E0308]: mismatched types --> $DIR/issue-67945-2.rs:4:11 | LL | enum Bug<S> { |          - this type parameter LL |     Var = 0: S, |           ^^^^ expected `isize`, found type parameter `S` | = note:        expected type `isize` found type parameter `S` error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. </ins>
<ins> error[E0283]: type annotations needed --> $DIR/issue-34979.rs:6:13 | LL | trait Foo {} | --------- required by this bound in `Foo` ... LL |     &'a (): Foo, |             ^^^ cannot infer type for reference `&'a ()` | = note: cannot satisfy `&'a (): Foo` error: aborting due to previous error For more information about this error, try `rustc --explain E0283`. </ins>
fn consume(&mut self, amt: usize) { self.pos += amt as u64; } } <ins> // Non-resizing write implementation fn slice_write(pos_mut: &mut u64, slice: &mut [u8], buf: &[u8]) -> io::Result<usize> { let pos = cmp::min(*pos_mut, slice.len() as u64); let amt = (&mut slice[(pos as usize)..]).write(buf)?; *pos_mut += amt as u64; Ok(amt) } // Resizing write implementation fn vec_write(pos_mut: &mut u64, vec: &mut Vec<u8>, buf: &[u8]) -> io::Result<usize> { let pos: usize = (*pos_mut).try_into().map_err(|_| { Error::new(ErrorKind::InvalidInput, "cursor position exceeds maximum possible vector length") })?; // Make sure the internal buffer is as least as big as where we // currently are let len = vec.len(); if len < pos { // use `resize` so that the zero filling is as efficient as possible vec.resize(pos, 0); } // Figure out what bytes will be used to overwrite what's currently // there (left), and what will be appended on the end (right) { let space = vec.len() - pos; let (left, right) = buf.split_at(cmp::min(space, buf.len())); vec[pos..pos + left.len()].copy_from_slice(left); vec.extend_from_slice(right); } // Bump us forward *pos_mut = (pos + buf.len()) as u64; Ok(buf.len()) } </ins> #[stable(feature = "rust1", since = "1.0.0")] impl<'a> Write for Cursor<&'a mut [u8]> { #[inline] <del> fn write(&mut self, data: &[u8]) -> io::Result<usize> { let pos = cmp::min(self.pos, self.inner.len() as u64); let amt = (&mut self.inner[(pos as usize)..]).write(data)?; self.pos += amt as u64; Ok(amt) </del> <ins> fn write(&mut self, buf: &[u8]) -> io::Result<usize> { slice_write(&mut self.pos, self.inner, buf) } fn flush(&mut self) -> io::Result<()> { Ok(()) } } #[unstable(feature = "cursor_mut_vec", issue = "30132")] impl<'a> Write for Cursor<&'a mut Vec<u8>> { fn write(&mut self, buf: &[u8]) -> io::Result<usize> { vec_write(&mut self.pos, self.inner, buf) </ins> } fn flush(&mut self) -> io::Result<()> { Ok(()) } }
#[stable(feature = "rust1", since = "1.0.0")] impl Write for Cursor<Vec<u8>> { fn write(&mut self, buf: &[u8]) -> io::Result<usize> { <del> let pos: usize = self.position().try_into().map_err(|_| { Error::new(ErrorKind::InvalidInput, "cursor position exceeds maximum possible vector length") })?; // Make sure the internal buffer is as least as big as where we // currently are let len = self.inner.len(); if len < pos { // use `resize` so that the zero filling is as efficient as possible self.inner.resize(pos, 0); } // Figure out what bytes will be used to overwrite what's currently // there (left), and what will be appended on the end (right) { let space = self.inner.len() - pos; let (left, right) = buf.split_at(cmp::min(space, buf.len())); self.inner[pos..pos + left.len()].copy_from_slice(left); self.inner.extend_from_slice(right); } // Bump us forward self.set_position((pos + buf.len()) as u64); Ok(buf.len()) </del> <ins> vec_write(&mut self.pos, &mut self.inner, buf) </ins> } fn flush(&mut self) -> io::Result<()> { Ok(()) } }
impl Write for Cursor<Box<[u8]>> { #[inline] fn write(&mut self, buf: &[u8]) -> io::Result<usize> { <del> let pos = cmp::min(self.pos, self.inner.len() as u64); let amt = (&mut self.inner[(pos as usize)..]).write(buf)?; self.pos += amt as u64; Ok(amt) </del> <ins> slice_write(&mut self.pos, &mut self.inner, buf) </ins> } fn flush(&mut self) -> io::Result<()> { Ok(()) } }
} #[test] <ins> fn test_mem_mut_writer() { let mut vec = Vec::new(); let mut writer = Cursor::new(&mut vec); assert_eq!(writer.write(&[0]).unwrap(), 1); assert_eq!(writer.write(&[1, 2, 3]).unwrap(), 3); assert_eq!(writer.write(&[4, 5, 6, 7]).unwrap(), 4); let b: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7]; assert_eq!(&writer.get_ref()[..], b); } #[test] </ins> fn test_box_slice_writer() { let mut writer = Cursor::new(vec![0u8; 9].into_boxed_slice()); assert_eq!(writer.position(), 0);
`unused_attributes`, and `dead_code`. Small examples often trigger these lints. 3. If the example does not contain `extern crate`, then `extern crate <del> <mycrate>;` is inserted. 2. Finally, if the example does not contain `fn main`, the remainder of the text is wrapped in `fn main() { your_code }` Sometimes, this isn't enough, though. For example, all of these code samples </del> <ins> <mycrate>;` is inserted (note the lack of `#[macro_use]`). 4. Finally, if the example does not contain `fn main`, the remainder of the text is wrapped in `fn main() { your_code }`. This generated `fn main` can be a problem! If you have `extern crate` or a `mod` statements in the example code that are referred to by `use` statements, they will fail to resolve unless you include at least `fn main() {}` to inhibit step 4. `#[macro_use] extern crate` also does not work except at the crate root, so when testing macros an explicit `main` is always required. It doesn't have to clutter up your docs, though -- keep reading! Sometimes this algorithm isn't enough, though. For example, all of these code samples </ins> with `///` we've been talking about? The raw text: ```text
You’ll note three things: we need to add our own `extern crate` line, so that we can add the `#[macro_use]` attribute. Second, we’ll need to add our own <del> `main()` as well. Finally, a judicious use of `#` to comment out those two things, so they don’t show up in the output. </del> <ins> `main()` as well (for reasons discussed above). Finally, a judicious use of `#` to comment out those two things, so they don’t show up in the output. </ins> Another case where the use of `#` is handy is when you want to ignore error handling. Lets say you want the following,
// the merge has confused the heck out of josh in the past. // We pass `--no-verify` to avoid running git hooks like `./miri fmt` that could in turn // trigger auto-actions. <del> sh.write_file("rust-version", &commit)?; </del> <ins> sh.write_file("rust-version", format!("{commit}n"))?; </ins> const PREPARING_COMMIT_MESSAGE: &str = "Preparing for merge from rustc"; cmd!(sh, "git commit rust-version --no-verify -m {PREPARING_COMMIT_MESSAGE}") .run()
// interleaving, but wether UB happens can depend on whether a write occurs in the // future... let is_write = new_perm.initial_state.is_active() <del> || (new_perm.initial_state.is_resrved() && new_perm.protector.is_some()); </del> <ins> || (new_perm.initial_state.is_reserved() && new_perm.protector.is_some()); </ins> if is_write { // Need to get mutable access to alloc_extra. // (Cannot always do this as we can do read-only reborrowing on read-only allocations.)
/// in an existing allocation, then returns Err containing the position /// where such allocation should be inserted fn find_offset(&self, offset: Size) -> Result<Position, Position> { <del> // We do a binary search. let mut left = 0usize; // inclusive let mut right = self.v.len(); // exclusive loop { if left == right { // No element contains the given offset. But the // position is where such element should be placed at. return Err(left); } let candidate = left.checked_add(right).unwrap() / 2; let elem = &self.v[candidate]; </del> <ins> self.v.binary_search_by(|elem| -> std::cmp::Ordering { </ins> if offset < elem.range.start { // We are too far right (offset is further left). <del> debug_assert!(candidate < right); // we are making progress right = candidate; </del> <ins> std::cmp::Ordering::Greater </ins> } else if offset >= elem.range.end() { // We are too far left (offset is further right). <del> debug_assert!(candidate >= left); // we are making progress left = candidate + 1; </del> <ins> std::cmp::Ordering::Less </ins> } else { // This is it! <del> return Ok(candidate); </del> <ins> std::cmp::Ordering::Equal </ins> } <del> } </del> <ins> }) </ins> } /// Determines whether a given access on `range` overlaps with
} ``` <ins> Your structure can still contain `&mut` pointers, which will let you do some kinds of mutation: ```rust struct Point { x: i32, y: i32, } struct PointRef<'a> { x: &'a mut i32, y: &'a mut i32, } fn main() { let mut point = Point { x: 0, y: 0 }; { let r = PointRef { x: &mut point.x, y: &mut point.y }; *r.x = 5; *r.y = 6; } assert_eq!(5, point.x); assert_eq!(6, point.y); } ``` </ins> # Update syntax A `struct` can include `..` to indicate that you want to use a copy of some
self } <ins> /// Configuration for the child process’s standard input (stdin) handle. /// /// See [`std::process::Command::stdin`]. pub fn stdin<T: Into<::std::process::Stdio>>(&mut self, cfg: T) -> &mut Self { self.cmd.stdin(cfg); self } /// Configuration for the child process’s standard output (stdout) handle. /// /// See [`std::process::Command::stdout`]. pub fn stdout<T: Into<::std::process::Stdio>>(&mut self, cfg: T) -> &mut Self { self.cmd.stdout(cfg); self } /// Configuration for the child process’s standard error (stderr) handle. /// /// See [`std::process::Command::stderr`]. pub fn stderr<T: Into<::std::process::Stdio>>(&mut self, cfg: T) -> &mut Self { self.cmd.stderr(cfg); self } </ins> /// Inspect what the underlying [`Command`] is up to the /// current construction. pub fn inspect<I>(&mut self, inspector: I) -> &mut Self
run-make/branch-protection-check-IBT/Makefile run-make/cat-and-grep-sanity-check/Makefile <del> run-make/emit-to-stdout/Makefile </del> run-make/extern-fn-reachable/Makefile run-make/incr-add-rust-src-component/Makefile run-make/issue-84395-lto-embed-bitcode/Makefile
ui/consts/issue-73976-monomorphic.rs ui/consts/issue-73976-polymorphic.rs ui/consts/issue-76064.rs <del> ui/consts/issue-77062-large-zst-array.rs </del> ui/consts/issue-78655.rs ui/consts/issue-79137-monomorphic.rs ui/consts/issue-79137-toogeneric.rs
<del> include ../tools.mk SRC=test.rs OUT=$(TMPDIR)/out all: asm llvm-ir dep-info mir llvm-bc obj metadata link multiple-types multiple-types-option-o asm: $(OUT) $(RUSTC) --emit asm=$(OUT)/$@ $(SRC) $(RUSTC) --emit asm=- $(SRC) | diff - $(OUT)/$@ llvm-ir: $(OUT) $(RUSTC) --emit llvm-ir=$(OUT)/$@ $(SRC) $(RUSTC) --emit llvm-ir=- $(SRC) | diff - $(OUT)/$@ dep-info: $(OUT) $(RUSTC) -Z dep-info-omit-d-target=yes --emit dep-info=$(OUT)/$@ $(SRC) $(RUSTC) --emit dep-info=- $(SRC) | diff - $(OUT)/$@ mir: $(OUT) $(RUSTC) --emit mir=$(OUT)/$@ $(SRC) $(RUSTC) --emit mir=- $(SRC) | diff - $(OUT)/$@ llvm-bc: $(OUT) $(RUSTC) --emit llvm-bc=- $(SRC) 1>/dev/ptmx 2>$(OUT)/$@ || true diff $(OUT)/$@ emit-llvm-bc.stderr obj: $(OUT) $(RUSTC) --emit obj=- $(SRC) 1>/dev/ptmx 2>$(OUT)/$@ || true diff $(OUT)/$@ emit-obj.stderr # For metadata output, a temporary directory will be created to hold the temporary # metadata file. But when output is stdout, the temporary directory will be located # in the same place as $(SRC), which is mounted as read-only in the tests. Thus as # a workaround, $(SRC) is copied to the test output directory $(OUT) and we compile # it there. metadata: $(OUT) cp $(SRC) $(OUT) (cd $(OUT); $(RUSTC) --emit metadata=- $(SRC) 1>/dev/ptmx 2>$(OUT)/$@ || true) diff $(OUT)/$@ emit-metadata.stderr link: $(OUT) $(RUSTC) --emit link=- $(SRC) 1>/dev/ptmx 2>$(OUT)/$@ || true diff $(OUT)/$@ emit-link.stderr multiple-types: $(OUT) $(RUSTC) --emit asm=- --emit llvm-ir=- --emit dep-info=- --emit mir=- $(SRC) 2>$(OUT)/$@ || true diff $(OUT)/$@ emit-multiple-types.stderr multiple-types-option-o: $(OUT) $(RUSTC) -o - --emit asm,llvm-ir,dep-info,mir $(SRC) 2>$(OUT)/$@ || true diff $(OUT)/$@ emit-multiple-types.stderr $(OUT): mkdir -p $(OUT) </del>
<ins> //! If `-o -` or `--emit KIND=-` is provided, output should be written to stdout //! instead. Binary output (`obj`, `llvm-bc`, `link` and `metadata`) //! being written this way will result in an error if stdout is a tty. //! Multiple output types going to stdout will trigger an error too, //! as they would all be mixed together. //! //! See <https://github.com/rust-lang/rust/pull/111626>. use std::fs::File; use run_make_support::{diff, run_in_tmpdir, rustc}; // Test emitting text outputs to stdout works correctly fn run_diff(name: &str, file_args: &[&str]) { rustc().emit(format!("{name}={name}")).input("test.rs").args(file_args).run(); let out = rustc().emit(format!("{name}=-")).input("test.rs").run().stdout_utf8(); diff().expected_file(name).actual_text("stdout", &out).run(); } // Test that emitting binary formats to a terminal gives the correct error fn run_terminal_err_diff(name: &str) { #[cfg(not(windows))] let terminal = File::create("/dev/ptmx").unwrap(); // FIXME: If this test fails and the compiler does print to the console, // then this will produce a lot of output. // We should spawn a new console instead to print stdout. #[cfg(windows)] let terminal = File::options().read(true).write(true).open(r".CONOUT$").unwrap(); let err = File::create(name).unwrap(); rustc().emit(format!("{name}=-")).input("test.rs").stdout(terminal).stderr(err).run_fail(); diff().expected_file(format!("emit-{name}.stderr")).actual_file(name).run(); } fn main() { run_in_tmpdir(|| { run_diff("asm", &[]); run_diff("llvm-ir", &[]); run_diff("dep-info", &["-Zdep-info-omit-d-target=yes"]); run_diff("mir", &[]); run_terminal_err_diff("llvm-bc"); run_terminal_err_diff("obj"); run_terminal_err_diff("metadata"); run_terminal_err_diff("link"); // Test error for emitting multiple types to stdout rustc() .input("test.rs") .emit("asm=-") .emit("llvm-ir=-") .emit("dep-info=-") .emit("mir=-") .stderr(File::create("multiple-types").unwrap()) .run_fail(); diff().expected_file("emit-multiple-types.stderr").actual_file("multiple-types").run(); // Same as above, but using `-o` rustc() .input("test.rs") .output("-") .emit("asm,llvm-ir,dep-info,mir") .stderr(File::create("multiple-types-option-o").unwrap()) .run_fail(); diff() .expected_file("emit-multiple-types.stderr") .actual_file("multiple-types-option-o") .run(); // Test that `-o -` redirected to a file works correctly (#26719) rustc().input("test.rs").output("-").stdout(File::create("out-stdout").unwrap()).run(); }); } </ins>
<ins> //@ check-pass //! Tests that associated type projections normalize properly in the presence of HRTBs. //! Original issue: <https://github.com/rust-lang/rust/issues/30472> pub trait MyFrom<T> {} impl<T> MyFrom<T> for T {} pub trait MyInto<T> {} impl<T, U> MyInto<U> for T where U: MyFrom<T> {} pub trait A<'self_> { type T; } pub trait B: for<'self_> A<'self_> { // Originally caused the `type U = usize` example below to fail with a type mismatch error type U: for<'self_> MyFrom<<Self as A<'self_>>::T>; } pub struct M; impl<'self_> A<'self_> for M { type T = usize; } impl B for M { type U = usize; } fn main() {} </ins>
<ins> //@ check-pass //! Tests that a HRTB + FnOnce bound involving an associated type don't prevent //! a function pointer from implementing `Fn` traits. //! Test for <https://github.com/rust-lang/rust/issues/28994> trait LifetimeToType<'a> { type Out; } impl<'a> LifetimeToType<'a> for () { type Out = &'a (); } fn id<'a>(val: &'a ()) -> <() as LifetimeToType<'a>>::Out { val } fn assert_fn<F: for<'a> FnOnce(&'a ()) -> <() as LifetimeToType<'a>>::Out>(_func: F) { } fn main() { assert_fn(id); } </ins>
<ins> //@ check-pass //! Tests that HRTB impl selection covers type parameters not directly related //! to the trait. //! Test for <https://github.com/rust-lang/rust/issues/30867> #![crate_type = "lib"] trait Unary<T> {} impl<T, U, F: Fn(T) -> U> Unary<T> for F {} fn unary<F: for<'a> Unary<&'a T>, T>() {} pub fn test<F: for<'a> Fn(&'a i32) -> &'a i32>() { unary::<F, i32>() } </ins>
// These items live in the type namespace. ItemTy(..) => { <del> let parent_link = ModuleParentLink(parent, name); </del> let def = Def::TyAlias(self.ast_map.local_def_id(item.id)); <del> let module = self.new_module(parent_link, Some(def), false, is_public); self.define(parent, name, TypeNS, (module, sp)); </del> <ins> self.define(parent, name, TypeNS, (def, sp, modifiers)); </ins> parent }
} match def { <del> Def::Mod(_) | Def::ForeignMod(_) | Def::Enum(..) | Def::TyAlias(..) => { </del> <ins> Def::Mod(_) | Def::ForeignMod(_) | Def::Enum(..) => { </ins> debug!("(building reduced graph for external crate) building module {} {}", final_ident, is_public);
let module = self.new_module(parent_link, Some(def), true, is_public); self.try_define(new_parent, name, TypeNS, (module, DUMMY_SP)); } <del> Def::AssociatedTy(..) => { </del> <ins> Def::TyAlias(..) | Def::AssociatedTy(..) => { </ins> debug!("(building reduced graph for external crate) building type {}", final_ident); self.try_define(new_parent, name, TypeNS, (def, DUMMY_SP, modifiers));
target_module: Module<'b>, directive: &'b ImportDirective) -> ResolveResult<()> { <ins> if let Some(Def::Trait(_)) = target_module.def { self.resolver.session.span_err(directive.span, "items in traits are not importable."); } </ins> if module_.def_id() == target_module.def_id() { // This means we are trying to glob import a module into itself, and it is a no-go let msg = "Cannot glob-import a module into itself.".into();
<ins> // Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. type Alias = (); use Alias::*; //~ ERROR Not a module use std::io::Result::*; //~ ERROR Not a module trait T {} use T::*; //~ ERROR items in traits are not importable fn main() {} </ins>
#[stable(feature = "rust1", since = "1.0.0")] pub trait Drop { /// A method called when the value goes out of scope. <ins> /// /// When this method has been called, `self` has not yet been deallocated. /// If it were, `self` would be a dangling reference. /// /// After this function is over, the memory of `self` will be deallocated. /// /// # Panics /// /// Given that a `panic!` will call `drop()` as it unwinds, any `panic!` in /// a `drop()` implementation will likely abort. </ins> #[stable(feature = "rust1", since = "1.0.0")] fn drop(&mut self); }
/// /// assert!(ecode.success()); /// ``` <ins> /// /// # Note /// /// Take note that there is no implementation of /// [`Drop`](../../core/ops/trait.Drop.html) for child processes, so if you /// do not ensure the `Child` has exited then it will continue to run, even /// after the `Child` handle to the child process has gone out of scope. /// /// Calling `wait` (or other functions that wrap around it) will make the /// parent process wait until the child has actually exited before continuing. </ins> #[stable(feature = "process", since = "1.0.0")] pub struct Child { handle: imp::Process,