提交 55a61a11 编写于 作者: B bors 提交者: GitHub

Auto merge of #36536 - jonathandturner:rollup, r=jonathandturner

Rollup of 8 pull requests

- Successful merges: #36383, #36424, #36480, #36484, #36505, #36509, #36519, #36521
- Failed merges:
......@@ -269,6 +269,7 @@ class RustBuild:
sys.exit(ret)
def build_triple(self):
default_encoding = sys.getdefaultencoding()
config = self.get_toml('build')
if config:
return config
......@@ -276,8 +277,8 @@ class RustBuild:
if config:
return config
try:
ostype = subprocess.check_output(['uname', '-s']).strip()
cputype = subprocess.check_output(['uname', '-m']).strip()
ostype = subprocess.check_output(['uname', '-s']).strip().decode(default_encoding)
cputype = subprocess.check_output(['uname', '-m']).strip().decode(default_encoding)
except (subprocess.CalledProcessError, WindowsError):
if sys.platform == 'win32':
return 'x86_64-pc-windows-msvc'
......@@ -289,7 +290,8 @@ class RustBuild:
# Darwin's `uname -s` lies and always returns i386. We have to use
# sysctl instead.
if ostype == 'Darwin' and cputype == 'i686':
sysctl = subprocess.check_output(['sysctl', 'hw.optional.x86_64'])
args = ['sysctl', 'hw.optional.x86_64']
sysctl = subprocess.check_output(args).decode(default_encoding)
if ': 1' in sysctl:
cputype = 'x86_64'
......
......@@ -291,7 +291,7 @@ let result = f.write(buf);
We need to `use` the `Write` trait first:
```rust,ignore
```rust,no_run
use std::io::Write;
let mut f = std::fs::File::create("foo.txt").expect("Couldn’t create foo.txt");
......
......@@ -92,6 +92,22 @@ pub trait AsRef<T: ?Sized> {
/// [`Option<T>`]: ../../std/option/enum.Option.html
/// [`Result<T, E>`]: ../../std/result/enum.Result.html
///
/// # Examples
///
/// [`Box<T>`] implements `AsMut<T>`:
///
/// [`Box<T>`]: ../../std/boxed/struct.Box.html
///
/// ```
/// fn add_one<T: AsMut<u64>>(num: &mut T) {
/// *num.as_mut() += 1;
/// }
///
/// let mut boxed_num = Box::new(0);
/// add_one(&mut boxed_num);
/// assert_eq!(*boxed_num, 1);
/// ```
///
/// # Generic Impls
///
/// - `AsMut` auto-dereferences if the inner type is a reference or a mutable
......
此差异已折叠。
......@@ -201,7 +201,7 @@ pub fn intersects(&self, other: $BitFlags) -> bool {
!(*self & other).is_empty()
}
/// Returns `true` all of the flags in `other` are contained within `self`.
/// Returns `true` if all of the flags in `other` are contained within `self`.
#[inline]
pub fn contains(&self, other: $BitFlags) -> bool {
(*self & other) == other
......
......@@ -1054,7 +1054,8 @@ fn parse_crate_attrs<'a>(sess: &'a Session, input: &Input) -> PResult<'a, Vec<as
/// The diagnostic emitter yielded to the procedure should be used for reporting
/// errors of the compiler.
pub fn monitor<F: FnOnce() + Send + 'static>(f: F) {
const STACK_SIZE: usize = 8 * 1024 * 1024; // 8MB
// Temporarily have stack size set to 16MB to deal with nom-using crates failing
const STACK_SIZE: usize = 16 * 1024 * 1024; // 16MB
struct Sink(Arc<Mutex<Vec<u8>>>);
impl Write for Sink {
......
......@@ -38,7 +38,8 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
impl_m_span: Span,
impl_m_body_id: ast::NodeId,
trait_m: &ty::Method<'tcx>,
impl_trait_ref: &ty::TraitRef<'tcx>) {
impl_trait_ref: &ty::TraitRef<'tcx>,
trait_item_span: Option<Span>) {
debug!("compare_impl_method(impl_trait_ref={:?})",
impl_trait_ref);
......@@ -97,14 +98,42 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
let num_impl_m_type_params = impl_m.generics.types.len();
let num_trait_m_type_params = trait_m.generics.types.len();
if num_impl_m_type_params != num_trait_m_type_params {
span_err!(tcx.sess, impl_m_span, E0049,
let impl_m_node_id = tcx.map.as_local_node_id(impl_m.def_id).unwrap();
let span = match tcx.map.expect_impl_item(impl_m_node_id).node {
ImplItemKind::Method(ref impl_m_sig, _) => {
if impl_m_sig.generics.is_parameterized() {
impl_m_sig.generics.span
} else {
impl_m_span
}
}
_ => bug!("{:?} is not a method", impl_m)
};
struct_span_err!(tcx.sess, span, E0049,
"method `{}` has {} type parameter{} \
but its trait declaration has {} type parameter{}",
trait_m.name,
num_impl_m_type_params,
if num_impl_m_type_params == 1 {""} else {"s"},
num_trait_m_type_params,
if num_trait_m_type_params == 1 {""} else {"s"});
if num_trait_m_type_params == 1 {""} else {"s"})
.span_label(trait_item_span.unwrap(),
&format!("expected {}",
&if num_trait_m_type_params != 1 {
format!("{} type parameters",
num_trait_m_type_params)
} else {
format!("{} type parameter",
num_trait_m_type_params)
}))
.span_label(span, &format!("found {}",
&if num_impl_m_type_params != 1 {
format!("{} type parameters", num_impl_m_type_params)
} else {
format!("1 type parameter")
}))
.emit();
return;
}
......
......@@ -1015,13 +1015,15 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
_ => span_bug!(impl_item.span, "non-method impl-item for method")
};
let trait_span = tcx.map.span_if_local(ty_trait_item.def_id());
if let &ty::MethodTraitItem(ref trait_method) = ty_trait_item {
compare_impl_method(ccx,
&impl_method,
impl_item.span,
body.id,
&trait_method,
&impl_trait_ref);
&impl_trait_ref,
trait_span);
} else {
let mut err = struct_span_err!(tcx.sess, impl_item.span, E0324,
"item `{}` is an associated method, \
......
......@@ -83,7 +83,7 @@ pub struct VarsOs { inner: os_imp::Env }
/// environment variables of the current process.
///
/// The returned iterator contains a snapshot of the process's environment
/// variables at the time of this invocation, modifications to environment
/// variables at the time of this invocation. Modifications to environment
/// variables afterwards will not be reflected in the returned iterator.
///
/// # Panics
......@@ -112,7 +112,7 @@ pub fn vars() -> Vars {
/// environment variables of the current process.
///
/// The returned iterator contains a snapshot of the process's environment
/// variables at the time of this invocation, modifications to environment
/// variables at the time of this invocation. Modifications to environment
/// variables afterwards will not be reflected in the returned iterator.
///
/// # Examples
......
......@@ -9,13 +9,14 @@
// except according to those terms.
trait Foo {
fn foo<T: Default>(x: T) -> Self;
fn foo<T: Default>(x: T) -> Self; //~ NOTE expected 1 type parameter
}
struct Bar;
impl Foo for Bar {
fn foo(x: bool) -> Self { Bar } //~ ERROR E0049
//~| NOTE found 0 type parameters
}
fn main() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册