mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-10 06:47:34 +00:00
Auto merge of #47962 - kennytm:rollup, r=kennytm
Rollup of 10 pull requests - Successful merges: #46156, #47829, #47842, #47898, #47914, #47916, #47919, #47942, #47951, #47973 - Failed merges: #47753
This commit is contained in:
commit
8d04b8fda7
@ -37,28 +37,23 @@ unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
|
|||||||
p
|
p
|
||||||
}
|
}
|
||||||
|
|
||||||
#[lang = "exchange_free"]
|
#[lang = "box_free"]
|
||||||
unsafe fn deallocate(ptr: *mut u8, _size: usize, _align: usize) {
|
unsafe fn box_free<T: ?Sized>(ptr: *mut T) {
|
||||||
libc::free(ptr as *mut libc::c_void)
|
libc::free(ptr as *mut libc::c_void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[lang = "box_free"]
|
|
||||||
unsafe fn box_free<T: ?Sized>(ptr: *mut T) {
|
|
||||||
deallocate(ptr as *mut u8, ::core::mem::size_of_val(&*ptr), ::core::mem::align_of_val(&*ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[start]
|
#[start]
|
||||||
fn main(argc: isize, argv: *const *const u8) -> isize {
|
fn main(_argc: isize, _argv: *const *const u8) -> isize {
|
||||||
let x = box 1;
|
let _x = box 1;
|
||||||
|
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
#[lang = "eh_personality"] extern fn rust_eh_personality() {}
|
#[lang = "eh_personality"] extern fn rust_eh_personality() {}
|
||||||
#[lang = "panic_fmt"] extern fn rust_begin_panic() -> ! { unsafe { intrinsics::abort() } }
|
#[lang = "panic_fmt"] extern fn rust_begin_panic() -> ! { unsafe { intrinsics::abort() } }
|
||||||
# #[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {}
|
#[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {}
|
||||||
# #[no_mangle] pub extern fn rust_eh_register_frames () {}
|
#[no_mangle] pub extern fn rust_eh_register_frames () {}
|
||||||
# #[no_mangle] pub extern fn rust_eh_unregister_frames () {}
|
#[no_mangle] pub extern fn rust_eh_unregister_frames () {}
|
||||||
```
|
```
|
||||||
|
|
||||||
Note the use of `abort`: the `exchange_malloc` lang item is assumed to
|
Note the use of `abort`: the `exchange_malloc` lang item is assumed to
|
||||||
@ -80,7 +75,7 @@ Other features provided by lang items include:
|
|||||||
|
|
||||||
Lang items are loaded lazily by the compiler; e.g. if one never uses
|
Lang items are loaded lazily by the compiler; e.g. if one never uses
|
||||||
`Box` then there is no need to define functions for `exchange_malloc`
|
`Box` then there is no need to define functions for `exchange_malloc`
|
||||||
and `exchange_free`. `rustc` will emit an error when an item is needed
|
and `box_free`. `rustc` will emit an error when an item is needed
|
||||||
but not found in the current crate or any that it depends on.
|
but not found in the current crate or any that it depends on.
|
||||||
|
|
||||||
Most lang items are defined by `libcore`, but if you're trying to build
|
Most lang items are defined by `libcore`, but if you're trying to build
|
||||||
@ -318,4 +313,4 @@ the source code.
|
|||||||
- `phantom_data`: `libcore/marker.rs`
|
- `phantom_data`: `libcore/marker.rs`
|
||||||
- `freeze`: `libcore/marker.rs`
|
- `freeze`: `libcore/marker.rs`
|
||||||
- `debug_trait`: `libcore/fmt/mod.rs`
|
- `debug_trait`: `libcore/fmt/mod.rs`
|
||||||
- `non_zero`: `libcore/nonzero.rs`
|
- `non_zero`: `libcore/nonzero.rs`
|
||||||
|
@ -992,7 +992,7 @@ extern "rust-intrinsic" {
|
|||||||
/// ptr::copy_nonoverlapping(y, x, 1);
|
/// ptr::copy_nonoverlapping(y, x, 1);
|
||||||
/// ptr::copy_nonoverlapping(&t, y, 1);
|
/// ptr::copy_nonoverlapping(&t, y, 1);
|
||||||
///
|
///
|
||||||
/// // y and t now point to the same thing, but we need to completely forget `tmp`
|
/// // y and t now point to the same thing, but we need to completely forget `t`
|
||||||
/// // because it's no longer relevant.
|
/// // because it's no longer relevant.
|
||||||
/// mem::forget(t);
|
/// mem::forget(t);
|
||||||
/// }
|
/// }
|
||||||
|
@ -189,6 +189,7 @@ pub fn forget<T>(t: T) {
|
|||||||
/// Type | size_of::\<Type>()
|
/// Type | size_of::\<Type>()
|
||||||
/// ---- | ---------------
|
/// ---- | ---------------
|
||||||
/// () | 0
|
/// () | 0
|
||||||
|
/// bool | 1
|
||||||
/// u8 | 1
|
/// u8 | 1
|
||||||
/// u16 | 2
|
/// u16 | 2
|
||||||
/// u32 | 4
|
/// u32 | 4
|
||||||
|
@ -239,7 +239,9 @@ impl Float for f32 {
|
|||||||
/// Converts to degrees, assuming the number is in radians.
|
/// Converts to degrees, assuming the number is in radians.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_degrees(self) -> f32 {
|
fn to_degrees(self) -> f32 {
|
||||||
self * (180.0f32 / consts::PI)
|
// Use a constant for better precision.
|
||||||
|
const PIS_IN_180: f32 = 57.2957795130823208767981548141051703_f32;
|
||||||
|
self * PIS_IN_180
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts to radians, assuming the number is in degrees.
|
/// Converts to radians, assuming the number is in degrees.
|
||||||
|
@ -237,6 +237,9 @@ impl Float for f64 {
|
|||||||
/// Converts to degrees, assuming the number is in radians.
|
/// Converts to degrees, assuming the number is in radians.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_degrees(self) -> f64 {
|
fn to_degrees(self) -> f64 {
|
||||||
|
// The division here is correctly rounded with respect to the true
|
||||||
|
// value of 180/π. (This differs from f32, where a constant must be
|
||||||
|
// used to ensure a correctly rounded result.)
|
||||||
self * (180.0f64 / consts::PI)
|
self * (180.0f64 / consts::PI)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,32 +10,8 @@
|
|||||||
|
|
||||||
// Code for annotating snippets.
|
// Code for annotating snippets.
|
||||||
|
|
||||||
use syntax_pos::{Span, FileMap};
|
|
||||||
use CodeMapper;
|
|
||||||
use std::rc::Rc;
|
|
||||||
use Level;
|
use Level;
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct SnippetData {
|
|
||||||
codemap: Rc<CodeMapper>,
|
|
||||||
files: Vec<FileInfo>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct FileInfo {
|
|
||||||
file: Rc<FileMap>,
|
|
||||||
|
|
||||||
/// The "primary file", if any, gets a `-->` marker instead of
|
|
||||||
/// `>>>`, and has a line-number/column printed and not just a
|
|
||||||
/// filename (other files are not guaranteed to have line numbers
|
|
||||||
/// or columns). It appears first in the listing. It is known to
|
|
||||||
/// contain at least one primary span, though primary spans (which
|
|
||||||
/// are designated with `^^^`) may also occur in other files.
|
|
||||||
primary_span: Option<Span>,
|
|
||||||
|
|
||||||
lines: Vec<Line>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
|
||||||
pub struct Line {
|
pub struct Line {
|
||||||
pub line_index: usize,
|
pub line_index: usize,
|
||||||
|
@ -396,8 +396,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
|
|||||||
// Issue #46746: Two-phase borrows handles
|
// Issue #46746: Two-phase borrows handles
|
||||||
// stmts of form `Tmp = &mut Borrow` ...
|
// stmts of form `Tmp = &mut Borrow` ...
|
||||||
match lhs {
|
match lhs {
|
||||||
Place::Local(..) => {} // okay
|
Place::Local(..) | Place::Static(..) => {} // okay
|
||||||
Place::Static(..) => unreachable!(), // (filtered by is_unsafe_place)
|
|
||||||
Place::Projection(..) => {
|
Place::Projection(..) => {
|
||||||
// ... can assign into projections,
|
// ... can assign into projections,
|
||||||
// e.g. `box (&mut _)`. Current
|
// e.g. `box (&mut _)`. Current
|
||||||
|
@ -119,6 +119,11 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
|
|||||||
kind.name())
|
kind.name())
|
||||||
.span_label(e.span,
|
.span_label(e.span,
|
||||||
"can only break with a value inside `loop`")
|
"can only break with a value inside `loop`")
|
||||||
|
.span_suggestion(e.span,
|
||||||
|
&format!("instead, use `break` on its own \
|
||||||
|
without a value inside this `{}` loop",
|
||||||
|
kind.name()),
|
||||||
|
"break".to_string())
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,15 +181,19 @@ nav.sub {
|
|||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar .current {
|
.sidebar .block > ul > li {
|
||||||
margin-right: -20px;
|
margin-right: -20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content, nav { max-width: 960px; }
|
.content, nav {
|
||||||
|
max-width: 960px;
|
||||||
|
}
|
||||||
|
|
||||||
/* Everything else */
|
/* Everything else */
|
||||||
|
|
||||||
.js-only, .hidden { display: none !important; }
|
.js-only, .hidden {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
.sidebar img {
|
.sidebar img {
|
||||||
margin: 20px auto;
|
margin: 20px auto;
|
||||||
@ -218,7 +222,9 @@ nav.sub {
|
|||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.location a:first-child { font-weight: 500; }
|
.location a:first-child {
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
.block {
|
.block {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@ -299,7 +305,9 @@ nav.sub {
|
|||||||
-ms-user-select: none;
|
-ms-user-select: none;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
.line-numbers span { cursor: pointer; }
|
.line-numbers span {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.docblock-short p {
|
.docblock-short p {
|
||||||
display: inline;
|
display: inline;
|
||||||
@ -317,7 +325,9 @@ nav.sub {
|
|||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
.docblock-short code { white-space: nowrap; }
|
.docblock-short code {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
.docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 {
|
.docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 {
|
||||||
border-bottom: 1px solid;
|
border-bottom: 1px solid;
|
||||||
@ -384,7 +394,9 @@ h4 > code, h3 > code, .invisible > code {
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
#main { position: relative; }
|
#main {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
#main > .since {
|
#main > .since {
|
||||||
top: inherit;
|
top: inherit;
|
||||||
font-family: "Fira Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
font-family: "Fira Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||||
@ -428,7 +440,9 @@ h4 > code, h3 > code, .invisible > code {
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content .item-list li { margin-bottom: 1em; }
|
.content .item-list li {
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
.content .multi-column {
|
.content .multi-column {
|
||||||
-moz-column-count: 5;
|
-moz-column-count: 5;
|
||||||
|
@ -1531,6 +1531,7 @@ mod tests {
|
|||||||
assert!(nan.to_degrees().is_nan());
|
assert!(nan.to_degrees().is_nan());
|
||||||
assert_eq!(inf.to_degrees(), inf);
|
assert_eq!(inf.to_degrees(), inf);
|
||||||
assert_eq!(neg_inf.to_degrees(), neg_inf);
|
assert_eq!(neg_inf.to_degrees(), neg_inf);
|
||||||
|
assert_eq!(1_f32.to_degrees(), 57.2957795130823208767981548141051703);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -246,14 +246,27 @@ impl<'a> StringReader<'a> {
|
|||||||
self.err_span(self.mk_sp(from_pos, to_pos), m)
|
self.err_span(self.mk_sp(from_pos, to_pos), m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Pushes a character to a message string for error reporting
|
||||||
|
fn push_escaped_char_for_msg(m: &mut String, c: char) {
|
||||||
|
match c {
|
||||||
|
'\u{20}'...'\u{7e}' => {
|
||||||
|
// Don't escape \, ' or " for user-facing messages
|
||||||
|
m.push(c);
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
for c in c.escape_default() {
|
||||||
|
m.push(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Report a lexical error spanning [`from_pos`, `to_pos`), appending an
|
/// Report a lexical error spanning [`from_pos`, `to_pos`), appending an
|
||||||
/// escaped character to the error message
|
/// escaped character to the error message
|
||||||
fn fatal_span_char(&self, from_pos: BytePos, to_pos: BytePos, m: &str, c: char) -> FatalError {
|
fn fatal_span_char(&self, from_pos: BytePos, to_pos: BytePos, m: &str, c: char) -> FatalError {
|
||||||
let mut m = m.to_string();
|
let mut m = m.to_string();
|
||||||
m.push_str(": ");
|
m.push_str(": ");
|
||||||
for c in c.escape_default() {
|
Self::push_escaped_char_for_msg(&mut m, c);
|
||||||
m.push(c)
|
|
||||||
}
|
|
||||||
self.fatal_span_(from_pos, to_pos, &m[..])
|
self.fatal_span_(from_pos, to_pos, &m[..])
|
||||||
}
|
}
|
||||||
fn struct_fatal_span_char(&self,
|
fn struct_fatal_span_char(&self,
|
||||||
@ -264,9 +277,7 @@ impl<'a> StringReader<'a> {
|
|||||||
-> DiagnosticBuilder<'a> {
|
-> DiagnosticBuilder<'a> {
|
||||||
let mut m = m.to_string();
|
let mut m = m.to_string();
|
||||||
m.push_str(": ");
|
m.push_str(": ");
|
||||||
for c in c.escape_default() {
|
Self::push_escaped_char_for_msg(&mut m, c);
|
||||||
m.push(c)
|
|
||||||
}
|
|
||||||
self.sess.span_diagnostic.struct_span_fatal(self.mk_sp(from_pos, to_pos), &m[..])
|
self.sess.span_diagnostic.struct_span_fatal(self.mk_sp(from_pos, to_pos), &m[..])
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,9 +286,7 @@ impl<'a> StringReader<'a> {
|
|||||||
fn err_span_char(&self, from_pos: BytePos, to_pos: BytePos, m: &str, c: char) {
|
fn err_span_char(&self, from_pos: BytePos, to_pos: BytePos, m: &str, c: char) {
|
||||||
let mut m = m.to_string();
|
let mut m = m.to_string();
|
||||||
m.push_str(": ");
|
m.push_str(": ");
|
||||||
for c in c.escape_default() {
|
Self::push_escaped_char_for_msg(&mut m, c);
|
||||||
m.push(c)
|
|
||||||
}
|
|
||||||
self.err_span_(from_pos, to_pos, &m[..]);
|
self.err_span_(from_pos, to_pos, &m[..]);
|
||||||
}
|
}
|
||||||
fn struct_err_span_char(&self,
|
fn struct_err_span_char(&self,
|
||||||
@ -288,9 +297,7 @@ impl<'a> StringReader<'a> {
|
|||||||
-> DiagnosticBuilder<'a> {
|
-> DiagnosticBuilder<'a> {
|
||||||
let mut m = m.to_string();
|
let mut m = m.to_string();
|
||||||
m.push_str(": ");
|
m.push_str(": ");
|
||||||
for c in c.escape_default() {
|
Self::push_escaped_char_for_msg(&mut m, c);
|
||||||
m.push(c)
|
|
||||||
}
|
|
||||||
self.sess.span_diagnostic.struct_span_err(self.mk_sp(from_pos, to_pos), &m[..])
|
self.sess.span_diagnostic.struct_span_err(self.mk_sp(from_pos, to_pos), &m[..])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,13 +347,24 @@ impl Span {
|
|||||||
|
|
||||||
/// Return a `Span` that would enclose both `self` and `end`.
|
/// Return a `Span` that would enclose both `self` and `end`.
|
||||||
pub fn to(self, end: Span) -> Span {
|
pub fn to(self, end: Span) -> Span {
|
||||||
let span = self.data();
|
let span_data = self.data();
|
||||||
let end = end.data();
|
let end_data = end.data();
|
||||||
|
// FIXME(jseyfried): self.ctxt should always equal end.ctxt here (c.f. issue #23480)
|
||||||
|
// Return the macro span on its own to avoid weird diagnostic output. It is preferable to
|
||||||
|
// have an incomplete span than a completely nonsensical one.
|
||||||
|
if span_data.ctxt != end_data.ctxt {
|
||||||
|
if span_data.ctxt == SyntaxContext::empty() {
|
||||||
|
return end;
|
||||||
|
} else if end_data.ctxt == SyntaxContext::empty() {
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
// both span fall within a macro
|
||||||
|
// FIXME(estebank) check if it is the *same* macro
|
||||||
|
}
|
||||||
Span::new(
|
Span::new(
|
||||||
cmp::min(span.lo, end.lo),
|
cmp::min(span_data.lo, end_data.lo),
|
||||||
cmp::max(span.hi, end.hi),
|
cmp::max(span_data.hi, end_data.hi),
|
||||||
// FIXME(jseyfried): self.ctxt should always equal end.ctxt here (c.f. issue #23480)
|
if span_data.ctxt == SyntaxContext::empty() { end_data.ctxt } else { span_data.ctxt },
|
||||||
if span.ctxt == SyntaxContext::empty() { end.ctxt } else { span.ctxt },
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
// these literals are just silly.
|
// these literals are just silly.
|
||||||
''';
|
''';
|
||||||
//~^ ERROR: character constant must be escaped: \'
|
//~^ ERROR: character constant must be escaped: '
|
||||||
|
|
||||||
// note that this is a literal "\n" byte
|
// note that this is a literal "\n" byte
|
||||||
'
|
'
|
||||||
|
13
src/test/parse-fail/lex-stray-backslash.rs
Normal file
13
src/test/parse-fail/lex-stray-backslash.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// Copyright 2014 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.
|
||||||
|
|
||||||
|
// compile-flags: -Z parse-only
|
||||||
|
|
||||||
|
\ //~ ERROR: unknown start of token: \
|
20
src/test/run-pass/issue-47789.rs
Normal file
20
src/test/run-pass/issue-47789.rs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
|
||||||
|
#![feature(nll)]
|
||||||
|
|
||||||
|
static mut x: &'static u32 = &0;
|
||||||
|
|
||||||
|
fn foo() {
|
||||||
|
unsafe { x = &1; }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() { }
|
@ -3,6 +3,10 @@ error[E0571]: `break` with value from a `for` loop
|
|||||||
|
|
|
|
||||||
22 | break 22 //~ ERROR `break` with value from a `for` loop
|
22 | break 22 //~ ERROR `break` with value from a `for` loop
|
||||||
| ^^^^^^^^ can only break with a value inside `loop`
|
| ^^^^^^^^ can only break with a value inside `loop`
|
||||||
|
help: instead, use `break` on its own without a value inside this `for` loop
|
||||||
|
|
|
||||||
|
22 | break //~ ERROR `break` with value from a `for` loop
|
||||||
|
| ^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
23
src/test/ui/macros/span-covering-argument-1.rs
Normal file
23
src/test/ui/macros/span-covering-argument-1.rs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
macro_rules! bad {
|
||||||
|
($s:ident whatever) => {
|
||||||
|
{
|
||||||
|
let $s = 0;
|
||||||
|
*&mut $s = 0;
|
||||||
|
//~^ ERROR cannot borrow immutable local variable `foo` as mutable [E0596]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
bad!(foo whatever);
|
||||||
|
}
|
13
src/test/ui/macros/span-covering-argument-1.stderr
Normal file
13
src/test/ui/macros/span-covering-argument-1.stderr
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
error[E0596]: cannot borrow immutable local variable `foo` as mutable
|
||||||
|
--> $DIR/span-covering-argument-1.rs:15:19
|
||||||
|
|
|
||||||
|
14 | let $s = 0;
|
||||||
|
| -- consider changing this to `mut $s`
|
||||||
|
15 | *&mut $s = 0;
|
||||||
|
| ^^ cannot borrow mutably
|
||||||
|
...
|
||||||
|
22 | bad!(foo whatever);
|
||||||
|
| ------------------- in this macro invocation
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
warning: struct is never used: `S`
|
warning: struct is never used: `S`
|
||||||
--> $DIR/macro-span-replacement.rs:17:9
|
--> $DIR/macro-span-replacement.rs:17:14
|
||||||
|
|
|
|
||||||
17 | $b $a; //~ WARN struct is never used
|
17 | $b $a; //~ WARN struct is never used
|
||||||
| ^^^^^^
|
| ^
|
||||||
...
|
...
|
||||||
22 | m!(S struct);
|
22 | m!(S struct);
|
||||||
| ------------- in this macro invocation
|
| ------------- in this macro invocation
|
||||||
|
Loading…
Reference in New Issue
Block a user