Auto merge of #32229 - Manishearth:rollup, r=Manishearth
Rollup of 4 pull requests - Successful merges: #32164, #32179, #32212, #32218 - Failed merges:
This commit is contained in:
commit
1c8b245928
@ -501,7 +501,7 @@ Cargo checks to see if any of your project’s files have been modified, and onl
|
||||
rebuilds your project if they’ve changed since the last time you built it.
|
||||
|
||||
With simple projects, Cargo doesn't bring a whole lot over just using `rustc`,
|
||||
but it will become useful in future. This is especially true when you start
|
||||
but it will become useful in the future. This is especially true when you start
|
||||
using crates; these are synonymous with a ‘library’ or ‘package’ in other
|
||||
programming languages. For complex projects composed of multiple crates, it’s
|
||||
much easier to let Cargo coordinate the build. Using Cargo, you can run `cargo
|
||||
|
@ -4,7 +4,7 @@ Rust’s take on `if` is not particularly complex, but it’s much more like the
|
||||
`if` you’ll find in a dynamically typed language than in a more traditional
|
||||
systems language. So let’s talk about it, to make sure you grasp the nuances.
|
||||
|
||||
`if` is a specific form of a more general concept, the ‘branch’. The name comes
|
||||
`if` is a specific form of a more general concept, the ‘branch’, whose name comes
|
||||
from a branch in a tree: a decision point, where depending on a choice,
|
||||
multiple paths can be taken.
|
||||
|
||||
|
@ -44,7 +44,7 @@ let s = "foo\
|
||||
assert_eq!("foobar", s);
|
||||
```
|
||||
|
||||
Rust has more than only `&str`s though. A `String`, is a heap-allocated string.
|
||||
Rust has more than only `&str`s though. A `String` is a heap-allocated string.
|
||||
This string is growable, and is also guaranteed to be UTF-8. `String`s are
|
||||
commonly created by converting from a string slice using the `to_string`
|
||||
method.
|
||||
@ -89,7 +89,7 @@ Viewing a `String` as a `&str` is cheap, but converting the `&str` to a
|
||||
|
||||
## Indexing
|
||||
|
||||
Because strings are valid UTF-8, strings do not support indexing:
|
||||
Because strings are valid UTF-8, they do not support indexing:
|
||||
|
||||
```rust,ignore
|
||||
let s = "hello";
|
||||
|
@ -1120,11 +1120,15 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
.map(|method| resolve_ty(method.ty)))
|
||||
}
|
||||
|
||||
pub fn errors_since_creation(&self) -> bool {
|
||||
self.tcx.sess.err_count() - self.err_count_on_creation != 0
|
||||
}
|
||||
|
||||
pub fn node_type(&self, id: ast::NodeId) -> Ty<'tcx> {
|
||||
match self.tables.borrow().node_types.get(&id) {
|
||||
Some(&t) => t,
|
||||
// FIXME
|
||||
None if self.tcx.sess.err_count() - self.err_count_on_creation != 0 =>
|
||||
None if self.errors_since_creation() =>
|
||||
self.tcx.types.err,
|
||||
None => {
|
||||
self.tcx.sess.bug(
|
||||
@ -1147,7 +1151,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
free_regions: &FreeRegionMap,
|
||||
subject_node_id: ast::NodeId) {
|
||||
let errors = self.region_vars.resolve_regions(free_regions, subject_node_id);
|
||||
self.report_region_errors(&errors); // see error_reporting.rs
|
||||
if !self.errors_since_creation() {
|
||||
// As a heuristic, just skip reporting region errors
|
||||
// altogether if other errors have been reported while
|
||||
// this infcx was in use. This is totally hokey but
|
||||
// otherwise we have a hard time separating legit region
|
||||
// errors from silly ones.
|
||||
self.report_region_errors(&errors); // see error_reporting.rs
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ty_to_string(&self, t: Ty<'tcx>) -> String {
|
||||
|
@ -1095,6 +1095,10 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||
}
|
||||
}
|
||||
|
||||
if cg.codegen_units < 1 {
|
||||
early_error(error_format, "Value for codegen units must be a positive nonzero integer");
|
||||
}
|
||||
|
||||
let cg = cg;
|
||||
|
||||
let sysroot_opt = matches.opt_str("sysroot").map(|m| PathBuf::from(&m));
|
||||
|
@ -927,7 +927,7 @@ pub enum ExprKind {
|
||||
Binary(BinOp, P<Expr>, P<Expr>),
|
||||
/// A unary operation (For example: `!x`, `*x`)
|
||||
Unary(UnOp, P<Expr>),
|
||||
/// A literal (For example: `1u8`, `"foo"`)
|
||||
/// A literal (For example: `1`, `"foo"`)
|
||||
Lit(P<Lit>),
|
||||
/// A cast (`foo as f64`)
|
||||
Cast(P<Expr>, P<Ty>),
|
||||
@ -1016,7 +1016,7 @@ pub enum ExprKind {
|
||||
|
||||
/// An array literal constructed from one repeated element.
|
||||
///
|
||||
/// For example, `[1u8; 5]`. The first expression is the element
|
||||
/// For example, `[1; 5]`. The first expression is the element
|
||||
/// to be repeated; the second is the number of times to repeat it.
|
||||
Repeat(P<Expr>, P<Expr>),
|
||||
|
||||
@ -1288,7 +1288,7 @@ pub enum LitKind {
|
||||
Byte(u8),
|
||||
/// A character literal (`'a'`)
|
||||
Char(char),
|
||||
/// An integer literal (`1u8`)
|
||||
/// An integer literal (`1`)
|
||||
Int(u64, LitIntType),
|
||||
/// A float literal (`1f64` or `1E10f64`)
|
||||
Float(InternedString, FloatTy),
|
||||
|
@ -168,8 +168,8 @@ pub fn mk_printer<'a>(out: Box<io::Write+'a>, linewidth: usize) -> Printer<'a> {
|
||||
let n: usize = 3 * linewidth;
|
||||
debug!("mk_printer {}", linewidth);
|
||||
let token = vec![Token::Eof; n];
|
||||
let size = vec![0_isize; n];
|
||||
let scan_stack = vec![0_usize; n];
|
||||
let size = vec![0; n];
|
||||
let scan_stack = vec![0; n];
|
||||
Printer {
|
||||
out: out,
|
||||
buf_len: n,
|
||||
|
27
src/test/compile-fail/issue-30580.rs
Normal file
27
src/test/compile-fail/issue-30580.rs
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright 2012 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.
|
||||
|
||||
// Test that we do not see uninformative region-related errors
|
||||
// when we get some basic type-checking failure. See #30580.
|
||||
|
||||
pub struct Foo { a: u32 }
|
||||
pub struct Pass<'a, 'tcx: 'a>(&'a mut &'a (), &'a &'tcx ());
|
||||
|
||||
impl<'a, 'tcx> Pass<'a, 'tcx>
|
||||
{
|
||||
pub fn tcx(&self) -> &'a &'tcx () { self.1 }
|
||||
fn lol(&mut self, b: &Foo)
|
||||
{
|
||||
b.c; //~ ERROR no field with that name was found
|
||||
self.tcx();
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
x
Reference in New Issue
Block a user