Skip to content

Rollup of 9 pull requests #87595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2953a2f
Mir borrowck does not generate lifetime variables for 'static lifetim…
oli-obk Jul 26, 2021
624df18
Track caller of Vec::remove()
kornelski Jul 26, 2021
886dea2
Make `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` warn by default
Aaron1011 Jul 22, 2021
cf167c9
Only emit lint for local macros
Aaron1011 Jul 24, 2021
b8eb1f1
Fix assert in diy_float
frogtd Jul 27, 2021
6954f9d
Update stderr
Aaron1011 Jul 27, 2021
cd6c0e4
Fix typo in rustc_driver::version
bjorn3 Jul 28, 2021
9829efb
Range PatKind implies discr should be read
roxelo Jul 28, 2021
d380ed1
fix nit
roxelo Jul 28, 2021
cf5e48d
min_type_alias_impl_trait is going to be removed in 1.56
spastorino Jul 28, 2021
2f6662d
Use strip_prefix
bjorn3 Jul 29, 2021
a2f3e4a
Change span for intra-doc links errors
GuillaumeGomez Jul 19, 2021
cbba940
BufWriter: actually export WriterPanicked error
ijackson Jun 1, 2021
66f3807
BufWriter: rename `into_parts` from `into_raw_parts`
ijackson Jun 1, 2021
bf30c51
Rename feature gate bufwriter_into_parts from bufwriter_into_raw_parts
ijackson Jul 19, 2021
e70ce57
Remove unnecessary trailing semicolons from clippy tests
Aaron1011 Jul 29, 2021
0f7f85e
Update rustdoc-ui tests for intra-doc links errors
GuillaumeGomez Jul 19, 2021
a5a44ad
Rollup merge of #85901 - ijackson:bufwriter-tweaks, r=joshtriplett
fee1-dead Jul 29, 2021
c46c25b
Rollup merge of #87285 - GuillaumeGomez:intra-doc-span, r=estebank
fee1-dead Jul 29, 2021
6b0321f
Rollup merge of #87385 - Aaron1011:final-enable-semi, r=petrochenkov
fee1-dead Jul 29, 2021
71d00b7
Rollup merge of #87483 - oli-obk:tait_ice, r=lqd
fee1-dead Jul 29, 2021
9b0310b
Rollup merge of #87488 - kornelski:track-remove, r=dtolnay
fee1-dead Jul 29, 2021
59b3d38
Rollup merge of #87522 - frogtd:patch-1, r=yaahc
fee1-dead Jul 29, 2021
433e5a1
Rollup merge of #87553 - bjorn3:fix_hotplug_codegen_version, r=wesley…
fee1-dead Jul 29, 2021
cee4f91
Rollup merge of #87554 - sexxi-goose:fix-issue-87426, r=nikomatsakis
fee1-dead Jul 29, 2021
afd3066
Rollup merge of #87564 - spastorino:adjust-min-tait-removed-version, …
fee1-dead Jul 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions compiler/rustc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -764,13 +764,7 @@ pub fn version(binary: &str, matches: &getopts::Matches) {
println!("release: {}", unw(util::release_str()));

let debug_flags = matches.opt_strs("Z");
let backend_name = debug_flags.iter().find_map(|x| {
if x.starts_with("codegen-backend=") {
Some(&x["codegen-backends=".len()..])
} else {
None
}
});
let backend_name = debug_flags.iter().find_map(|x| x.strip_prefix("codegen-backend="));
get_codegen_backend(&None, backend_name).print_version();
}
}
Expand Down
26 changes: 19 additions & 7 deletions compiler/rustc_expand/src/mbe/macro_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ crate struct ParserAnyMacro<'a> {
lint_node_id: NodeId,
is_trailing_mac: bool,
arm_span: Span,
/// Whether or not this macro is defined in the current crate
is_local: bool,
}

crate fn annotate_err_with_kind(
Expand Down Expand Up @@ -124,6 +126,7 @@ impl<'a> ParserAnyMacro<'a> {
lint_node_id,
arm_span,
is_trailing_mac,
is_local,
} = *self;
let snapshot = &mut parser.clone();
let fragment = match parse_ast_fragment(parser, kind) {
Expand All @@ -138,13 +141,15 @@ impl<'a> ParserAnyMacro<'a> {
// `macro_rules! m { () => { panic!(); } }` isn't parsed by `.parse_expr()`,
// but `m!()` is allowed in expression positions (cf. issue #34706).
if kind == AstFragmentKind::Expr && parser.token == token::Semi {
parser.sess.buffer_lint_with_diagnostic(
SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
parser.token.span,
lint_node_id,
"trailing semicolon in macro used in expression position",
BuiltinLintDiagnostics::TrailingMacro(is_trailing_mac, macro_ident),
);
if is_local {
parser.sess.buffer_lint_with_diagnostic(
SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
parser.token.span,
lint_node_id,
"trailing semicolon in macro used in expression position",
BuiltinLintDiagnostics::TrailingMacro(is_trailing_mac, macro_ident),
);
}
parser.bump();
}

Expand All @@ -162,6 +167,7 @@ struct MacroRulesMacroExpander {
lhses: Vec<mbe::TokenTree>,
rhses: Vec<mbe::TokenTree>,
valid: bool,
is_local: bool,
}

impl TTMacroExpander for MacroRulesMacroExpander {
Expand All @@ -183,6 +189,7 @@ impl TTMacroExpander for MacroRulesMacroExpander {
input,
&self.lhses,
&self.rhses,
self.is_local,
)
}
}
Expand Down Expand Up @@ -210,6 +217,7 @@ fn generic_extension<'cx>(
arg: TokenStream,
lhses: &[mbe::TokenTree],
rhses: &[mbe::TokenTree],
is_local: bool,
) -> Box<dyn MacResult + 'cx> {
let sess = &cx.sess.parse_sess;

Expand Down Expand Up @@ -311,6 +319,7 @@ fn generic_extension<'cx>(
lint_node_id: cx.current_expansion.lint_node_id,
is_trailing_mac: cx.current_expansion.is_trailing_mac,
arm_span,
is_local,
});
}
Failure(token, msg) => match best_failure {
Expand Down Expand Up @@ -544,6 +553,9 @@ pub fn compile_declarative_macro(
lhses,
rhses,
valid,
// Macros defined in the current crate have a real node id,
// whereas macros from an external crate have a dummy id.
is_local: def.id != DUMMY_NODE_ID,
}))
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ declare_features! (
Some("the implementation was not maintainable, the feature may get reintroduced once the current refactorings are done")),

/// Allows the use of type alias impl trait in function return positions
(removed, min_type_alias_impl_trait, "1.55.0", Some(63063), None,
(removed, min_type_alias_impl_trait, "1.56.0", Some(63063), None,
Some("removed in favor of full type_alias_impl_trait")),

// -------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2799,7 +2799,7 @@ declare_lint! {
/// [issue #79813]: https://github.com/rust-lang/rust/issues/79813
/// [future-incompatible]: ../index.md#future-incompatible-lints
pub SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
Allow,
Warn,
"trailing semicolon in macro body used as expression",
@future_incompatible = FutureIncompatibleInfo {
reference: "issue #79813 <https://github.com/rust-lang/rust/issues/79813>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
.and_then(|ur_vid| self.definitions[*ur_vid].external_name)
.unwrap_or(infcx.tcx.lifetimes.re_root_empty),
ty::ReLateBound(..) => region,
ty::ReStatic => region,
_ => {
infcx.tcx.sess.delay_span_bug(
span,
Expand Down
15 changes: 12 additions & 3 deletions compiler/rustc_typeck/src/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,21 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
}
}
}
PatKind::Lit(_) => {
// If the PatKind is a Lit then we want
PatKind::Lit(_) | PatKind::Range(..) => {
// If the PatKind is a Lit or a Range then we want
// to borrow discr.
needs_to_be_read = true;
}
_ => {}
PatKind::Or(_)
| PatKind::Box(_)
| PatKind::Slice(..)
| PatKind::Ref(..)
| PatKind::Wild => {
// If the PatKind is Or, Box, Slice or Ref, the decision is made later
// as these patterns contains subpatterns
// If the PatKind is Wild, the decision is made based on the other patterns being
// examined
}
}
}));
}
Expand Down
2 changes: 2 additions & 0 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1372,9 +1372,11 @@ impl<T, A: Allocator> Vec<T, A> {
/// assert_eq!(v, [1, 3]);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[track_caller]
pub fn remove(&mut self, index: usize) -> T {
#[cold]
#[inline(never)]
#[track_caller]
fn assert_failed(index: usize, len: usize) -> ! {
panic!("removal index (is {}) should be < len (is {})", index, len);
}
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/num/diy_float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl Fp {
f <<= 1;
e -= 1;
}
debug_assert!(f >= (1 >> 63));
debug_assert!(f >= (1 << 63));
Fp { f, e }
}

Expand Down
28 changes: 14 additions & 14 deletions library/std/src/io/buffered/bufwriter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl<W: Write> BufWriter<W> {
pub fn into_inner(mut self) -> Result<W, IntoInnerError<BufWriter<W>>> {
match self.flush_buf() {
Err(e) => Err(IntoInnerError::new(self, e)),
Ok(()) => Ok(self.into_raw_parts().0),
Ok(()) => Ok(self.into_parts().0),
}
}

Expand All @@ -318,24 +318,24 @@ impl<W: Write> BufWriter<W> {
/// In this case, we return `WriterPanicked` for the buffered data (from which the buffer
/// contents can still be recovered).
///
/// `into_raw_parts` makes no attempt to flush data and cannot fail.
/// `into_parts` makes no attempt to flush data and cannot fail.
///
/// # Examples
///
/// ```
/// #![feature(bufwriter_into_raw_parts)]
/// #![feature(bufwriter_into_parts)]
/// use std::io::{BufWriter, Write};
///
/// let mut buffer = [0u8; 10];
/// let mut stream = BufWriter::new(buffer.as_mut());
/// write!(stream, "too much data").unwrap();
/// stream.flush().expect_err("it doesn't fit");
/// let (recovered_writer, buffered_data) = stream.into_raw_parts();
/// let (recovered_writer, buffered_data) = stream.into_parts();
/// assert_eq!(recovered_writer.len(), 0);
/// assert_eq!(&buffered_data.unwrap(), b"ata");
/// ```
#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
pub fn into_raw_parts(mut self) -> (W, Result<Vec<u8>, WriterPanicked>) {
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
pub fn into_parts(mut self) -> (W, Result<Vec<u8>, WriterPanicked>) {
let buf = mem::take(&mut self.buf);
let buf = if !self.panicked { Ok(buf) } else { Err(WriterPanicked { buf }) };

Expand Down Expand Up @@ -444,14 +444,14 @@ impl<W: Write> BufWriter<W> {
}
}

#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
/// Error returned for the buffered data from `BufWriter::into_raw_parts`, when the underlying
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
/// Error returned for the buffered data from `BufWriter::into_parts`, when the underlying
/// writer has previously panicked. Contains the (possibly partly written) buffered data.
///
/// # Example
///
/// ```
/// #![feature(bufwriter_into_raw_parts)]
/// #![feature(bufwriter_into_parts)]
/// use std::io::{self, BufWriter, Write};
/// use std::panic::{catch_unwind, AssertUnwindSafe};
///
Expand All @@ -467,7 +467,7 @@ impl<W: Write> BufWriter<W> {
/// stream.flush().unwrap()
/// }));
/// assert!(result.is_err());
/// let (recovered_writer, buffered_data) = stream.into_raw_parts();
/// let (recovered_writer, buffered_data) = stream.into_parts();
/// assert!(matches!(recovered_writer, PanickingWriter));
/// assert_eq!(buffered_data.unwrap_err().into_inner(), b"some data");
/// ```
Expand All @@ -478,7 +478,7 @@ pub struct WriterPanicked {
impl WriterPanicked {
/// Returns the perhaps-unwritten data. Some of this data may have been written by the
/// panicking call(s) to the underlying writer, so simply writing it again is not a good idea.
#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
pub fn into_inner(self) -> Vec<u8> {
self.buf
}
Expand All @@ -487,22 +487,22 @@ impl WriterPanicked {
"BufWriter inner writer panicked, what data remains unwritten is not known";
}

#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
impl error::Error for WriterPanicked {
#[allow(deprecated, deprecated_in_future)]
fn description(&self) -> &str {
Self::DESCRIPTION
}
}

#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
impl fmt::Display for WriterPanicked {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", Self::DESCRIPTION)
}
}

#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
impl fmt::Debug for WriterPanicked {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("WriterPanicked")
Expand Down
2 changes: 2 additions & 0 deletions library/std/src/io/buffered/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use crate::io::Error;

pub use bufreader::BufReader;
pub use bufwriter::BufWriter;
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
pub use bufwriter::WriterPanicked;
pub use linewriter::LineWriter;
use linewritershim::LineWriterShim;

Expand Down
2 changes: 2 additions & 0 deletions library/std/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ use crate::sys_common::memchr;

#[stable(feature = "rust1", since = "1.0.0")]
pub use self::buffered::IntoInnerError;
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
pub use self::buffered::WriterPanicked;
#[stable(feature = "rust1", since = "1.0.0")]
pub use self::buffered::{BufReader, BufWriter, LineWriter};
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ macro_rules! dbg {
// `$val` expression could be a block (`{ .. }`), in which case the `eprintln!`
// will be malformed.
() => {
$crate::eprintln!("[{}:{}]", $crate::file!(), $crate::line!());
$crate::eprintln!("[{}:{}]", $crate::file!(), $crate::line!())
};
($val:expr $(,)?) => {
// Use of `match` here is intentional because it affects the lifetimes
Expand Down
Loading